@justanarthur/modo-ui-notch 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blocks/activities/agenda/examples.mdx +8 -0
- package/blocks/activities/agenda/index.tsx +164 -16
- package/blocks/activities/clock/examples.mdx +16 -0
- package/blocks/activities/clock/index.tsx +357 -59
- package/blocks/activities/now-playing/examples.mdx +8 -0
- package/blocks/activities/now-playing/index.tsx +140 -54
- package/blocks/activities/weather/examples.mdx +9 -1
- package/blocks/activities/weather/index.tsx +241 -12
- package/blocks/app/expanded-island/index.tsx +3 -1
- package/blocks/app/settings-window/examples.mdx +8 -0
- package/blocks/app/settings-window/index.tsx +8 -3
- package/blocks/system/clipboard/examples.mdx +8 -0
- package/blocks/system/clipboard/index.tsx +262 -52
- package/blocks/system/recent-files/examples.mdx +14 -0
- package/blocks/system/recent-files/index.tsx +110 -25
- package/blocks/system/system-stats/examples.mdx +8 -0
- package/blocks/system/system-stats/index.tsx +211 -4
- package/components/island/widget/index.tsx +38 -4
- package/dist/blocks/activities/agenda/index.d.ts +2 -1
- package/dist/blocks/activities/agenda/index.js +2 -2
- package/dist/blocks/activities/clock/index.d.ts +2 -1
- package/dist/blocks/activities/clock/index.js +2 -2
- package/dist/blocks/activities/now-playing/index.d.ts +2 -1
- package/dist/blocks/activities/now-playing/index.js +2 -2
- package/dist/blocks/activities/weather/index.d.ts +2 -1
- package/dist/blocks/activities/weather/index.js +2 -2
- package/dist/blocks/app/expanded-island/index.d.ts +1 -1
- package/dist/blocks/app/expanded-island/index.js +1 -1
- package/dist/blocks/app/settings-window/index.d.ts +1 -1
- package/dist/blocks/app/settings-window/index.js +1 -1
- package/dist/blocks/system/clipboard/index.d.ts +2 -1
- package/dist/blocks/system/clipboard/index.js +2 -2
- package/dist/blocks/system/recent-files/index.d.ts +2 -1
- package/dist/blocks/system/recent-files/index.js +2 -2
- package/dist/blocks/system/system-stats/index.d.ts +2 -1
- package/dist/blocks/system/system-stats/index.js +2 -2
- package/dist/components/island/widget/index.d.ts +2 -2
- package/dist/components/island/widget/index.js +3 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +12 -10
- package/dist/shared/{chunk-2m5dz8nf.d.ts → chunk-0ym9mcqc.d.ts} +6 -2
- package/dist/shared/{chunk-7fvnrtz4.d.ts → chunk-1v35ck2y.d.ts} +12 -2
- package/dist/shared/{chunk-wkg17nxs.d.ts → chunk-2bqmmfg9.d.ts} +13 -2
- package/dist/shared/{chunk-mt0k6v8x.js → chunk-2nxwdn5s.js} +147 -39
- package/dist/shared/{chunk-pfhy5e4q.d.ts → chunk-6tnq6p89.d.ts} +2 -0
- package/dist/shared/{chunk-bvtyjcce.d.ts → chunk-72s4sqwh.d.ts} +16 -1
- package/dist/shared/{chunk-t0hcxh89.d.ts → chunk-9b8b7fw6.d.ts} +12 -0
- package/dist/shared/{chunk-xq5hc5gv.js → chunk-a059ccj0.js} +177 -66
- package/dist/shared/{chunk-qdzemt2v.js → chunk-cry81asr.js} +401 -89
- package/dist/shared/{chunk-da177e8r.d.ts → chunk-fr9jf804.d.ts} +16 -1
- package/dist/shared/{chunk-9c7ewvkk.js → chunk-kbk4bp6p.js} +162 -19
- package/dist/shared/{chunk-3thgcfcq.d.ts → chunk-kv0w8vhq.d.ts} +18 -1
- package/dist/shared/{chunk-416tsgbc.d.ts → chunk-nqjermbr.d.ts} +25 -3
- package/dist/shared/chunk-p3nezxvx.js +481 -0
- package/dist/shared/{chunk-2818esrq.d.ts → chunk-sen170mz.d.ts} +10 -1
- package/dist/shared/{chunk-9m0xbg5v.js → chunk-wayv5rhr.js} +1 -1
- package/dist/shared/{chunk-ym0xbses.js → chunk-ygnrrqta.js} +274 -18
- package/dist/shared/{chunk-j77cx8dp.js → chunk-yw478nmj.js} +325 -58
- package/dist/shared/{chunk-cc9nwbtf.js → chunk-z3tj1ydg.js} +3 -0
- package/dist/shared/{chunk-x7f3g82r.js → chunk-zxsw11dr.js} +14 -4
- package/dist/styles.css +61 -1
- package/mock/clipboard.tsx +34 -0
- package/mock/clock.tsx +3 -3
- package/mock/data.ts +48 -0
- package/mock/files.tsx +14 -1
- package/mock/island-content.tsx +47 -15
- package/mock/system.ts +3 -0
- package/mock/weather.tsx +42 -12
- package/package.json +2 -2
- package/dist/shared/chunk-s2jeqqan.js +0 -243
|
@@ -35,7 +35,7 @@ import { type ReactNode, useState } from 'react'
|
|
|
35
35
|
import Equalizer from '../../../components/indicators/equalizer'
|
|
36
36
|
import MediaScrubber from '../../../components/indicators/media-scrubber'
|
|
37
37
|
import IslandFlash from '../../../components/island/island-flash'
|
|
38
|
-
import Widget from '../../../components/island/widget'
|
|
38
|
+
import Widget, { type WidgetLayout } from '../../../components/island/widget'
|
|
39
39
|
import { type Artwork, type ShownArtwork, useArtworkTint, useStableArtwork } from '../../../lib/artwork'
|
|
40
40
|
|
|
41
41
|
type NowPlayingOutput = 'built-in' | 'headphones' | 'speaker' | 'airplay'
|
|
@@ -104,10 +104,19 @@ interface NowPlayingProps {
|
|
|
104
104
|
emptyDescription?: ReactNode
|
|
105
105
|
/** The empty state's way forward, such as a Button that opens a player. */
|
|
106
106
|
emptyActions?: ReactNode
|
|
107
|
+
/** `tall` is the open island's tall snap: the artwork large, the title on the display role, a full-width scrubber and the transport under it, and where it plays from and to as rows. Defaults to `'fit'`. */
|
|
108
|
+
layout?: WidgetLayout
|
|
107
109
|
/** Classes for the root, which fills its container. */
|
|
108
110
|
className?: string
|
|
109
111
|
}
|
|
110
112
|
|
|
113
|
+
const OUTPUT_LABEL: Record<NowPlayingOutput, string> = {
|
|
114
|
+
'built-in': 'Built-in speakers',
|
|
115
|
+
headphones: 'Headphones',
|
|
116
|
+
speaker: 'Speaker',
|
|
117
|
+
airplay: 'AirPlay',
|
|
118
|
+
}
|
|
119
|
+
|
|
111
120
|
const OUTPUT_ICON = { 'built-in': Laptop, headphones: Headphones, speaker: Speaker, airplay: Airplay }
|
|
112
121
|
const NEXT_REPEAT: Record<NowPlayingRepeat, NowPlayingRepeat> = { off: 'all', all: 'one', one: 'off' }
|
|
113
122
|
const REPEAT_LABEL: Record<NowPlayingRepeat, string> = {
|
|
@@ -233,6 +242,23 @@ function NowPlayingFlash({ track, playing = true }: { track: NowPlayingTrack; pl
|
|
|
233
242
|
|
|
234
243
|
// Literal tables: UnoCSS only generates the classes it can read whole.
|
|
235
244
|
const ART = { default: 'size-36 rounded-2xl', compact: 'size-28 rounded-xl' }
|
|
245
|
+
const SHEET_ART = { default: 'size-52 rounded-3xl', compact: 'size-44 rounded-2xl' }
|
|
246
|
+
const SHEET_TITLE = { default: 'text-display', compact: 'text-display-compact' }
|
|
247
|
+
|
|
248
|
+
function Glow({ tint, children }: { tint?: string; children: ReactNode }) {
|
|
249
|
+
return (
|
|
250
|
+
<span className="relative flex">
|
|
251
|
+
{tint && (
|
|
252
|
+
<span
|
|
253
|
+
aria-hidden
|
|
254
|
+
className="absolute -inset-x-8 -inset-y-4 -z-1 opacity-70"
|
|
255
|
+
style={{ backgroundImage: `radial-gradient(closest-side, ${tint}, transparent)` }}
|
|
256
|
+
/>
|
|
257
|
+
)}
|
|
258
|
+
{children}
|
|
259
|
+
</span>
|
|
260
|
+
)
|
|
261
|
+
}
|
|
236
262
|
|
|
237
263
|
/**
|
|
238
264
|
* What's playing, as a notch app's open island shows it: the artwork, the
|
|
@@ -255,6 +281,12 @@ const ART = { default: 'size-36 rounded-2xl', compact: 'size-28 rounded-xl' }
|
|
|
255
281
|
* `defaultPlaying`; the toggles are the same. Without a track it says
|
|
256
282
|
* nothing is playing and how to change that.
|
|
257
283
|
*
|
|
284
|
+
* At the open island's tall snap (`layout="tall"`) it becomes a sheet: the
|
|
285
|
+
* artwork large beside the source, the title on the display role, the
|
|
286
|
+
* artist and the album on lines of their own; then the scrubber across the
|
|
287
|
+
* whole width with the transport and the toggles in one row under it; then
|
|
288
|
+
* where it plays from and to, the app and the output device, as rows.
|
|
289
|
+
*
|
|
258
290
|
* The other forms are parts: `NowPlaying.Leading` and `NowPlaying.Trailing`
|
|
259
291
|
* for the compact island's wings (the artwork, and the tinted Equalizer that
|
|
260
292
|
* settles when paused), `NowPlaying.Minimal` for the split island's bubble
|
|
@@ -283,6 +315,7 @@ const NowPlaying = Object.assign(
|
|
|
283
315
|
onLikedChange,
|
|
284
316
|
emptyDescription = 'Play something in Music, Spotify or a browser and it shows up here.',
|
|
285
317
|
emptyActions,
|
|
318
|
+
layout = 'fit',
|
|
286
319
|
className,
|
|
287
320
|
}: NowPlayingProps) {
|
|
288
321
|
const size = useSize()
|
|
@@ -307,21 +340,115 @@ const NowPlaying = Object.assign(
|
|
|
307
340
|
const showRepeat = repeatProp !== undefined || defaultRepeat !== undefined || onRepeatChange !== undefined
|
|
308
341
|
const showLiked = likedProp !== undefined || defaultLiked !== undefined || onLikedChange !== undefined
|
|
309
342
|
const byline = [track.artist, track.album].filter(Boolean).join(' — ')
|
|
343
|
+
const toggles = (
|
|
344
|
+
<>
|
|
345
|
+
{showShuffle && (
|
|
346
|
+
<Widget.Action
|
|
347
|
+
icon={Shuffle}
|
|
348
|
+
label="Shuffle"
|
|
349
|
+
pressed={shuffle}
|
|
350
|
+
color={tint}
|
|
351
|
+
onClick={() => setShuffle(!shuffle)}
|
|
352
|
+
/>
|
|
353
|
+
)}
|
|
354
|
+
{showRepeat && (
|
|
355
|
+
<Widget.Action
|
|
356
|
+
icon={repeat === 'one' ? Repeat1 : Repeat}
|
|
357
|
+
label={REPEAT_LABEL[repeat]}
|
|
358
|
+
pressed={repeat !== 'off'}
|
|
359
|
+
color={tint}
|
|
360
|
+
onClick={() => setRepeat(NEXT_REPEAT[repeat])}
|
|
361
|
+
/>
|
|
362
|
+
)}
|
|
363
|
+
{showLiked && (
|
|
364
|
+
<Widget.Action
|
|
365
|
+
icon={Heart}
|
|
366
|
+
label={liked ? 'Remove from library' : 'Add to library'}
|
|
367
|
+
pressed={liked}
|
|
368
|
+
filled={liked}
|
|
369
|
+
color={tint}
|
|
370
|
+
onClick={() => setLiked(!liked)}
|
|
371
|
+
/>
|
|
372
|
+
)}
|
|
373
|
+
</>
|
|
374
|
+
)
|
|
375
|
+
const transport = (
|
|
376
|
+
<div className="flex items-center gap-1">
|
|
377
|
+
<Widget.Action icon={SkipBack} label="Previous" filled onClick={onPrevious} />
|
|
378
|
+
<Widget.Action
|
|
379
|
+
icon={playing ? Pause : Play}
|
|
380
|
+
label={playing ? 'Pause' : 'Play'}
|
|
381
|
+
emphasis="primary"
|
|
382
|
+
filled
|
|
383
|
+
onClick={() => setPlaying(!playing)}
|
|
384
|
+
/>
|
|
385
|
+
<Widget.Action icon={SkipForward} label="Next" filled onClick={onNext} />
|
|
386
|
+
</div>
|
|
387
|
+
)
|
|
388
|
+
const OutputIcon = OUTPUT_ICON[track.outputKind ?? 'built-in']
|
|
389
|
+
|
|
390
|
+
if (layout === 'tall')
|
|
391
|
+
return (
|
|
392
|
+
<Widget.Sheet className={cn('relative isolate', className)}>
|
|
393
|
+
<div className="flex min-w-0 items-center gap-6">
|
|
394
|
+
<Glow tint={tint}>
|
|
395
|
+
<NowPlayingArtwork track={track} glyph={40} className={SHEET_ART[size.variant]} />
|
|
396
|
+
</Glow>
|
|
397
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
398
|
+
<Widget.Header icon={Disc3} trailing={<TintedBars track={track} playing={playing} />}>
|
|
399
|
+
{track.source ?? 'Now playing'}
|
|
400
|
+
</Widget.Header>
|
|
401
|
+
<span className={cn('line-clamp-2 weight-bold text-foreground text-balance', SHEET_TITLE[size.variant])}>
|
|
402
|
+
{track.title || 'Unknown title'}
|
|
403
|
+
</span>
|
|
404
|
+
{track.artist && <span className="truncate text-title text-foreground">{track.artist}</span>}
|
|
405
|
+
{track.album && <Widget.Subtitle>{track.album}</Widget.Subtitle>}
|
|
406
|
+
</div>
|
|
407
|
+
</div>
|
|
408
|
+
|
|
409
|
+
<div className="flex flex-col gap-2">
|
|
410
|
+
{track.duration > 0 && (
|
|
411
|
+
<MediaScrubber position={track.position} duration={track.duration} playing={playing} onSeek={onSeek} />
|
|
412
|
+
)}
|
|
413
|
+
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2">
|
|
414
|
+
<span />
|
|
415
|
+
{transport}
|
|
416
|
+
<div className="flex items-center justify-end">{toggles}</div>
|
|
417
|
+
</div>
|
|
418
|
+
</div>
|
|
419
|
+
|
|
420
|
+
{(track.source || track.output) && (
|
|
421
|
+
<Widget.Section label="Playing">
|
|
422
|
+
{track.source && (
|
|
423
|
+
<Widget.Row trailing={<Disc3 size={14} strokeWidth={1.5} />} leading="From">
|
|
424
|
+
{track.source}
|
|
425
|
+
</Widget.Row>
|
|
426
|
+
)}
|
|
427
|
+
{track.output && (
|
|
428
|
+
<Widget.Row
|
|
429
|
+
leading="On"
|
|
430
|
+
trailing={
|
|
431
|
+
<>
|
|
432
|
+
<OutputIcon size={14} strokeWidth={1.5} />
|
|
433
|
+
{OUTPUT_LABEL[track.outputKind ?? 'built-in']}
|
|
434
|
+
</>
|
|
435
|
+
}
|
|
436
|
+
>
|
|
437
|
+
{track.output}
|
|
438
|
+
</Widget.Row>
|
|
439
|
+
)}
|
|
440
|
+
</Widget.Section>
|
|
441
|
+
)}
|
|
442
|
+
</Widget.Sheet>
|
|
443
|
+
)
|
|
310
444
|
|
|
311
445
|
return (
|
|
312
446
|
<div className={cn('relative isolate flex w-full flex-col justify-center', className)}>
|
|
313
447
|
<Widget
|
|
314
448
|
media={
|
|
315
|
-
<
|
|
316
|
-
{tint && (
|
|
317
|
-
<span
|
|
318
|
-
aria-hidden
|
|
319
|
-
className="absolute -inset-x-8 -inset-y-4 -z-1 opacity-70"
|
|
320
|
-
style={{ backgroundImage: `radial-gradient(closest-side, ${tint}, transparent)` }}
|
|
321
|
-
/>
|
|
322
|
-
)}
|
|
449
|
+
<Glow tint={tint}>
|
|
323
450
|
<NowPlayingArtwork track={track} glyph={28} className={ART[size.variant]} />
|
|
324
|
-
</
|
|
451
|
+
</Glow>
|
|
325
452
|
}
|
|
326
453
|
>
|
|
327
454
|
<div className="flex min-w-0 items-start gap-3">
|
|
@@ -346,51 +473,10 @@ const NowPlaying = Object.assign(
|
|
|
346
473
|
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2">
|
|
347
474
|
<Widget.Meta>
|
|
348
475
|
{track.source && <Widget.MetaItem icon={Disc3}>{track.source}</Widget.MetaItem>}
|
|
349
|
-
{track.output &&
|
|
350
|
-
<Widget.MetaItem icon={OUTPUT_ICON[track.outputKind ?? 'built-in']}>{track.output}</Widget.MetaItem>
|
|
351
|
-
)}
|
|
476
|
+
{track.output && <Widget.MetaItem icon={OutputIcon}>{track.output}</Widget.MetaItem>}
|
|
352
477
|
</Widget.Meta>
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
<Widget.Action
|
|
356
|
-
icon={playing ? Pause : Play}
|
|
357
|
-
label={playing ? 'Pause' : 'Play'}
|
|
358
|
-
emphasis="primary"
|
|
359
|
-
filled
|
|
360
|
-
onClick={() => setPlaying(!playing)}
|
|
361
|
-
/>
|
|
362
|
-
<Widget.Action icon={SkipForward} label="Next" filled onClick={onNext} />
|
|
363
|
-
</div>
|
|
364
|
-
<div className="flex items-center justify-end">
|
|
365
|
-
{showShuffle && (
|
|
366
|
-
<Widget.Action
|
|
367
|
-
icon={Shuffle}
|
|
368
|
-
label="Shuffle"
|
|
369
|
-
pressed={shuffle}
|
|
370
|
-
color={tint}
|
|
371
|
-
onClick={() => setShuffle(!shuffle)}
|
|
372
|
-
/>
|
|
373
|
-
)}
|
|
374
|
-
{showRepeat && (
|
|
375
|
-
<Widget.Action
|
|
376
|
-
icon={repeat === 'one' ? Repeat1 : Repeat}
|
|
377
|
-
label={REPEAT_LABEL[repeat]}
|
|
378
|
-
pressed={repeat !== 'off'}
|
|
379
|
-
color={tint}
|
|
380
|
-
onClick={() => setRepeat(NEXT_REPEAT[repeat])}
|
|
381
|
-
/>
|
|
382
|
-
)}
|
|
383
|
-
{showLiked && (
|
|
384
|
-
<Widget.Action
|
|
385
|
-
icon={Heart}
|
|
386
|
-
label={liked ? 'Remove from library' : 'Add to library'}
|
|
387
|
-
pressed={liked}
|
|
388
|
-
filled={liked}
|
|
389
|
-
color={tint}
|
|
390
|
-
onClick={() => setLiked(!liked)}
|
|
391
|
-
/>
|
|
392
|
-
)}
|
|
393
|
-
</div>
|
|
478
|
+
{transport}
|
|
479
|
+
<div className="flex items-center justify-end">{toggles}</div>
|
|
394
480
|
</div>
|
|
395
481
|
</Widget>
|
|
396
482
|
</div>
|
|
@@ -101,7 +101,7 @@ const res = await fetch(
|
|
|
101
101
|
`https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}&timeformat=unixtime&timezone=auto` +
|
|
102
102
|
'¤t=temperature_2m,apparent_temperature,is_day,weather_code,wind_speed_10m,relative_humidity_2m,uv_index' +
|
|
103
103
|
'&hourly=temperature_2m,weather_code,is_day,precipitation_probability' +
|
|
104
|
-
'&daily=weather_code,temperature_2m_max,temperature_2m_min,precipitation_probability_max&forecast_days=
|
|
104
|
+
'&daily=weather_code,temperature_2m_max,temperature_2m_min,precipitation_probability_max,sunrise,sunset&forecast_days=7',
|
|
105
105
|
)
|
|
106
106
|
const { current, hourly, daily } = await res.json()
|
|
107
107
|
|
|
@@ -113,3 +113,11 @@ const hours: WeatherHour[] = hourly.time.map((time: number, i: number) => ({
|
|
|
113
113
|
precipitation: hourly.precipitation_probability[i],
|
|
114
114
|
}))
|
|
115
115
|
```
|
|
116
|
+
|
|
117
|
+
# Tall
|
|
118
|
+
|
|
119
|
+
`layout="tall"` at the island's tall snap: the hero larger, the next 24 hours as a strip with the temperature's curve and the chance of rain, the week on range bars, and the details beside it.
|
|
120
|
+
|
|
121
|
+
<WidgetIsland tab="weather" tall>
|
|
122
|
+
<Weather {...FORECAST} onRefresh={() => {}} layout="tall" />
|
|
123
|
+
</WidgetIsland>
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
'use client'
|
|
10
10
|
|
|
11
11
|
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
12
|
+
import Sparkline from '@justanarthur/modo-ui/components/data-display/sparkline'
|
|
12
13
|
import { type SizeVariant, useSize } from '@justanarthur/modo-ui/lib/size-context'
|
|
13
14
|
import { SURFACE_BG } from '@justanarthur/modo-ui/lib/surface-classes'
|
|
14
15
|
import { useLift } from '@justanarthur/modo-ui/lib/surface-context'
|
|
15
16
|
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
16
17
|
import Skeleton from '@justanarthur/modo-ui/primitives/content/skeleton'
|
|
18
|
+
import ScrollArea from '@justanarthur/modo-ui/primitives/layout/scroll-area'
|
|
17
19
|
import {
|
|
18
20
|
ArrowDown,
|
|
19
21
|
ArrowUp,
|
|
@@ -35,12 +37,16 @@ import {
|
|
|
35
37
|
Moon,
|
|
36
38
|
RotateCw,
|
|
37
39
|
Sun,
|
|
40
|
+
Sunrise,
|
|
41
|
+
Sunset,
|
|
42
|
+
Thermometer,
|
|
38
43
|
Umbrella,
|
|
39
44
|
WifiOff,
|
|
40
45
|
Wind,
|
|
41
46
|
} from 'lucide-react'
|
|
47
|
+
import type { ReactNode } from 'react'
|
|
42
48
|
import IslandFlash from '../../../components/island/island-flash'
|
|
43
|
-
import Widget from '../../../components/island/widget'
|
|
49
|
+
import Widget, { type WidgetLayout } from '../../../components/island/widget'
|
|
44
50
|
import { MINUTE, useEdgeClock } from '../../../lib/clock'
|
|
45
51
|
|
|
46
52
|
type WeatherCondition =
|
|
@@ -98,6 +104,10 @@ interface WeatherDay {
|
|
|
98
104
|
low: number
|
|
99
105
|
/** The day's highest chance of rain or snow, 0–100: `precipitation_probability_max`. */
|
|
100
106
|
precipitation?: number
|
|
107
|
+
/** When the sun rises, in epoch ms: `sunrise`. The tall layout lists today's. */
|
|
108
|
+
sunrise?: number
|
|
109
|
+
/** When the sun sets, in epoch ms: `sunset`. The tall layout lists today's. */
|
|
110
|
+
sunset?: number
|
|
101
111
|
}
|
|
102
112
|
|
|
103
113
|
interface WeatherProps {
|
|
@@ -125,6 +135,8 @@ interface WeatherProps {
|
|
|
125
135
|
onRequestAccess?: () => void
|
|
126
136
|
/** Called by Open System Settings while access is denied. */
|
|
127
137
|
onOpenSettings?: () => void
|
|
138
|
+
/** `tall` is the open island's tall snap: the hero larger, the next 24 hours as a scrolling strip with a temperature curve and the chance of rain, the week as rows with a range bar, and the wind, humidity, UV and the sun's times as details. Defaults to `'fit'`. */
|
|
139
|
+
layout?: WidgetLayout
|
|
128
140
|
/** Classes for the root, which fills its container. */
|
|
129
141
|
className?: string
|
|
130
142
|
}
|
|
@@ -172,10 +184,16 @@ const HUE: Record<WeatherCondition, string> = {
|
|
|
172
184
|
const HERO_GLYPH: Record<SizeVariant, number> = { default: 30, compact: 24 }
|
|
173
185
|
const STRIP_GLYPH: Record<SizeVariant, number> = { default: 16, compact: 14 }
|
|
174
186
|
|
|
187
|
+
const SHEET_GLYPH: Record<SizeVariant, number> = { default: 44, compact: 36 }
|
|
188
|
+
|
|
175
189
|
/** A chance of rain worth showing, in %. */
|
|
176
190
|
const WET = 30
|
|
177
191
|
/** Hours the strip shows. */
|
|
178
192
|
const HOURS = 6
|
|
193
|
+
/** Hours the tall layout's strip scrolls through. */
|
|
194
|
+
const DAY_HOURS = 24
|
|
195
|
+
/** Days the tall layout lists. */
|
|
196
|
+
const WEEK = 7
|
|
179
197
|
|
|
180
198
|
/**
|
|
181
199
|
* Open-Meteo's `weather_code` (WMO 4677) as a condition.
|
|
@@ -220,6 +238,18 @@ const speed = (kmh: number, unit: WeatherUnit) =>
|
|
|
220
238
|
const hourOf = (ms: number, locale?: Intl.LocalesArgument) =>
|
|
221
239
|
new Date(ms).toLocaleTimeString(locale, { hour: 'numeric' })
|
|
222
240
|
|
|
241
|
+
const clockOf = (ms: number, locale?: Intl.LocalesArgument) =>
|
|
242
|
+
new Date(ms).toLocaleTimeString(locale, { hour: 'numeric', minute: '2-digit' })
|
|
243
|
+
|
|
244
|
+
/** The UV index in the WHO's words. */
|
|
245
|
+
function uvLevel(uv: number) {
|
|
246
|
+
if (uv < 3) return 'Low'
|
|
247
|
+
if (uv < 6) return 'Moderate'
|
|
248
|
+
if (uv < 8) return 'High'
|
|
249
|
+
if (uv < 11) return 'Very high'
|
|
250
|
+
return 'Extreme'
|
|
251
|
+
}
|
|
252
|
+
|
|
223
253
|
function ago(ms: number) {
|
|
224
254
|
const minutes = Math.floor(ms / MINUTE)
|
|
225
255
|
if (minutes < 1) return 'Just now'
|
|
@@ -293,6 +323,110 @@ function Tomorrow({ day, unit }: { day: WeatherDay; unit: WeatherUnit }) {
|
|
|
293
323
|
)
|
|
294
324
|
}
|
|
295
325
|
|
|
326
|
+
interface StripProps {
|
|
327
|
+
hours: WeatherHour[]
|
|
328
|
+
unit: WeatherUnit
|
|
329
|
+
locale?: Intl.LocalesArgument
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** The tall layout's day ahead: a column per hour (hour, glyph, temperature, chance of rain) with the temperature's curve through them, scrolling sideways. */
|
|
333
|
+
function HourStrip({ hours, unit, locale }: StripProps) {
|
|
334
|
+
const size = useSize()
|
|
335
|
+
const temperatures = hours.map(hour => hour.temperature)
|
|
336
|
+
const low = Math.min(...temperatures)
|
|
337
|
+
const wet = hours.some(hour => (hour.precipitation ?? 0) >= WET)
|
|
338
|
+
return (
|
|
339
|
+
<ScrollArea orientation="horizontal" viewportClassName="scroll-fade-x">
|
|
340
|
+
<div className="flex w-max flex-col gap-1.5 pb-3 tabular-nums">
|
|
341
|
+
<div className="flex">
|
|
342
|
+
{hours.map((hour, i) => (
|
|
343
|
+
<div key={hour.time} className="flex w-12 shrink-0 flex-col items-center gap-1.5">
|
|
344
|
+
<span className="whitespace-nowrap text-caption text-muted-foreground">
|
|
345
|
+
{i === 0 ? 'Now' : hourOf(hour.time, locale)}
|
|
346
|
+
</span>
|
|
347
|
+
<Glyph
|
|
348
|
+
condition={hour.condition}
|
|
349
|
+
isDay={hour.isDay}
|
|
350
|
+
size={STRIP_GLYPH[size.variant]}
|
|
351
|
+
className={hueFor(hour.condition, hour.isDay)}
|
|
352
|
+
/>
|
|
353
|
+
</div>
|
|
354
|
+
))}
|
|
355
|
+
</div>
|
|
356
|
+
{/* Inset half a column, so each point sits over its hour. */}
|
|
357
|
+
<div className="px-6">
|
|
358
|
+
<Sparkline
|
|
359
|
+
values={temperatures.map(value => value - low)}
|
|
360
|
+
max={Math.max(...temperatures) - low}
|
|
361
|
+
label={`Temperature over the next ${hours.length} hours`}
|
|
362
|
+
tone="muted"
|
|
363
|
+
/>
|
|
364
|
+
</div>
|
|
365
|
+
<div className="flex">
|
|
366
|
+
{hours.map(hour => (
|
|
367
|
+
<div key={hour.time} className="flex w-12 shrink-0 flex-col items-center gap-0.5">
|
|
368
|
+
<span className="text-body text-foreground">{temp(hour.temperature, unit)}</span>
|
|
369
|
+
{wet && (
|
|
370
|
+
<span className="h-4 text-caption text-status-info">
|
|
371
|
+
{(hour.precipitation ?? 0) >= WET && `${hour.precipitation}%`}
|
|
372
|
+
</span>
|
|
373
|
+
)}
|
|
374
|
+
</div>
|
|
375
|
+
))}
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
</ScrollArea>
|
|
379
|
+
)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
interface WeekProps {
|
|
383
|
+
days: WeatherDay[]
|
|
384
|
+
unit: WeatherUnit
|
|
385
|
+
locale?: Intl.LocalesArgument
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** The tall layout's week: a row per day, its low and high on a bar spanning the week's range. */
|
|
389
|
+
function Week({ days, unit, locale }: WeekProps) {
|
|
390
|
+
const low = Math.min(...days.map(day => day.low))
|
|
391
|
+
const span = Math.max(...days.map(day => day.high)) - low || 1
|
|
392
|
+
return days.map((day, i) => (
|
|
393
|
+
<div key={day.date} className="flex h-8 min-w-0 items-center gap-3 text-body tabular-nums">
|
|
394
|
+
<span className="w-12 shrink-0 truncate text-foreground">
|
|
395
|
+
{i === 0 ? 'Today' : new Date(day.date).toLocaleDateString(locale, { weekday: 'short' })}
|
|
396
|
+
</span>
|
|
397
|
+
<Glyph condition={day.condition} size={16} className={hueFor(day.condition)} />
|
|
398
|
+
<span className="w-9 shrink-0 text-caption text-status-info">
|
|
399
|
+
{(day.precipitation ?? 0) >= WET && `${day.precipitation}%`}
|
|
400
|
+
</span>
|
|
401
|
+
<span className="w-8 shrink-0 text-right text-muted-foreground">{temp(day.low, unit)}</span>
|
|
402
|
+
<span className="relative h-1 min-w-12 flex-1 rounded-full bg-active">
|
|
403
|
+
<span
|
|
404
|
+
className="absolute inset-y-0 rounded-full bg-foreground"
|
|
405
|
+
style={{ left: `${((day.low - low) / span) * 100}%`, width: `${((day.high - day.low) / span) * 100}%` }}
|
|
406
|
+
/>
|
|
407
|
+
</span>
|
|
408
|
+
<span className="w-8 shrink-0 text-foreground">{temp(day.high, unit)}</span>
|
|
409
|
+
</div>
|
|
410
|
+
))
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
interface DetailProps {
|
|
414
|
+
icon: LucideIcon
|
|
415
|
+
label: string
|
|
416
|
+
children: ReactNode
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** One fact of the tall layout's details: a glyph, what it is, muted, and its value. */
|
|
420
|
+
function Detail({ icon: Icon, label, children }: DetailProps) {
|
|
421
|
+
return (
|
|
422
|
+
<div className="flex h-8 min-w-0 items-center gap-2 text-body">
|
|
423
|
+
<Icon aria-hidden size={14} strokeWidth={1.5} className="shrink-0 text-muted-foreground" />
|
|
424
|
+
<span className="min-w-0 flex-1 truncate text-muted-foreground">{label}</span>
|
|
425
|
+
<span className="shrink-0 whitespace-nowrap tabular-nums text-foreground">{children}</span>
|
|
426
|
+
</div>
|
|
427
|
+
)
|
|
428
|
+
}
|
|
429
|
+
|
|
296
430
|
/** The widget's shape while the first forecast loads: the header, the hero and the strip as placeholders. */
|
|
297
431
|
function Loading({ location, className }: { location?: string; className?: string }) {
|
|
298
432
|
return (
|
|
@@ -448,6 +582,16 @@ function WeatherAlert({
|
|
|
448
582
|
* (`"offline"`). Once there is a forecast, those keep it up and say so in
|
|
449
583
|
* the header instead.
|
|
450
584
|
*
|
|
585
|
+
* At the open island's tall snap (`layout="tall"`) it becomes a sheet: the
|
|
586
|
+
* hero larger, the condition, how warm it feels and today's high and low
|
|
587
|
+
* beside it; then the next 24 hours as a strip that scrolls sideways, each
|
|
588
|
+
* hour's glyph and temperature with the temperature's curve running through
|
|
589
|
+
* them and the chance of rain under each once any hour is wet; then, split
|
|
590
|
+
* by a hairline, the week as rows of day, glyph, chance of rain and the low
|
|
591
|
+
* and high on a bar spanning the week's range, and beside it the details:
|
|
592
|
+
* how warm it feels, the wind, the humidity, the UV index in words and
|
|
593
|
+
* today's sunrise and sunset (`sunrise` / `sunset` on the day).
|
|
594
|
+
*
|
|
451
595
|
* The other forms are parts: `Weather.Leading` and `Weather.Trailing` for
|
|
452
596
|
* the compact island's wings (the glyph and the temperature),
|
|
453
597
|
* `Weather.Minimal`, the glyph on a disc, for the split island's bubble,
|
|
@@ -470,6 +614,7 @@ const Weather = Object.assign(
|
|
|
470
614
|
onRefresh,
|
|
471
615
|
onRequestAccess,
|
|
472
616
|
onOpenSettings,
|
|
617
|
+
layout = 'fit',
|
|
473
618
|
className,
|
|
474
619
|
}: WeatherProps) {
|
|
475
620
|
const size = useSize()
|
|
@@ -544,6 +689,100 @@ const Weather = Object.assign(
|
|
|
544
689
|
status === 'offline' ? `Offline · ${fresh}` : status === 'error' ? `Not updated · ${fresh}` : fresh
|
|
545
690
|
const feels = current.apparent !== undefined && `Feels like ${temp(current.apparent, unit)}`
|
|
546
691
|
const soon = rain && `${LABEL[rain.condition]} around ${hourOf(rain.time, locale)}`
|
|
692
|
+
const header = (
|
|
693
|
+
<Widget.Header
|
|
694
|
+
icon={MapPin}
|
|
695
|
+
trailing={
|
|
696
|
+
<>
|
|
697
|
+
<span className="whitespace-nowrap pr-1 text-caption">{freshness}</span>
|
|
698
|
+
{onRefresh && <Widget.Action icon={RotateCw} label="Refresh" onClick={onRefresh} />}
|
|
699
|
+
</>
|
|
700
|
+
}
|
|
701
|
+
>
|
|
702
|
+
{location ?? 'Current location'}
|
|
703
|
+
</Widget.Header>
|
|
704
|
+
)
|
|
705
|
+
|
|
706
|
+
if (layout === 'tall') {
|
|
707
|
+
const week = days.slice(0, WEEK)
|
|
708
|
+
return (
|
|
709
|
+
<Widget.Sheet className={className}>
|
|
710
|
+
<div className="flex min-w-0 flex-col gap-2">
|
|
711
|
+
{header}
|
|
712
|
+
<div className="flex min-w-0 items-center gap-5">
|
|
713
|
+
<div className="flex shrink-0 items-center gap-3">
|
|
714
|
+
<Glyph
|
|
715
|
+
condition={current.condition}
|
|
716
|
+
isDay={current.isDay}
|
|
717
|
+
size={SHEET_GLYPH[size.variant]}
|
|
718
|
+
className={hueFor(current.condition, current.isDay)}
|
|
719
|
+
/>
|
|
720
|
+
<Widget.Figure value={degrees(current.temperature, unit)} unit={unit === 'fahrenheit' ? '°F' : '°C'} />
|
|
721
|
+
</div>
|
|
722
|
+
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
723
|
+
<Widget.Title>{LABEL[current.condition]}</Widget.Title>
|
|
724
|
+
{today && (
|
|
725
|
+
<Widget.Subtitle>
|
|
726
|
+
{[`H ${temp(today.high, unit)}`, `L ${temp(today.low, unit)}`, soon].filter(Boolean).join(' · ')}
|
|
727
|
+
</Widget.Subtitle>
|
|
728
|
+
)}
|
|
729
|
+
</div>
|
|
730
|
+
</div>
|
|
731
|
+
</div>
|
|
732
|
+
|
|
733
|
+
{ahead.length > 1 && (
|
|
734
|
+
<Widget.Section label="Next 24 hours">
|
|
735
|
+
<HourStrip hours={ahead.slice(0, DAY_HOURS)} unit={unit} locale={locale} />
|
|
736
|
+
</Widget.Section>
|
|
737
|
+
)}
|
|
738
|
+
|
|
739
|
+
<div className="flex min-w-0 items-start gap-5">
|
|
740
|
+
{week.length > 0 && (
|
|
741
|
+
<Widget.Section label={`${week.length}-day forecast`} className="flex-1">
|
|
742
|
+
<Week days={week} unit={unit} locale={locale} />
|
|
743
|
+
</Widget.Section>
|
|
744
|
+
)}
|
|
745
|
+
<Widget.Section label="Details" className="w-[38%] shrink-0 border-l border-border pl-5">
|
|
746
|
+
{current.apparent !== undefined && (
|
|
747
|
+
<Detail icon={Thermometer} label="Feels like">
|
|
748
|
+
{temp(current.apparent, unit)}
|
|
749
|
+
</Detail>
|
|
750
|
+
)}
|
|
751
|
+
{today?.precipitation !== undefined && (
|
|
752
|
+
<Detail icon={Umbrella} label="Chance of rain">
|
|
753
|
+
{today.precipitation}%
|
|
754
|
+
</Detail>
|
|
755
|
+
)}
|
|
756
|
+
{current.wind !== undefined && (
|
|
757
|
+
<Detail icon={Wind} label="Wind">
|
|
758
|
+
{speed(current.wind, unit)}
|
|
759
|
+
</Detail>
|
|
760
|
+
)}
|
|
761
|
+
{current.humidity !== undefined && (
|
|
762
|
+
<Detail icon={Droplets} label="Humidity">
|
|
763
|
+
{Math.round(current.humidity)}%
|
|
764
|
+
</Detail>
|
|
765
|
+
)}
|
|
766
|
+
{current.uv !== undefined && (
|
|
767
|
+
<Detail icon={Sun} label="UV index">
|
|
768
|
+
{Math.round(current.uv)} · {uvLevel(current.uv)}
|
|
769
|
+
</Detail>
|
|
770
|
+
)}
|
|
771
|
+
{today?.sunrise !== undefined && (
|
|
772
|
+
<Detail icon={Sunrise} label="Sunrise">
|
|
773
|
+
{clockOf(today.sunrise, locale)}
|
|
774
|
+
</Detail>
|
|
775
|
+
)}
|
|
776
|
+
{today?.sunset !== undefined && (
|
|
777
|
+
<Detail icon={Sunset} label="Sunset">
|
|
778
|
+
{clockOf(today.sunset, locale)}
|
|
779
|
+
</Detail>
|
|
780
|
+
)}
|
|
781
|
+
</Widget.Section>
|
|
782
|
+
</div>
|
|
783
|
+
</Widget.Sheet>
|
|
784
|
+
)
|
|
785
|
+
}
|
|
547
786
|
|
|
548
787
|
return (
|
|
549
788
|
<Widget
|
|
@@ -563,17 +802,7 @@ const Weather = Object.assign(
|
|
|
563
802
|
)
|
|
564
803
|
}
|
|
565
804
|
>
|
|
566
|
-
|
|
567
|
-
icon={MapPin}
|
|
568
|
-
trailing={
|
|
569
|
-
<>
|
|
570
|
-
<span className="whitespace-nowrap pr-1 text-caption">{freshness}</span>
|
|
571
|
-
{onRefresh && <Widget.Action icon={RotateCw} label="Refresh" onClick={onRefresh} />}
|
|
572
|
-
</>
|
|
573
|
-
}
|
|
574
|
-
>
|
|
575
|
-
{location ?? 'Current location'}
|
|
576
|
-
</Widget.Header>
|
|
805
|
+
{header}
|
|
577
806
|
|
|
578
807
|
<div className="flex min-w-0 items-center gap-2.5">
|
|
579
808
|
<Glyph
|
|
@@ -63,6 +63,8 @@ interface ExpandedIslandProps {
|
|
|
63
63
|
* at 720 × 240): build each one on the kit's Widget frame, so every tab has
|
|
64
64
|
* one hero set large, a muted line, its facts and quiet actions in the same
|
|
65
65
|
* places.
|
|
66
|
+
* Pulled down to a 560 px sheet the area is about 692 × 476: pass each
|
|
67
|
+
* block `layout="tall"` there, for its fuller view.
|
|
66
68
|
*
|
|
67
69
|
* Pass it as the Island's `expanded`; it reads the notch from the Island.
|
|
68
70
|
* Selection runs through `value` / `onValueChange`, or is kept here from
|
|
@@ -118,7 +120,7 @@ export default function ExpandedIsland({
|
|
|
118
120
|
<ScrollArea
|
|
119
121
|
key={tab?.value}
|
|
120
122
|
className="min-h-0 flex-1"
|
|
121
|
-
viewportClassName="scroll-fade [&>div]:flex [&>div]:min-h-full [&>div]:flex-col"
|
|
123
|
+
viewportClassName="scroll-fade [&>div]:flex [&>div]:min-h-full [&>div]:flex-col [&>div]:!min-w-0"
|
|
122
124
|
>
|
|
123
125
|
<motion.div
|
|
124
126
|
className="flex flex-1 flex-col py-1 [&>*]:flex-1"
|
|
@@ -32,3 +32,11 @@ Grouped rows: a label, what it does, the control at the end.
|
|
|
32
32
|
<MockWindow title="Settings">
|
|
33
33
|
<SettingsWindow name="Just Notch" defaultValue="plugin:clock" plugins={PLUGINS} permissions={PERMISSIONS} about={ABOUT} />
|
|
34
34
|
</MockWindow>
|
|
35
|
+
|
|
36
|
+
# Flush
|
|
37
|
+
|
|
38
|
+
`flush` drops the sidebar's left inset, for a host frame that sets its own edge, such as the open island.
|
|
39
|
+
|
|
40
|
+
<MockWindow title="Settings">
|
|
41
|
+
<SettingsWindow name="Just Notch" flush plugins={PLUGINS} permissions={PERMISSIONS} about={ABOUT} />
|
|
42
|
+
</MockWindow>
|