Skip to content

Commit 4e0b38a

Browse files
authored
added example with icons. Changed segments props to be mandatory (#3093)
1 parent 19fd161 commit 4e0b38a

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

demo/src/screens/componentScreens/SegmentedControlScreen.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const segments: Record<string, Array<SegmentedControlItemProps>> = {
1717
forth: [{label: 'With'}, {label: 'Custom'}, {label: 'Style'}],
1818
fifth: [{label: 'Full'}, {label: 'Width'}],
1919
sixth: [{label: 'Full'}, {label: 'Width'}, {label: 'With'}, {label: 'A'}, {label: 'Very Long Segment'}],
20-
seventh: [{label: '$'}, {label: '%'}]
20+
seventh: [{label: '$'}, {label: '%'}],
21+
eighth: [{label: 'Plus', iconSource: Assets.icons.plusSmall}, {label: 'Minus', iconSource: Assets.icons.minusSmall}, {label: 'Check', iconSource: Assets.icons.checkSmall}]
2122
};
2223

2324
const SegmentedControlScreen = () => {
@@ -70,6 +71,8 @@ const SegmentedControlScreen = () => {
7071
segmentLabelStyle={styles.customTypography}
7172
preset={screenPreset}
7273
/>
74+
<Text center marginT-s4>With Icons</Text>
75+
<SegmentedControl segments={segments.eighth} preset={screenPreset}/>
7376
<Text marginT-s4 center>
7477
Custom Styling
7578
</Text>

src/components/segmentedControl/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type SegmentedControlProps = {
3131
/**
3232
* Array on segments.
3333
*/
34-
segments?: SegmentedControlItemProps[];
34+
segments: SegmentedControlItemProps[];
3535
/**
3636
* The color of the active segment label.
3737
*/

src/components/segmentedControl/useSegmentedControlPreset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const useSegmentedControlPreset = (props: SegmentedControlProps): useSegmentedCo
2626
return presetProps;
2727
};
2828

29-
const defaultsPresetsProps: Record<`${Presets}`, useSegmentedControlPresetProps> = {
29+
const defaultsPresetsProps: Record<`${Presets}`, Omit<useSegmentedControlPresetProps, 'segments'>> = {
3030
default: {
3131
activeColor: DEFAULT_ACTIVE_COLOR,
3232
borderRadius: BorderRadiuses.br100,

0 commit comments

Comments
 (0)