mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat(component): add more customizable prop for radio-group with new story (#7850)

This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { AiIcon, FrameIcon, TocIcon, TodayIcon } from '@blocksuite/icons/rc';
|
||||
import { cssVar } from '@toeverything/theme';
|
||||
import { cssVarV2 } from '@toeverything/theme/v2';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { ResizePanel } from '../resize-panel/resize-panel';
|
||||
@@ -147,3 +148,31 @@ export const CustomizeActiveStyle = () => {
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const shapes = [
|
||||
'Square',
|
||||
'Ellipse',
|
||||
'Diamond',
|
||||
'Triangle',
|
||||
'Rounded ',
|
||||
'Rectangle',
|
||||
];
|
||||
export const ShapeSelectorDemo = () => {
|
||||
const [shape, setShape] = useState(shapes[0]);
|
||||
return (
|
||||
<RadioGroup
|
||||
padding={0}
|
||||
gap={4}
|
||||
itemHeight={28}
|
||||
borderRadius={8}
|
||||
value={shape}
|
||||
items={shapes}
|
||||
onChange={setShape}
|
||||
style={{ background: 'transparent' }}
|
||||
indicatorStyle={{
|
||||
boxShadow: 'none',
|
||||
backgroundColor: cssVarV2('layer/background/tertiary'),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -69,6 +69,7 @@ export const RadioGroup = memo(function RadioGroup({
|
||||
items,
|
||||
value,
|
||||
width,
|
||||
className,
|
||||
style,
|
||||
padding = 2,
|
||||
gap = 4,
|
||||
@@ -78,6 +79,8 @@ export const RadioGroup = memo(function RadioGroup({
|
||||
animationEasing = 'cubic-bezier(.18,.22,0,1)',
|
||||
activeItemClassName,
|
||||
activeItemStyle,
|
||||
indicatorClassName,
|
||||
indicatorStyle,
|
||||
iconMode,
|
||||
onChange,
|
||||
}: RadioProps) {
|
||||
@@ -152,7 +155,7 @@ export const RadioGroup = memo(function RadioGroup({
|
||||
<RadixRadioGroup.Root
|
||||
value={value}
|
||||
onValueChange={onChange}
|
||||
className={styles.radioButtonGroup}
|
||||
className={clsx(styles.radioButtonGroup, className)}
|
||||
style={finalStyle}
|
||||
data-icon-mode={iconMode}
|
||||
>
|
||||
@@ -179,8 +182,9 @@ export const RadioGroup = memo(function RadioGroup({
|
||||
>
|
||||
<RadixRadioGroup.Indicator
|
||||
forceMount
|
||||
className={styles.indicator}
|
||||
className={clsx(styles.indicator, indicatorClassName)}
|
||||
ref={item.indicatorRef}
|
||||
style={indicatorStyle}
|
||||
/>
|
||||
<span className={styles.radioButtonContent}>
|
||||
{customRender?.(item, index) ?? item.label ?? item.value}
|
||||
|
||||
@@ -47,6 +47,10 @@ export interface RadioProps extends RadioGroupItemProps {
|
||||
activeItemClassName?: string;
|
||||
/** Customize active item's style */
|
||||
activeItemStyle?: CSSProperties;
|
||||
/** Customize indicator's className */
|
||||
indicatorClassName?: string;
|
||||
/** Customize indicator's style */
|
||||
indicatorStyle?: CSSProperties;
|
||||
/**
|
||||
* This prop is used to use a different color scheme
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user