Skip to content

Commit

Permalink
Merge pull request #546 from sudhanshutech/theme/refactor
Browse files Browse the repository at this point in the history
[Theme] Refactor theme in components and list all tokens
  • Loading branch information
aabidsofi19 authored Apr 12, 2024
2 parents be989e1 + ae8a8e3 commit 897d6ab
Show file tree
Hide file tree
Showing 33 changed files with 954 additions and 389 deletions.
5 changes: 5 additions & 0 deletions src/base/Collapse/Collapse.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Collapse as MuiCollapse, CollapseProps as MuiCollapseProps } from '@mui/material';

export function Collapse(props: MuiCollapseProps): JSX.Element {
return <MuiCollapse {...props} />;
}
5 changes: 5 additions & 0 deletions src/base/Collapse/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CollapseProps } from '@mui/material';
import { Collapse } from './Collapse';

export { Collapse };
export type { CollapseProps };
8 changes: 8 additions & 0 deletions src/base/CssBaseLine/CssBaseLine.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {
CssBaseline as MuiCssBaseline,
CssBaselineProps as MuiCssBaselineProps
} from '@mui/material';

export function CssBaseline(props: MuiCssBaselineProps): JSX.Element {
return <MuiCssBaseline {...props} />;
}
5 changes: 5 additions & 0 deletions src/base/CssBaseLine/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CssBaselineProps } from '@mui/material';
import { CssBaseline } from './CssBaseLine';

export { CssBaseline };
export type { CssBaselineProps };
8 changes: 8 additions & 0 deletions src/base/ListItemText/ListItemText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {
ListItemText as MuiListItemText,
ListItemTextProps as MuiListItemTextProps
} from '@mui/material';

export function ListItemText(props: MuiListItemTextProps): JSX.Element {
return <MuiListItemText {...props} />;
}
5 changes: 5 additions & 0 deletions src/base/ListItemText/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ListItemTextProps } from '@mui/material';
import { ListItemText } from './ListItemText';

export { ListItemText };
export type { ListItemTextProps };
8 changes: 8 additions & 0 deletions src/base/OutlinedInput/OutlinedInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {
OutlinedInput as MuiOutlinedInput,
OutlinedInputProps as MuiOutlinedInputProps
} from '@mui/material';

export function OutlinedInput(props: MuiOutlinedInputProps): JSX.Element {
return <MuiOutlinedInput {...props} />;
}
5 changes: 5 additions & 0 deletions src/base/OutlinedInput/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { OutlinedInputProps } from '@mui/material';
import { OutlinedInput } from './OutlinedInput';

export { OutlinedInput };
export type { OutlinedInputProps };
4 changes: 4 additions & 0 deletions src/base/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export * from './Checkbox';
export * from './Chip';
export * from './CircularProgress';
export * from './ClickAwayListener';
export * from './Collapse';
export * from './Container';
export * from './CssBaseLine';
export * from './Dialog';
export * from './DialogActions';
export * from './DialogContent';
Expand All @@ -41,10 +43,12 @@ export * from './ListItemAvatar';
export * from './ListItemButton';
export * from './ListItemIcon';
export * from './ListItemSecondaryAction';
export * from './ListItemText';
export * from './ListSubheader';
export * from './Menu';
export * from './MenuItem';
export * from './MenuList';
export * from './OutlinedInput';
export * from './Pagination';
export * from './Paper';
export * from './Popper';
Expand Down
32 changes: 15 additions & 17 deletions src/custom/ErrorBoundary/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import { styled } from '@mui/system';
import { styled } from '@mui/material';
import React from 'react';
import { FallbackProps, ErrorBoundary as ReactErrorBoundary } from 'react-error-boundary';
import { Box } from '../../base/Box';
import { Link } from '../../base/Link';
import { Typography } from '../../base/Typography';
import { BLACK, KEPPEL } from '../../theme/colors';
import { DARK_JUNGLE_GREEN } from '../../theme/colors/colors';

