Skip to content

Commit ca12c21

Browse files
Add some common picker props at the base level for better usage
1 parent 443ad8d commit ca12c21

File tree

7 files changed

+168
-9
lines changed

7 files changed

+168
-9
lines changed

src/documentation/components/PropsTable.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@
4848
class="text-primary"
4949
:class="classes.appLink"
5050
:href="`#props-${sectionId ? `${sectionId}-${item.name}` : item.name}`"
51-
>{{ item.name }}</a>
51+
>{{ item.name }} <v-icon
52+
v-if="item.pickerProp"
53+
class=""
54+
color="primary"
55+
icon="mdi:mdi-palette"
56+
/></a>
5257
</span>
58+
5359
</td>
5460
</template>
5561

src/documentation/sections/PropsSection.vue

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,27 @@
1616
When using the <code class="ic">VTextField</code>, you can use the regular props
1717
that are available for that component.
1818
</div>
19+
</v-col>
1920

20-
<div>
21-
For component specific props, please refer to the <a
22-
:href="store.links.vuetify"
23-
target="_blank"
24-
>Vuetify</a> documentation.
25-
</div>
21+
<v-col cols="12">
22+
<v-alert>
23+
Some of the more common <code class="ic">VColorPicker</code> props that have a <v-icon
24+
color="primary"
25+
icon="mdi:mdi-palette"
26+
/>
27+
next to them in the prop table below. Any other props can be added to the <code
28+
class="ic">color-picker-props</code>
29+
prop. Please note that the <code class="ic">color-picker-props</code> have a higher priority than the individual
30+
props.
31+
32+
</v-alert>
33+
</v-col>
34+
35+
<v-col cols="12">
36+
For other component specific props, please refer to the <a
37+
:href="store.links.vuetify"
38+
target="_blank"
39+
>Vuetify</a> documentation.
2640
</v-col>
2741

2842
<v-col cols="12">
@@ -31,7 +45,6 @@
3145
:items="propsStore.componentProps"
3246
section-id="component-props"
3347
section-title="Component Props"
34-
subtitle="These props are used by the component."
3548
/>
3649
</v-col>
3750
</v-row>

