File tree Expand file tree Collapse file tree 6 files changed +46
-39
lines changed
Expand file tree Collapse file tree 6 files changed +46
-39
lines changed Original file line number Diff line number Diff line change @@ -44,18 +44,6 @@ const EnvBanner = styled.div`
4444 justify-content: center;
4545` ;
4646
47- const Footer = styled . footer `
48- margin: 0;
49- padding: 0;
50- width: 100%;
51- min-height: 25vh;
52- background-color: #444;
53-
54- > * {
55- max-width: 64em;
56- }
57- ` ;
58-
5947const backend = import . meta. env . VITE_API_URL ?? "" ;
6048
6149function App ( ) {
@@ -158,7 +146,6 @@ function App() {
158146 < Settings backend = { backend } />
159147 </ Route >
160148 </ Wrapper >
161- < Footer > </ Footer >
162149 </ ThemeProvider >
163150 ) ;
164151}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
1010 rgbToHex ,
1111 updateDeviceState ,
1212} from "../../utils/deviceUtilities" ;
13- import { numericTransformer } from "../../utils/transformers" ;
13+ import { numericTransformer , readableNames } from "../../utils/transformers" ;
1414import Toggle from "../Toggle/Toggle" ;
1515import ColorPicker from "../ColorPicker/ColorPicker" ;
1616
@@ -31,6 +31,7 @@ export const deviceSettingsGenerator = (
3131 settingComponentsArray . push (
3232 < Toggle
3333 key = { feature . name }
34+ label = { readableNames [ feature . name ] }
3435 checked = { mqttStateToBoolean ( deviceSettingsState [ feature . name ] ) }
3536 onChange = { ( event ) => {
3637 const newMqttState = booleanToMqttState ( event . target . checked ) ;
Original file line number Diff line number Diff line change @@ -16,7 +16,14 @@ const StyledEditable = styled.input`
1616 margin-bottom: 1em;
1717 padding: 10px 0px;
1818 width: auto;
19- max-width: 50%;
19+
20+ @media only screen and (max-width: 500px) {
21+ max-width: 100%;
22+ }
23+
24+ @media only screen and (min-width: 768px) {
25+ max-width: 75%;
26+ }
2027
2128 text-align: left;
2229
Original file line number Diff line number Diff line change @@ -5,7 +5,14 @@ import styled from "styled-components";
55
66const SliderContainer = styled . label `
77 display: grid;
8- grid-template-columns: [setting-name] 15% [slider] 75% [value] 10%;
8+
9+ @media only screen and (max-width: 500px) {
10+ grid-template-columns: [setting-name] 25% [slider] 50% [value] 25%;
11+ }
12+
13+ @media only screen and (min-width: 768px) {
14+ grid-template-columns: [setting-name] 15% [slider] 75% [value] 10%;
15+ }
916
1017 span,
1118 output {
Original file line number Diff line number Diff line change 33
44import styled from "styled-components" ;
55
6- const Switch = styled . label `
7- position: relative;
8- display: inline-block;
9- width: 60px;
10- height: 34px;
6+ const ToggleContainer = styled . label `
7+ display: grid;
8+ grid-template-columns: [setting-name] 15% [value] 0% auto;
9+ align-items: center;
1110
1211 input {
13- opacity: 0;
14- width: 0;
15- height: 0;
12+ visibility: hidden;
13+ justify-self: baseline;
1614 }
1715` ;
1816
1917const Slider = styled . span `
20- position: absolute;
18+ --toggle-width: 60px;
19+ --toggle-height: 34px;
20+ --slider-width: 26px;
21+ --slider-height: 26px;
22+
23+ position: relative;
24+ width: var(--toggle-width);
25+ height: var(--toggle-height);
2126 cursor: pointer;
22- top: 0;
23- left: 0;
24- right: 0;
25- bottom: 0;
2627 background-color: ${ ( { theme } ) => theme . shadow } ;
2728 transition: 0.4s;
28- border-radius: 1em ;
29+ border-radius: 0.5em ;
2930
3031 &:before {
31- position: absolute;
32+ display: block;
33+ position: relative;
3234 content: "";
33- height: 26px;
34- width: 26px;
35- left: 4px;
36- bottom: 4px;
35+ margin: calc((var(--toggle-height) - var(--slider-height)) / 2);
36+ height: var(--slider-height);
37+ width: var(--slider-width);
3738 background-color: ${ ( { theme } ) => theme . background } ;
3839 transition: 0.4s;
39- border-radius: 50 %;
40+ border-radius: 25 %;
4041 }
4142
4243 input:checked + && {
@@ -54,15 +55,15 @@ function Toggle(props: {
5455 onChange : Function ;
5556} ) {
5657 return (
57- < Switch >
58- { props . label }
58+ < ToggleContainer >
59+ < span > { props . label } </ span >
5960 < input
6061 type = { "checkbox" }
6162 checked = { props . checked }
6263 onChange = { props . onChange }
6364 />
6465 < Slider > </ Slider >
65- </ Switch >
66+ </ ToggleContainer >
6667 ) ;
6768}
6869
Original file line number Diff line number Diff line change @@ -77,3 +77,7 @@ export const numericTransformer = (
7777
7878 return componentsArray ;
7979} ;
80+
81+ export const readableNames = {
82+ state : "Power" ,
83+ } ;
You can’t perform that action at this time.
0 commit comments