Skip to content

Commit 28cbf4d

Browse files
committed
fix: button styles ported to css modules
1 parent b01a2cb commit 28cbf4d

File tree

6 files changed

+147
-70
lines changed

6 files changed

+147
-70
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.button {
2+
font-family: 'Commissioner', sans-serif;
3+
font-size: 14px;
4+
line-height: 1.25rem;
5+
padding: 0.5rem;
6+
outline: none;
7+
border-radius: 0.375rem;
8+
border: 1px solid rgb(207, 207, 211);
9+
background-color: white;
10+
cursor: pointer;
11+
}
12+
13+
.button:hover {
14+
background-color: rgb(0, 66, 235);
15+
color: white;
16+
transition: all 0.2s;
17+
}
18+
19+
.button:disabled {
20+
pointer-events: none;
21+
background-color: rgb(240, 240, 240);
22+
color: rgb(150, 150, 150);
23+
border-color: rgb(207, 207, 211);
24+
}
25+
26+
.buttonLoading {
27+
pointer-events: none;
28+
background-color: rgb(240, 240, 240);
29+
color: rgb(150, 150, 150);
30+
border-color: rgb(207, 207, 211);
31+
}

src/client/components/button.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Box, CircularProgress } from '@mui/material';
2+
import { FunctionComponent } from 'react';
3+
import styles from './button.module.css';
4+
5+
interface ButtonProps {
6+
onClick: () => void;
7+
children: React.ReactNode;
8+
disabled?: boolean;
9+
style?: React.CSSProperties;
10+
loading?: boolean;
11+
}
12+
13+
const Button: FunctionComponent<ButtonProps> = ({
14+
onClick,
15+
children,
16+
disabled,
17+
style,
18+
loading = false,
19+
...rest
20+
}) => {
21+
return (
22+
<button
23+
className={`${styles.button} ${loading ? styles.buttonLoading : ''} `}
24+
style={style}
25+
onClick={onClick}
26+
disabled={disabled}
27+
{...rest}
28+
>
29+
<Box display="flex" alignItems="center">
30+
{loading && (
31+
<CircularProgress
32+
size={14}
33+
color="inherit"
34+
sx={{ marginRight: '8px' }}
35+
/>
36+
)}{' '}
37+
{children}
38+
</Box>
39+
</button>
40+
);
41+
};
42+
43+
export default Button;

src/client/sidebar/components/Sidebar.tsx

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useCallback, useEffect, useRef, useState } from 'react';
22
import {
3-
Button,
43
CircularProgress,
54
Container,
65
Typography,
6+
Button as MuiButton,
77
Divider,
88
Box,
99
Tabs,
@@ -13,6 +13,7 @@ import { serverFunctions } from '../../utils/serverFunctions';
1313
import LoadingOverlay from '../../components/loading-overlay';
1414
import { buildUrl } from '../../utils/helpers';
1515
import useAuth from '../../hooks/useAuth';
16+
import Button from '../../components/button';
1617

1718
interface ChartImage {
1819
altDescription: string;
@@ -238,27 +239,9 @@ const Sidebar = () => {
238239
/>
239240
<>
240241
{authState?.authorized ? (
241-
<Button
242-
onClick={signOut}
243-
color="primary"
244-
variant="outlined"
245-
sx={{
246-
textTransform: 'initial',
247-
}}
248-
>
249-
Logout
250-
</Button>
242+
<Button onClick={signOut}>Logout</Button>
251243
) : (
252-
<Button
253-
onClick={handleLoginClick}
254-
color="primary"
255-
variant="outlined"
256-
sx={{
257-
textTransform: 'initial',
258-
}}
259-
>
260-
Login
261-
</Button>
244+
<Button onClick={handleLoginClick}>Login</Button>
262245
)}
263246
</>
264247
</Container>
@@ -270,7 +253,7 @@ const Sidebar = () => {
270253
justifyContent: 'space-between',
271254
alignItems: 'center',
272255
padding: '20px',
273-
height: 'calc(100vh - 68px)',
256+
height: 'calc(100vh - 69px)',
274257
}}
275258
>
276259
<div>
@@ -280,43 +263,28 @@ const Sidebar = () => {
280263
Create a new diagram
281264
</Typography>
282265
<Button
283-
color="primary"
284-
variant="outlined"
285-
sx={{
286-
marginBottom: 2,
287-
textTransform: 'initial',
288-
}}
266+
style={{ marginBottom: '16px' }}
289267
onClick={handleCreateDiagram}
290-
disabled={createDiagramState === 'loading'}
268+
loading={createDiagramState === 'loading'}
291269
>
292270
New diagram
293271
</Button>
294272
<Typography title="h3" color={'#883a79'} mb={1}>
295273
Insert a diagram from Mermaid Chart
296274
</Typography>
297275
<Button
298-
color="primary"
299-
variant="outlined"
300-
sx={{
301-
marginBottom: 2,
302-
textTransform: 'initial',
303-
}}
276+
style={{ marginBottom: '16px' }}
304277
onClick={handleSelectDiagram}
305-
disabled={selectDiagramState === 'loading'}
278+
loading={selectDiagramState === 'loading'}
306279
>
307280
Browse diagrams
308281
</Button>
309282
<Typography title="h3" color={'#883a79'} mb={1}>
310283
Update all diagrams in document to most recent version
311284
</Typography>
312285
<Button
313-
color="primary"
314-
variant="outlined"
315-
sx={{
316-
textTransform: 'initial',
317-
}}
318286
onClick={handleDiagramsUpdate}
319-
disabled={updateDiagramsState === 'loading'}
287+
loading={updateDiagramsState === 'loading'}
320288
>
321289
Update all diagrams
322290
</Button>
@@ -402,7 +370,8 @@ const Sidebar = () => {
402370
</Typography>
403371
<Typography paragraph textAlign="center" mt={4} color={'#883a79'}>
404372
Don't have an account?{' '}
405-
<Button
373+
<MuiButton
374+
onClick={() => {}}
406375
sx={{
407376
textTransform: 'initial',
408377
color: 'inherit',
@@ -416,7 +385,7 @@ const Sidebar = () => {
416385
}}
417386
>
418387
Sign up
419-
</Button>{' '}
388+
</MuiButton>{' '}
420389
</Typography>
421390
</>
422391
)}

src/client/sidebar/styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Commissioner:wght@100..900&display=swap');
2+
13
body {
24
margin: 0;
35
padding: 0;
46
}
7+
8+
button {
9+
font-family: 'Commissioner', sans-serif;
10+
}

src/server/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
openEditDiagramDialogWithUrl,
66
openSelectDiagramDialog,
77
openPreviewDiagramDialog,
8+
openHelpDialog,
9+
openAboutDialog,
810
openSidebar,
911
getOAuthURL,
1012
setBaseUrl,
@@ -27,6 +29,8 @@ export {
2729
openEditDiagramDialogWithUrl,
2830
openSelectDiagramDialog,
2931
openPreviewDiagramDialog,
32+
openHelpDialog,
33+
openAboutDialog,
3034
openSidebar,
3135
getOAuthURL,
3236
setBaseUrl,

0 commit comments

Comments
 (0)