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 +102 -14
- package/package.json +39 -27
- package/src/components/VSwatches.vue +91 -69
- package/dist/VSwatches.es.js +0 -3143
- package/dist/VSwatches.umd.js +0 -33
- package/dist/components/VSwatches.vue.d.ts +0 -23
- package/dist/components/VSwatches.vue.d.ts.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.esm.d.ts +0 -6
- package/dist/index.esm.d.ts.map +0 -1
- package/dist/style.css +0 -5
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Vuetify Swatches
|
|
2
2
|
|
|
3
|
-
](https://www.jsdelivr.com/package/npm/vuetify-swatches)
|
|
4
|
+
[](https://www.npmjs.com/package/vuetify-swatches)
|
|
5
|
+
[](https://uiwjs.github.io/npm-unpkg/#/pkg/vuetify-swatches/file/README.md)
|
|
6
|
+
[](https://www.npmjs.com/package/vuetify-swatches)
|
|
7
|
+
[](https://gitpod.io/#https://github.com/logue/vuetify-swatches)
|
|
8
|
+
|
|
9
|
+

|
|
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
|
-
<
|
|
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
|
-
<
|
|
25
|
-
<
|
|
26
|
-
<
|
|
27
|
-
<v-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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.
|
|
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
|
-
"
|
|
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
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"@
|
|
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.
|
|
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.
|
|
81
|
-
"eslint-plugin-import": "^2.
|
|
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.
|
|
85
|
-
"eslint-plugin-vue": "^8.
|
|
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.
|
|
91
|
-
"postcss-html": "^1.
|
|
92
|
-
"prettier": "^2.6.
|
|
93
|
-
"prettier-plugin-jsdoc": "^0.3.
|
|
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.
|
|
109
|
+
"stylelint": "^14.7.1",
|
|
99
110
|
"stylelint-config-prettier": "^9.0.3",
|
|
100
|
-
"stylelint-config-recommended-scss": "^
|
|
101
|
-
"stylelint-config-recommended-vue": "^1.
|
|
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": "
|
|
105
|
-
"unplugin-vue-components": "^0.
|
|
106
|
-
"vite": "^2.
|
|
107
|
-
"vite-plugin-
|
|
108
|
-
"vite-plugin-
|
|
109
|
-
"
|
|
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.
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
colors.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
80
|
-
readonly size!: string;
|
|
96
|
+
/** Palette */
|
|
97
|
+
const palette: Ref<string[] | string[][]> = ref(props.swatches);
|
|
81
98
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
readonly icon!: string;
|
|
99
|
+
/** Selected color */
|
|
100
|
+
const selected: Ref<string> = ref(props.modelValue);
|
|
85
101
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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"
|
|
107
|
-
.v-
|
|
108
|
-
|
|
109
|
-
|
|
126
|
+
<style lang="scss">
|
|
127
|
+
.v-swatches {
|
|
128
|
+
.v-btn {
|
|
129
|
+
padding: 0 !important;
|
|
130
|
+
margin: 0.1rem;
|
|
110
131
|
|
|
111
|
-
|
|
112
|
-
|
|
132
|
+
.v-icon {
|
|
133
|
+
filter: invert(100%);
|
|
134
|
+
}
|
|
113
135
|
}
|
|
114
136
|
}
|
|
115
137
|
</style>
|