Skip to content

Commit 912e07d

Browse files
committed
Add checkbox indicator
1 parent 86eac43 commit 912e07d

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/components/card2/CardCheckbox.tsx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,41 @@ const CardCheckbox = ({
3232
className={cx('sg-card-radio', className)}
3333
style={{...style, ...cssVariables}}
3434
>
35-
<Checkbox />
35+
<CardCheckboxIndicator />
3636
{children}
3737
</label>
3838
);
3939
};
4040

41+
export interface CardCheckboxIndicatorPropsType {
42+
slot?:
43+
| 'top-left'
44+
| 'center-left'
45+
| 'bottom-left'
46+
| 'top-right'
47+
| 'center-right'
48+
| 'bottom-right';
49+
style?: React.CSSProperties;
50+
className?: string;
51+
}
52+
53+
const CardCheckboxIndicator = ({
54+
slot = 'top-left',
55+
style,
56+
className,
57+
}: CardCheckboxIndicatorPropsType) => {
58+
return (
59+
<div
60+
className={cx(
61+
'sg-card-checkbox__indicator',
62+
`sg-card-checkbox__indicator--${slot}`,
63+
className
64+
)}
65+
style={style}
66+
>
67+
<Checkbox />
68+
</div>
69+
);
70+
};
71+
4172
export default CardCheckbox;

src/components/card2/card.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.sg-card-radio,
33
.sg-card-checkbox {
44
display: block;
5+
position: relative;
56
width: var(--card-width, auto);
67
height: var(--card-height, auto);
78
border-radius: 8px;
@@ -17,3 +18,9 @@
1718
border-color: #46535f;
1819
}
1920
}
21+
22+
.sg-card-checkbox__indicator {
23+
position: absolute;
24+
top: 0;
25+
left: 0;
26+
}

0 commit comments

Comments
 (0)