-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] Add automatic refreshing to measurements
- Loading branch information
Showing
5 changed files
with
144 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import styled from "styled-components"; | ||
|
||
const Overlay = styled.div` | ||
backdrop-filter: blur(50px); | ||
opacity: 0.9; | ||
background-color: ${({ theme }) => theme.palette.background.paper}; | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export default Overlay; |
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
interface SwitchProps { | ||
checked: boolean; | ||
label: string; | ||
onChange: () => void; | ||
} | ||
|
||
const HiddenSwitch = styled.input.attrs({ | ||
type: "checkbox", | ||
})` | ||
left: -100%; | ||
opacity: 0; | ||
position: absolute; | ||
margin: 0; | ||
padding: 0; | ||
`; | ||
|
||
const SwitchContainer = styled.label` | ||
position: relative; | ||
display: inline-flex; | ||
flex-flow: row nowrap; | ||
flex-grow: 0; | ||
overflow: hidden; | ||
padding-top: ${({ theme }) => theme.spacing.d1}px; | ||
padding-bottom: ${({ theme }) => theme.spacing.d1}px; | ||
`; | ||
|
||
const SwitchLabel = styled.span` | ||
display: block; | ||
margin-left: ${({ theme }) => theme.spacing.d1}px; | ||
`; | ||
|
||
const SwitchBackground = styled.span<Pick<SwitchProps, "checked">>` | ||
display: block; | ||
width: ${({ theme }) => theme.spacing.d4 + theme.spacing.d2}px; | ||
height: ${({ theme }) => theme.spacing.d2}px; | ||
border-radius: ${({ theme }) => theme.shapes.borderRadius}px; | ||
background-color: ${({ theme }) => theme.palette.grey[100]}; | ||
`; | ||
|
||
const SwitchBullet = styled.span<Pick<SwitchProps, "checked">>` | ||
display: block; | ||
position: absolute; | ||
left: ${({ theme, checked }) => (!checked ? "0" : theme.spacing.d4 + "px")}; | ||
transition: all 0.1s ease-in-out; | ||
height: ${({ theme }) => theme.spacing.d2}px; | ||
width: ${({ theme }) => theme.spacing.d2}px; | ||
border-radius: ${({ theme }) => theme.shapes.borderRadius}px; | ||
background-color: ${({ theme, checked }) => | ||
!checked ? theme.palette.grey[400] : theme.palette.primary.main}; | ||
`; | ||
|
||
const Switch = ({ checked, label, onChange }: SwitchProps) => ( | ||
<SwitchContainer> | ||
<SwitchBackground checked={checked}> | ||
<SwitchBullet checked={checked} /> | ||
<HiddenSwitch checked={checked} onChange={onChange} /> | ||
</SwitchBackground> | ||
<SwitchLabel>{label}</SwitchLabel> | ||
</SwitchContainer> | ||
); | ||
|
||
export default Switch; |
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