vuetify-swatches 0.0.1 → 0.0.4

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/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Vuetify Swatches
2
2
 
3
- ![anime](https://user-images.githubusercontent.com/480173/156681882-d3d5e868-ba9a-4a34-9e75-08272d39da64.gif)
3
+ [![jsdelivr CDN](https://data.jsdelivr.com/v1/package/npm/vuetify-swatches/badge)](https://www.jsdelivr.com/package/npm/vuetify-swatches)
4
+ [![NPM Downloads](https://img.shields.io/npm/dm/vuetify-swatches.svg?style=flat)](https://www.npmjs.com/package/vuetify-swatches)
5
+ [![Open in unpkg](https://img.shields.io/badge/Open%20in-unpkg-blue)](https://uiwjs.github.io/npm-unpkg/#/pkg/vuetify-swatches/file/README.md)
6
+ [![npm version](https://img.shields.io/npm/v/vuetify-swatches.svg)](https://www.npmjs.com/package/vuetify-swatches)
7
+ [![Open in Gitpod](https://shields.io/badge/Open%20in-Gitpod-green?logo=Gitpod)](https://gitpod.io/#https://github.com/logue/vuetify-swatches)
8
+
9
+ ![demo](https://user-images.githubusercontent.com/480173/156681882-d3d5e868-ba9a-4a34-9e75-08272d39da64.gif)
4
10
 
5
11
  This project is a remake of [saintplay's vue-swatches](https://saintplay.github.io/vue-swatches/) with [Vuetify](https://vuetifyjs.com/).
6
12
 
@@ -12,25 +18,107 @@ This library is positioned as a complement to Vuetify and provides a minimal UI.
12
18
 
13
19
  In this example, the selected color is assigned to `selected`.
14
20
 
15
- The method of specifying `swatches` is the same as [nested-color of Vue Swatches](https://saintplay.github.io/vue-swatches/examples/#nested-colors).
16
-
17
21
  ```vue
18
- <v-swatches v-model="selected" :swatches="colors" />
22
+ <template>
23
+ <v-swatches v-model="selected" />
24
+ </template>
25
+
26
+ <script>
27
+ import Vue from 'vue';
28
+
29
+ import VSwatches from 'vuetify-swatches';
30
+
31
+ export default Vue.extend({
32
+ data() {
33
+ return {
34
+ selected: '#ffffff',
35
+ };
36
+ },
37
+ });
38
+ </script>
39
+
40
+ <style>
41
+ @import 'vuetify-swatches/dist/style.css';
42
+ </style>
19
43
  ```
20
44
 
45
+ The method of specifying `swatches` is the same as [nested-color of Vue Swatches](https://saintplay.github.io/vue-swatches/examples/#nested-colors).
46
+
21
47
  If you want to make the color palette appear when you click it, combine it with VMenu.
22
48
 
23
49
  ```vue
24
- <v-menu offset-y>
25
- <template #activator="{ on, attrs }">
26
- <v-btn v-bind="attrs" min-width="auto" :color="selected" v-on="on">
27
- <v-icon :color="selected" style="filter: invert(100%)">
28
- mdi-menu-down
29
- </v-icon>
30
- </v-btn>
31
- </template>
32
- <v-swatches v-model="selected" :swatches="palette" />
33
- </v-menu>
50
+ <template>
51
+ <v-menu offset-y>
52
+ <template #activator="{ on, attrs }">
53
+ <v-btn v-bind="attrs" min-width="auto" :color="selected" v-on="on">
54
+ <v-icon :color="selected" style="filter: invert(100%)">
55
+ mdi-menu-down
56
+ </v-icon>
57
+ </v-btn>
58
+ </template>
59
+ <v-swatches v-model="selected" :swatches="palette" />
60
+ </v-menu>
61
+ </template>
62
+
63
+ <script>
64
+ import Vue from 'vue';
65
+
66
+ import VSwatches from 'vuetify-swatches';
67
+
68
+ export default Vue.extend({
69
+ data() {
70
+ return {
71
+ selected: '#ffffff',
72
+ palette: [
73
+ [
74
+ '#ffb7b7',
75
+ '#ffdbb7',
76
+ '#ffffb7',
77
+ '#b7ffb7',
78
+ '#b7ffff',
79
+ '#b7b7ff',
80
+ '#ffb7ff',
81
+ '#ffffff',
82
+ ],
83
+ [
84
+ '#ff5555',
85
+ '#ffa555',
86
+ '#ffff55',
87
+ '#55ff55',
88
+ '#55ffff',
89
+ '#5555ff',
90
+ '#ff55ff',
91
+ '#aaaaaa',
92
+ ],
93
+ [
94
+ '#ff0000',
95
+ '#ff7f00',
96
+ '#ffff00',
97
+ '#00ff00',
98
+ '#00ffff',
99
+ '#0000ff',
100
+ '#ff00ff',
101
+ '#555555',
102
+ ],
103
+ [
104
+ '#7f0000',
105
+ '#7f4c00',
106
+ '#7f7f00',
107
+ '#007f00',
108
+ '#007f7f',
109
+ '#00007f',
110
+ '#7f007f',
111
+ '#000000',
112
+ ],
113
+ ],
114
+ };
115
+ },
116
+ });
117
+ </script>
118
+
119
+ <style>
120
+ @import 'vuetify-swatches/dist/style.css';
121
+ </style>
34
122
  ```
35
123
 
36
124
  ### Options
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "vuetify-swatches",
4
4
  "private": false,
5
- "version": "0.0.1",
5
+ "version": "0.0.4",
6
6
  "description": "Color Swatch component for Vuetify.",
7
7
  "keywords": [
8
8
  "vuejs",
@@ -53,7 +53,8 @@
53
53
  "sideEffects": false,
54
54
  "scripts": {
55
55
  "dev": "vite",
56
- "build": "vite build & vue-tsc",
56
+ "clean": "rimraf node_modules/.vite",
57
+ "build": "vite build & vue-tsc --declaration --emitDeclarationOnly",
57
58
  "build:clean": "rimraf dist && rimraf types",
58
59
  "lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
59
60
  "lint:style": "stylelint **/*.{css,sass,scss,htm,html,vue} --fix --cache",
@@ -61,55 +62,66 @@
61
62
  "prepare": "husky install"
62
63
  },
63
64
  "dependencies": {
65
+ "vue-demi": "latest"
66
+ },
67
+ "peerDependencies": {
68
+ "@vue/composition-api": "^1.5.0",
64
69
  "vue": "^2.6.14",
65
- "vue-class-component": "^7.2.6",
66
- "vue-property-decorator": "^9.1.2",
67
70
  "vuetify": "^2.6.4"
68
71
  },
72
+ "peerDependenciesMeta": {
73
+ "@vue/composition-api": {
74
+ "optional": true
75
+ }
76
+ },
69
77
  "devDependencies": {
70
- "@types/node": "^17.0.21",
71
- "@typescript-eslint/eslint-plugin": "^5.15.0",
72
- "@typescript-eslint/parser": "^5.15.0",
73
- "@vue/compiler-sfc": "^3.2.31",
78
+ "@codemirror/basic-setup": "^0.20.0",
79
+ "@codemirror/lang-html": "^0.20.0",
80
+ "@modyqyw/vite-plugin-eslint": "^1.3.0",
81
+ "@types/node": "^17.0.27",
82
+ "@typescript-eslint/eslint-plugin": "^5.21.0",
83
+ "@typescript-eslint/parser": "^5.21.0",
84
+ "@vue/composition-api": "^1.5.0",
74
85
  "@vue/eslint-config-typescript": "^10.0.0",
75
- "eslint": "^8.11.0",
86
+ "eslint": "^8.14.0",
76
87
  "eslint-config-google": "^0.14.0",
77
88
  "eslint-config-prettier": "^8.5.0",
78
89
  "eslint-config-vuetify": "^0.6.1",
79
90
  "eslint-import-resolver-alias": "^1.1.2",
80
- "eslint-import-resolver-typescript": "^2.5.0",
81
- "eslint-plugin-import": "^2.25.4",
91
+ "eslint-import-resolver-typescript": "^2.7.1",
92
+ "eslint-plugin-import": "^2.26.0",
82
93
  "eslint-plugin-prettier": "^4.0.0",
83
94
  "eslint-plugin-prettier-vue": "^3.1.0",
84
- "eslint-plugin-tsdoc": "^0.2.14",
85
- "eslint-plugin-vue": "^8.5.0",
95
+ "eslint-plugin-tsdoc": "^0.2.16",
96
+ "eslint-plugin-vue": "^8.7.1",
86
97
  "eslint-plugin-vuejs-accessibility": "^1.1.1",
87
98
  "eslint-plugin-vuetify": "^1.1.0",
88
99
  "eslint-plugin-yaml": "^0.5.0",
89
100
  "husky": "^7.0.4",
90
- "lint-staged": "^12.3.6",
91
- "postcss-html": "^1.3.0",
92
- "prettier": "^2.6.0",
93
- "prettier-plugin-jsdoc": "^0.3.31",
101
+ "lint-staged": "^12.4.0",
102
+ "postcss-html": "^1.4.1",
103
+ "prettier": "^2.6.2",
104
+ "prettier-plugin-jsdoc": "^0.3.38",
94
105
  "prettier-plugin-md-nocjsp": "^1.2.0",
95
106
  "prettier-plugin-sort-imports": "^1.6.0",
96
107
  "rimraf": "^3.0.2",
97
108
  "sass": "1.32.12",
98
- "stylelint": "^14.6.0",
109
+ "stylelint": "^14.7.1",
99
110
  "stylelint-config-prettier": "^9.0.3",
100
- "stylelint-config-recommended-scss": "^5.0.2",
101
- "stylelint-config-recommended-vue": "^1.3.0",
111
+ "stylelint-config-recommended-scss": "^6.0.0",
112
+ "stylelint-config-recommended-vue": "^1.4.0",
102
113
  "stylelint-order": "^5.0.0",
103
114
  "stylelint-prettier": "^2.0.0",
104
- "typescript": ">=3.3.1 <4.6.0",
105
- "unplugin-vue-components": "^0.18.0",
106
- "vite": "^2.8.6",
107
- "vite-plugin-eslint": "^1.3.0",
108
- "vite-plugin-stylelint": "^1.2.0",
109
- "vite-plugin-vue2": "^1.9.3",
115
+ "typescript": "^4.6.3",
116
+ "unplugin-vue-components": "^0.19.3",
117
+ "vite": "^2.9.5",
118
+ "vite-plugin-stylelint": "^2.2.0",
119
+ "vite-plugin-vue2": "^2.0.0",
120
+ "vue": "^2.6.14",
121
+ "vue-codemirror6": "0.1.3",
110
122
  "vue-eslint-parser": "^8.3.0",
111
123
  "vue-template-compiler": "^2.6.14",
112
- "vue-tsc": "^0.33.2"
124
+ "vue-tsc": "^0.34.10"
113
125
  },
114
126
  "husky": {
115
127
  "hooks": {
@@ -24,92 +24,114 @@
24
24
  </template>
25
25
 
26
26
  <script lang="ts">
27
- import { Component, Prop, PropSync, Vue } from 'vue-property-decorator';
27
+ import { ref, defineComponent, type SetupContext, type Ref } from 'vue-demi';
28
28
 
29
29
  import { VSheet, VIcon, VBtn } from 'vuetify/lib';
30
30
  import colors from 'vuetify/lib/util/colors';
31
31
 
32
- @Component({
32
+ /** Vuetify Swatches */
33
+ export default defineComponent({
34
+ /** Component name */
35
+ name: 'VSwatches',
36
+ /** Components */
33
37
  components: {
34
38
  VSheet,
35
39
  VBtn,
36
40
  VIcon,
37
41
  },
38
- })
39
- /** Swatch */
40
- export default class VSwatches extends Vue {
41
- /** チェックアイコンの表示制御 */
42
- checkedVisibilty = false;
43
-
44
- /** カラー一覧 */
45
- @PropSync('swatches', {
46
- type: Array,
47
- default: () => [
48
- [colors.shades.black, colors.shades.white],
49
- [
50
- colors.red.base,
51
- colors.pink.base,
52
- colors.purple.base,
53
- colors.deepPurple.base,
54
- colors.indigo.base,
55
- colors.blue.base,
56
- colors.lightBlue.base,
57
- colors.cyan.base,
58
- ],
59
- [
60
- colors.teal.base,
61
- colors.green.base,
62
- colors.lightGreen.base,
63
- colors.lime.base,
64
- colors.yellow.base,
65
- colors.amber.base,
66
- colors.orange.base,
67
- colors.deepOrange.base,
42
+ /** Model Definition */
43
+ model: {
44
+ prop: 'modelValue',
45
+ event: 'update:modelValue',
46
+ },
47
+ props: {
48
+ /** Model value */
49
+ modelValue: { type: String, required: true },
50
+ /** Swatch colors */
51
+ swatches: {
52
+ type: Array as () => string[] | string[][],
53
+ default: () => [
54
+ [colors.shades.black, colors.shades.white],
55
+ [
56
+ colors.red.base,
57
+ colors.pink.base,
58
+ colors.purple.base,
59
+ colors.deepPurple.base,
60
+ colors.indigo.base,
61
+ colors.blue.base,
62
+ colors.lightBlue.base,
63
+ colors.cyan.base,
64
+ ],
65
+ [
66
+ colors.teal.base,
67
+ colors.green.base,
68
+ colors.lightGreen.base,
69
+ colors.lime.base,
70
+ colors.yellow.base,
71
+ colors.amber.base,
72
+ colors.orange.base,
73
+ colors.deepOrange.base,
74
+ ],
75
+ [colors.brown.base, colors.blueGrey.base, colors.grey.base],
68
76
  ],
69
- [colors.brown.base, colors.blueGrey.base, colors.grey.base],
70
- ],
71
- })
72
- palette!: string[] | string[][];
73
-
74
- /** 親コンポーネントからのバインディング */
75
- @PropSync('value', { required: true, type: String })
76
- selected!: string;
77
+ },
78
+ /** Swatch sized */
79
+ size: { type: String, default: '2rem' },
80
+ /** selected icon */
81
+ icon: { type: String, default: 'mdi-checkbox-marked-circle' },
82
+ /** selected icon size */
83
+ iconSize: { type: String, default: '1rem' },
84
+ },
85
+ /** Emits */
86
+ emits: ['update:modelValue'],
87
+ /**
88
+ * Setup
89
+ * @param props - Props
90
+ * @param context - Context
91
+ */
92
+ setup(props, context: SetupContext) {
93
+ /** チェックアイコンの表示制御 */
94
+ const checkedVisibilty: Ref<boolean> = ref(false);
77
95
 
78
- /** ボタンの大きさ */
79
- @Prop({ default: '2rem', type: String })
80
- readonly size!: string;
96
+ /** Palette */
97
+ const palette: Ref<string[] | string[][]> = ref(props.swatches);
81
98
 
82
- /** 使用するアイコン */
83
- @Prop({ default: 'mdi-checkbox-marked-circle', type: String })
84
- readonly icon!: string;
99
+ /** Selected color */
100
+ const selected: Ref<string> = ref(props.modelValue);
85
101
 
86
- /** アイコンサイズ */
87
- @Prop({ default: '1rem', type: String })
88
- readonly iconSize!: string;
102
+ /**
103
+ * ボタンがクリックされた
104
+ *
105
+ * @param e - イベント
106
+ */
107
+ const onSwatchClick = (e: Event) => {
108
+ const value = (e.target as HTMLButtonElement).value;
109
+ if (!value || selected.value === value) {
110
+ return;
111
+ }
112
+ selected.value = value;
113
+ context.emit('update:modelValue', value);
114
+ };
89
115
 
90
- /**
91
- * ボタンがクリックされた
92
- *
93
- * @param e - イベント
94
- */
95
- onSwatchClick(e: Event) {
96
- const value = (e.target as HTMLButtonElement).value;
97
- if (!value || this.selected === value) {
98
- return;
99
- }
100
- this.selected = value;
101
- this.$emit('input', value);
102
- }
103
- }
116
+ return {
117
+ checkedVisibilty,
118
+ palette,
119
+ selected,
120
+ onSwatchClick,
121
+ };
122
+ },
123
+ });
104
124
  </script>
105
125
 
106
- <style lang="scss" scoped>
107
- .v-btn {
108
- padding: 0 !important;
109
- margin: 0.1rem;
126
+ <style lang="scss">
127
+ .v-swatches {
128
+ .v-btn {
129
+ padding: 0 !important;
130
+ margin: 0.1rem;
110
131
 
111
- .v-icon {
112
- filter: invert(100%);
132
+ .v-icon {
133
+ filter: invert(100%);
134
+ }
113
135
  }
114
136
  }
115
137
  </style>