Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Display noise level in red if currently triggering #636

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .storybook/seed-fake.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,11 @@ export const seedFake = (db) => {
noiseaware_metadata: {
device_model: 'indoor',
noise_level_nrs: 1,
noise_level_decibel: 42,
noise_level_decibel: 80,
device_name: 'Living room',
device_id: 'noiseaware_123',
},
currently_triggering_noise_threshold_ids: [],
},
errors: [],
})
Expand Down
6 changes: 6 additions & 0 deletions assets/icons/noise-levels-red.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"luxon": "^3.3.0",
"queue": "^7.0.0",
"react-hook-form": "^7.46.1",
"seamapi": "^8.22.1",
"seamapi": "^8.24.0",
"uuid": "^9.0.0",
"zoned-time": "^1.1.2"
},
Expand Down
33 changes: 33 additions & 0 deletions src/lib/icons/NoiseLevelsRed.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions src/lib/ui/device/NoiseLevelStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import classNames from 'classnames'
import type { NoiseSensorDevice } from 'seamapi'

import { NoiseLevelsIcon } from 'lib/icons/NoiseLevels.js'
import { NoiseLevelsRedIcon } from 'lib/icons/NoiseLevelsRed.js'

interface NoiseLevelStatusProps {
device: NoiseSensorDevice
Expand All @@ -9,13 +11,22 @@ interface NoiseLevelStatusProps {
export function NoiseLevelStatus({
device,
}: NoiseLevelStatusProps): JSX.Element {
const isActivated =
(device?.properties?.currently_triggering_noise_threshold_ids ?? [])
?.length > 0

return (
<>
<span className='seam-label'>{t.noiseLevel}:</span>

<div className='seam-device-status'>
<NoiseLevelsIcon />
<span className='seam-text'>{getNoiseLevel(device)}</span>
{isActivated ? <NoiseLevelsRedIcon /> : <NoiseLevelsIcon />}
<span
className={classNames('seam-text', isActivated && 'seam-text-danger')}
>
{getNoiseLevel(device)}
{isActivated && ` (${t.noisy})`}
</span>
</div>
</>
)
Expand Down Expand Up @@ -55,4 +66,5 @@ const t = {
unknown: 'Unknown',
decibel: 'dB',
noiseAwareDefault: '0-40 dB',
noisy: 'noisy',
}
Loading