const ErrorMessage = styled(Typography)(() => ({
color: BLACK,
const ErrorMessage = styled(Typography)(({ theme }) => ({
color: theme.palette.text.default,
fontWeight: 'normal',
marginTop: '2px',
marginBottom: '2px',
fontSize: '1.15rem'
}));

const StyledLink = styled(Link)(() => ({
color: KEPPEL,
const StyledLink = styled(Link)(({ theme }) => ({
color: theme.palette.border.brand,
textDecoration: 'underline',
cursor: 'pointer'
}));

const CodeMessage = styled('div')(({ theme }) => ({
backgroundColor: theme.palette.background.code,
color: theme.palette.text.tertiary,
padding: '.85rem',
borderRadius: '.2rem',
marginBlock: '.5rem'
}));

interface FallbackComponentProps extends FallbackProps {
resetErrorBoundary: () => void;
children?: React.ReactNode;
Expand All @@ -30,17 +36,9 @@ export function Fallback({ error, children }: FallbackComponentProps): JSX.Eleme
return (
<div role="alert">
<h2>Uh-oh!😔 Please pardon the mesh.</h2>
<div
style={{
backgroundColor: DARK_JUNGLE_GREEN,
color: '#FFFFFF',
padding: '.85rem',
borderRadius: '.2rem',
marginBlock: '.5rem'
}}
>
<CodeMessage>
<code>{(error as Error).message}</code>
</div>
</CodeMessage>
<ErrorMessage>
We apologize for the inconvenience. The issue may be on our end. If troubleshooting doesn't
work, please check out our support channels{' '}
Expand Down
11 changes: 5 additions & 6 deletions src/custom/ModalCard/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ import {
BLACK,
BUTTON_MODAL,
BUTTON_MODAL_DARK,
CULTURED,
NOT_FOUND,
SLIGHT_BLACK_2,
SLIGHT_BLUE,
WHITE
SLIGHT_BLUE
} from '../../theme/colors/colors';

export const ContentContainer = styled('div')(({ theme }) => ({
backgroundColor: theme.palette.mode === 'light' ? WHITE : NOT_FOUND
backgroundColor: theme.palette.background.default
}));

export const ModalWrapper = styled('div')(() => ({
Expand Down Expand Up @@ -42,13 +39,15 @@ export const HeaderModal = styled('div')(({ theme }) => {
const startColor = theme.palette.mode === 'light' ? BUTTON_MODAL : BLACK;
const endColor = theme.palette.mode === 'light' ? SLIGHT_BLUE : SLIGHT_BLACK_2;

const iconColor = theme.palette.icon?.inverse;

return {
display: 'flex',
borderRadius: '5px 5px 0px 0px',
justifyContent: 'space-between',
padding: '11px 16px',
height: '52px',
fill: CULTURED,
fill: iconColor,
boxShadow: 'inset 0px -1px 3px 0px rgba(0,0,0,0.2)',
background: `linear-gradient(90deg, ${startColor}, ${endColor})`,
filter:
Expand Down
2 changes: 1 addition & 1 deletion src/custom/TooltipIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Tooltip from '../patches/Tooltip';

interface TooltipIconProps {
title: string;
onClick: (event: React.MouseEvent<HTMLElement>) => void;
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
icon: React.ReactNode;
arrow?: boolean;
style?: React.CSSProperties;
Expand Down
32 changes: 15 additions & 17 deletions src/custom/TransferModal/TransferList/style.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { styled } from '@mui/material';
import { Button, Chip, Grid, Paper, Typography } from '../../../base';
import { ALICE_BLUE, BLACK, DARK_TEAL, KEPPEL, WHITE, accentGrey } from '../../../theme';
import { STEEL_GRAY } from '../../../theme/colors/colors';

export const StyledChip = styled(Chip)({
export const StyledChip = styled(Chip)(({ theme }) => ({
padding: '5px 6px !important',
color: BLACK,
color: theme.palette.text.default,
fontSize: '0.875rem',
textTransform: 'uppercase',
fontWeight: 400,
height: 'unset',
borderRadius: '100px',
border: `0.5px solid ${accentGrey[40]}`,
background: WHITE,
border: `0.5px solid ${theme.palette.border?.normal}`,
background: theme.palette.background.default,
maxWidth: '14.375rem'
});
}));

export const StyledPaper = styled(Paper)({
export const StyledPaper = styled(Paper)(({ theme }) => ({
width: 300,
height: 280,
overflow: 'auto',
backgroundColor: ALICE_BLUE,
backgroundColor: theme.palette.background.blur?.heavy,
borderRadius: '10px',
boxShadow: '0px 1px 4px 0px rgba(0, 0, 0, 0.25) inset',
'@media (max-width: 843px)': {
Expand All @@ -32,26 +30,26 @@ export const StyledPaper = styled(Paper)({
'@media (max-width: 375px)': {
width: '100%'
}
});
}));

export const ListHeading = styled(Typography)({
export const ListHeading = styled(Typography)(({ theme }) => ({
paddingBottom: '15px',
color: STEEL_GRAY,
color: theme.palette.text?.default,
textAlign: 'center',
fontSize: '1rem',
letterSpacing: '0.15px'
});
}));

export const TransferButton = styled(Button)({
export const TransferButton = styled(Button)(({ theme }) => ({
margin: '5px 0',
padding: '7px 0',
borderRadius: '10px',
borderColor: DARK_TEAL,
borderColor: theme.palette.border?.strong,
boxShadow: 'none',
'&:hover': {
borderColor: KEPPEL
borderColor: theme.palette.border?.brand
}
});
}));

export const ListGrid = styled(Grid)({
padding: '0 1rem',
Expand Down
75 changes: 75 additions & 0 deletions src/theme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Sistent Theme Palette

This document provides an overview of the custom palette used for theme components.

## Palette Options

### Interactiveness

Defines the interaction color options used in the palette.

- `default`: Default interaction color.
- `hover`: Color on hover.
- `disabled`: Color when disabled (optional).
- `pressed`: Color when pressed.
- `secondary`: Secondary interaction color.
- `tertiary`: Tertiary interaction color.

### TypeBackground

Defines the extended background color options used in the palette.

- `secondary`: Secondary background color.
- `graphics`: Graphics background color.
- `tertiary`: Tertiary background color.
- `hover`: Hover background color.
- `blur`: Blur effect colors (heavy and light).
- `brand`: Brand interaction colors.
- `cta`: Call to action interaction colors.
- `info`: Information interaction colors.
- `success`: Success interaction colors.
- `warning`: Warning interaction colors.
- `error`: Error interaction colors.
- `code`: Code background color.

To add a new background color, add a new key to the `TypeBackground` type and update the `background` property in the `PaletteColor` type.

### TypeText

Defines the extended text color options used in the palette.

- `default`: Default text color.
- `secondary`: Secondary text color.
- `tertiary`: Tertiary text color.
- `inverse`: Inverse text color.
- `brand`: Brand text color.
- `info`: Information text color.
- `success`: Success text color.
- `warning`: Warning text color.
- `error`: Error text color.

To add a new text color, add a new key to the `TypeText` type and update the `text` property in the `PaletteColor` type.

### PaletteColor

Defines the color options for the palette.

### SimplePaletteColorOptions

Defines the simple palette color options.

## Palette Configuration

The palette configuration includes the following sections:

### lightModePalette

Defines the palette options for the light mode.

### darkModePalette

Defines the palette options for the dark mode.

## Color Definitions

The color definitions are imported from the `./colors` module and include various shades and hues used throughout the palette.
49 changes: 37 additions & 12 deletions src/theme/colors/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,35 @@ export const common = {
white: WHITE
};

export const keppel = {};

export const carribean = {};

export const saffron = {};
export const keppel = {
70: '#daf3eb',
60: '#93E6D1',
50: '#41CCB3',
40: '#00B39F',
30: '#007763',
20: '#006661',
10: '#00403f'
};

export const carribean = {
70: '#E6FFF6',
60: '#A3FFE0',
50: '#78FAD3',
40: '#00D3A9',
30: '#00AD90',
20: '#006157',
10: '#003B37'
};

export const saffron = {
70: '#FFFEE6',
60: '#fffbbd',
50: '#ffeb6b',
40: '#ebc017',
30: '#c4990a',
20: '#785400',
10: '#523600'
};

/**
* Grayscale Colors
Expand All @@ -71,6 +95,7 @@ export const charcoal = {
};

export const accentGrey = {
100: '#F6F8F8',
90: '#E8EFF3',
80: '#C9DBE3',
70: '#ABBDC5',
Expand All @@ -86,13 +111,13 @@ export const accentGrey = {
* Function Colors
*/
export const blue = {
70: '#EBF6FF',
60: '#99CCFF',
50: '#4797FF',
40: '#1E77FC',
30: '#0F58D6',
20: '#043DB0',
10: '#001B63'
70: '#F0FBFF',
60: '#9EDDFF',
50: '#75CAFF',
40: '#2196F3',
30: '#1272CC',
20: '#0754A6',
10: '#003980'
};

export const green = {
Expand Down
Loading

0 comments on commit 897d6ab

Please sign in to comment.