Skip to content

Commit

Permalink
fix: button styles ported to css modules
Browse files Browse the repository at this point in the history
  • Loading branch information
boris0301 committed Aug 13, 2024
1 parent b01a2cb commit 28cbf4d
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 70 deletions.
31 changes: 31 additions & 0 deletions src/client/components/button.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.button {
font-family: 'Commissioner', sans-serif;
font-size: 14px;
line-height: 1.25rem;
padding: 0.5rem;
outline: none;
border-radius: 0.375rem;
border: 1px solid rgb(207, 207, 211);
background-color: white;
cursor: pointer;
}

.button:hover {
background-color: rgb(0, 66, 235);
color: white;
transition: all 0.2s;
}

.button:disabled {
pointer-events: none;
background-color: rgb(240, 240, 240);
color: rgb(150, 150, 150);
border-color: rgb(207, 207, 211);
}

.buttonLoading {
pointer-events: none;
background-color: rgb(240, 240, 240);
color: rgb(150, 150, 150);
border-color: rgb(207, 207, 211);
}
43 changes: 43 additions & 0 deletions src/client/components/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Box, CircularProgress } from '@mui/material';
import { FunctionComponent } from 'react';
import styles from './button.module.css';

interface ButtonProps {
onClick: () => void;
children: React.ReactNode;
disabled?: boolean;
style?: React.CSSProperties;
loading?: boolean;
}

const Button: FunctionComponent<ButtonProps> = ({
onClick,
children,
disabled,
style,
loading = false,
...rest
}) => {
return (
<button
className={`${styles.button} ${loading ? styles.buttonLoading : ''} `}
style={style}
onClick={onClick}
disabled={disabled}
{...rest}
>
<Box display="flex" alignItems="center">
{loading && (
<CircularProgress
size={14}
color="inherit"
sx={{ marginRight: '8px' }}
/>
)}{' '}
{children}
</Box>
</button>
);
};

export default Button;
57 changes: 13 additions & 44 deletions src/client/sidebar/components/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import {
Button,
CircularProgress,
Container,
Typography,
Button as MuiButton,
Divider,
Box,
Tabs,
Expand All @@ -13,6 +13,7 @@ import { serverFunctions } from '../../utils/serverFunctions';
import LoadingOverlay from '../../components/loading-overlay';
import { buildUrl } from '../../utils/helpers';
import useAuth from '../../hooks/useAuth';
import Button from '../../components/button';

interface ChartImage {
altDescription: string;
Expand Down Expand Up @@ -238,27 +239,9 @@ const Sidebar = () => {
/>
<>
{authState?.authorized ? (
<Button
onClick={signOut}
color="primary"
variant="outlined"
sx={{
textTransform: 'initial',
}}
>
Logout
</Button>
<Button onClick={signOut}>Logout</Button>
) : (
<Button
onClick={handleLoginClick}
color="primary"
variant="outlined"
sx={{
textTransform: 'initial',
}}
>
Login
</Button>
<Button onClick={handleLoginClick}>Login</Button>
)}
</>
</Container>
Expand All @@ -270,7 +253,7 @@ const Sidebar = () => {
justifyContent: 'space-between',
alignItems: 'center',
padding: '20px',
height: 'calc(100vh - 68px)',
height: 'calc(100vh - 69px)',
}}
>
<div>
Expand All @@ -280,43 +263,28 @@ const Sidebar = () => {
Create a new diagram
</Typography>
<Button
color="primary"
variant="outlined"
sx={{
marginBottom: 2,
textTransform: 'initial',
}}
style={{ marginBottom: '16px' }}
onClick={handleCreateDiagram}
disabled={createDiagramState === 'loading'}
loading={createDiagramState === 'loading'}
>
New diagram
</Button>
<Typography title="h3" color={'#883a79'} mb={1}>
Insert a diagram from Mermaid Chart
</Typography>
<Button
color="primary"
variant="outlined"
sx={{
marginBottom: 2,
textTransform: 'initial',
}}
style={{ marginBottom: '16px' }}
onClick={handleSelectDiagram}
disabled={selectDiagramState === 'loading'}
loading={selectDiagramState === 'loading'}
>
Browse diagrams
</Button>
<Typography title="h3" color={'#883a79'} mb={1}>
Update all diagrams in document to most recent version
</Typography>
<Button
color="primary"
variant="outlined"
sx={{
textTransform: 'initial',
}}
onClick={handleDiagramsUpdate}
disabled={updateDiagramsState === 'loading'}
loading={updateDiagramsState === 'loading'}
>
Update all diagrams
</Button>
Expand Down Expand Up @@ -402,7 +370,8 @@ const Sidebar = () => {
</Typography>
<Typography paragraph textAlign="center" mt={4} color={'#883a79'}>
Don't have an account?{' '}
<Button
<MuiButton
onClick={() => {}}
sx={{
textTransform: 'initial',
color: 'inherit',
Expand All @@ -416,7 +385,7 @@ const Sidebar = () => {
}}
>
Sign up
</Button>{' '}
</MuiButton>{' '}
</Typography>
</>
)}
Expand Down
6 changes: 6 additions & 0 deletions src/client/sidebar/styles.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
@import url('https://fonts.googleapis.com/css2?family=Commissioner:[email protected]&display=swap');

body {
margin: 0;
padding: 0;
}

button {
font-family: 'Commissioner', sans-serif;
}
4 changes: 4 additions & 0 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
openEditDiagramDialogWithUrl,
openSelectDiagramDialog,
openPreviewDiagramDialog,
openHelpDialog,
openAboutDialog,
openSidebar,
getOAuthURL,
setBaseUrl,
Expand All @@ -27,6 +29,8 @@ export {
openEditDiagramDialogWithUrl,
openSelectDiagramDialog,
openPreviewDiagramDialog,
openHelpDialog,
openAboutDialog,
openSidebar,
getOAuthURL,
setBaseUrl,
Expand Down
Loading

0 comments on commit 28cbf4d

Please sign in to comment.