Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui / sidebar: "alerts on top" toggle (tests, styling tk) [ch10933] (#…
…4143) * behavior implemented (needs tests) * storybook entry for tests with errors * ugh stupid snapshot tests * prettier * web: style resource filters and alerts toggle * tests: fix failing tests for Sidebar Options * run prettier * fix review comments Co-authored-by: Han Yu <han@tilt.dev>
- Loading branch information
Maia McCormick
and
Han Yu
committed
Feb 2, 2021
1 parent
24ede89
commit c04ecf0
Showing
6 changed files
with
326 additions
and
212 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,112 @@ | ||
import Checkbox from "@material-ui/core/Checkbox" | ||
import FormControlLabel from "@material-ui/core/FormControlLabel" | ||
import { makeStyles } from "@material-ui/core/styles" | ||
import CheckBoxIcon from "@material-ui/icons/CheckBox" | ||
import CheckBoxOutlineBlankIcon from "@material-ui/icons/CheckBoxOutlineBlank" | ||
import React from "react" | ||
import styled from "styled-components" | ||
import { | ||
Color, | ||
Font, | ||
FontSize, | ||
mixinResetButtonStyle, | ||
mixinResetListStyle, | ||
SizeUnit, | ||
} from "./style-helpers" | ||
import { SidebarOptions } from "./types" | ||
|
||
const OverviewSidebarOptionsRoot = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
font-family: ${Font.sansSerif}; | ||
font-size: ${FontSize.smallester}; | ||
padding-left: ${SizeUnit(0.5)}; | ||
padding-right: ${SizeUnit(0.5)}; | ||
color: ${Color.offWhite}; | ||
` | ||
|
||
const FilterOptionList = styled.ul` | ||
${mixinResetListStyle} | ||
display: flex; | ||
user-select: none; // Prevent unsightly highlighting on the label | ||
` | ||
|
||
const useStyles = makeStyles({ | ||
root: { | ||
color: Color.offWhite, | ||
}, | ||
}) | ||
|
||
const AlertsOnTopToggle = styled.button` | ||
${mixinResetButtonStyle} | ||
color: ${Color.grayLightest}; | ||
background-color: ${Color.gray}; | ||
padding: ${SizeUnit(0.125)} ${SizeUnit(0.25)}; | ||
border-radius: 3px; | ||
font-size: ${FontSize.smallester}; | ||
&.is-enabled { | ||
color: ${Color.grayDarkest}; | ||
background-color: ${Color.offWhite}; | ||
} | ||
` | ||
|
||
type OverviewSidebarOptionsProps = { | ||
curState: SidebarOptions | ||
toggleShowResources: () => void | ||
toggleShowTests: () => void | ||
toggleAlertsOnTop: () => void | ||
} | ||
|
||
export function OverviewSidebarOptions( | ||
props: OverviewSidebarOptionsProps | ||
): JSX.Element { | ||
const classes = useStyles() | ||
|
||
return ( | ||
<OverviewSidebarOptionsRoot> | ||
<div> | ||
<input | ||
type="checkbox" | ||
id="resources" | ||
name="resources" | ||
checked={props.curState.showResources} | ||
onChange={(evt) => props.toggleShowResources()} | ||
<OverviewSidebarOptionsRoot | ||
style={{ marginTop: SizeUnit(0.75), marginBottom: SizeUnit(-0.5) }} | ||
> | ||
<FilterOptionList> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
className={classes.root} | ||
color={"default"} | ||
icon={<CheckBoxOutlineBlankIcon fontSize="small" />} | ||
checkedIcon={<CheckBoxIcon fontSize="small" />} | ||
checked={props.curState.showResources} | ||
onChange={(e) => props.toggleShowResources()} | ||
name="resources" | ||
id="resources" | ||
/> | ||
} | ||
label="Resources" | ||
/> | ||
<label htmlFor="resources">Resources</label> | ||
</div> | ||
<div> | ||
<input | ||
type="checkbox" | ||
id="tests" | ||
name="tests" | ||
checked={props.curState.showTests} | ||
onChange={(evt) => props.toggleShowTests()} | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
className={classes.root} | ||
color={"default"} | ||
icon={<CheckBoxOutlineBlankIcon fontSize="small" />} | ||
checkedIcon={<CheckBoxIcon fontSize="small" />} | ||
checked={props.curState.showTests} | ||
onChange={(e) => props.toggleShowTests()} | ||
name="tests" | ||
id="tests" | ||
/> | ||
} | ||
label="Tests" | ||
/> | ||
<label htmlFor="tests">Tests</label> | ||
</div> | ||
</FilterOptionList> | ||
|
||
<AlertsOnTopToggle | ||
className={props.curState.alertsOnTop ? "is-enabled" : ""} | ||
onClick={(e) => props.toggleAlertsOnTop()} | ||
> | ||
Alerts on Top | ||
</AlertsOnTopToggle> | ||
</OverviewSidebarOptionsRoot> | ||
) | ||
} |
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.