-
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.
feat: Add fast simulation mode switch [PT-187321091]
- Loading branch information
1 parent
8067a91
commit 32b1bd6
Showing
4 changed files
with
119 additions
and
9 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,56 @@ | ||
.speedToggle { | ||
|
||
&>div { | ||
margin: 7px 0; | ||
display: flex; | ||
gap: 10px; | ||
cursor: pointer; | ||
|
||
&>div { | ||
width: 40px; | ||
} | ||
|
||
.fast { | ||
flex-grow: 1; | ||
} | ||
} | ||
|
||
input.slider { | ||
cursor: pointer; | ||
-webkit-appearance: none; | ||
-moz-appearance: none; | ||
appearance: none; | ||
position: relative; | ||
font-size: inherit; | ||
width: 40px; | ||
height: 14px; | ||
box-sizing: content-box; | ||
border: 1px solid #177991; | ||
border-radius: 16px; | ||
vertical-align: text-bottom; | ||
margin: auto; | ||
color: inherit; | ||
background-color: #177991; | ||
|
||
&::before { | ||
content: ""; | ||
position: absolute; | ||
top: 50%; | ||
left: -3px; | ||
transform: translate(0, -50%); | ||
box-sizing: border-box; | ||
width: 24px; | ||
height: 24px; | ||
margin: 0 0.15em; | ||
border: 1px solid black; | ||
border-radius: 50%; | ||
background: currentcolor; | ||
color: white; | ||
box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.35); | ||
} | ||
|
||
&:checked::before { | ||
left: 18px; | ||
} | ||
} | ||
} |
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,35 @@ | ||
import React from "react"; | ||
|
||
import "./speed-toggle.scss"; | ||
|
||
interface Props { | ||
fastSimulation: boolean; | ||
onChange: (newValue: boolean) => void; | ||
} | ||
|
||
export const SpeedToggle = ({fastSimulation, onChange}: Props) => { | ||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
onChange(e.target.checked); | ||
}; | ||
const getStyle = (isBold: boolean): React.CSSProperties => ({fontWeight: isBold ? "bold" : "normal"}); | ||
const title = `Simulation Speed: ${fastSimulation ? "Fast" : "Normal"}`; | ||
|
||
return ( | ||
<div className="speedToggle"> | ||
<label htmlFor="simulationSpeed">Simulation Speed:</label> | ||
<div> | ||
<div style={getStyle(!fastSimulation)} onClick={() => onChange(false)}>Normal</div> | ||
<input | ||
id="simulationSpeed" | ||
className="slider" | ||
type="checkbox" | ||
role="switch" | ||
title={title} | ||
checked={fastSimulation} | ||
onChange={handleChange} | ||
/> | ||
<div style={getStyle(fastSimulation)} className="fast" onClick={() => onChange(true)}>Fast</div> | ||
</div> | ||
</div> | ||
); | ||
}; |