-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from linagora/refactor-with-MUI
- Loading branch information
Showing
42 changed files
with
12,527 additions
and
11,978 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,36 @@ | ||
import { Dispatch, SetStateAction } from "react"; | ||
import "./ToggleButton.css"; | ||
function ToggleButton({ | ||
toggled, | ||
setToggled, | ||
testid, | ||
}: { | ||
toggled: boolean | number; | ||
setToggled: Dispatch<SetStateAction<boolean>>; | ||
testid: string; | ||
}) { | ||
return ( | ||
<label className={`toggleButton ${toggled ? "toggled" : ""}`}> | ||
<input | ||
data-testid={testid} | ||
type="checkbox" | ||
onChange={() => { | ||
setToggled(!toggled); | ||
}} | ||
checked={toggled ? true : false} | ||
/> | ||
<span className="thumb"></span> | ||
</label> | ||
); | ||
} | ||
import { Switch, styled } from "@mui/material"; | ||
|
||
const ToggleButton = styled(Switch)(({ theme }) => ({ | ||
padding: 8, | ||
"& .MuiSwitch-track": { | ||
borderRadius: 22 / 2, | ||
"&::before, &::after": { | ||
content: '""', | ||
position: "absolute", | ||
top: "50%", | ||
transform: "translateY(-50%)", | ||
width: 16, | ||
height: 16, | ||
}, | ||
"&::before": { | ||
backgroundImage: `url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 24 24"><path fill="${encodeURIComponent( | ||
theme.palette.getContrastText(theme.palette.primary.main) | ||
)}" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg>')`, | ||
left: 12, | ||
}, | ||
"&::after": { | ||
backgroundImage: `url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 24 24"><path fill="${encodeURIComponent( | ||
theme.palette.getContrastText(theme.palette.primary.main) | ||
)}" d="M19,13H5V11H19V13Z" /></svg>')`, | ||
right: 12, | ||
}, | ||
}, | ||
"& .MuiSwitch-thumb": { | ||
boxShadow: "none", | ||
width: 16, | ||
height: 16, | ||
margin: 2, | ||
}, | ||
})); | ||
|
||
export default ToggleButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.