forked from qwikifiers/qwik-storefront-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac3adac
commit 1d34d91
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { component$, useContext, useTask$ } from '@builder.io/qwik'; | ||
import { SfBadge, SfBadgePlacement, SfBadgeVariant, SfButton, SfIconShoppingCart } from 'qwik-storefront-ui'; | ||
import { ComponentExample } from '../../../components/utils/ComponentExample'; | ||
import { ControlsType } from '../../../components/utils/types'; | ||
import { EXAMPLES_STATE } from '../layout'; | ||
|
||
export default component$(() => { | ||
|
||
const examplesState = useContext(EXAMPLES_STATE); | ||
|
||
useTask$(() => { | ||
examplesState.data = { | ||
controls: [ | ||
{ | ||
type: 'text', | ||
modelName: 'content', | ||
description: 'Content to display in the badge.', | ||
propType: 'string | number', | ||
}, | ||
{ | ||
type: 'text', | ||
modelName: 'max', | ||
description: 'Maximum number of counter to show.', | ||
propType: 'number', | ||
propDefaultValue: '99', | ||
}, | ||
{ | ||
type: 'select', | ||
modelName: 'variant', | ||
description: 'Badge can have content or be a simple dot.', | ||
options: Object.values(SfBadgeVariant), | ||
propType: 'SfBadgeVariant', | ||
propDefaultValue: 'standard', | ||
}, | ||
{ | ||
type: 'select', | ||
modelName: 'placement', | ||
description: 'Position of the badge relatively to a container.', | ||
options: Object.values(SfBadgePlacement), | ||
propType: 'SfBadgePlacement', | ||
propDefaultValue: 'top-right', | ||
}, | ||
] satisfies ControlsType, | ||
|
||
state: { | ||
content: '1', | ||
max: 99, | ||
variant: SfBadgeVariant.standard, | ||
placement: SfBadgePlacement['top-right'], | ||
} | ||
} | ||
}); | ||
|
||
return ( | ||
<ComponentExample> | ||
<SfButton class="relative" square variant="tertiary"> | ||
<SfIconShoppingCart /> | ||
<SfBadge {...examplesState.data.state} max={Number(examplesState.data.state.max)} /> | ||
</SfButton> | ||
</ComponentExample> | ||
); | ||
}); |