diff --git a/src/tedi/components/form/choice-group/choice-group.stories.tsx b/src/tedi/components/form/choice-group/choice-group.stories.tsx
index 1f61927d..2b211d09 100644
--- a/src/tedi/components/form/choice-group/choice-group.stories.tsx
+++ b/src/tedi/components/form/choice-group/choice-group.stories.tsx
@@ -49,11 +49,11 @@ interface GenerateItemsArgs {
variant?: 'primary' | 'secondary';
withHelper?: boolean;
withIndicator?: boolean;
- extraLongTitle?: boolean;
tooltip?: boolean;
colProps?: ColProps;
layout?: 'separated' | 'segmented';
justifyContent?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';
+ withIcons?: boolean;
}
const generateItems = ({
@@ -66,36 +66,44 @@ const generateItems = ({
colProps,
layout,
justifyContent,
-}: GenerateItemsArgs): ExtendedChoiceGroupItemProps[] => [
- {
- id: `${inputType}-${variant}-value-${index * 10 + 1}-${withHelper}-${withIndicator}-${layout}`,
- label: 'Text',
- value: `${inputType}-${variant}-value-${index * 10 + 1}-${withHelper}-${withIndicator}-${layout}`,
- ...(withHelper && { helper: { text: 'Description' } }),
- colProps,
- tooltip: tooltip ? 'Tooltip' : undefined,
- justifyContent,
- },
- {
- id: `${inputType}-${variant}-value-${index * 10 + 2}-${withHelper}-${withIndicator}-${layout}`,
- label: 'Text',
- value: `${inputType}-${variant}-value-${index * 10 + 2}-${withHelper}-${withIndicator}-${layout}`,
- ...(withHelper && { helper: { text: 'Description' } }),
- colProps,
- tooltip: tooltip ? 'Tooltip' : undefined,
- justifyContent,
- },
- {
- id: `${inputType}-${variant}-value-${index * 10 + 3}-${withHelper}-${withIndicator}-${layout}`,
- label: 'Text',
- value: `${inputType}-${variant}-value-${index * 10 + 3}-${withHelper}-${withIndicator}-${layout}`,
- ...(withHelper && { helper: { text: 'Description', type: 'error' } }),
- disabled: true,
- colProps,
- tooltip: tooltip ? 'Tooltip' : undefined,
- justifyContent,
- },
-];
+ withIcons = false,
+}: GenerateItemsArgs): ExtendedChoiceGroupItemProps[] => {
+ const baseId = withIcons ? `icon-${inputType}-${variant}` : `${inputType}-${variant}`;
+ const icons = withIcons ? ['train', 'directions_walk', 'directions_car'] : [];
+
+ return [1, 2, 3].map((i) => {
+ const itemIndex = index * 10 + i;
+ const suffix = `${withHelper}-${withIndicator}-${layout ?? 'default'}`;
+
+ let label: React.ReactNode = 'Text';
+
+ if (withIcons) {
+ label = (
+
+
+ {' Text'}
+
+ );
+ }
+
+ return {
+ id: `${baseId}-value-${itemIndex}-${suffix}`,
+ label,
+ value: `${baseId}-value-${itemIndex}`,
+ ...(withHelper && {
+ helper: {
+ text: 'Description',
+ ...(i === 3 && { type: 'error' }),
+ },
+ }),
+ disabled: i === 3,
+ colProps,
+ tooltip: tooltip ? 'Tooltip' : undefined,
+ justifyContent,
+ ...(withIcons && i === 1 && { defaultChecked: true }),
+ };
+ });
+};
const renderGroup = (
inputType: 'radio' | 'checkbox',
@@ -104,13 +112,14 @@ const renderGroup = (
withIndicator: boolean,
layout: 'segmented' | 'separated',
index: number,
- justifyContent: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'
+ justifyContent: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly' = 'start',
+ withIcons = false
) => (
-
+
);
-const renderChoiceGroups = (inputType: 'radio' | 'checkbox', layout: 'segmented' | 'separated') => (
+const renderChoiceGroups = (inputType: 'radio' | 'checkbox', layout: 'segmented' | 'separated', withIcons = false) => (
@@ -164,12 +175,12 @@ const renderChoiceGroups = (inputType: 'radio' | 'checkbox', layout: 'segmented'
Secondary
- {renderGroup(inputType, 'primary', false, true, layout, 1, 'start')}
- {renderGroup(inputType, 'primary', true, true, layout, 2, 'start')}
+ {renderGroup(inputType, 'primary', false, true, layout, 1, 'start', withIcons)}
+ {renderGroup(inputType, 'primary', true, true, layout, 2, 'start', withIcons)}
{inputType !== 'radio' ||
- (layout !== 'separated' && renderGroup(inputType, 'primary', false, false, layout, 3, 'start'))}
+ (layout !== 'separated' && renderGroup(inputType, 'primary', false, false, layout, 3, 'start', withIcons))}
{inputType !== 'radio' ||
- (layout !== 'separated' && renderGroup(inputType, 'primary', true, false, layout, 4, 'start'))}
+ (layout !== 'separated' && renderGroup(inputType, 'primary', true, false, layout, 4, 'start', withIcons))}
);
@@ -223,6 +234,40 @@ export const RadioCardSegmented = () => {renderChoiceGroups('ra
export const RadioCardSeparated = () => {renderChoiceGroups('radio', 'separated')};
export const CheckboxCard = () => {renderChoiceGroups('checkbox', 'separated')};
+export const RadioCardWithIcon: Story = {
+ render: () => (
+
+
+
+ Primary
+
+
+ Secondary
+
+
+ {renderGroup('radio', 'primary', false, true, 'segmented', 1, 'start', true)}
+ {renderGroup('radio', 'secondary', true, true, 'segmented', 2, 'start', true)}
+
+ ),
+};
+
+export const CheckboxCardWithIcon: Story = {
+ render: () => (
+
+
+
+ Primary
+
+
+ Secondary
+
+
+ {renderGroup('checkbox', 'primary', false, true, 'separated', 5, 'start', true)}
+ {renderGroup('checkbox', 'secondary', true, true, 'separated', 6, 'start', true)}
+
+ ),
+};
+
export const WithError: Story = {
render: function Render(args) {
const [selectedValues, setSelectedValues] = useState([]);