1.0.9 • Published 3 years ago

vuezik v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Vuezik - Real (SFC) Single-File Components for Vue3

Vuezik is pronounced like music but with "Vue-" instead of "Mu-"

Information

dist/bundle.js | 39.75 KiB / gzip: 12.70 KiB

Install

npm install vuezik

Uses

$style (Global-Variable) | @Emotion-CSS

KeyValue
csscss
injectinjectGlobal
keyframeskeyframes
appxtyle

$device (Global-Variable)

KeyValue
widthDevice's width
heightDevice's height
typeDevice's size abbreviation (xs, sm, md, lg, xl) (default: xs)
isDevice's size function to be used with v-if example below

Directives

NameDescription
v-rippleRipple effect from Material Design Styling
v-resizeDetects resize changes of the browser's window
v-click-outsideDetects click outside element
v-swipeDetects swipe (left, right, up, down)
v-wheelDetects swipe (up, down)

<template>
  <div
    v-ripple
    v-wheel="log"
    v-swipe="log"
    v-resize="log"
    v-click-outside="log"
  >
    {{ $device }}
  </div>
  <button v-ripple="{ color: red, center: true, class: 'some-class' }">
    Click Me
  </button>
</template>
<script>
  export default {
    methods: {
      log(data) {
        console.log(data);
      },
    },
  };
</script>

Component

NameDescription
x-elementCustomizable <html-element>
<x-element resize class="only-once-per-project-use-resize">
  My App Container
  <br />
  {{ $device }}
  <br />
  <div v-if='$device.is("xs", "sm")'>Show Content Only On Devices(XS, SM)</div>
</x-element>

Props

NameDescriptionDefaultType
css@emotion/css Object-Style Based{}Object
tag<html> element type for example buttondivString
v-modelRequires hoverfalseBoolean
hoverTrack mouse hoverfalseBoolean
resizeUpdate $device variables. Use once's per projectfalseBoolean
activeElement is active ?falseBoolean

CSS (Prop)

NameDefaultTypeEmotion
base{}ObjectMain CSS-Class (Object-Style)
hoverAndFocusfalseBooleanturn hover into Hover-and-Focus
hover{}Object&:hover or &:hover,&:focus
focus{}Object&:focus
active{}ObjectActive CSS-Class (Object-Style)
children{}ObjectChildren CSS-Class(es) (Object-Style)

CSS (Only) Main

  • active

active only works on the Main (Object-Style)

CSS Active & Children

  • base
  • hover
  • focus

active & children only have 3 props


Demo

<script>
  export default {
    computed: {
      css() {
        return {
          base: {},
          hover: {},
          hoverAndFocus: true,
          active: {
            base: {},
            hover: {},
            focus: {},
          },
          children: {
            "children-class": {
              base: {},
              hover: {},
              focus: {},
            },
          },
        };
      },
    },
  };
</script>

Example


Template

<template>
  <x-element
    tag="div"
    @click="active = active"
    :active="active"
    hover
    v-model="hover"
    :css="css"
  >
    <div>
      Hello World <br />
      {{ active }} | {{ hover }}
      <div class="children-class">Hola Mundo</div>
    </div>
  </x-element>
</template>

Script

<script>
  export default {
    data() {
      return {
        active: true,
        hover: false,
      };
    },
    methods: {
      log(text) {
        console.log(text);
      },
    },
    computed: {
      css() {
        return {
          // Merge with Hover-And-Focus
          hoverAndFocus: true,
          // Base (Object)
          base: {
            // Base (Object-Style)
            color: "black",
            backgroundColor: "red",
            fontSize: "60px",
            textAlign: "center",
          },
          // Hover-And-Focus (Object-Style)
          hover: {
            color: "red",
            backgroundColor: "black",
          },
          // Active (Object)
          active: {
            // Active (Object-Style)
            base: {
              color: "blue",
              backgroundColor: "orange",
              fontSize: "20px",
            },
            // Active-Hover (Object-Style)
            hover: {
              color: "white",
              backgroundColor: "purple",
            },
          },
          // Children (Objects)
          children: {
            "children-class": {
              base: {
                color: "orange",
                backgroundColor: "darkorchid",
              },
              hover: {
                color: "red",
                backgroundColor: "darkorchid",
              },
              focus: {
                color: "white",
                backgroundColor: "darkorchid",
              },
            },
          },
        };
      },
    },
  };
</script>

Vue-Sync (Prop)

Use kebab-case for the sync declaration and as the attribute <div v-model:kebab-case="value" />

Then, use camelCase for the actual value inside the component.


Component

Create A Component

Script Code

export default {
  sync: ["count", "camel-case"],
};

Template Code

<div>{{ count }} | {{ camelCase }}</div>

Usage

Example Usage of The Component with v-model

Script Code

export default {
  data() {
    return {
      count: 1,
      camelCase: "kebab-case",
    };
  },
};

Template Code

<my-component v-model:count="count" v-model:camel-case="camelCase" />
1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago