@veritree/ui 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,6 +1,13 @@
1
+ import VTAvatar from './src/Avatar/VTAvatar.vue';
2
+ import VTAvatarImage from './src/Avatar/VTAvatarImage.vue';
3
+ import VTAvatarText from './src/Avatar/VTAvatarText.vue';
4
+ import VTImage from './src/Image/VTImage.vue';
5
+ import VTImageCounter from './src/Image/VTImageCounter.vue';
6
+ import VTImageHover from './src/Image/VTImageHover.vue';
7
+
1
8
  import VTAlert from './src/Alerts/VTAlert.vue';
2
9
 
3
- // import VTSpinner from './src/Spinner/VTSpinner.vue';
10
+ import VTSpinner from './src/Spinner/VTSpinner.vue';
4
11
 
5
12
  import VTButton from './src/Button/VTButton.vue';
6
13
  // import VTButtonSave from './src/Button/VTButtonSave.vue';
@@ -49,8 +56,14 @@ import VTDrawerMain from './src/Drawer/VTDrawerMain.vue';
49
56
  import VTDrawerOverlay from './src/Drawer/VTDrawerOverlay.vue';
50
57
 
51
58
  export {
59
+ VTAvatar,
60
+ VTAvatarImage,
61
+ VTAvatarText,
62
+ VTImage,
63
+ VTImageCounter,
64
+ VTImageHover,
52
65
  VTAlert,
53
- // VTSpinner,
66
+ VTSpinner,
54
67
  VTButton,
55
68
  // VTButtonSave,
56
69
  VTInput,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -0,0 +1,50 @@
1
+ <template>
2
+ <div
3
+ :class="{
4
+ Avatar: headless,
5
+ 'flex items-center justify-center overflow-hidden rounded-full':
6
+ !headless,
7
+ 'h-10 w-10': !small,
8
+ 'h-8 w-8': small,
9
+ 'border border-solid': !dark,
10
+ 'bg-white text-fd-500': dark,
11
+ }"
12
+ >
13
+ <slot></slot>
14
+ </div>
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+ name: 'VTAvatar',
20
+
21
+ provide() {
22
+ return {
23
+ api: () => {
24
+ const { dark: isDark, headless: isHeadless, light: isLight } = this;
25
+
26
+ return {
27
+ isDark,
28
+ isHeadless,
29
+ isLight,
30
+ };
31
+ },
32
+ };
33
+ },
34
+
35
+ props: {
36
+ headless: {
37
+ type: Boolean,
38
+ default: false,
39
+ },
40
+ dark: {
41
+ type: Boolean,
42
+ default: false,
43
+ },
44
+ small: {
45
+ type: Boolean,
46
+ default: false,
47
+ },
48
+ },
49
+ };
50
+ </script>
@@ -0,0 +1,38 @@
1
+ <template>
2
+ <VTImage v-if="src" :src="src" v-bind="attrs" width="40" />
3
+ <VTImage v-else-if="cdnSrc" :cdn-src="cdnSrc" v-bind="attrs" width="40" />
4
+ </template>
5
+
6
+ <script>
7
+ import VTImage from '~/components/Image/VTImage.vue';
8
+
9
+ export default {
10
+ name: 'VTAvatarImage',
11
+
12
+ components: { VTImage },
13
+
14
+ props: {
15
+ alt: {
16
+ type: String,
17
+ required: true,
18
+ },
19
+ src: {
20
+ type: String,
21
+ default: '',
22
+ },
23
+ cdnSrc: {
24
+ type: [String, Object],
25
+ default: null,
26
+ },
27
+ },
28
+
29
+ computed: {
30
+ attrs() {
31
+ return {
32
+ alt: this.alt,
33
+ class: 'h-auto w-full',
34
+ };
35
+ },
36
+ },
37
+ };
38
+ </script>
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <span class="font-semibold"><slot></slot></span>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ name: 'VTAvatarText',
8
+ };
9
+ </script>
@@ -4,17 +4,17 @@
4
4
  :id="id"
5
5
  :class="{ Drawer: headless, 'fixed inset-0 z-50 h-screen': !headless }"
6
6
  aria-modal="true"
7
- @click="hide"
7
+ @click="onClick"
8
8
  >
9
9
  <slot></slot>
10
10
  </div>
11
11
  </template>
12
12
 
13
13
  <script>
14
- import { genId } from '~/utils/ids';
14
+ import { genId } from "~/utils/ids";
15
15
 
16
16
  export default {
17
- name: 'VTDrawer',
17
+ name: "VTDrawer",
18
18
 
19
19
  provide() {
20
20
  return {
@@ -53,7 +53,7 @@ export default {
53
53
  },
54
54
 
55
55
  model: {
56
- prop: 'visible',
56
+ prop: "visible",
57
57
  },
58
58
 
59
59
  props: {
@@ -104,10 +104,20 @@ export default {
104
104
 
105
105
  emit() {
106
106
  this.$nextTick(() => {
107
- this.$emit('input', false);
108
- this.$emit('hidden');
107
+ this.$emit("input", false);
108
+ this.$emit("hidden");
109
109
  });
110
110
  },
111
+
112
+ /**
113
+ * Hides the dialog when clicking outside its content.
114
+ *
115
+ * @param {object} event
116
+ */
117
+ onClick(ev) {
118
+ if (!ev || ev.target.id !== this.overlay.id) return;
119
+ this.hide();
120
+ },
111
121
  },
112
122
  };
113
123
  </script>
@@ -20,7 +20,6 @@
20
20
  }"
21
21
  tabindex="-1"
22
22
  @keyup.esc="hide"
23
- @click.stop
24
23
  >
25
24
  <slot></slot>
26
25
  </div>
@@ -2,6 +2,7 @@
2
2
  <FadeInOut>
3
3
  <div
4
4
  v-if="visible"
5
+ :id="id"
5
6
  :class="{
6
7
  'Drawer-overlay': headless,
7
8
  'fixed inset-0 z-10 bg-fd-450/80': !headless,
@@ -11,14 +12,14 @@
11
12
  </template>
12
13
 
13
14
  <script>
14
- import FadeInOut from '../Transitions/FadeInOut.vue';
15
+ import FadeInOut from "../Transitions/FadeInOut.vue";
15
16
 
16
17
  export default {
17
18
  components: {
18
19
  FadeInOut,
19
20
  },
20
21
 
21
- inject: ['api'],
22
+ inject: ["api"],
22
23
 
23
24
  data() {
24
25
  return {
@@ -34,6 +35,10 @@ export default {
34
35
  headless() {
35
36
  return this.api().isHeadless;
36
37
  },
38
+
39
+ id() {
40
+ return `${this.api().id}-overlay`;
41
+ },
37
42
  },
38
43
 
39
44
  mounted() {
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <img
3
+ :src="srcComputed"
4
+ :class="{ 'animate-pulse': !isLoaded }"
5
+ v-bind="$attrs"
6
+ @load="onLoad"
7
+ @error="onError"
8
+ />
9
+ </template>
10
+
11
+ <script>
12
+ import { specifyImageWidth } from "~/utils/images";
13
+
14
+ export default {
15
+ name: "VTImage",
16
+
17
+ props: {
18
+ src: {
19
+ type: String,
20
+ default: "",
21
+ },
22
+ cdnSrc: {
23
+ type: [String, Object],
24
+ default: null,
25
+ },
26
+ placeholder: {
27
+ type: String,
28
+ default: `data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%22600%22%20height%3D%22400%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20%25%7Bw%7D%20%25%7Bh%7D%22%20preserveAspectRatio%3D%22none%22%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20style%3D%22fill%3A%23bbb%3B%22%3E%3C%2Frect%3E%3C%2Fsvg%3E`,
29
+ },
30
+ },
31
+
32
+ data() {
33
+ return {
34
+ canLoad: true,
35
+ isLoaded: false,
36
+ };
37
+ },
38
+
39
+ computed: {
40
+ srcComputed() {
41
+ if (!this.isLoaded) {
42
+ return this.placeholder;
43
+ } else {
44
+ if (!this.canLoad) {
45
+ return this.placeholder;
46
+ }
47
+
48
+ if (this.cdnSrc) {
49
+ return this.specifyImageWidth(this.cdnSrc, this.$attrs.width);
50
+ }
51
+
52
+ if (this.src) {
53
+ return this.src;
54
+ }
55
+ }
56
+
57
+ return null;
58
+ },
59
+ },
60
+
61
+ methods: {
62
+ specifyImageWidth,
63
+
64
+ onLoad() {
65
+ this.isLoaded = true;
66
+ },
67
+
68
+ onError() {
69
+ this.canLoad = false;
70
+ this.$emit("error");
71
+ },
72
+ },
73
+ };
74
+ </script>
@@ -0,0 +1,6 @@
1
+ <template>
2
+ <span
3
+ class="absolute inset-0 grid place-content-center bg-gray-500/75 font-semibold text-white no-underline transition-all hover:bg-gray-600/50"
4
+ >+ <slot></slot> images</span
5
+ >
6
+ </template>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <span
3
+ class="before:absolute before:inset-0 before:bg-transparent before:transition-all before:content-[''] before:hover:bg-gray-600/50"
4
+ ></span>
5
+ </template>
@@ -8,7 +8,7 @@
8
8
  >
9
9
  <path
10
10
  d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
11
- fill="currentFill"
11
+ fill="currentColor"
12
12
  />
13
13
  </svg>
14
14
  </template>