1919 :tabindex =" scope.tabindex"
2020 :square =" chipSquare"
2121 :style =" getChipStyles"
22- :text-color = " chipOutline ? 'black' : 'white' "
22+ :class = " getChipClasses "
2323 >
2424 <q-icon
2525 :name =" styles.icon"
2828 class =" q-mr-sm"
2929 />
3030
31- <span class =" q-mr-sm " style =" letter-spacing : 0.8 px " >{{
32- scope.opt[optionLabel]
33- }} </span >
31+ <span class =" q-mr-xs ellipsis " style =" letter-spacing : 0.5 px " >
32+ {{ scope.opt[optionLabel] }}
33+ </span >
3434 </q-chip >
3535 </template >
3636
4242 <q-item-section >
4343 <q-item-label >{{ scope.opt[optionLabel] }}</q-item-label >
4444 <q-item-label caption v-if =" scope.opt.description" >
45- {{ truncate(scope.opt.description) }}
45+ {{ truncate(scope.opt.description) }}
4646 </q-item-label >
4747 </q-item-section >
4848 </q-item >
@@ -64,7 +64,6 @@ const props = defineProps({
6464 type: { type: String , required: true },
6565 label: String ,
6666 optionLabel: { type: String , default: " name" },
67-
6867 chipOutline: { type: Boolean , default: false },
6968 chipSquare: { type: Boolean , default: false },
7069 color: { type: String , default: null },
@@ -81,23 +80,49 @@ const computedColor = computed(() => {
8180 return getConceptColorHex (props .type , isDark);
8281});
8382
84- // Dynamic Styles for the Chip container
83+ const computedColorOpposite = computed (() => {
84+ if (props .color ) return props .color ;
85+ const isLight = $q .dark .isActive ;
86+ return getConceptColorHex (props .type , isLight);
87+ });
88+
89+ // Manage purely dynamic styles (borders, custom background colors)
8590const getChipStyles = computed (() => {
8691 if (props .chipOutline ) {
8792 return {
88- border: ` 2px solid ${ computedColor .value } ` ,
89- backgroundColor: " transparent" ,
90- };
91- } else {
92- return {
93- backgroundColor: computedColor .value ,
94- border: " none" ,
93+ border: ` 1px solid ${ computedColor .value } `
9594 };
95+ } else {
96+ if ($q .dark .isActive ){
97+ return {
98+ backgroundColor: computedColor .value ,
99+ color: ' black' ,
100+ border: " none"
101+ };
102+ }
103+ else {
104+ return {
105+ backgroundColor: computedColorOpposite .value ,
106+ color: ' white' ,
107+ border: " none"
108+ };
109+ }
110+ }
111+ });
112+
113+ // Manage Quasar utility classes (theme-aware backgrounds and text)
114+ const getChipClasses = computed (() => {
115+ if (props .chipOutline ) {
116+ // Provides a subtle background and guarantees high-contrast text + remove icon
117+ return $q .dark .isActive
118+ ? ' bg-grey-10 text-grey-3'
119+ : ' bg-grey-2 text-grey-9' ;
96120 }
121+ return ' ' ; // Solid mode classes aren't needed; it relies on getChipStyles
97122});
98123
99124function truncate (str ) {
100125 if (! str) return " " ;
101126 return str .length > 50 ? str .slice (0 , 50 ) + " ..." : str;
102127}
103- </script >
128+ </script >
0 commit comments