src/playground/configs/templates/PlaygroundPage.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
v-model="color"
1212
:append-icon="VColorFieldProps.appendIcon"
1313
:append-inner-icon="VColorFieldProps.appendInnerIcon"
14+
:canvasHeight="VColorFieldProps.canvasHeight"
1415
:cardFieldWidth="VColorFieldProps.cardFieldWidth"
1516
:cardOffsetX="VColorFieldProps.cardOffsetX"
1617
:cardOffsetY="VColorFieldProps.cardOffsetY"
@@ -20,12 +21,18 @@
2021
:color="VColorFieldProps.color"
2122
:color-picker-props="VColorFieldProps.colorPickerProps"
2223
:density="VColorFieldProps.density"
24+
:dotSize="VColorFieldProps.dotSize"
25+
:hideCanvas="VColorFieldProps.hideCanvas"
26+
:hideInputs="VColorFieldProps.hideInputs"
27+
:hideSliders="VColorFieldProps.hideSliders"
2328
:hint="VColorFieldProps.hint"
2429
:hint-align="VColorFieldProps.hintAlign"
2530
:icon-hover-color="VColorFieldProps.iconHoverColor"
2631
:iconSize="VColorFieldProps.iconSize"
2732
:label="VColorFieldProps.label"
2833
:messages="VColorFieldProps.messages"
34+
:mode="VColorFieldProps.mode"
35+
:modes="VColorFieldProps.modes"
2936
:name="VColorFieldProps.name"
3037
:open="VColorFieldProps.open"
3138
:persistent-hint="VColorFieldProps.persistentHint"
@@ -43,6 +50,9 @@
4350
:readonly="VColorFieldProps.readonly"
4451
:readonlyInput="VColorFieldProps.readonlyInput"
4552
:required="VColorFieldProps.required"
53+
:showSwatches="VColorFieldProps.showSwatches"
54+
:swatches="VColorFieldProps.swatches"
55+
:swatchesMaxHeight="VColorFieldProps.swatchesMaxHeight"
4656
:theme="VColorFieldProps.theme"
4757
:variant="VColorFieldProps.variant"
4858
>
@@ -88,7 +98,27 @@
8898
<script setup>
8999
const color = ref(null);
90100
101+
const colorPickerProps = {
102+
canvasHeight: 150,
103+
dotSize: 10,
104+
hideCanvas: false,
105+
hideInputs: false,
106+
hideSliders: false,
107+
mode: 'rgba',
108+
modes: ['rgb', 'rgba', 'hsl', 'hsla', 'hex', 'hexa'],
109+
showSwatches: true,
110+
// swatches: [
111+
// ['#FF0000', '#AA0000', '#550000'],
112+
// ['#FFFF00', '#AAAA00', '#555500'],
113+
// ['#00FF00', '#00AA00', '#005500'],
114+
// ['#00FFFF', '#00AAAA', '#005555'],
115+
// ['#0000FF', '#0000AA', '#000055'],
116+
// ],
117+
swatchesMaxHeight: 150,
118+
};
119+
91120
const VColorFieldProps = ref({
121+
...colorPickerProps,
92122
appendIcon: undefined,
93123
appendInnerIcon: undefined,
94124
cardFieldWidth: false,
@@ -105,6 +135,7 @@ const VColorFieldProps = ref({
105135
clearable: true,
106136
color: '',
107137
colorPickerProps: {
138+
dotSize: 30,
108139
// mode: 'hex',
109140
// modes: ['hex'],
110141
// showSwatches: true,

src/plugin/VColorField.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,18 @@ const defaults = ref<VuetifyDefaults>({
300300
},
301301
VColorPicker: {
302302
...defaultColorPickerProps,
303+
...{
304+
canvasHeight: props.canvasHeight,
305+
dotSize: props.dotSize,
306+
hideCanvas: props.hideCanvas,
307+
hideInputs: props.hideInputs,
308+
hideSliders: props.hideSliders,
309+
mode: props.mode,
310+
modes: props.modes,
311+
showSwatches: props.showSwatches,
312+
swatches: props.swatches,
313+
swatchesMaxHeight: props.swatchesMaxHeight,
314+
},
303315
...props.colorPickerProps,
304316
},
305317
});

src/plugins/vuetify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default createVuetify({
2626
},
2727
},
2828
theme: {
29-
defaultTheme: 'light',
29+
defaultTheme: 'dark',
3030
themes: {
3131
...defaultThemes,
3232
},

src/stores/props.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,82 @@ const propsHeaders = [
3434
},
3535
];
3636

37+
const colorPickerProps = [
38+
{
39+
default: '150',
40+
desc: 'Height of canvas.',
41+
name: 'canvas-height',
42+
pickerProp: true,
43+
type: `VColorPicker['$props']['canvasHeight']`,
44+
},
45+
{
46+
default: '10',
47+
desc: 'Changes the size of the selection dot on the canvas.',
48+
name: 'dot-size',
49+
pickerProp: true,
50+
type: `VColorPicker['$props']['dotSize']`,
51+
},
52+
{
53+
default: 'false',
54+
desc: 'Hides canvas.',
55+
name: 'hide-canvas',
56+
pickerProp: true,
57+
type: `VColorPicker['$props']['hideCanvas']`,
58+
},
59+
{
60+
default: 'false',
61+
desc: 'Hides inputs.',
62+
name: 'hide-inputs',
63+
pickerProp: true,
64+
type: `VColorPicker['$props']['hideInputs']`,
65+
},
66+
{
67+
default: 'false',
68+
desc: 'Hides sliders.',
69+
name: 'hide-sliders',
70+
pickerProp: true,
71+
type: `VColorPicker['$props']['hideSliders']`,
72+
},
73+
{
74+
default: 'rgba',
75+
desc: 'The current selected input type.',
76+
name: 'mode',
77+
pickerProp: true,
78+
type: `VColorPicker['$props']['mode']`,
79+
},
80+
{
81+
default: `['rgb', 'rgba', 'hsl', 'hsla', 'hex', 'hexa']`,
82+
desc: 'Sets available input types.',
83+
name: 'modes',
84+
pickerProp: true,
85+
type: `VColorPicker['$props']['modes']`,
86+
},
87+
{
88+
default: 'false',
89+
desc: 'Displays color swatches.',
90+
name: 'show-swatches',
91+
pickerProp: true,
92+
type: `VColorPicker['$props']['showSwatches']`,
93+
},
94+
{
95+
default: 'undefined',
96+
desc: 'Sets the available color swatches to select from. 2D array of rows and columns, accepts any color format the picker does.',
97+
name: 'swatches',
98+
pickerProp: true,
99+
type: `VColorPicker['$props']['swatches']`,
100+
},
101+
{
102+
default: '150',
103+
desc: 'Sets the maximum height of the swatches section.',
104+
name: 'swatches-max-height',
105+
pickerProp: true,
106+
type: `VColorPicker['$props']['swatchesMaxHeight']`,
107+
},
108+
];
109+
37110

38111
const componentProps = [
112+
...colorPickerProps,
39113
{
40114
default: 'false',
41115
desc: 'Sets the <code class="ic">VCard</code> width to the same width as the <code class="ic">VTextField</code> input.',
@@ -141,6 +215,17 @@ const componentProps = [
141215
];
142216

143217

218+
// canvasHeight: 150,
219+
// dotSize: 10,
220+
// hideCanvas: false,
221+
// hideInputs: false,
222+
// hideSliders: false,
223+
// mode: 'rgba',
224+
// modes: ['rgb', 'rgba', 'hsl', 'hsla', 'hex', 'hexa'],
225+
// showSwatches: true,
226+
// swatchesMaxHeight: 150,
227+
228+
144229
export const usePropsStore = defineStore('props', {
145230
state: () => {
146231
return {

src/types/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ export interface Props extends PipProps {
6868
readonlyInput?: boolean | null | undefined;
6969
required?: boolean;
7070
theme?: VTextField['$props']['theme'];
71+
72+
// Color Picker Specific //
73+
canvasHeight?: VColorPicker['$props']['canvasHeight'];
74+
dotSize?: VColorPicker['$props']['dotSize'];
75+
hideCanvas?: VColorPicker['$props']['hideCanvas'];
76+
hideInputs?: VColorPicker['$props']['hideInputs'];
77+
hideSliders?: VColorPicker['$props']['hideSliders'];
78+
mode?: VColorPicker['$props']['mode'];
79+
modes?: VColorPicker['$props']['modes'];
80+
showSwatches?: VColorPicker['$props']['showSwatches'];
81+
swatches?: VColorPicker['$props']['swatches'];
82+
swatchesMaxHeight?: VColorPicker['$props']['swatchesMaxHeight'];
7183
}
7284

7385
export interface PipComponentProps extends PipProps {

0 commit comments

Comments
 (0)