Skip to content

Commit e2cdead

Browse files
author
Gianluca La Manna
authored
fix: disabled chips effect and selected chips (#4)
Closed #3
1 parent 09c71e3 commit e2cdead

File tree

1 file changed

+14
-2
lines changed
  • packages/qwik-storefront-ui/src/components/SfChip

1 file changed

+14
-2
lines changed

packages/qwik-storefront-ui/src/components/SfChip/SfChip.tsx

+14-2
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,31 @@ export const SfChip = component$<SfChipProps>(
4141
return 'text-base py-2 gap-2';
4242
}
4343
};
44+
45+
const getCheckedClasses = (checked: boolean | undefined) => {
46+
return checked ? 'ring-2 ring-primary-700 hover:ring-primary-700' : ' hover:ring-primary-200 ring-neutral-200';
47+
}
48+
49+
50+
const getDisabledClasses = (disabled: boolean | undefined) => {
51+
return disabled ? 'cursor-not-allowed bg-disabled-100 opacity-50 ring-1 ring-disabled-200 hover:ring-disabled-200' : 'hover:bg-primary-100 cursor-pointer';
52+
}
53+
4454
return (
4555
<>
4656
<input
4757
id={chipId}
4858
{...(ref ? { ref } : {})}
49-
class="absolute w-0 outline-none appearance-none peer"
59+
class='hidden'
5060
type="checkbox"
5161
{...inputProps}
5262
/>
5363
<label
5464
for={chipId}
5565
class={[
56-
'cursor-pointer ring-1 ring-neutral-200 ring-inset rounded-full inline-flex items-center transition duration-300 justify-center outline-offset-2 outline-secondary-600 peer-next-checked:ring-2 peer-next-checked:ring-primary-700 hover:bg-primary-100 peer-next-hover:ring-primary-200 active:bg-primary-200 peer-next-active:ring-primary-300 peer-next-disabled:cursor-not-allowed peer-next-disabled:bg-disabled-100 peer-next-disabled:opacity-50 peer-next-disabled:ring-1 peer-next-disabled:ring-disabled-200 peer-next-disabled:hover:ring-disabled-200 peer-next-checked:hover:ring-primary-700 peer-next-checked:active:ring-primary-700 peer-next-focus-visible:outline',
66+
'ring-1 ring-inset rounded-full inline-flex items-center transition duration-200 justify-center outline-offset-2 outline-secondary-600 focus-visible:outline',
67+
getCheckedClasses(inputProps?.checked),
68+
getDisabledClasses(inputProps?.disabled),
5769
getSizeClasses(size),
5870
paddingForSize(size, square, !!showSlotPrefix, !!showSlotSuffix),
5971
_class,

0 commit comments

Comments
 (0)