Skip to content

Commit 92544e7

Browse files
committed
refactor: dialog button style
1 parent 93c2c92 commit 92544e7

File tree

8 files changed

+145
-47
lines changed

8 files changed

+145
-47
lines changed

.storybook/preview.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ export const parameters = {
2020
},
2121
},
2222
backgrounds: {
23-
default: 'figma',
23+
default: 'dark',
2424
values: [
2525
{
26-
name: 'figma',
27-
value: '#E5E5E5',
26+
name: 'dark',
27+
value: '#3E3E3E',
28+
},
29+
{
30+
name: 'light',
31+
value: '#EBEBEB',
2832
},
2933
],
3034
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@beeinventor/dasiot-react-component-lib",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"module": "lib/index.js",
55
"types": "lib/index.d.ts",
66
"files": [

src/Theme.types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export interface Color {
2828
$80: string;
2929
$100: string;
3030
};
31+
green: {
32+
$100: string;
33+
};
3134
highlight: string;
3235
box_bbg: string;
3336
}

src/components/Button/DialogButton/DialogButton.stories.tsx

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,43 @@ export default {
4040

4141
const Template: Story<DialogButtonProps> = (args) => <DialogButton {...args} />;
4242

43-
const Default: Story<DialogButtonProps> = Template.bind({});
43+
export const Default: Story<DialogButtonProps> = Template.bind({});
4444

4545
Default.args = {
46+
color: 'primary',
4647
variant: 'contained',
48+
children: 'Back',
4749
fullWidth: false,
4850
disabled: false,
51+
previousIcon: false,
52+
nextIcon: false,
4953
};
5054

51-
export const Primary: Story<DialogButtonProps> = Template.bind({});
55+
export const DefaultLight: Story<DialogButtonProps> = Template.bind({});
5256

53-
Primary.args = {
57+
DefaultLight.parameters = {
58+
backgrounds: {
59+
default: 'light',
60+
},
61+
};
62+
DefaultLight.args = {
5463
...Default.args,
55-
children: 'Back',
56-
color: 'primary',
64+
mode: 'light',
65+
color: 'secondary',
66+
variant: 'outlined',
67+
};
68+
69+
export const Loading: Story<DialogButtonProps> = Template.bind({});
70+
71+
Loading.args = {
72+
...Default.args,
73+
isLoading: true,
5774
};
5875

59-
export const PrimaryWithIcon: Story<DialogButtonProps> = Template.bind({});
76+
export const WithIcon: Story<DialogButtonProps> = Template.bind({});
6077

61-
PrimaryWithIcon.args = {
62-
...Primary.args,
78+
WithIcon.args = {
79+
...Default.args,
6380
previousIcon: true,
6481
nextIcon: false,
6582
};

src/components/Button/DialogButton/DialogButton.tsx

Lines changed: 103 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,117 @@
1+
import classnames from 'classnames';
12
import React from 'react';
23
import MUIButton from '@mui/material/Button';
3-
import { DialogButtonProps } from './DialogButton.types';
44
import ChevronLeft from '@mui/icons-material/ChevronLeft';
55
import ChevronRight from '@mui/icons-material/ChevronRight';
66
import { styled } from '@mui/material/styles';
77

8-
const Styled = styled(MUIButton)(({ theme }) => ({
9-
...theme.text.Subtitle_16_Med,
10-
minWidth: 120,
11-
color: '#FFF',
12-
paddingTop: 4,
13-
paddingBottom: 4,
14-
textTransform: 'none',
15-
boxShadow: 'none',
16-
'&:active, &:hover': {
17-
backgroundColor: theme.color.primary.$80,
18-
},
19-
'&.MuiButton-containedSecondary': {
20-
color: theme.color.primary.$100,
21-
backgroundColor: '#FFF',
22-
'&:active, &:hover': {
23-
backgroundColor: 'rgba(0, 0, 0, .05)',
24-
},
25-
},
26-
'&.Mui-disabled': {
27-
opacity: '.3',
8+
import { Mode } from 'components/main.types';
9+
import { DialogButtonProps } from './DialogButton.types';
10+
11+
interface ButtonProps {
12+
mode?: Mode;
13+
}
14+
15+
const Button = styled(MUIButton)<ButtonProps>`
16+
min-width: 120px;
17+
color: white;
18+
font-weight: bold;
19+
padding: 4px 0;
20+
text-transform: none;
21+
box-shadow: none;
22+
23+
&:hover {
24+
box-shadow: none;
25+
}
26+
27+
&.Mui-disabled {
28+
opacity: 0.3;
29+
}
30+
31+
& .MuiButton-startIcon {
32+
margin-right: 10px;
33+
}
34+
35+
& .MuiButton-endIcon {
36+
margin-left: 10px;
37+
}
38+
39+
${({ theme }) => ({
40+
...theme.typography.body2,
2841
'&.MuiButton-containedPrimary': {
29-
color: '#FFF',
30-
backgroundColor: theme.color.primary.$80,
42+
'&:hover': {
43+
backgroundColor: theme.color.primary.$80,
44+
},
45+
'&.loading': {
46+
pointerEvents: 'none',
47+
border: `1px solid ${theme.color.primary.$100}`,
48+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
49+
},
50+
'&.Mui-disabled': {
51+
color: 'white',
52+
backgroundColor: theme.color.primary.$80,
53+
},
3154
},
32-
},
33-
'& .MuiButton-startIcon': { marginRight: '10px' },
34-
'& .MuiButton-endIcon': { marginLeft: '10px' },
35-
}));
36-
37-
const DialogButton: React.VFC<DialogButtonProps> = (props) => {
38-
const { className, previousIcon, nextIcon, color, ...otherProps } =
39-
props ?? {};
55+
56+
'&.MuiButton-containedSecondary': {
57+
backgroundColor: theme.color.secondary.$80,
58+
'&:hover': {
59+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
60+
},
61+
'&.Mui-disabled': {
62+
color: 'white',
63+
backgroundColor: theme.color.secondary.$80,
64+
},
65+
},
66+
67+
'&.MuiButton-containedSuccess': {
68+
border: `1px solid ${theme.color.green.$100}`,
69+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
70+
'&:hover': {
71+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
72+
},
73+
'&.Mui-disabled': {
74+
color: 'white',
75+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
76+
},
77+
},
78+
79+
'&.MuiButton-outlined': {
80+
'&[mode="light"]': {
81+
color: theme.color.secondary.$60,
82+
'&:hover': {
83+
color: theme.color.secondary.$100,
84+
},
85+
},
86+
},
87+
88+
'&.MuiButton-outlinedSecondary': {
89+
borderColor: `1px solid ${theme.color.secondary.$60}`,
90+
'&:hover': {
91+
borderColor: theme.color.secondary.$100,
92+
},
93+
},
94+
})}
95+
`;
96+
97+
const DialogButton: React.VFC<DialogButtonProps> = ({
98+
className,
99+
mode = 'dark',
100+
previousIcon,
101+
nextIcon,
102+
isLoading = false,
103+
...props
104+
}) => {
40105
return (
41-
<Styled
42-
className={className}
43-
color={color}
106+
<Button
107+
mode={mode}
108+
className={classnames({
109+
className,
110+
loading: isLoading,
111+
})}
44112
startIcon={previousIcon && <ChevronLeft />}
45113
endIcon={nextIcon && <ChevronRight />}
46-
{...otherProps}
114+
{...props}
47115
/>
48116
);
49117
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { ButtonProps } from '@mui/material';
22

33
export interface DialogButtonProps extends ButtonProps {
4+
mode?: 'dark' | 'light';
45
previousIcon?: boolean;
56
nextIcon?: boolean;
7+
isLoading?: boolean;
68
}

src/components/main.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type Mode = 'dark' | 'light';

src/theme.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export const color: Color = {
5656
$80: '#656565',
5757
$100: '#3E3E3E',
5858
},
59+
green: {
60+
$100: '#78DC00',
61+
},
5962
highlight: '#FF6B00',
6063
box_bbg: '#F3F3F3',
6164
};

0 commit comments

Comments
 (0)