@designcrowd/library.brand-page 5.8.6 → 5.8.8
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/lib/src/brand-page/components/media/Shape.mixin.js +3 -0
- package/lib/src/brand-page/constants/misc.constants.d.ts +0 -22
- package/lib/src/brand-page/constants/misc.constants.js +0 -22
- package/lib/src/brand-page/utils/color.util.d.ts +2 -0
- package/lib/src/brand-page/utils/color.util.js +13 -0
- package/lib/src/brand-page/utils/style.util.d.ts +6 -2
- package/lib/src/brand-page/utils/style.util.js +43 -27
- package/lib/src/brand-page-maker/components/admin-background-settings/AdminBackgroundSettings.mixin.d.ts +0 -22
- package/lib/src/brand-page-maker/stores/event-manager/event-manager-store.js +6 -0
- package/lib/src/index.mjs +14681 -13726
- package/lib/src/shared/content-settings/components/color-field/ColorField.mixin.d.ts +8 -26
- package/lib/src/shared/content-settings/components/color-field/ColorField.mixin.js +3 -2
- package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +0 -22
- package/package.json +2 -1
- package/src/brand-page/components/media/Shape.mixin.ts +4 -0
- package/src/brand-page/constants/misc.constants.ts +0 -22
- package/src/brand-page/utils/color.util.test.ts +47 -0
- package/src/brand-page/utils/color.util.ts +18 -0
- package/src/brand-page/utils/style.util.test.ts +1 -0
- package/src/brand-page/utils/style.util.ts +94 -27
- package/src/brand-page-maker/stores/event-manager/event-manager-store.ts +7 -0
- package/src/shared/content-settings/components/color-field/ColorField.mixin.ts +3 -2
- package/src/shared/content-settings/components/color-replacements-field/ColorReplacementsField.vue +126 -37
- package/lib/src/shared/content-settings/components/color-replacements-field/ColorReplacementsField.mixin.d.ts +0 -112
- package/lib/src/shared/content-settings/components/color-replacements-field/ColorReplacementsField.mixin.js +0 -104
- package/src/shared/content-settings/components/color-replacements-field/ColorReplacementsField.mixin.ts +0 -118
package/src/shared/content-settings/components/color-replacements-field/ColorReplacementsField.vue
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
>{{ label }}
|
|
13
13
|
</span>
|
|
14
14
|
<Toggle
|
|
15
|
-
v-if="
|
|
15
|
+
v-if="
|
|
16
|
+
isAdmin && data.colorReplacements && data.colorReplacements.length > 0
|
|
17
|
+
"
|
|
16
18
|
:id="`${id}-${name}-color-matched${toggleIdSuffix}`"
|
|
17
19
|
:model-value="isOptionColorMatched"
|
|
18
20
|
color="info"
|
|
@@ -21,11 +23,14 @@
|
|
|
21
23
|
@update:model-value="onColorMatchToggled"
|
|
22
24
|
/>
|
|
23
25
|
<div
|
|
24
|
-
class="tw-flex tw-flex-wrap
|
|
25
|
-
:class="{
|
|
26
|
+
class="tw-flex tw-flex-wrap"
|
|
27
|
+
:class="{
|
|
28
|
+
'tw-flex-col': isOptionColorMatched,
|
|
29
|
+
'tw-gap-2': !isOptionColorMatched,
|
|
30
|
+
}"
|
|
26
31
|
>
|
|
27
32
|
<div
|
|
28
|
-
v-for="(colorReplacement, index) in colorReplacements"
|
|
33
|
+
v-for="(colorReplacement, index) in data.colorReplacements"
|
|
29
34
|
:key="`${colorReplacement.attribute}-${colorReplacement.originalColor}`"
|
|
30
35
|
>
|
|
31
36
|
<ColorField
|
|
@@ -37,47 +42,131 @@
|
|
|
37
42
|
:logo-theme="logoTheme"
|
|
38
43
|
@update:model-value="onColorPickerInput($event, index)"
|
|
39
44
|
/>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
</div>
|
|
46
|
+
<div
|
|
47
|
+
v-if="
|
|
48
|
+
isAdmin &&
|
|
49
|
+
data.colorReplacements &&
|
|
50
|
+
data.colorReplacements.length > 0 &&
|
|
51
|
+
isOptionColorMatched
|
|
52
|
+
"
|
|
53
|
+
>
|
|
54
|
+
<select
|
|
55
|
+
class="c-select c-button-style tw-flex-grow tw-border tw-appearance-none tw-border-none tw-h-10 tw-pl-2 tw-rounded tw-cursor-pointer tw-transition-all tw-duration-300 tw-bg-white"
|
|
56
|
+
@change.stop="
|
|
57
|
+
onColorPickerInputDropdown(($event!.target as any).value)
|
|
58
|
+
"
|
|
59
|
+
>
|
|
60
|
+
<option
|
|
61
|
+
v-for="(styleThemeKey, styleKeyThemeIndex) in data.styleThemeKeys"
|
|
62
|
+
:key="styleKeyThemeIndex"
|
|
63
|
+
:value="styleThemeKey"
|
|
64
|
+
:selected="styleThemeKey === selectedColor"
|
|
51
65
|
>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
:value="styleThemeKey"
|
|
56
|
-
:selected="
|
|
57
|
-
styleThemeKey === colorReplacement.replacementColor
|
|
58
|
-
? 'selected'
|
|
59
|
-
: null
|
|
60
|
-
"
|
|
61
|
-
>
|
|
62
|
-
{{ styleThemeKey }}
|
|
63
|
-
</option>
|
|
64
|
-
</select>
|
|
65
|
-
</div>
|
|
66
|
-
<!-- End Admin Style Theme Key Select -->
|
|
66
|
+
{{ styleThemeKey }}
|
|
67
|
+
</option>
|
|
68
|
+
</select>
|
|
67
69
|
</div>
|
|
68
70
|
</div>
|
|
69
71
|
</div>
|
|
70
72
|
</template>
|
|
71
|
-
<script>
|
|
73
|
+
<script setup lang="ts">
|
|
72
74
|
import { Toggle } from '@designcrowd/fe-shared-lib';
|
|
73
|
-
import ColorReplacementsFieldMixin from './ColorReplacementsField.mixin.ts';
|
|
74
75
|
import ColorField from '../../../content-settings/components/color-field/ColorField.vue';
|
|
76
|
+
import type { ColorReplacement, LogoTheme } from '../../../../brand-page';
|
|
77
|
+
import { reactive, watch, computed } from 'vue';
|
|
78
|
+
import { STYLE_THEME_KEYS } from '../../../../brand-page/constants';
|
|
79
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
80
|
+
import debounce from 'lodash.debounce';
|
|
81
|
+
import { isColorMatched } from '../../../../brand-page-maker/utils';
|
|
82
|
+
import type { DebounceHandle } from 'lodash.debounce';
|
|
83
|
+
import type { UpdateItemValuePayload } from '../../../content-settings/models';
|
|
84
|
+
|
|
85
|
+
const DEBOUNCE_WAIT_IN_MS = 10;
|
|
86
|
+
|
|
87
|
+
const props = defineProps<{
|
|
88
|
+
id: string;
|
|
89
|
+
name: string;
|
|
90
|
+
value: ColorReplacement[];
|
|
91
|
+
isAdmin: boolean;
|
|
92
|
+
label?: string;
|
|
93
|
+
toggleUniqueId?: string;
|
|
94
|
+
logoTheme: LogoTheme;
|
|
95
|
+
}>();
|
|
75
96
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
97
|
+
const emit = defineEmits(['update:modelValue']);
|
|
98
|
+
|
|
99
|
+
const changeColor = () => {
|
|
100
|
+
emit('update:modelValue', {
|
|
101
|
+
id: props.id,
|
|
102
|
+
name: props.name,
|
|
103
|
+
value: data.colorReplacements,
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const data = reactive<{
|
|
108
|
+
colorReplacements: ColorReplacement[];
|
|
109
|
+
changeColorDebounce: DebounceHandle;
|
|
110
|
+
styleThemeKeys: typeof STYLE_THEME_KEYS;
|
|
111
|
+
}>({
|
|
112
|
+
colorReplacements: cloneDeep(props.value),
|
|
113
|
+
changeColorDebounce: debounce(changeColor, DEBOUNCE_WAIT_IN_MS),
|
|
114
|
+
styleThemeKeys: STYLE_THEME_KEYS,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
watch(
|
|
118
|
+
() => props.value,
|
|
119
|
+
(newVal: ColorReplacement[]) => {
|
|
120
|
+
data.colorReplacements = cloneDeep(newVal);
|
|
80
121
|
},
|
|
81
|
-
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const selectedColor = computed(
|
|
125
|
+
() => data.colorReplacements[0]?.replacementColor,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const isOptionColorMatched = computed(() =>
|
|
129
|
+
data.colorReplacements?.every((x) => isColorMatched(x.replacementColor)),
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const toggleIdSuffix = computed(() =>
|
|
133
|
+
props.toggleUniqueId ? `-${props.toggleUniqueId}` : '',
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const onColorPickerInput = (
|
|
137
|
+
color: UpdateItemValuePayload<string>,
|
|
138
|
+
index: number,
|
|
139
|
+
) => {
|
|
140
|
+
if (color) {
|
|
141
|
+
if (typeof color.value === 'string') {
|
|
142
|
+
data.colorReplacements[index].replacementColor = color.value;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
data.changeColorDebounce();
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const onColorPickerInputDropdown = (color: string) => {
|
|
150
|
+
if (typeof color === 'string') {
|
|
151
|
+
data.colorReplacements.forEach((c) => {
|
|
152
|
+
c.replacementColor = color;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
data.changeColorDebounce();
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const onColorMatchToggled = (value: boolean) => {
|
|
160
|
+
if (value) {
|
|
161
|
+
data.colorReplacements.forEach((x) => {
|
|
162
|
+
x.replacementColor = STYLE_THEME_KEYS.LogoTextColor;
|
|
163
|
+
});
|
|
164
|
+
} else {
|
|
165
|
+
data.colorReplacements.forEach((x) => {
|
|
166
|
+
x.replacementColor = x.originalColor;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
data.changeColorDebounce();
|
|
82
171
|
};
|
|
83
172
|
</script>
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/// <reference types="types/lodash-shims" />
|
|
2
|
-
import type { DebounceHandle } from 'lodash.debounce';
|
|
3
|
-
import type { PropType } from 'vue';
|
|
4
|
-
import type { ColorReplacement, LogoTheme } from '../../../../brand-page';
|
|
5
|
-
import type { UpdateItemValuePayload } from '../../../content-settings/models';
|
|
6
|
-
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
7
|
-
id: {
|
|
8
|
-
type: StringConstructor;
|
|
9
|
-
required: true;
|
|
10
|
-
};
|
|
11
|
-
name: {
|
|
12
|
-
type: StringConstructor;
|
|
13
|
-
required: true;
|
|
14
|
-
};
|
|
15
|
-
value: {
|
|
16
|
-
type: PropType<ColorReplacement[]>;
|
|
17
|
-
required: true;
|
|
18
|
-
};
|
|
19
|
-
isAdmin: {
|
|
20
|
-
type: BooleanConstructor;
|
|
21
|
-
required: true;
|
|
22
|
-
};
|
|
23
|
-
label: {
|
|
24
|
-
type: StringConstructor;
|
|
25
|
-
required: false;
|
|
26
|
-
default: undefined;
|
|
27
|
-
};
|
|
28
|
-
toggleUniqueId: {
|
|
29
|
-
type: StringConstructor;
|
|
30
|
-
required: false;
|
|
31
|
-
default: string;
|
|
32
|
-
};
|
|
33
|
-
logoTheme: {
|
|
34
|
-
type: PropType<LogoTheme>;
|
|
35
|
-
required: true;
|
|
36
|
-
};
|
|
37
|
-
}>, {}, {
|
|
38
|
-
colorReplacements: ColorReplacement[];
|
|
39
|
-
changeColorDebounce: DebounceHandle;
|
|
40
|
-
styleThemeKeys: Readonly<{
|
|
41
|
-
LogoTextColor: "logo-text-color";
|
|
42
|
-
LogoBackgroundColor: "logo-background-color";
|
|
43
|
-
LogoTextColor50: "logo-text-color-50";
|
|
44
|
-
LogoTextColor100: "logo-text-color-100";
|
|
45
|
-
LogoTextColor200: "logo-text-color-200";
|
|
46
|
-
LogoTextColor300: "logo-text-color-300";
|
|
47
|
-
LogoTextColor400: "logo-text-color-400";
|
|
48
|
-
LogoTextColor500: "logo-text-color-500";
|
|
49
|
-
LogoTextColor600: "logo-text-color-600";
|
|
50
|
-
LogoTextColor700: "logo-text-color-700";
|
|
51
|
-
LogoTextColor800: "logo-text-color-800";
|
|
52
|
-
LogoTextColor900: "logo-text-color-900";
|
|
53
|
-
LogoTextColor950: "logo-text-color-950";
|
|
54
|
-
LogoBackgroundColor50: "logo-background-color-50";
|
|
55
|
-
LogoBackgroundColor100: "logo-background-color-100";
|
|
56
|
-
LogoBackgroundColor200: "logo-background-color-200";
|
|
57
|
-
LogoBackgroundColor300: "logo-background-color-300";
|
|
58
|
-
LogoBackgroundColor400: "logo-background-color-400";
|
|
59
|
-
LogoBackgroundColor500: "logo-background-color-500";
|
|
60
|
-
LogoBackgroundColor600: "logo-background-color-600";
|
|
61
|
-
LogoBackgroundColor700: "logo-background-color-700";
|
|
62
|
-
LogoBackgroundColor800: "logo-background-color-800";
|
|
63
|
-
LogoBackgroundColor900: "logo-background-color-900";
|
|
64
|
-
LogoBackgroundColor950: "logo-background-color-950";
|
|
65
|
-
}>;
|
|
66
|
-
}, {
|
|
67
|
-
colorFieldMode(): string;
|
|
68
|
-
isOptionColorMatched(): boolean;
|
|
69
|
-
toggleIdSuffix(): string;
|
|
70
|
-
}, {
|
|
71
|
-
onColorPickerInput(color: UpdateItemValuePayload<string>, index: number): void;
|
|
72
|
-
onColorPickerInputDropdown(color: string, index: number): void;
|
|
73
|
-
changeColor(): void;
|
|
74
|
-
onColorMatchToggled(value: boolean): void;
|
|
75
|
-
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
76
|
-
id: {
|
|
77
|
-
type: StringConstructor;
|
|
78
|
-
required: true;
|
|
79
|
-
};
|
|
80
|
-
name: {
|
|
81
|
-
type: StringConstructor;
|
|
82
|
-
required: true;
|
|
83
|
-
};
|
|
84
|
-
value: {
|
|
85
|
-
type: PropType<ColorReplacement[]>;
|
|
86
|
-
required: true;
|
|
87
|
-
};
|
|
88
|
-
isAdmin: {
|
|
89
|
-
type: BooleanConstructor;
|
|
90
|
-
required: true;
|
|
91
|
-
};
|
|
92
|
-
label: {
|
|
93
|
-
type: StringConstructor;
|
|
94
|
-
required: false;
|
|
95
|
-
default: undefined;
|
|
96
|
-
};
|
|
97
|
-
toggleUniqueId: {
|
|
98
|
-
type: StringConstructor;
|
|
99
|
-
required: false;
|
|
100
|
-
default: string;
|
|
101
|
-
};
|
|
102
|
-
logoTheme: {
|
|
103
|
-
type: PropType<LogoTheme>;
|
|
104
|
-
required: true;
|
|
105
|
-
};
|
|
106
|
-
}>> & Readonly<{
|
|
107
|
-
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
108
|
-
}>, {
|
|
109
|
-
label: string;
|
|
110
|
-
toggleUniqueId: string;
|
|
111
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
112
|
-
export default _default;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'vue';
|
|
2
|
-
import debounce from 'lodash.debounce';
|
|
3
|
-
import cloneDeep from 'lodash.clonedeep';
|
|
4
|
-
import { isColorMatched } from '../../../../brand-page-maker/utils';
|
|
5
|
-
import { STYLE_THEME_KEYS } from '../../../../brand-page/constants';
|
|
6
|
-
const DEBOUNCE_WAIT_IN_MS = 10;
|
|
7
|
-
export default defineComponent({
|
|
8
|
-
props: {
|
|
9
|
-
id: {
|
|
10
|
-
type: String,
|
|
11
|
-
required: true,
|
|
12
|
-
},
|
|
13
|
-
name: {
|
|
14
|
-
type: String,
|
|
15
|
-
required: true,
|
|
16
|
-
},
|
|
17
|
-
value: {
|
|
18
|
-
type: Array,
|
|
19
|
-
required: true,
|
|
20
|
-
},
|
|
21
|
-
isAdmin: {
|
|
22
|
-
type: Boolean,
|
|
23
|
-
required: true,
|
|
24
|
-
},
|
|
25
|
-
label: {
|
|
26
|
-
type: String,
|
|
27
|
-
required: false,
|
|
28
|
-
default: undefined,
|
|
29
|
-
},
|
|
30
|
-
toggleUniqueId: {
|
|
31
|
-
type: String,
|
|
32
|
-
required: false,
|
|
33
|
-
default: '',
|
|
34
|
-
},
|
|
35
|
-
logoTheme: {
|
|
36
|
-
type: Object,
|
|
37
|
-
required: true,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
emits: ['update:modelValue'],
|
|
41
|
-
data() {
|
|
42
|
-
return {
|
|
43
|
-
colorReplacements: [],
|
|
44
|
-
changeColorDebounce: null,
|
|
45
|
-
styleThemeKeys: STYLE_THEME_KEYS,
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
computed: {
|
|
49
|
-
colorFieldMode() {
|
|
50
|
-
return this.value.length === 1 ? 'color-and-text' : 'color-only';
|
|
51
|
-
},
|
|
52
|
-
isOptionColorMatched() {
|
|
53
|
-
return this.colorReplacements?.every((x) => isColorMatched(x.replacementColor));
|
|
54
|
-
},
|
|
55
|
-
toggleIdSuffix() {
|
|
56
|
-
return this.toggleUniqueId ? `-${this.toggleUniqueId}` : '';
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
watch: {
|
|
60
|
-
value(newVal) {
|
|
61
|
-
this.colorReplacements = cloneDeep(newVal);
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
created() {
|
|
65
|
-
this.changeColorDebounce = debounce(this.changeColor, DEBOUNCE_WAIT_IN_MS);
|
|
66
|
-
this.colorReplacements = cloneDeep(this.value);
|
|
67
|
-
},
|
|
68
|
-
methods: {
|
|
69
|
-
onColorPickerInput(color, index) {
|
|
70
|
-
if (color) {
|
|
71
|
-
if (typeof color.value === 'string') {
|
|
72
|
-
this.colorReplacements[index].replacementColor = color.value;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
this.changeColorDebounce();
|
|
76
|
-
},
|
|
77
|
-
onColorPickerInputDropdown(color, index) {
|
|
78
|
-
if (typeof color === 'string') {
|
|
79
|
-
this.colorReplacements[index].replacementColor = color;
|
|
80
|
-
}
|
|
81
|
-
this.changeColorDebounce();
|
|
82
|
-
},
|
|
83
|
-
changeColor() {
|
|
84
|
-
this.$emit('update:modelValue', {
|
|
85
|
-
id: this.id,
|
|
86
|
-
name: this.name,
|
|
87
|
-
value: this.colorReplacements,
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
onColorMatchToggled(value) {
|
|
91
|
-
if (value) {
|
|
92
|
-
this.colorReplacements.forEach((x) => {
|
|
93
|
-
x.replacementColor = STYLE_THEME_KEYS.LogoTextColor;
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
this.colorReplacements.forEach((x) => {
|
|
98
|
-
x.replacementColor = x.originalColor;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
this.changeColorDebounce();
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'vue';
|
|
2
|
-
import type { DebounceHandle } from 'lodash.debounce';
|
|
3
|
-
import debounce from 'lodash.debounce';
|
|
4
|
-
import type { PropType } from 'vue';
|
|
5
|
-
import type { ColorReplacement, LogoTheme } from '../../../../brand-page';
|
|
6
|
-
import cloneDeep from 'lodash.clonedeep';
|
|
7
|
-
import { isColorMatched } from '../../../../brand-page-maker/utils';
|
|
8
|
-
import { STYLE_THEME_KEYS } from '../../../../brand-page/constants';
|
|
9
|
-
import type { UpdateItemValuePayload } from '../../../content-settings/models';
|
|
10
|
-
|
|
11
|
-
const DEBOUNCE_WAIT_IN_MS = 10;
|
|
12
|
-
|
|
13
|
-
export default defineComponent({
|
|
14
|
-
props: {
|
|
15
|
-
id: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: true,
|
|
18
|
-
},
|
|
19
|
-
name: {
|
|
20
|
-
type: String,
|
|
21
|
-
required: true,
|
|
22
|
-
},
|
|
23
|
-
value: {
|
|
24
|
-
type: Array as PropType<ColorReplacement[]>,
|
|
25
|
-
required: true,
|
|
26
|
-
},
|
|
27
|
-
isAdmin: {
|
|
28
|
-
type: Boolean,
|
|
29
|
-
required: true,
|
|
30
|
-
},
|
|
31
|
-
label: {
|
|
32
|
-
type: String,
|
|
33
|
-
required: false,
|
|
34
|
-
default: undefined,
|
|
35
|
-
},
|
|
36
|
-
toggleUniqueId: {
|
|
37
|
-
type: String,
|
|
38
|
-
required: false,
|
|
39
|
-
default: '',
|
|
40
|
-
},
|
|
41
|
-
logoTheme: {
|
|
42
|
-
type: Object as PropType<LogoTheme>,
|
|
43
|
-
required: true,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
emits: ['update:modelValue'],
|
|
47
|
-
data() {
|
|
48
|
-
return {
|
|
49
|
-
colorReplacements: [] as ColorReplacement[],
|
|
50
|
-
changeColorDebounce: null as any as DebounceHandle,
|
|
51
|
-
styleThemeKeys: STYLE_THEME_KEYS,
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
computed: {
|
|
55
|
-
colorFieldMode(): string {
|
|
56
|
-
return this.value.length === 1 ? 'color-and-text' : 'color-only';
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
isOptionColorMatched(): boolean {
|
|
60
|
-
return this.colorReplacements?.every((x) =>
|
|
61
|
-
isColorMatched(x.replacementColor),
|
|
62
|
-
);
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
toggleIdSuffix(): string {
|
|
66
|
-
return this.toggleUniqueId ? `-${this.toggleUniqueId}` : '';
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
watch: {
|
|
70
|
-
value(newVal: ColorReplacement[]) {
|
|
71
|
-
this.colorReplacements = cloneDeep(newVal);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
created() {
|
|
75
|
-
this.changeColorDebounce = debounce(this.changeColor, DEBOUNCE_WAIT_IN_MS);
|
|
76
|
-
|
|
77
|
-
this.colorReplacements = cloneDeep(this.value);
|
|
78
|
-
},
|
|
79
|
-
methods: {
|
|
80
|
-
onColorPickerInput(color: UpdateItemValuePayload<string>, index: number) {
|
|
81
|
-
if (color) {
|
|
82
|
-
if (typeof color.value === 'string') {
|
|
83
|
-
this.colorReplacements[index].replacementColor = color.value;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
this.changeColorDebounce();
|
|
88
|
-
},
|
|
89
|
-
onColorPickerInputDropdown(color: string, index: number) {
|
|
90
|
-
if (typeof color === 'string') {
|
|
91
|
-
this.colorReplacements[index].replacementColor = color;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
this.changeColorDebounce();
|
|
95
|
-
},
|
|
96
|
-
changeColor() {
|
|
97
|
-
this.$emit('update:modelValue', {
|
|
98
|
-
id: this.id,
|
|
99
|
-
name: this.name,
|
|
100
|
-
value: this.colorReplacements,
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
onColorMatchToggled(value: boolean) {
|
|
105
|
-
if (value) {
|
|
106
|
-
this.colorReplacements.forEach((x) => {
|
|
107
|
-
x.replacementColor = STYLE_THEME_KEYS.LogoTextColor;
|
|
108
|
-
});
|
|
109
|
-
} else {
|
|
110
|
-
this.colorReplacements.forEach((x) => {
|
|
111
|
-
x.replacementColor = x.originalColor;
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
this.changeColorDebounce();
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
});
|