Skip to content

Commit d5cd693

Browse files
authored
Merge pull request #174 from /issues/169-style_the_senseHAT_astro_pi_model_pane
style the senseHAT astro pi model pane
2 parents ceac7ab + 4868e92 commit d5cd693

30 files changed

Lines changed: 413 additions & 7794 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
## [Unreleased]
77

88
### Changed
9+
- Update styling on the `sense_hat` visual output (#174)
910
- Update build workflow with a reusable job to update preview, staging, and prod (#176)
1011

1112
## [0.3.0]

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"react-tabs": "^3.2.3",
4343
"react-timer-hook": "^3.0.5",
4444
"react-toastify": "^8.1.0",
45+
"react-toggle": "^4.1.3",
4546
"redux-oidc": "^4.0.0-beta1",
4647
"skulpt": "^1.2.0",
4748
"three": "^0.140.0",

src/App.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ button {
1515
color: $editor-white;
1616
caret-color: $editor-white;
1717

18-
#sense-hat-sensor-controls-container {
19-
background-color: #565555;
20-
}
21-
2218
.pythonrunner-input {
2319
color: rgb(36, 186, 236);
2420
}

src/Icons.js

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ export const FontIcon = (props) => {
7373
)
7474
}
7575

76+
export const HumidityIcon = () => {
77+
const [cookies] = useCookies(['fontSize'])
78+
const scale = (fontScaleFactors[cookies.fontSize] || 1) * 1.6
79+
return (
80+
<svg transform={`scale(${scale}, ${scale})`} width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg">
81+
<g>
82+
<path d="M7.5 2.5C4.909 4.775 3.611 6.74 3.611 8.4c0 2.49 1.847 4.1 3.889 4.1s3.889-1.61 3.889-4.1c0-1.66-1.298-3.625-3.889-5.9zm0 9c-1.628 0-2.917-1.285-2.917-3.1 0-1.17.948-2.72 2.917-4.57 1.969 1.85 2.917 3.395 2.917 4.57 0 1.815-1.289 3.1-2.917 3.1z"/>
83+
<path d="M7.978 6.032a.339.339 0 1 1 .625.262l-1.605 3.831a.338.338 0 0 1-.624-.261z"/>
84+
<path fillRule="evenodd" clipRule="evenodd" d="M6.357 8.051c.473 0 .857-.511.857-1.142 0-.632-.384-1.143-.857-1.143S5.5 6.277 5.5 6.909c0 .63.384 1.142.857 1.142zm-.001-.572c.158 0 .286-.256.286-.572 0-.315-.128-.571-.286-.571-.158 0-.286.256-.286.571 0 .316.128.572.286.572zM8.644 10.34c.473 0 .857-.511.857-1.142 0-.632-.384-1.143-.857-1.143s-.857.511-.857 1.143c0 .63.384 1.143.857 1.143zm-.001-.572c.158 0 .286-.256.286-.572 0-.315-.128-.571-.286-.571-.158 0-.286.256-.286.571 0 .316.128.572.286.572z"/>
85+
</g>
86+
</svg>
87+
)
88+
}
89+
7690
export const LoginIcon = () => {
7791
return (
7892
<svg width="17" height="17" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -101,6 +115,20 @@ export const NewFileIcon = () => {
101115
)
102116
}
103117

118+
export const PressureIcon = () => {
119+
const [cookies] = useCookies(['fontSize'])
120+
const scale = (fontScaleFactors[cookies.fontSize] || 1) * 1.6
121+
return (
122+
<svg transform={`scale(${scale}, ${scale})`} width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg">
123+
<g>
124+
<path d="M8.752 7.001a1 1 0 0 1-1.971.237c-.062-.252-.123-.52-.307-.704L5.411 5.471a.5.5 0 1 1 .707-.707l.957.957c.207.207.52.25.81.29a1 1 0 0 1 .867.99Z"/>
125+
<path fillRule="evenodd" clipRule="evenodd" d="M11.75 6.75a4.25 4.25 0 1 1-8.5 0 4.25 4.25 0 0 1 8.5 0zm-1 0a3.25 3.25 0 1 1-6.5 0 3.25 3.25 0 0 1 6.5 0z"/>
126+
<path d="M6.252 10.5h2.5v.75a1.25 1.25 0 1 1-2.5 0z"/>
127+
</g>
128+
</svg>
129+
)
130+
}
131+
104132
export const RemixIcon = () => {
105133
const [cookies] = useCookies(['fontSize'])
106134
const scale = fontScaleFactors[cookies.fontSize] || 1
@@ -112,6 +140,16 @@ export const RemixIcon = () => {
112140
)
113141
}
114142

143+
export const ResetIcon = () => {
144+
const [cookies] = useCookies(['fontSize'])
145+
const scale = fontScaleFactors[cookies.fontSize] || 1
146+
return (
147+
<svg transform={`scale(${scale}, ${scale})`} width="12" height="12" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
148+
<path d="M13.65 2.35C12.2 0.9 10.21 0 8 0C3.58 0 0.0100021 3.58 0.0100021 8C0.0100021 12.42 3.58 16 8 16C11.73 16 14.84 13.45 15.73 10H13.65C12.83 12.33 10.61 14 8 14C4.69 14 2 11.31 2 8C2 4.69 4.69 2 8 2C9.66 2 11.14 2.69 12.22 3.78L9 7H16V0L13.65 2.35Z" />
149+
</svg>
150+
)
151+
}
152+
115153
export const RunIcon = () => {
116154
const [cookies] = useCookies(['fontSize'])
117155
const scale = fontScaleFactors[cookies.fontSize] || 1
@@ -140,7 +178,7 @@ export const SettingsIcon = () => {
140178
const scale = fontScaleFactors[cookies.fontSize] || 1
141179
return (
142180
<svg transform={`scale(${scale}, ${scale})`} width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
143-
<path d="M1 3H5M5 3C5 4.10457 5.89543 5 7 5C8.10457 5 9 4.10457 9 3M5 3C5 1.89543 5.89543 1 7 1C8.10457 1 9 1.89543 9 3M19 3H9M1 10H13M13 10C13 11.1046 13.8954 12 15 12C16.1046 12 17 11.1046 17 10M13 10C13 8.89543 13.8954 8 15 8C16.1046 8 17 8.89543 17 10M19 10H17M1 17H3M3 17C3 18.1046 3.89543 19 5 19C6.10457 19 7 18.1046 7 17M3 17C3 15.8954 3.89543 15 5 15C6.10457 15 7 15.8954 7 17M19 17H7" fill="none" stroke={isDarkMode? "white" : "black"} stroke-width="2" stroke-linecap="round"/>
181+
<path d="M1 3H5M5 3C5 4.10457 5.89543 5 7 5C8.10457 5 9 4.10457 9 3M5 3C5 1.89543 5.89543 1 7 1C8.10457 1 9 1.89543 9 3M19 3H9M1 10H13M13 10C13 11.1046 13.8954 12 15 12C16.1046 12 17 11.1046 17 10M13 10C13 8.89543 13.8954 8 15 8C16.1046 8 17 8.89543 17 10M19 10H17M1 17H3M3 17C3 18.1046 3.89543 19 5 19C6.10457 19 7 18.1046 7 17M3 17C3 15.8954 3.89543 15 5 15C6.10457 15 7 15.8954 7 17M19 17H7" fill="none" stroke={isDarkMode? "white" : "black"} strokeWidth="2" strokeLinecap="round"/>
144182
</svg>
145183

146184
)
@@ -184,6 +222,16 @@ export const SunIcon = () => {
184222
)
185223
}
186224

225+
export const TemperatureIcon = () => {
226+
const [cookies] = useCookies(['fontSize'])
227+
const scale = (fontScaleFactors[cookies.fontSize] || 1) * 1.6
228+
return (
229+
<svg transform={`scale(${scale}, ${scale})`} width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg">
230+
<path d="M7.954 5.657a.457.457 0 0 0-.455-.456.454.454 0 0 0-.454.456v2.978a1.214 1.214 0 0 0-.734 1.36 1.217 1.217 0 0 0 1.19.984 1.21 1.21 0 0 0 1.19-.984 1.22 1.22 0 0 0-.736-1.36ZM5.379 4.593v-.001c.01-.558.237-1.09.633-1.482a2.116 2.116 0 0 1 2.973 0c.397.392.624.924.633 1.482v3.447a2.741 2.741 0 0 1-.662 4.039 2.72 2.72 0 0 1-3.918-1.137 2.746 2.746 0 0 1 .344-2.902c0-1.056-.005-2.42-.005-3.446zm.91-.001c-.004 1.265.002 2.531.002 3.797l-.122.131a1.827 1.827 0 0 0 1.332 3.068 1.813 1.813 0 0 0 1.667-1.096 1.83 1.83 0 0 0-.336-1.972L8.71 8.39V4.592c0-.323-.128-.632-.355-.86a1.209 1.209 0 0 0-2.067.86Z"/>
231+
</svg>
232+
)
233+
}
234+
187235
export const ThemeIcon = () => {
188236
return (
189237
<svg width="18" height="18" fill="none" xmlns="http://www.w3.org/2000/svg">

src/colours.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
$editor-white: white;
22
$editor-light-light-light-grey: #FFFFFF80;
3-
$editor-light-light-grey: #0000000D;
4-
$editor-light-grey: #0000001A;
5-
$editor-mid-grey: #1A1A1A80;
3+
$editor-light-light-grey: #F3F4F6;
4+
$editor-light-grey: #E8E9ED;
5+
$editor-mid-light-grey: #BFC3CE;
6+
$editor-mid-grey: #8C93A4;
67
$editor-grey: #43454C;
78
$editor-dark: #2E3038;
89
$editor-dark-dark: #24262D;
@@ -14,9 +15,8 @@ $editor-pale-purple: #BBCAF7;
1415
$editor-pale-blue: #F0F3FD;
1516
$editor-light-blue: #B2E3EF;
1617
$editor-blue: #2143B3;
18+
$editor-dark-blue: #002B3F;
1719

1820
$editor-turquoise: #14BCAC;
1921
$editor-dark-turquoise: #11A99A;
2022
$editor-turquoise-grey: #72D7CD1A;
21-
22-

src/components/AstroPiModel/AstroPiControls/AstroPiControls.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ import MotionInput from './MotionInput';
44
import SliderInput from './SliderInput';
55
import '../AstroPiModel.scss';
66
import Stopwatch from './Stopwatch';
7+
import { HumidityIcon, PressureIcon, TemperatureIcon } from '../../../Icons';
78

89
const AstroPiControls = (props) => {
910
const {temperature, pressure, humidity, colour, motion} = props
1011

1112
return (
12-
<div id="sense-hat-sensor-controls-container" className="top hide-for-snapshot">
13-
<div className="controls-container">
14-
<SliderInput name="temperature" unit="°C" min={-40} max={120} defaultValue={temperature} />
15-
<SliderInput name="pressure" unit="hPa" min={260} max={1260} defaultValue={pressure} />
16-
<SliderInput name="humidity" unit="%" min={0} max={100} defaultValue={humidity} />
17-
</div>
18-
19-
<div className="controls-container motion-colour">
20-
<MotionInput defaultValue={motion} />
21-
<Input name="colour" label="Colour" type="color" defaultValue={colour} />
22-
<Stopwatch />
13+
<div className='sense-hat-controls'>
14+
<h2 className='sense-hat-controls-heading'>Space Station Control Panel</h2>
15+
<div className="sense-hat-controls-panel">
16+
<SliderInput name="temperature" unit="°C" min={-40} max={120} defaultValue={temperature} Icon={TemperatureIcon} />
17+
<SliderInput name="pressure" unit="hPa" min={260} max={1260} defaultValue={pressure} Icon={PressureIcon}/>
18+
<SliderInput name="humidity" unit="%" min={0} max={100} defaultValue={humidity} Icon={HumidityIcon}/>
19+
20+
<div className="sense-hat-controls-panel__control">
21+
<Input name="colour" label="Colour Picker" type="color" defaultValue={colour} />
22+
<MotionInput defaultValue={motion} />
23+
<Stopwatch />
24+
</div>
2325
</div>
2426
</div>
2527
)

src/components/AstroPiModel/AstroPiControls/Input.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ const Input = (props) => {
1414
}, [name, value])
1515

1616
return (
17-
<div className="rangeslider-container">
18-
<div className={`readings-container ${name}-sensor`}>
19-
<label htmlFor={`sense_hat_${name}`}>{label}:</label>
20-
<input type={type} id={`sense_hat_${name}`} name={`sense_hat_${name}`} defaultValue={value} onChange={e => setValue(e.target.value)} />
17+
<div className='sense-hat-controls-panel__container'>
18+
<label className='sense-hat-controls-panel__control-name' htmlFor={`sense_hat_${name}`}>{label}</label>
19+
<input type={type} id={`sense_hat_${name}`} defaultValue={value} onChange={e => setValue(e.target.value)} />
2120
</div>
22-
</div>
2321
)
2422
};
2523

src/components/AstroPiModel/AstroPiControls/MotionInput.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React from 'react';
22
import { useEffect, useState } from 'react';
33
import { useSelector } from 'react-redux';
4+
import Toggle from 'react-toggle';
45
import Sk from 'skulpt';
56
import '../AstroPiModel.scss';
7+
import "react-toggle/style.css"
68

79
const MotionInput = (props) => {
810
const {defaultValue} = props;
@@ -24,10 +26,12 @@ const MotionInput = (props) => {
2426
}, [value])
2527

2628
return (
27-
<div className="rangeslider-container">
28-
<div className={`readings-container motion-sensor`}>
29-
<label htmlFor={`sense_hat_motion`}>Motion:</label>
30-
<input type="checkbox" id="sense_hat_motion" name="sense_hat_motion" checked={value} onChange={e => setValue(e.target.checked)} />
29+
<div className="sense-hat-controls-panel__container">
30+
<label className='sense-hat-controls-panel__control-name' htmlFor={`sense_hat_motion`}>Motion</label>
31+
<div className='sense-hat-controls-panel__control-toggle'>
32+
<label htmlFor={`sense_hat_motion`} >No</label>
33+
<Toggle id='sense_hat_motion' icons={false} checked={value} onChange={e => setValue(e.target.checked)}/>
34+
<label htmlFor={`sense_hat_motion`} >Yes</label>
3135
</div>
3236
</div>
3337
)

src/components/AstroPiModel/AstroPiControls/SliderInput.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,26 @@
11
import React from 'react';
22
import { useEffect, useState } from 'react';
3-
import { useCookies } from 'react-cookie';
4-
import { Barometer, Humidity, Thermometer } from "@intern0t/react-weather-icons";
53
import '../AstroPiModel.scss';
64
import Sk from 'skulpt';
75

86
const SliderInput = (props) => {
9-
const { name, unit, min, max, defaultValue} = props;
7+
const { name, unit, min, max, defaultValue, Icon} = props;
108
const [value, setValue] = useState(defaultValue);
11-
const [cookies] = useCookies(['theme'])
12-
const isDarkMode = cookies.theme==="dark" || (!cookies.theme && window.matchMedia("(prefers-color-scheme:dark)").matches)
13-
const iconColour = isDarkMode ? "white" : "black"
14-
9+
1510
useEffect(() => {
1611
if (Sk.sense_hat) {
1712
Sk.sense_hat.rtimu[name][1] = value+Math.random()-0.5
1813
}
1914
}, [name, value])
2015

2116
return (
22-
<div className="rangeslider-container">
23-
<div className="readings-container">
24-
{name==="temperature" ?
25-
<Thermometer color={iconColour} size={"1.5em"}/>
26-
:
27-
name==="pressure" ?
28-
<Barometer color={iconColour} size={"1.5em"}/>
29-
:
30-
name==="humidity" ?
31-
<Humidity color={iconColour} size={"1.5em"}/>
32-
:
33-
null}
34-
<span className={`sensor-value sense-hat-${name}`}>{value}{unit}</span>
17+
<div className="sense-hat-controls-panel__control">
18+
<label className='sense-hat-controls-panel__control-name' htmlFor={`sense_hat_${name}`}>{name}</label>
19+
<input id={`sense_hat_${name}`} className="sense-hat-controls-panel__control-input" type="range" min={min} max={max} step="1" defaultValue={value} onChange={e => setValue(parseFloat(e.target.value))}/>
20+
<div className="sense-hat-controls-panel__control-reading">
21+
{Icon ? <Icon /> : null}
22+
<span className='sense-hat-controls-panel__control-value'>{value}{unit}</span>
3523
</div>
36-
<input id={`sense_hat_${name}`} className="rangeslider" type="range" min={min} max={max} step="1" defaultValue={value} onChange={e => setValue(parseFloat(e.target.value))}/>
3724
</div>
3825
)
3926
};

src/components/AstroPiModel/AstroPiControls/Stopwatch.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useEffect } from 'react'
22
import { useSelector } from 'react-redux';
33
import { useStopwatch } from 'react-timer-hook';
4-
import './Stopwatch.scss'
54
import Sk from 'skulpt'
65

76
const Stopwatch = () => {
@@ -26,9 +25,9 @@ const Stopwatch = () => {
2625

2726

2827
return (
29-
<div className='astro-pi-stopwatch-container'>
30-
<label htmlFor='astro_pi_stopwatch'>Timer: </label>
31-
<span className='astro-pi-stopwatch' id='astro_pi_stopwatch'>
28+
<div className='sense-hat-controls-panel__container sense-hat-controls-panel__container-timer'>
29+
<label className='sense-hat-controls-panel__control-name' htmlFor='sense_hat_timer'>Timer</label>
30+
<span className='sense-hat-controls-panel__control-reading sense-hat-controls-panel__control-reading-timer' id='sense_hat_timer'>
3231
<span>{String(minutes).padStart(2, '0')}</span>:<span>{String(seconds).padStart(2, '0')}</span>
3332
</span>
3433
</div>

0 commit comments

Comments
 (0)