Skip to content

Commit f49a107

Browse files
committed
feat(button): add 'raised' button
1 parent acaacd8 commit f49a107

File tree

5 files changed

+61
-23
lines changed

5 files changed

+61
-23
lines changed

src/Button/Button.stories.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,47 @@ Default.story = {
6363
name: 'default'
6464
};
6565

66+
export function Raised() {
67+
return (
68+
<div id='default-buttons'>
69+
<Button variant='raised'>Default</Button>
70+
<br />
71+
<Button variant='raised' primary>
72+
Primary
73+
</Button>
74+
<br />
75+
<Button variant='raised' disabled>
76+
Disabled
77+
</Button>
78+
<br />
79+
<Button variant='raised' active>
80+
Active
81+
</Button>
82+
<br />
83+
<Button variant='raised' square>
84+
<span role='img' aria-label='recycle'>
85+
♻︎
86+
</span>
87+
</Button>
88+
<br />
89+
<Button variant='raised' fullWidth>
90+
Full width
91+
</Button>
92+
<br />
93+
<Button variant='raised' size='sm'>
94+
Size small
95+
</Button>
96+
<Button variant='raised' size='lg'>
97+
Size large
98+
</Button>
99+
</div>
100+
);
101+
}
102+
103+
Raised.story = {
104+
name: 'raised'
105+
};
106+
66107
export function Flat() {
67108
return (
68109
<Window>

src/Button/Button.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type ButtonProps = {
2525
type?: string;
2626
} & (
2727
| {
28-
variant?: 'default' | 'flat' | 'thin';
28+
variant?: 'default' | 'raised' | 'flat' | 'thin';
2929
}
3030
| {
3131
/** @deprecated Use `thin` */
@@ -146,11 +146,21 @@ export const StyledButton = styled.button<StyledButtonProps>`
146146
`}
147147
148148
${active
149-
? createBorderStyles({ invert: true })
150-
: createBorderStyles({ invert: false })}
149+
? createBorderStyles({
150+
style: variant === 'raised' ? 'window' : 'button',
151+
invert: true
152+
})
153+
: createBorderStyles({
154+
style: variant === 'raised' ? 'window' : 'button',
155+
invert: false
156+
})}
151157
}
152158
&:active:before {
153-
${!disabled && createBorderStyles({ invert: true })}
159+
${!disabled &&
160+
createBorderStyles({
161+
style: variant === 'raised' ? 'window' : 'button',
162+
invert: true
163+
})}
154164
}
155165
&:focus:after,
156166
&:active:after {

src/NumberInput/NumberInput.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const StyledNumberInputWrapper = styled.div`
2828
align-items: center;
2929
`;
3030

31-
const StyledButton = styled(Button)<Pick<NumberInputProps, 'variant'>>`
31+
const StyledButton = styled(Button)`
3232
width: 30px;
3333
padding: 0;
3434
flex-shrink: 0;
@@ -40,13 +40,6 @@ const StyledButton = styled(Button)<Pick<NumberInputProps, 'variant'>>`
4040
`
4141
: css`
4242
height: 50%;
43-
&:before {
44-
border-left-color: ${({ theme }) => theme.borderLight};
45-
border-top-color: ${({ theme }) => theme.borderLight};
46-
box-shadow: inset 1px 1px 0px 1px
47-
${({ theme }) => theme.borderLightest},
48-
inset -1px -1px 0 1px ${({ theme }) => theme.borderDark};
49-
}
5043
`}
5144
`;
5245

@@ -159,6 +152,7 @@ const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(
159152
handleClick(-step);
160153
}, [handleClick, step]);
161154

155+
const buttonVariant = variant === 'flat' ? 'flat' : 'raised';
162156
return (
163157
<StyledNumberInputWrapper
164158
className={className}
@@ -181,15 +175,15 @@ const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(
181175
<StyledButtonWrapper variant={variant}>
182176
<StyledButton
183177
data-testid='increment'
184-
variant={variant}
178+
variant={buttonVariant}
185179
disabled={disabled || readOnly}
186180
onClick={stepUp}
187181
>
188182
<StyledButtonIcon invert />
189183
</StyledButton>
190184
<StyledButton
191185
data-testid='decrement'
192-
variant={variant}
186+
variant={buttonVariant}
193187
disabled={disabled || readOnly}
194188
onClick={stepDown}
195189
>

src/Select/Select.styles.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const StyledNativeSelect = styled.select`
109109

110110
export const StyledDropdownButton = styled(Button).attrs(() => ({
111111
'aria-hidden': 'true'
112-
}))<CommonSelectStyleProps>`
112+
}))<Omit<CommonSelectStyleProps, 'variant'>>`
113113
width: 30px;
114114
padding: 0;
115115
flex-shrink: 0;
@@ -121,13 +121,6 @@ export const StyledDropdownButton = styled(Button).attrs(() => ({
121121
`
122122
: css`
123123
height: 100%;
124-
&:before {
125-
border-left-color: ${({ theme }) => theme.borderLight};
126-
border-top-color: ${({ theme }) => theme.borderLight};
127-
box-shadow: inset 1px 1px 0px 1px
128-
${({ theme }) => theme.borderLightest},
129-
inset -1px -1px 0 1px ${({ theme }) => theme.borderDark};
130-
}
131124
`}
132125
${({ native = false, variant = 'default' }) =>
133126
native &&

src/Select/useSelectCommon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const useSelectCommon = <T,>({
5454
$disabled={disabled}
5555
native={native}
5656
tabIndex={-1}
57-
variant={variant}
57+
variant={variant === 'flat' ? 'flat' : 'raised'}
5858
>
5959
<StyledDropdownIcon data-testid='select-icon' $disabled={disabled} />
6060
</StyledDropdownButton>

0 commit comments

Comments
 (0)