@propelinc/citrus-ui 1.0.5 → 1.3.0
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 +39 -14
- package/dist/citrus-ui.cdn.css +1 -0
- package/dist/citrus-ui.css +1 -0
- package/dist/colors/colors.d.ts +31 -0
- package/dist/colors/theme.d.ts +3 -0
- package/dist/colors/util-classes.d.ts +11 -0
- package/dist/components/CAccordion.vue.d.ts +34 -0
- package/dist/components/CAccordionItem.vue.d.ts +39 -0
- package/dist/components/CAppBar.vue.d.ts +59 -0
- package/dist/components/CBadge.vue.d.ts +35 -0
- package/dist/components/CBottomSheet.vue.d.ts +90 -0
- package/dist/components/CButton/CButton.vue.d.ts +97 -0
- package/dist/components/CButton/types.d.ts +5 -0
- package/dist/components/CButtonStack.vue.d.ts +27 -0
- package/dist/components/CCard.vue.d.ts +53 -0
- package/dist/components/CCardFooter.vue.d.ts +20 -0
- package/dist/components/CCardHeader.vue.d.ts +22 -0
- package/dist/components/CCardSection.vue.d.ts +26 -0
- package/dist/components/CCheckbox.vue.d.ts +62 -0
- package/dist/components/CCol.vue.d.ts +30 -0
- package/dist/components/CDivider.vue.d.ts +9 -0
- package/dist/components/CDobField.vue.d.ts +60 -0
- package/dist/components/CDobSelect.vue.d.ts +50 -0
- package/dist/components/CEmailField.vue.d.ts +48 -0
- package/dist/components/CExpandTransition.vue.d.ts +29 -0
- package/dist/components/CFadeTransition.vue.d.ts +20 -0
- package/dist/components/CFileInput.vue.d.ts +50 -0
- package/dist/components/CFixedPageFooter.vue.d.ts +153 -0
- package/dist/components/CForm.vue.d.ts +44 -0
- package/dist/components/CFormFieldCounter.vue.d.ts +15 -0
- package/dist/components/CIconButton.vue.d.ts +97 -0
- package/dist/components/CLabel.vue.d.ts +36 -0
- package/dist/components/CListItem.vue.d.ts +56 -0
- package/dist/components/CListItemContent.vue.d.ts +27 -0
- package/dist/components/CListItemIcon.vue.d.ts +28 -0
- package/dist/components/CLoader.vue.d.ts +23 -0
- package/dist/components/CLogo.vue.d.ts +9 -0
- package/dist/components/CMaskedTextField.vue.d.ts +511 -0
- package/dist/components/CMenu.vue.d.ts +17 -0
- package/dist/components/CMenuItem.vue.d.ts +37 -0
- package/dist/components/CMenuLabel.vue.d.ts +20 -0
- package/dist/components/CModal.vue.d.ts +59 -0
- package/dist/components/CModalLoading.vue.d.ts +36 -0
- package/dist/components/CNotification.vue.d.ts +64 -0
- package/dist/components/CPhoneField.vue.d.ts +792 -0
- package/dist/components/CPill.vue.d.ts +41 -0
- package/dist/components/CPillGroup.vue.d.ts +39 -0
- package/dist/components/CPopup.vue.d.ts +37 -0
- package/dist/components/CProgressLinear.vue.d.ts +21 -0
- package/dist/components/CProgressRing.vue.d.ts +48 -0
- package/dist/components/CRadio.vue.d.ts +40 -0
- package/dist/components/CRadioGroup.vue.d.ts +54 -0
- package/dist/components/CRebrand.vue.d.ts +28 -0
- package/dist/components/CRow.vue.d.ts +41 -0
- package/dist/components/CSafeArea.vue.d.ts +18 -0
- package/dist/components/CSectionHeader.vue.d.ts +29 -0
- package/dist/components/CSelect.vue.d.ts +96 -0
- package/dist/components/CSkeleton.vue.d.ts +3 -0
- package/dist/components/CSkeletonLoaderCard.vue.d.ts +9 -0
- package/dist/components/CSkeletonLoaderCircle.vue.d.ts +3 -0
- package/dist/components/CSkeletonLoaderText.vue.d.ts +16 -0
- package/dist/components/CSlideFadeTransition.vue.d.ts +36 -0
- package/dist/components/CSplitInput.vue.d.ts +56 -0
- package/dist/components/CSquaredIcon.vue.d.ts +33 -0
- package/dist/components/CSsnField.vue.d.ts +798 -0
- package/dist/components/CStatusDot.vue.d.ts +10 -0
- package/dist/components/CSwitch.vue.d.ts +39 -0
- package/dist/components/CSwitchListItem.vue.d.ts +48 -0
- package/dist/components/CTextArea.vue.d.ts +96 -0
- package/dist/components/CTextField.vue.d.ts +129 -0
- package/dist/components/CTextLink.vue.d.ts +36 -0
- package/dist/components/CThirdPartyLogo.vue.d.ts +22 -0
- package/dist/components/CTimeago.vue.d.ts +12 -0
- package/dist/components/CToast.vue.d.ts +69 -0
- package/dist/components/CToastsList.vue.d.ts +3 -0
- package/dist/components/CValidationMessage.vue.d.ts +37 -0
- package/dist/components/CZipcodeField.vue.d.ts +796 -0
- package/dist/components/index.d.ts +66 -0
- package/dist/components/internal/CCloseButton.vue.d.ts +14 -0
- package/dist/composables/accessibility.d.ts +1 -0
- package/dist/composables/animation.d.ts +12 -0
- package/dist/composables/binding.d.ts +19 -0
- package/dist/composables/colors.d.ts +13 -0
- package/dist/composables/elements.d.ts +3 -0
- package/dist/composables/fields.d.ts +10 -0
- package/dist/composables/gestures.d.ts +53 -0
- package/dist/composables/i18n.d.ts +3 -0
- package/dist/composables/id.d.ts +11 -0
- package/dist/composables/input-mask.d.ts +18 -0
- package/dist/composables/router.d.ts +30 -0
- package/dist/composables/slots.d.ts +2 -0
- package/dist/composables/toast.d.ts +21 -0
- package/dist/composables/validations.d.ts +77 -0
- package/dist/icons.cdn.mjs +3 -0
- package/dist/icons.cdn.mjs.map +1 -0
- package/dist/icons.d.ts +1 -0
- package/dist/icons.mjs +6 -0
- package/dist/icons.mjs.map +1 -0
- package/dist/index.cdn.mjs +9328 -12875
- package/dist/index.cdn.mjs.map +1 -1
- package/dist/index.cdn2.mjs +55255 -0
- package/dist/index.cdn2.mjs.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +3946 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/services/animation.d.ts +17 -0
- package/dist/services/directives/index.d.ts +2 -0
- package/dist/services/directives/scroll-into-view.d.ts +7 -0
- package/dist/services/directives/tap-animation.d.ts +6 -0
- package/dist/services/id.d.ts +22 -0
- package/dist/services/injections/accordions.d.ts +3 -0
- package/dist/services/injections/animations.d.ts +2 -0
- package/dist/services/injections/buttons.d.ts +4 -0
- package/dist/services/injections/forms.d.ts +6 -0
- package/dist/services/injections/icon-buttons.d.ts +3 -0
- package/dist/services/injections/pills.d.ts +4 -0
- package/dist/services/injections/radio.d.ts +10 -0
- package/dist/{styles/main.css → styles.css} +8 -6
- package/dist/theme/icons.d.ts +36 -0
- package/dist/types/CForm.d.ts +12 -0
- package/dist/types/font-awesome.d.ts +5 -0
- package/dist/types.d.ts +13 -0
- package/package.json +8 -3
- package/src/colors/colors.ts +8 -3
- package/src/components/CAccordion.vue +31 -24
- package/src/components/CAccordionItem.vue +46 -45
- package/src/components/CAppBar.vue +108 -101
- package/src/components/CBadge.vue +33 -25
- package/src/components/CBottomSheet.vue +212 -199
- package/src/components/CButton/CButton.vue +135 -147
- package/src/components/CButtonStack.vue +21 -13
- package/src/components/CCard.vue +72 -69
- package/src/components/CCardFooter.vue +5 -5
- package/src/components/CCardHeader.vue +9 -7
- package/src/components/CCardSection.vue +15 -8
- package/src/components/CCheckbox.vue +68 -69
- package/src/components/CCol.vue +21 -22
- package/src/components/CDivider.vue +9 -8
- package/src/components/CDobField.vue +114 -105
- package/src/components/CDobSelect.vue +162 -164
- package/src/components/CEmailField.vue +39 -27
- package/src/components/CExpandTransition.vue +14 -17
- package/src/components/CFadeTransition.vue +3 -3
- package/src/components/CFileInput.vue +57 -50
- package/src/components/CFixedPageFooter.vue +23 -17
- package/src/components/CForm.vue +67 -60
- package/src/components/CFormFieldCounter.vue +25 -28
- package/src/components/CIconButton.vue +84 -65
- package/src/components/CLabel.vue +19 -13
- package/src/components/CListItem.vue +67 -66
- package/src/components/CListItemContent.vue +14 -16
- package/src/components/CListItemIcon.vue +18 -14
- package/src/components/CLoader.vue +47 -56
- package/src/components/CLogo.vue +13 -12
- package/src/components/CMaskedTextField.vue +80 -64
- package/src/components/CMenu.vue +14 -6
- package/src/components/CMenuItem.vue +28 -22
- package/src/components/CMenuLabel.vue +6 -5
- package/src/components/CModal.vue +76 -71
- package/src/components/CModalLoading.vue +24 -15
- package/src/components/CNotification.vue +77 -28
- package/src/components/CPhoneField.vue +34 -25
- package/src/components/CPill.vue +92 -88
- package/src/components/CPillGroup.vue +30 -21
- package/src/components/CPopup.vue +46 -37
- package/src/components/CProgressLinear.vue +17 -11
- package/src/components/CProgressRing.vue +33 -33
- package/src/components/CRadio.vue +57 -57
- package/src/components/CRadioGroup.vue +85 -72
- package/src/components/CRow.vue +22 -20
- package/src/components/CSectionHeader.vue +20 -12
- package/src/components/CSelect.vue +89 -73
- package/src/components/CSkeletonLoaderCard.vue +9 -15
- package/src/components/CSkeletonLoaderCircle.vue +1 -9
- package/src/components/CSkeletonLoaderText.vue +17 -18
- package/src/components/CSlideFadeTransition.vue +12 -34
- package/src/components/CSplitInput.vue +46 -45
- package/src/components/CSquaredIcon.vue +39 -29
- package/src/components/CSsnField.vue +48 -36
- package/src/components/CStatusDot.vue +16 -16
- package/src/components/CSwitch.vue +31 -22
- package/src/components/CSwitchListItem.vue +27 -28
- package/src/components/CTextArea.vue +116 -83
- package/src/components/CTextField.vue +194 -198
- package/src/components/CTextLink.vue +28 -25
- package/src/components/CThirdPartyLogo.vue +30 -59
- package/src/components/CToast.vue +135 -132
- package/src/components/CToastsList.vue +2 -15
- package/src/components/CValidationMessage.vue +31 -24
- package/src/components/CZipcodeField.vue +40 -27
- package/src/composables/elements.ts +1 -1
- package/src/composables/fields.ts +4 -4
- package/src/composables/router.ts +6 -5
- package/src/icons.ts +6 -0
- package/src/services/injections/buttons.ts +1 -1
- package/src/styles/_core.scss +1 -2
- package/src/styles/_reset.scss +1 -1
- package/src/types.ts +2 -0
- package/dist/index.cdn.css +0 -1
- package/dist/styles/utils.css +0 -2709
|
@@ -48,16 +48,12 @@
|
|
|
48
48
|
</header>
|
|
49
49
|
</template>
|
|
50
50
|
|
|
51
|
-
<script lang="ts">
|
|
52
|
-
import type {
|
|
53
|
-
import { computed,
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
import type { VNode } from 'vue';
|
|
53
|
+
import { computed, provide, ref } from 'vue';
|
|
54
54
|
|
|
55
55
|
import type { HexColor } from '@propelinc/citrus-ui/src/colors/colors';
|
|
56
|
-
import Colors, {
|
|
57
|
-
isHexColor,
|
|
58
|
-
isRgbaColor,
|
|
59
|
-
isValidColor,
|
|
60
|
-
} from '@propelinc/citrus-ui/src/colors/colors';
|
|
56
|
+
import Colors, { isHexColor, isRgbaColor } from '@propelinc/citrus-ui/src/colors/colors';
|
|
61
57
|
import CFadeTransition from '@propelinc/citrus-ui/src/components/CFadeTransition.vue';
|
|
62
58
|
import CLoader from '@propelinc/citrus-ui/src/components/CLoader.vue';
|
|
63
59
|
import { useCssColor } from '@propelinc/citrus-ui/src/composables/colors';
|
|
@@ -66,109 +62,120 @@ import {
|
|
|
66
62
|
TERTIARY as TERTIARY_ICON_BUTTON,
|
|
67
63
|
} from '@propelinc/citrus-ui/src/services/injections/icon-buttons';
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
props: {
|
|
65
|
+
const props = withDefaults(
|
|
66
|
+
defineProps<{
|
|
72
67
|
/**
|
|
73
68
|
* Used to set the background color of the app bar. Needs to accept either a hex code or a
|
|
74
69
|
* a valid color key from the Colors object.
|
|
75
70
|
*/
|
|
76
|
-
backgroundColor
|
|
77
|
-
type: String as PropType<HexColor | keyof typeof Colors>,
|
|
78
|
-
default: 'default',
|
|
79
|
-
validator: isValidColor,
|
|
80
|
-
},
|
|
81
|
-
color: {
|
|
82
|
-
type: String as PropType<HexColor | keyof typeof Colors>,
|
|
83
|
-
default: undefined,
|
|
84
|
-
validator: isValidColor,
|
|
85
|
-
},
|
|
86
|
-
/** If true, the app bar will be fixed to the top of the viewport. */
|
|
87
|
-
fixed: { type: Boolean, default: false },
|
|
71
|
+
backgroundColor?: HexColor | keyof typeof Colors;
|
|
88
72
|
/** If true, the app bar will have a bottom border. */
|
|
89
|
-
border
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
border?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Used to set the text color of the app bar. Needs to accept either a hex code or a
|
|
76
|
+
* a valid color key from the Colors object.
|
|
77
|
+
* If unset, defaults to either white or black based on the background color's luminance.
|
|
78
|
+
*/
|
|
79
|
+
color?: HexColor | keyof typeof Colors;
|
|
80
|
+
/** If true, the app bar will be fixed to the top of the viewport. */
|
|
81
|
+
fixed?: boolean;
|
|
94
82
|
/** Adds screen reader only text alternative to loading icon, text should be translated */
|
|
95
|
-
loaderAccessibleText
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
83
|
+
loaderAccessibleText?: string;
|
|
84
|
+
/** Shows a loading spinner. Overrides the title slot. */
|
|
85
|
+
loading?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Shows text in the center of the component. Typically used for page names.
|
|
88
|
+
* Overrides the title slot.
|
|
89
|
+
*/
|
|
90
|
+
title?: string;
|
|
91
|
+
}>(),
|
|
92
|
+
{
|
|
93
|
+
backgroundColor: 'default',
|
|
94
|
+
border: false,
|
|
95
|
+
color: undefined,
|
|
96
|
+
fixed: false,
|
|
97
|
+
loaderAccessibleText: '',
|
|
98
|
+
loading: false,
|
|
99
|
+
title: '',
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
defineSlots<{
|
|
104
|
+
left?: () => VNode[];
|
|
105
|
+
title?: () => VNode[];
|
|
106
|
+
right?: () => VNode[];
|
|
107
|
+
}>();
|
|
108
|
+
|
|
109
|
+
provide(TERTIARY_ICON_BUTTON, ref(true));
|
|
110
|
+
provide(INHERIT_COLOR_ICON_BUTTON, ref(true));
|
|
111
|
+
|
|
112
|
+
const initialBackgroundColor = computed(() => {
|
|
113
|
+
if (props.backgroundColor === 'default') {
|
|
114
|
+
return Colors.WHITE;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return props.backgroundColor;
|
|
118
|
+
});
|
|
100
119
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
120
|
+
const { cssColor: bgCssColor } = useCssColor(initialBackgroundColor);
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* This text color is computed based on the background color's luminance.
|
|
124
|
+
* Dark backgrounds get white text, light backgrounds get black text.
|
|
125
|
+
* Supports both hex and rgba (e.g. gray palette); rgba is composited over white for luminance.
|
|
126
|
+
*
|
|
127
|
+
* This is overridden by the `color` prop.
|
|
128
|
+
*/
|
|
129
|
+
const calculatedTextColor = computed(() => {
|
|
130
|
+
const color = bgCssColor.value;
|
|
131
|
+
if (!color) {
|
|
132
|
+
return Colors.BLACK;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let r: number;
|
|
136
|
+
let g: number;
|
|
137
|
+
let b: number;
|
|
138
|
+
|
|
139
|
+
if (isHexColor(color)) {
|
|
140
|
+
const hex = color.substring(1);
|
|
141
|
+
const fullHex = hex.length === 3 ? hex.replace(/(.)/g, '$1$1') : hex;
|
|
142
|
+
r = parseInt(fullHex.substring(0, 2), 16) / 255;
|
|
143
|
+
g = parseInt(fullHex.substring(2, 4), 16) / 255;
|
|
144
|
+
b = parseInt(fullHex.substring(4, 6), 16) / 255;
|
|
145
|
+
} else if (isRgbaColor(color)) {
|
|
146
|
+
const match = color.match(
|
|
147
|
+
/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([\d.]+)\s*\)$/i
|
|
148
|
+
);
|
|
149
|
+
if (!match) {
|
|
150
|
+
return Colors.BLACK;
|
|
151
|
+
}
|
|
152
|
+
const ra = Number(match[1]) / 255;
|
|
153
|
+
const ga = Number(match[2]) / 255;
|
|
154
|
+
const ba = Number(match[3]) / 255;
|
|
155
|
+
const a = Number(match[4]);
|
|
156
|
+
// Composite over white to get effective RGB for luminance
|
|
157
|
+
r = ra * a + (1 - a);
|
|
158
|
+
g = ga * a + (1 - a);
|
|
159
|
+
b = ba * a + (1 - a);
|
|
160
|
+
} else {
|
|
161
|
+
return Colors.BLACK;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Calculate relative luminance using sRGB coefficients
|
|
165
|
+
const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
166
|
+
|
|
167
|
+
// Use white text if background is dark enough (luminance < 0.5)
|
|
168
|
+
return luminance < 0.5 ? Colors.WHITE : Colors.BLACK;
|
|
169
|
+
});
|
|
105
170
|
|
|
106
|
-
|
|
107
|
-
});
|
|
171
|
+
const { cssColor: userTextCssColor } = useCssColor(() => props.color);
|
|
108
172
|
|
|
109
|
-
|
|
173
|
+
const textCssColor = computed(() => {
|
|
174
|
+
if (userTextCssColor.value) {
|
|
175
|
+
return userTextCssColor.value;
|
|
176
|
+
}
|
|
110
177
|
|
|
111
|
-
|
|
112
|
-
* This text color is computed based on the background color's luminance.
|
|
113
|
-
* Dark backgrounds get white text, light backgrounds get black text.
|
|
114
|
-
* Supports both hex and rgba (e.g. gray palette); rgba is composited over white for luminance.
|
|
115
|
-
*
|
|
116
|
-
* This is overridden by the `color` prop.
|
|
117
|
-
*/
|
|
118
|
-
const calculatedTextColor = computed(() => {
|
|
119
|
-
const color = bgCssColor.value;
|
|
120
|
-
if (!color) {
|
|
121
|
-
return Colors.BLACK;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
let r: number;
|
|
125
|
-
let g: number;
|
|
126
|
-
let b: number;
|
|
127
|
-
|
|
128
|
-
if (isHexColor(color)) {
|
|
129
|
-
const hex = color.substring(1);
|
|
130
|
-
const fullHex = hex.length === 3 ? hex.replace(/(.)/g, '$1$1') : hex;
|
|
131
|
-
r = parseInt(fullHex.substring(0, 2), 16) / 255;
|
|
132
|
-
g = parseInt(fullHex.substring(2, 4), 16) / 255;
|
|
133
|
-
b = parseInt(fullHex.substring(4, 6), 16) / 255;
|
|
134
|
-
} else if (isRgbaColor(color)) {
|
|
135
|
-
const match = color.match(
|
|
136
|
-
/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([\d.]+)\s*\)$/i
|
|
137
|
-
);
|
|
138
|
-
if (!match) {
|
|
139
|
-
return Colors.BLACK;
|
|
140
|
-
}
|
|
141
|
-
const ra = Number(match[1]) / 255;
|
|
142
|
-
const ga = Number(match[2]) / 255;
|
|
143
|
-
const ba = Number(match[3]) / 255;
|
|
144
|
-
const a = Number(match[4]);
|
|
145
|
-
// Composite over white to get effective RGB for luminance
|
|
146
|
-
r = ra * a + (1 - a);
|
|
147
|
-
g = ga * a + (1 - a);
|
|
148
|
-
b = ba * a + (1 - a);
|
|
149
|
-
} else {
|
|
150
|
-
return Colors.BLACK;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Calculate relative luminance using sRGB coefficients
|
|
154
|
-
const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
155
|
-
|
|
156
|
-
// Use white text if background is dark enough (luminance < 0.5)
|
|
157
|
-
return luminance < 0.5 ? Colors.WHITE : Colors.BLACK;
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
const { cssColor: userTextCssColor } = useCssColor(() => props.color);
|
|
161
|
-
|
|
162
|
-
const textCssColor = computed(() => {
|
|
163
|
-
if (userTextCssColor.value) {
|
|
164
|
-
return userTextCssColor.value;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return calculatedTextColor.value;
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
return { bgCssColor, textCssColor };
|
|
171
|
-
},
|
|
178
|
+
return calculatedTextColor.value;
|
|
172
179
|
});
|
|
173
180
|
</script>
|
|
174
181
|
|
|
@@ -12,42 +12,50 @@
|
|
|
12
12
|
</span>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
-
<script lang="ts">
|
|
16
|
-
import {
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import type { VNode } from 'vue';
|
|
17
|
+
import { computed } from 'vue';
|
|
17
18
|
|
|
18
19
|
import { useCssColor } from '@propelinc/citrus-ui/src/composables/colors';
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/** Sets the text of the badge, can also use default slot */
|
|
23
|
-
text: { type: String, default: undefined },
|
|
21
|
+
const props = withDefaults(
|
|
22
|
+
defineProps<{
|
|
24
23
|
/** Adds a unique data-test attribute for testing to the container */
|
|
25
|
-
dataTest
|
|
24
|
+
dataTest?: string;
|
|
26
25
|
/** Sets the background color */
|
|
27
|
-
color
|
|
26
|
+
color?: string;
|
|
27
|
+
/** Sets the text of the badge, can also use default slot */
|
|
28
|
+
text?: string;
|
|
28
29
|
/** Sets the text color */
|
|
29
|
-
textColor
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
textColor?: string;
|
|
31
|
+
}>(),
|
|
32
|
+
{
|
|
33
|
+
color: 'purple-200',
|
|
34
|
+
dataTest: 'badge',
|
|
35
|
+
text: undefined,
|
|
36
|
+
textColor: 'text-primary',
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
defineSlots<{
|
|
41
|
+
default?: () => VNode[];
|
|
42
|
+
}>();
|
|
34
43
|
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
const { cssColor: backgroundCssColor } = useCssColor(() => props.color);
|
|
45
|
+
const { cssColor: textCssColor } = useCssColor(() => props.textColor);
|
|
37
46
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
47
|
+
const computedStyle = computed(() => {
|
|
48
|
+
const style: Record<string, string> = {};
|
|
41
49
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
if (backgroundCssColor.value) {
|
|
51
|
+
style['--c-badge-background-color'] = backgroundCssColor.value;
|
|
52
|
+
}
|
|
45
53
|
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
if (textCssColor.value) {
|
|
55
|
+
style['--c-badge-text-color'] = textCssColor.value;
|
|
56
|
+
}
|
|
48
57
|
|
|
49
|
-
|
|
50
|
-
},
|
|
58
|
+
return style;
|
|
51
59
|
});
|
|
52
60
|
</script>
|
|
53
61
|
|