Skip to content

Commit c1d2823

Browse files
authored
fix: Radio in pureCard mode (#95)
1 parent 01a1d15 commit c1d2823

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze-arch/coze-design",
5+
"comment": "Radio in pureCard mode",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@coze-arch/coze-design",
10+
"email": "[email protected]"
11+
}

config/tailwind-config/src/coze.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ const semanticMiddleground = {
164164
'coz-mg': 'colors.background.4',
165165
'coz-mg-mask': 'colors.mask.5',
166166
'coz-mg-table-fixed-hovered': 'colors.background.0',
167-
'coz-mg-card-pressed': 'colors.background.3',
168-
'coz-mg-card-hovered': 'colors.background.3',
167+
'coz-mg-card-pressed': 'colors.background.1',
168+
'coz-mg-card-hovered': 'colors.background.2',
169169
'coz-mg-card': 'colors.background.3',
170170
/** brand */
171171
'coz-mg-color-plus-brand': 'colors.brand.50',

packages/components/coze-design/src/components/radio/radio-group.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,36 @@ import { forwardRef } from 'react';
66
import { type RadioGroupProps } from '@douyinfe/semi-ui/lib/es/radio/index.js';
77
import { RadioGroup as SemiRadioGroup } from '@douyinfe/semi-ui';
88

9+
import { cn } from '@/utils';
10+
11+
import { radioButtonVariants } from './radio-variant';
12+
913
export const RadioGroup = forwardRef<SemiRadioGroup, RadioGroupProps>(
1014
(props, ref): JSX.Element => {
1115
const { children, ...restProps } = props;
1216

17+
const { options } = restProps;
18+
19+
/**
20+
* pureCard 模式下,将 coz-radio 的样式拼接上去
21+
* 暂时只兼容 pureCard 模式,其他模式下业务侧已经有了很多自定义 className
22+
*/
23+
if (options && restProps.type === 'pureCard') {
24+
restProps.options = options.map(opt => {
25+
if (typeof opt === 'string') {
26+
return {
27+
label: opt,
28+
className: radioButtonVariants(),
29+
};
30+
} else {
31+
return {
32+
...opt,
33+
className: cn(radioButtonVariants(), opt.className),
34+
};
35+
}
36+
});
37+
}
38+
1339
return (
1440
<SemiRadioGroup {...restProps} ref={ref}>
1541
{children}

0 commit comments

Comments
 (0)