Skip to content

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

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

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .storybook/seed-fake.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ export const seedFake = (db) => {
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.
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.

15 changes: 13 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,21 @@
export function NoiseLevelStatus({
device,
}: NoiseLevelStatusProps): JSX.Element {
const isActivated =
device.properties.currently_triggering_noise_threshold_ids?.length <= 0

Check failure on line 15 in src/lib/ui/device/NoiseLevelStatus.tsx

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Property 'currently_triggering_noise_threshold_ids' does not exist on type 'NoiseSensorDeviceProperties'.

Check failure on line 15 in src/lib/ui/device/NoiseLevelStatus.tsx

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Property 'currently_triggering_noise_threshold_ids' does not exist on type 'NoiseSensorDeviceProperties'.

Check failure on line 15 in src/lib/ui/device/NoiseLevelStatus.tsx

View workflow job for this annotation

GitHub Actions / Build / Package

Property 'currently_triggering_noise_threshold_ids' does not exist on type 'NoiseSensorDeviceProperties'.

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 +65,5 @@
unknown: 'Unknown',
decibel: 'dB',
noiseAwareDefault: '0-40 dB',
noisy: 'noisy',
}
Loading