| 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 |
|