Skip to content

Commit cfc367e

Browse files
committed
feat(component): add more customizable prop for radio-group with new story (#7850)
![CleanShot 2024-08-13 at 16.40.22@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/LakojjjzZNf6ogjOVwKE/06a128c3-f0bb-47f9-babf-6d4eca2597d7.png)
1 parent 69c507f commit cfc367e

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

packages/frontend/component/src/ui/radio/radio.stories.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { AiIcon, FrameIcon, TocIcon, TodayIcon } from '@blocksuite/icons/rc';
22
import { cssVar } from '@toeverything/theme';
3+
import { cssVarV2 } from '@toeverything/theme/v2';
34
import { useState } from 'react';
45

56
import { ResizePanel } from '../resize-panel/resize-panel';
@@ -147,3 +148,31 @@ export const CustomizeActiveStyle = () => {
147148
/>
148149
);
149150
};
151+
152+
const shapes = [
153+
'Square',
154+
'Ellipse',
155+
'Diamond',
156+
'Triangle',
157+
'Rounded ',
158+
'Rectangle',
159+
];
160+
export const ShapeSelectorDemo = () => {
161+
const [shape, setShape] = useState(shapes[0]);
162+
return (
163+
<RadioGroup
164+
padding={0}
165+
gap={4}
166+
itemHeight={28}
167+
borderRadius={8}
168+
value={shape}
169+
items={shapes}
170+
onChange={setShape}
171+
style={{ background: 'transparent' }}
172+
indicatorStyle={{
173+
boxShadow: 'none',
174+
backgroundColor: cssVarV2('layer/background/tertiary'),
175+
}}
176+
/>
177+
);
178+
};

packages/frontend/component/src/ui/radio/radio.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const RadioGroup = memo(function RadioGroup({
6969
items,
7070
value,
7171
width,
72+
className,
7273
style,
7374
padding = 2,
7475
gap = 4,
@@ -78,6 +79,8 @@ export const RadioGroup = memo(function RadioGroup({
7879
animationEasing = 'cubic-bezier(.18,.22,0,1)',
7980
activeItemClassName,
8081
activeItemStyle,
82+
indicatorClassName,
83+
indicatorStyle,
8184
iconMode,
8285
onChange,
8386
}: RadioProps) {
@@ -152,7 +155,7 @@ export const RadioGroup = memo(function RadioGroup({
152155
<RadixRadioGroup.Root
153156
value={value}
154157
onValueChange={onChange}
155-
className={styles.radioButtonGroup}
158+
className={clsx(styles.radioButtonGroup, className)}
156159
style={finalStyle}
157160
data-icon-mode={iconMode}
158161
>
@@ -179,8 +182,9 @@ export const RadioGroup = memo(function RadioGroup({
179182
>
180183
<RadixRadioGroup.Indicator
181184
forceMount
182-
className={styles.indicator}
185+
className={clsx(styles.indicator, indicatorClassName)}
183186
ref={item.indicatorRef}
187+
style={indicatorStyle}
184188
/>
185189
<span className={styles.radioButtonContent}>
186190
{customRender?.(item, index) ?? item.label ?? item.value}

packages/frontend/component/src/ui/radio/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export interface RadioProps extends RadioGroupItemProps {
4747
activeItemClassName?: string;
4848
/** Customize active item's style */
4949
activeItemStyle?: CSSProperties;
50+
/** Customize indicator's className */
51+
indicatorClassName?: string;
52+
/** Customize indicator's style */
53+
indicatorStyle?: CSSProperties;
5054
/**
5155
* This prop is used to use a different color scheme
5256
*/

0 commit comments

Comments
 (0)