PluginProbe
The Innovative Form Builder – IvyForms / 1.1
The Innovative Form Builder – IvyForms v1.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / utils / form-styles / styleSettings.ts

styleSettings.ts in The Innovative Form Builder – IvyForms 1.1, at frontend/src/utils/form-styles/styleSettings.ts

75 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import type { CornerValueSettings, FormStyleSettings } from '@/types/form-style'
2
3 export interface ActiveColors {
4 buttonText?: string
5 fieldText?: string
6 formTitleColor?: string
7 formDescriptionColor?: string
8 fieldLabels?: string
9 fieldPlaceholder?: string
10 checkboxRadioSelection?: string
11 checkboxRadioBorder?: string
12 checkboxRadioLabel?: string
13 }
14
15 export function resolveCornerRadiusValue(
16 cornerSetting: CornerValueSettings | string | undefined,
17 fallbackValue?: string,
18 ): string | undefined {
19 if (!cornerSetting) {
20 return fallbackValue
21 }
22
23 if (typeof cornerSetting === 'string') {
24 return cornerSetting || fallbackValue
25 }
26
27 const isLinked = cornerSetting.isLinked !== false
28 const linkedValue = cornerSetting.value || fallbackValue
29
30 if (isLinked) {
31 return linkedValue || fallbackValue
32 }
33
34 const topLeftValue = cornerSetting.topLeft || linkedValue || fallbackValue
35 const topRightValue = cornerSetting.topRight || topLeftValue
36 const bottomRightValue = cornerSetting.bottomRight || topLeftValue
37 const bottomLeftValue = cornerSetting.bottomLeft || topLeftValue
38
39 if (!topLeftValue && !topRightValue && !bottomRightValue && !bottomLeftValue) {
40 return fallbackValue
41 }
42
43 return `${topLeftValue} ${topRightValue} ${bottomRightValue} ${bottomLeftValue}`
44 }
45
46 export function resolveActiveColors(styleSettings: FormStyleSettings): ActiveColors {
47 let activeColors: ActiveColors = {}
48
49 if (styleSettings.quickMode) {
50 activeColors = {
51 ...activeColors,
52 fieldText: styleSettings.quickMode.fieldText,
53 buttonText: styleSettings.quickMode.buttonText,
54 formTitleColor: styleSettings.quickMode.formTitleText,
55 fieldLabels: styleSettings.quickMode.labelFontColor,
56 }
57 }
58
59 if (styleSettings.advancedMode) {
60 const adv = styleSettings.advancedMode
61 activeColors = {
62 ...activeColors,
63 formTitleColor: adv.formTitle?.fontColor || activeColors.formTitleColor,
64 formDescriptionColor: adv.formDescription?.fontColor,
65 fieldLabels: adv.fieldLabels?.label?.fontColor || activeColors.fieldLabels,
66 fieldPlaceholder: adv.fieldPlaceholder?.fontColor,
67 checkboxRadioSelection: adv.checkboxRadio?.selectionColor,
68 checkboxRadioBorder: adv.checkboxRadio?.borderColor,
69 checkboxRadioLabel: adv.checkboxRadio?.fontColor,
70 }
71 }
72
73 return activeColors
74 }
75