Skip to content

Commit 17eec67

Browse files
committed
fix(checkbox): remove 'menu' variant
Remove 'menu' variant, as this should be a part of MenuList component BREAKING CHANGE: Removal of 'menu' Checkbox variant
1 parent 06cba7c commit 17eec67

File tree

2 files changed

+9
-116
lines changed

2 files changed

+9
-116
lines changed

src/Checkbox/Checkbox.stories.tsx

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@ import React, { useState } from 'react';
22
import styled from 'styled-components';
33

44
import { ComponentMeta } from '@storybook/react';
5-
import {
6-
Checkbox,
7-
GroupBox,
8-
MenuList,
9-
MenuListItem,
10-
ScrollView,
11-
Separator
12-
} from 'react95';
5+
import { Checkbox, GroupBox, ScrollView } from 'react95';
136

147
const Wrapper = styled.div`
158
background: ${({ theme }) => theme.material};
@@ -237,44 +230,3 @@ export function Flat() {
237230
Flat.story = {
238231
name: 'flat'
239232
};
240-
241-
export function Menu() {
242-
return (
243-
<MenuList>
244-
<MenuListItem size='md'>
245-
<Checkbox
246-
name='useGradient'
247-
variant='menu'
248-
value='useGradient'
249-
label='Use gradient'
250-
defaultChecked
251-
/>
252-
</MenuListItem>
253-
<MenuListItem size='md'>
254-
<Checkbox
255-
name='thickBrush'
256-
variant='menu'
257-
defaultChecked={false}
258-
value='thickBrush'
259-
label='Thick brush'
260-
indeterminate
261-
/>
262-
</MenuListItem>
263-
<Separator />
264-
<MenuListItem size='md' disabled>
265-
<Checkbox
266-
name='autoSave'
267-
variant='menu'
268-
value='autoSave'
269-
checked
270-
label='Auto-save'
271-
disabled
272-
/>
273-
</MenuListItem>
274-
</MenuList>
275-
);
276-
}
277-
278-
Menu.story = {
279-
name: 'menu'
280-
};

src/Checkbox/Checkbox.tsx

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
StyledLabel
1111
} from '../common/SwitchBase';
1212
import { noOp } from '../common/utils';
13-
import { StyledMenuListItem } from '../MenuList/MenuList';
1413
import { StyledScrollView } from '../ScrollView/ScrollView';
1514
import { CommonThemeProps } from '../types';
1615

@@ -25,7 +24,7 @@ type CheckboxProps = {
2524
onChange?: React.ChangeEventHandler<HTMLInputElement>;
2625
style?: React.CSSProperties;
2726
value?: number | string;
28-
variant?: 'default' | 'flat' | 'menu';
27+
variant?: 'default' | 'flat';
2928
} & Omit<
3029
React.InputHTMLAttributes<HTMLInputElement>,
3130
| 'checked'
@@ -41,7 +40,7 @@ type CheckboxProps = {
4140

4241
type CheckmarkProps = {
4342
$disabled: boolean;
44-
variant: 'default' | 'flat' | 'menu';
43+
variant: 'default' | 'flat';
4544
};
4645

4746
const sharedCheckboxStyles = css`
@@ -77,20 +76,6 @@ const StyledFlatCheckbox = styled.div<CommonThemeProps>`
7776
$disabled ? theme.flatLight : theme.canvas};
7877
`;
7978

80-
const StyledMenuCheckbox = styled.div<CommonThemeProps>`
81-
position: relative;
82-
box-sizing: border-box;
83-
display: inline-block;
84-
background: ${({ $disabled, theme }) =>
85-
$disabled ? theme.flatLight : theme.canvas};
86-
${sharedCheckboxStyles}
87-
width: ${size - 4}px;
88-
height: ${size - 4}px;
89-
background: none;
90-
border: none;
91-
outline: none;
92-
`;
93-
9479
const CheckmarkIcon = styled.span.attrs(() => ({
9580
'data-testid': 'checkmarkIcon'
9681
}))<CheckmarkProps>`
@@ -113,30 +98,8 @@ const CheckmarkIcon = styled.span.attrs(() => ({
11398
border-width: 0 3px 3px 0;
11499
transform: translate(-50%, -50%) rotate(45deg);
115100
116-
${({ $disabled, theme, variant }) =>
117-
variant === 'menu'
118-
? css`
119-
border-color: ${$disabled
120-
? theme.materialTextDisabled
121-
: theme.materialText};
122-
filter: drop-shadow(
123-
1px 1px 0px
124-
${$disabled ? theme.materialTextDisabledShadow : 'transparent'}
125-
);
126-
`
127-
: css`
128-
border-color: ${$disabled
129-
? theme.checkmarkDisabled
130-
: theme.checkmark};
131-
`}
132-
${StyledMenuListItem}:hover & {
133-
${({ $disabled, theme, variant }) =>
134-
!$disabled &&
135-
variant === 'menu' &&
136-
css`
137-
border-color: ${theme.materialTextInvert};
138-
`};
139-
}
101+
border-color: ${p =>
102+
p.$disabled ? p.theme.checkmarkDisabled : p.theme.checkmark};
140103
}
141104
`;
142105
const IndeterminateIcon = styled.span.attrs(() => ({
@@ -145,16 +108,9 @@ const IndeterminateIcon = styled.span.attrs(() => ({
145108
display: inline-block;
146109
position: relative;
147110
148-
${({ variant }) =>
149-
variant === 'menu'
150-
? css`
151-
height: calc(100% - 4px);
152-
width: calc(100% - 4px);
153-
`
154-
: css`
155-
width: 100%;
156-
height: 100%;
157-
`}
111+
width: 100%;
112+
height: 100%;
113+
158114
&:after {
159115
content: '';
160116
display: block;
@@ -167,27 +123,12 @@ const IndeterminateIcon = styled.span.attrs(() => ({
167123
mainColor: $disabled ? theme.checkmarkDisabled : theme.checkmark
168124
})}
169125
background-position: 0px 0px, 2px 2px;
170-
171-
${({ $disabled, theme, variant }) =>
172-
variant === 'menu' &&
173-
css`
174-
${StyledMenuListItem}:hover & {
175-
${createHatchedBackground({
176-
mainColor: theme.materialTextInvert
177-
})}
178-
}
179-
filter: drop-shadow(
180-
1px 1px 0px
181-
${$disabled ? theme.materialTextDisabledShadow : 'transparent'}
182-
);
183-
`};
184126
}
185127
`;
186128

187129
const CheckboxComponents = {
188130
flat: StyledFlatCheckbox,
189-
default: StyledCheckbox,
190-
menu: StyledMenuCheckbox
131+
default: StyledCheckbox
191132
};
192133

193134
const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(

0 commit comments

Comments
 (0)