Skip to content

Commit 2d346c2

Browse files
authored
Merge branch 'master' into resize
2 parents 9a23089 + c0e750b commit 2d346c2

File tree

2 files changed

+53
-17
lines changed

2 files changed

+53
-17
lines changed

src/custom/UniversalFilter.tsx

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface UniversalFilterProps {
2626
handleApplyFilter: () => void;
2727
showAllOption?: boolean;
2828
id: string;
29+
'data-testid'?: string;
2930
}
3031

3132
export const FilterHeader = styled('div')(({ theme }) => ({
@@ -44,7 +45,8 @@ function UniversalFilter({
4445
variant = 'outlined',
4546
handleApplyFilter,
4647
showAllOption = true,
47-
id
48+
id,
49+
'data-testid': testId = 'universal-filter'
4850
}: UniversalFilterProps): JSX.Element {
4951
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
5052
const [open, setOpen] = React.useState(false);
@@ -77,16 +79,26 @@ function UniversalFilter({
7779

7880
const renderFilterContent = () => (
7981
<div>
80-
<FilterHeader>
82+
<FilterHeader data-testid={`${testId}-header`}>
8183
<h3>Filters: </h3>
8284
</FilterHeader>
8385
{Object.keys(filters).map((filterColumn) => {
8486
const options = filters[filterColumn].options;
8587
return (
86-
<div key={filterColumn} role="presentation">
87-
<InputLabel id={filters[filterColumn].name}>{filters[filterColumn].name}</InputLabel>
88+
<div
89+
key={filterColumn}
90+
role="presentation"
91+
data-testid={`${testId}-filter-group-${filterColumn}`}
92+
>
93+
<InputLabel
94+
id={filters[filterColumn].name}
95+
data-testid={`${testId}-label-${filterColumn}`}
96+
>
97+
{filters[filterColumn].name}
98+
</InputLabel>
8899
<Select
89100
defaultValue="All"
101+
data-testid={`${testId}-select-${filterColumn}`}
90102
key={filterColumn}
91103
value={selectedFilters[filterColumn]}
92104
variant={variant}
@@ -97,12 +109,23 @@ function UniversalFilter({
97109
width: '20rem',
98110
marginBottom: '1rem'
99111
}}
100-
inputProps={{ 'aria-label': 'Without label' }}
112+
inputProps={{
113+
'aria-label': 'Without label',
114+
'data-testid': `${testId}-select-${filterColumn}`
115+
}}
101116
displayEmpty
102117
>
103-
{showAllOption && <MenuItem value="All">All</MenuItem>}
118+
{showAllOption && (
119+
<MenuItem value="All" data-testid={`${testId}-option-all`}>
120+
All
121+
</MenuItem>
122+
)}
104123
{options.map((option) => (
105-
<MenuItem key={option.value} value={option.value}>
124+
<MenuItem
125+
key={option.value}
126+
value={option.value}
127+
data-testid={`${testId}-option-${option.value}`}
128+
>
106129
{option.label}
107130
</MenuItem>
108131
))}
@@ -112,7 +135,11 @@ function UniversalFilter({
112135
})}
113136

114137
<div style={{ display: 'flex', justifyContent: 'center' }}>
115-
<Button variant="contained" onClick={handleApplyOnClick}>
138+
<Button
139+
variant="contained"
140+
onClick={handleApplyOnClick}
141+
data-testid={`${testId}-apply-btn`}
142+
>
116143
Apply
117144
</Button>
118145
</div>
@@ -121,7 +148,7 @@ function UniversalFilter({
121148

122149
return (
123150
<>
124-
<div id={id}>
151+
<div id={id} data-testid={testId}>
125152
<TooltipIcon
126153
title="Filter"
127154
onClick={handleClick}

src/theme/theme.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@ import { Interactiveness, PaletteMode, createTheme } from '@mui/material';
22
import { components } from './components';
33
import { darkModePalette, lightModePalette } from './palette';
44
import { typography } from './typography';
5+
import _ from 'lodash';
56

67
export const drawerWidth = 240;
78

89
export const createCustomTheme = (mode: PaletteMode, brandPalette?: Interactiveness) => {
910
const basePalette = mode == 'light' ? lightModePalette : darkModePalette;
1011

11-
const themePalette = {
12-
...basePalette,
12+
console.log('Creating theme with mode:', mode, 'and brandPalette:', brandPalette);
13+
14+
const customBrandedTheme = brandPalette ? {
15+
primary: {
16+
main: brandPalette.default ,
17+
secondary: brandPalette.hover,
18+
},
19+
secondary: {
20+
main: brandPalette.secondary,
21+
secondary: brandPalette.secondary,
22+
},
1323
background: {
14-
...(basePalette.background || {}),
15-
brand: {
16-
...((basePalette?.background?.brand || {}) as Interactiveness),
17-
...(brandPalette || {})
18-
}
24+
brand: brandPalette
1925
}
20-
};
26+
} : {};
27+
28+
const themePalette = _.merge({}, basePalette, customBrandedTheme);
29+
2130

2231
return createTheme({
2332
palette: {

0 commit comments

Comments
 (0)