Skip to content

Commit

Permalink
fix: Use LoadingToast for NoiseSensorDeviceDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
xplato committed May 7, 2024
1 parent 25df528 commit 23c0fb7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/lib/ui/noise-sensor/NoiseThresholdsList.tsx
Expand Up @@ -7,6 +7,7 @@ import { useNoiseThresholds } from 'lib/seam/noise-sensors/use-noise-thresholds.
import { DetailRow } from 'lib/ui/layout/DetailRow.js'
import { DetailSection } from 'lib/ui/layout/DetailSection.js'
import { DetailSectionGroup } from 'lib/ui/layout/DetailSectionGroup.js'
import { LoadingToast } from 'lib/ui/LoadingToast/LoadingToast.js'

interface NoiseThresholdsListProps {
device: NoiseSensorDevice
Expand All @@ -21,6 +22,14 @@ export function NoiseThresholdsList({

return (
<DetailSectionGroup>
<div className='seam-loading-toast-centered-wrap'>
<LoadingToast
isLoading={isInitialLoading}
label={t.loading}
top='10%'
/>
</div>

<div className='seam-detail-section-wrap'>
<DetailSection
label={t.noiseThresholds}
Expand All @@ -39,10 +48,7 @@ export function NoiseThresholdsList({
)
}
>
<Content
isInitialLoading={isInitialLoading}
noiseThresholds={noiseThresholds}
/>
<Content noiseThresholds={noiseThresholds} />
</DetailSection>

<div className='seam-detail-section-footer'>
Expand All @@ -59,20 +65,10 @@ export function NoiseThresholdsList({
}

function Content({
isInitialLoading,
noiseThresholds,
}: {
isInitialLoading: boolean
noiseThresholds: NoiseThresholds[] | undefined
}): JSX.Element | JSX.Element[] {
if (isInitialLoading) {
return (
<DetailRow
label={<span className='seam-detail-row-empty-label'>{t.loading}</span>}
/>
)
}

if (noiseThresholds == null || noiseThresholds.length === 0) {
return (
<DetailRow
Expand Down
7 changes: 7 additions & 0 deletions src/styles/_loading_toast.scss
Expand Up @@ -2,6 +2,13 @@
@use './motion';

@mixin all {
.seam-loading-toast-centered-wrap {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}

.seam-loading-toast {
@include motion.scale-in;

Expand Down

0 comments on commit 23c0fb7

Please sign in to comment.