Skip to content

Commit d4507f2

Browse files
authored
Merge pull request #2159 from bconti123/Style-manager-access-MUI-Switch-to-match-Figma-design
Update MUI Switch (Toggle ON/Toggle OFF) styling
2 parents 5fa8828 + 40ed587 commit d4507f2

1 file changed

Lines changed: 59 additions & 23 deletions

File tree

client/src/components/user-admin/EditUsers.jsx

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,65 @@
1-
import { useEffect, useState } from 'react';
21
import {
3-
Grid,
4-
FormGroup,
5-
FormControlLabel,
6-
Switch,
72
Button,
8-
Typography,
93
Container,
4+
FormControl,
5+
FormControlLabel,
6+
FormGroup,
7+
Grid,
8+
InputLabel,
109
List,
1110
ListItem,
1211
ListItemText,
13-
Select,
1412
MenuItem,
15-
FormControl,
16-
InputLabel,
13+
Select,
14+
Switch,
15+
Typography,
1716
} from '@mui/material';
17+
import { useEffect, useState } from 'react';
1818
import '../../sass/UserAdmin.scss';
19-
import useAuth from '../../hooks/useAuth';
2019
import { ROLES } from '../../../../shared/roles';
20+
import useAuth from '../../hooks/useAuth';
21+
22+
const muiSwitchStyles = {
23+
width: 40,
24+
height: 24,
25+
padding: 0,
26+
top: 4,
27+
marginRight: 2,
28+
marginLeft: 1,
29+
'& .MuiSwitch-switchBase': {
30+
padding: 0,
31+
margin: '4px',
32+
color: '#6b7280',
33+
'&.Mui-checked': {
34+
transform: 'translateX(16px)',
35+
color: '#fff',
36+
},
37+
'&.Mui-checked + .MuiSwitch-track': {
38+
backgroundColor: '#359F3A',
39+
borderColor: '#359F3A',
40+
opacity: 1,
41+
},
42+
},
43+
'& .MuiSwitch-thumb': {
44+
width: 8,
45+
height: 8,
46+
boxShadow: 'none',
47+
},
48+
'& .MuiSwitch-track': {
49+
width: 32,
50+
height: 16,
51+
borderRadius: 1000,
52+
backgroundColor: '#fff',
53+
border: '2px solid #6b7280',
54+
opacity: 1,
55+
boxSizing: 'border-box',
56+
},
57+
};
58+
59+
const muiFormControlLabelStyles = {
60+
alignItems: 'flex-end',
61+
marginLeft: 1,
62+
};
2163

2264
// child of UserAdmin. Displays form to update users.
2365
const EditUsers = ({
@@ -51,9 +93,7 @@ const EditUsers = ({
5193
setUserManagedProjects(userToEdit.managedProjects);
5294
}, [userToEdit]);
5395

54-
const userProjectsToDisplay = activeProjects.filter((item) =>
55-
userProjects.includes(item[0]),
56-
);
96+
const userProjectsToDisplay = activeProjects.filter((item) => userProjects.includes(item[0]));
5797

5898
const onSubmit = (event) => {
5999
event.preventDefault();
@@ -75,9 +115,7 @@ const EditUsers = ({
75115

76116
const handleRemoveProject = (projectToRemove) => {
77117
if (!superAdmin && userManagedProjects.length > 0) {
78-
const newProjects = userManagedProjects.filter(
79-
(p) => p !== projectToRemove,
80-
);
118+
const newProjects = userManagedProjects.filter((p) => p !== projectToRemove);
81119
updateUserDb(userToEdit, projectToRemove, 'remove');
82120
setUserManagedProjects(newProjects);
83121
}
@@ -107,10 +145,11 @@ const EditUsers = ({
107145
Is Active:
108146
</Typography>
109147
<FormControlLabel
110-
sx={{ marginLeft: 1 }}
148+
sx={muiFormControlLabelStyles}
111149
control={
112150
<Switch
113151
checked={isActive}
152+
sx={muiSwitchStyles}
114153
onChange={handleSetIsActive}
115154
disabled={superAdmin}
116155
/>
@@ -123,10 +162,11 @@ const EditUsers = ({
123162
VRMS Admin:
124163
</Typography>
125164
<FormControlLabel
126-
sx={{ marginLeft: 1 }}
165+
sx={muiFormControlLabelStyles}
127166
control={
128167
<Switch
129168
checked={admin || superAdmin}
169+
sx={muiSwitchStyles}
130170
onChange={handleSetAccessLevel}
131171
disabled={superAdmin}
132172
/>
@@ -183,11 +223,7 @@ const EditUsers = ({
183223
Add project
184224
</Button>
185225
</FormControl>
186-
<Button
187-
variant="outlined"
188-
onClick={backToSearch}
189-
style={{ marginTop: '1rem' }}
190-
>
226+
<Button variant="outlined" onClick={backToSearch} style={{ marginTop: '1rem' }}>
191227
Back to search
192228
</Button>
193229
</Container>

0 commit comments

Comments
 (0)