Skip to content

Commit 7d32d1f

Browse files
authored
Merge pull request #572 from sudhanshutech/add/tokens
Enhancements in tokens and components
2 parents eefb2b3 + 3a145fe commit 7d32d1f

File tree

4 files changed

+94
-28
lines changed

4 files changed

+94
-28
lines changed

src/custom/Modal/index.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,17 @@ export const ModalFooter: React.FC<ModalFooterProps> = ({ helpText, children, va
172172
// ModalButtonPrimary
173173
export const ModalButtonPrimary: React.FC = styled(ContainedButton)(({ theme }) => ({
174174
backgroundColor: theme.palette.background.brand?.default,
175-
color: theme.palette.text.inverse
175+
color: theme.palette.text.constant?.white
176176
}));
177177

178178
// ModalButtonSecondary
179179
export const ModalButtonSecondary = styled(OutlinedButton)(({ theme }) => ({
180180
'&.MuiButton-outlined': {
181181
border: `1px solid ${theme.palette.common.white}`,
182-
color: theme.palette.common?.white,
182+
color: theme.palette.text.constant?.white,
183183
'&:hover': {
184184
background: 'transparent',
185-
color: theme.palette.common?.white
185+
color: theme.palette.text.constant?.white
186186
}
187187
}
188188
}));
@@ -191,3 +191,9 @@ export const ModalButtonSecondary = styled(OutlinedButton)(({ theme }) => ({
191191
export const ModalButtonTertiary = styled(TextButton)(({ theme }) => ({
192192
color: theme.palette.text.inverse
193193
}));
194+
195+
// ModalButtonDanger
196+
export const ModalButtonDanger = styled(ContainedButton)(({ theme }) => ({
197+
backgroundColor: theme.palette.background.error?.default,
198+
color: theme.palette.text.constant?.white
199+
}));

src/custom/SearchBar.tsx

+69-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,59 @@
1+
import { outlinedInputClasses } from '@mui/material/OutlinedInput';
2+
import { Theme, ThemeProvider, createTheme, useTheme } from '@mui/material/styles';
13
import React from 'react';
24
import { ClickAwayListener } from '../base/ClickAwayListener';
35
import { TextField } from '../base/TextField';
46
import { CloseIcon, SearchIcon } from '../icons';
57
import TooltipIcon from './TooltipIcon';
68

9+
const customTheme = (theme: Theme) =>
10+
createTheme({
11+
components: {
12+
MuiTextField: {
13+
styleOverrides: {
14+
root: {
15+
'--TextField-brandBorderColor': 'rgba(0, 0, 0, 0.5)',
16+
'--TextField-brandBorderHoverColor': theme.palette.background.graphics?.default,
17+
'--TextField-brandBorderFocusedColor': theme.palette.background.graphics?.default,
18+
'& label.Mui-focused': {
19+
color: 'var(--TextField-brandBorderFocusedColor)'
20+
}
21+
}
22+
}
23+
},
24+
MuiOutlinedInput: {
25+
styleOverrides: {
26+
notchedOutline: {
27+
borderColor: 'var(--TextField-brandBorderColor)'
28+
},
29+
root: {
30+
[`&:hover .${outlinedInputClasses.notchedOutline}`]: {
31+
borderColor: 'var(--TextField-brandBorderHoverColor)'
32+
},
33+
[`&.Mui-focused .${outlinedInputClasses.notchedOutline}`]: {
34+
borderColor: 'var(--TextField-brandBorderFocusedColor)'
35+
}
36+
}
37+
}
38+
},
39+
MuiInput: {
40+
styleOverrides: {
41+
root: {
42+
'&::before': {
43+
borderBottom: '2px solid var(--TextField-brandBorderColor)'
44+
},
45+
'&:hover:not(.Mui-disabled, .Mui-error):before': {
46+
borderBottom: '2px solid var(--TextField-brandBorderHoverColor)'
47+
},
48+
'&.Mui-focused:after': {
49+
borderBottom: '2px solid var(--TextField-brandBorderFocusedColor)'
50+
}
51+
}
52+
}
53+
}
54+
}
55+
});
56+
757
export interface SearchBarProps {
858
onSearch: (searchText: string) => void;
959
style?: React.CSSProperties;
@@ -25,6 +75,8 @@ function SearchBar({
2575
const [searchText, setSearchText] = React.useState('');
2676
const searchRef = React.useRef<HTMLInputElement | null>(null);
2777

78+
const outerTheme = useTheme();
79+
2880
const handleSearchChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
2981
setSearchText(event.target.value);
3082
};
@@ -71,21 +123,23 @@ function SearchBar({
71123
}}
72124
>
73125
<div>
74-
<TextField
75-
variant="standard"
76-
value={searchText}
77-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
78-
handleSearchChange(e);
79-
onSearch(e.target.value);
80-
}}
81-
inputRef={searchRef}
82-
placeholder={placeholder}
83-
style={{
84-
width: expanded ? '150px' : '0',
85-
opacity: expanded ? 1 : 0,
86-
transition: 'width 0.3s ease, opacity 0.3s ease'
87-
}}
88-
/>
126+
<ThemeProvider theme={customTheme(outerTheme)}>
127+
<TextField
128+
variant="standard"
129+
value={searchText}
130+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
131+
handleSearchChange(e);
132+
onSearch(e.target.value);
133+
}}
134+
inputRef={searchRef}
135+
placeholder={placeholder}
136+
style={{
137+
width: expanded ? '150px' : '0',
138+
opacity: expanded ? 1 : 0,
139+
transition: 'width 0.3s ease, opacity 0.3s ease'
140+
}}
141+
/>
142+
</ThemeProvider>
89143
{expanded ? (
90144
<TooltipIcon
91145
title="Close"

src/theme/components/button.modifier.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,37 @@ export const MuiButton: Components<Theme>['MuiButton'] = {
55
root: ({ theme }) => {
66
const {
77
palette: {
8-
background: { brand },
9-
text: { tertiary, default: defaultText }
8+
background: { brand, neutral: BgNeutral },
9+
text: { disabled, constant, neutral: TextNeutral },
10+
border: { neutral }
1011
},
1112
typography: { textB2SemiBold }
1213
} = theme;
1314
return {
1415
...textB2SemiBold,
1516
fontFamily: 'Qanelas Soft, sans-serif',
1617
'&.MuiButton-contained': {
17-
color: defaultText,
18+
color: constant?.white,
1819
backgroundColor: brand?.default,
1920
'&:hover': {
2021
backgroundColor: brand?.hover
2122
}
2223
},
2324
'&.MuiButton-outlined': {
24-
border: `1px solid ${brand?.default}`,
25+
border: `1px solid ${neutral?.default}`,
2526
'&:hover': {
26-
backgroundColor: brand?.hover,
27-
color: defaultText
27+
backgroundColor: BgNeutral?.pressed,
28+
color: TextNeutral?.default
2829
}
2930
},
3031
'&.MuiButton-contained.Mui-disabled': {
31-
color: tertiary,
32+
color: disabled,
3233
backgroundColor: brand?.disabled
3334
},
3435
'&.MuiButton-outlined.Mui-disabled': {
35-
border: `1px solid ${tertiary}`,
36+
border: `1px solid ${disabled}`,
3637
backgroundColor: brand?.disabled,
37-
color: tertiary
38+
color: disabled
3839
}
3940
};
4041
}

src/theme/palette.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ declare module '@mui/material/styles' {
4545
default?: string;
4646
secondary: string;
4747
tertiary?: string;
48+
disabled: string;
4849
inverse?: string;
4950
brand?: string;
5051
info?: string;
@@ -87,6 +88,7 @@ declare module '@mui/material/styles' {
8788
code?: string;
8889
strong?: string;
8990
normal?: string;
91+
disabled?: string;
9092
}
9193

9294
// Defines the simple palette color options.
@@ -116,6 +118,7 @@ declare module '@mui/material/styles' {
116118
code?: string;
117119
strong?: string;
118120
normal?: string;
121+
disabled?: string;
119122
}
120123

121124
/* Defines the palette containing border and icon color options.
@@ -241,7 +244,8 @@ export const lightModePalette: PaletteOptions = {
241244
text: {
242245
default: Colors.charcoal[10],
243246
secondary: Colors.charcoal[40],
244-
tertiary: Colors.charcoal[70],
247+
tertiary: Colors.charcoal[50],
248+
disabled: Colors.charcoal[70],
245249
inverse: Colors.charcoal[100],
246250
brand: Colors.keppel[40],
247251
info: Colors.blue[40],
@@ -348,6 +352,7 @@ export const darkModePalette: PaletteOptions = {
348352
default: Colors.charcoal[100],
349353
secondary: Colors.charcoal[40],
350354
tertiary: Colors.charcoal[60],
355+
disabled: Colors.charcoal[70],
351356
inverse: Colors.charcoal[10],
352357
brand: Colors.keppel[40],
353358
info: Colors.blue[40],

0 commit comments

Comments
 (0)