@justanarthur/modo-ui-notch 0.2.0 → 0.4.0

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.
Files changed (148) hide show
  1. package/README.md +11 -11
  2. package/blocks/activities/agenda/examples.mdx +29 -5
  3. package/blocks/activities/agenda/index.tsx +438 -181
  4. package/blocks/activities/clock/examples.mdx +89 -0
  5. package/blocks/activities/clock/index.tsx +917 -0
  6. package/blocks/activities/now-playing/examples.mdx +40 -13
  7. package/blocks/activities/now-playing/index.tsx +399 -120
  8. package/blocks/activities/weather/examples.mdx +123 -0
  9. package/blocks/activities/weather/index.tsx +863 -0
  10. package/blocks/app/expanded-island/examples.mdx +8 -7
  11. package/blocks/app/expanded-island/index.tsx +22 -4
  12. package/blocks/app/settings-window/examples.mdx +14 -2
  13. package/blocks/app/settings-window/index.tsx +33 -10
  14. package/blocks/system/clipboard/examples.mdx +91 -0
  15. package/blocks/system/clipboard/index.tsx +773 -0
  16. package/blocks/system/recent-files/examples.mdx +80 -0
  17. package/blocks/system/recent-files/index.tsx +627 -0
  18. package/blocks/system/system-stats/examples.mdx +46 -9
  19. package/blocks/system/system-stats/index.tsx +445 -104
  20. package/components/indicators/media-scrubber/examples.mdx +8 -0
  21. package/components/indicators/media-scrubber/index.tsx +37 -13
  22. package/components/island/island/examples.mdx +4 -4
  23. package/components/island/island/index.tsx +2 -2
  24. package/components/island/island-flash/examples.mdx +15 -18
  25. package/components/island/island-flash/index.tsx +4 -4
  26. package/components/island/island-tabs/examples.mdx +5 -5
  27. package/components/island/widget/examples.mdx +76 -0
  28. package/components/island/widget/index.tsx +465 -0
  29. package/dist/blocks/activities/agenda/index.d.ts +2 -1
  30. package/dist/blocks/activities/agenda/index.js +3 -3
  31. package/dist/blocks/activities/clock/index.d.ts +3 -0
  32. package/dist/blocks/activities/clock/index.js +25 -0
  33. package/dist/blocks/activities/now-playing/index.d.ts +4 -2
  34. package/dist/blocks/activities/now-playing/index.js +5 -3
  35. package/dist/blocks/activities/weather/index.d.ts +3 -0
  36. package/dist/blocks/activities/weather/index.js +21 -0
  37. package/dist/blocks/app/expanded-island/index.d.ts +1 -1
  38. package/dist/blocks/app/expanded-island/index.js +4 -3
  39. package/dist/blocks/app/settings-window/index.d.ts +1 -1
  40. package/dist/blocks/app/settings-window/index.js +1 -1
  41. package/dist/blocks/system/clipboard/index.d.ts +3 -0
  42. package/dist/blocks/system/clipboard/index.js +17 -0
  43. package/dist/blocks/system/recent-files/index.d.ts +3 -0
  44. package/dist/blocks/system/recent-files/index.js +19 -0
  45. package/dist/blocks/system/system-stats/index.d.ts +3 -2
  46. package/dist/blocks/system/system-stats/index.js +4 -1
  47. package/dist/components/indicators/media-scrubber/index.d.ts +1 -1
  48. package/dist/components/indicators/media-scrubber/index.js +1 -1
  49. package/dist/components/island/island/index.d.ts +1 -1
  50. package/dist/components/island/island/index.js +2 -2
  51. package/dist/components/island/island-flash/index.d.ts +1 -1
  52. package/dist/components/island/island-flash/index.js +1 -1
  53. package/dist/components/island/island-tabs/index.js +2 -2
  54. package/dist/components/island/widget/index.d.ts +2 -0
  55. package/dist/components/island/widget/index.js +32 -0
  56. package/dist/index.d.ts +15 -15
  57. package/dist/index.js +104 -58
  58. package/dist/lib/artwork.d.ts +2 -0
  59. package/dist/lib/artwork.js +8 -0
  60. package/dist/lib/geometry.js +1 -1
  61. package/dist/shared/{chunk-yngkkxz2.d.ts → chunk-0ym9mcqc.d.ts} +10 -6
  62. package/dist/shared/chunk-2b6gpn8k.js +444 -0
  63. package/dist/shared/chunk-3hcnf4yx.js +481 -0
  64. package/dist/shared/chunk-42wab62s.d.ts +197 -0
  65. package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
  66. package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-6tnq6p89.d.ts} +9 -1
  67. package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
  68. package/dist/shared/chunk-93dtpjz7.js +789 -0
  69. package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
  70. package/dist/shared/chunk-a6njb8db.d.ts +129 -0
  71. package/dist/shared/chunk-ab8mdg0n.d.ts +149 -0
  72. package/dist/shared/chunk-evqpf92s.d.ts +168 -0
  73. package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
  74. package/dist/shared/chunk-gcyspvgr.js +582 -0
  75. package/dist/shared/chunk-gejenfap.d.ts +25 -0
  76. package/dist/shared/chunk-gkj0hjrn.d.ts +136 -0
  77. package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
  78. package/dist/shared/chunk-n739am8j.d.ts +112 -0
  79. package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
  80. package/dist/shared/chunk-nwzpekvy.js +774 -0
  81. package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
  82. package/dist/shared/chunk-sbrtesdg.d.ts +138 -0
  83. package/dist/shared/chunk-swc7dqpw.d.ts +115 -0
  84. package/dist/shared/chunk-t9wqhgzt.js +765 -0
  85. package/dist/shared/chunk-w5h6ay93.js +72 -0
  86. package/dist/shared/{chunk-mp1nx0ez.js → chunk-wayv5rhr.js} +15 -4
  87. package/dist/shared/chunk-wf0jtzhs.js +295 -0
  88. package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
  89. package/dist/shared/chunk-yq5svpk7.js +524 -0
  90. package/dist/shared/{chunk-s33y1pcq.js → chunk-z3tj1ydg.js} +23 -10
  91. package/dist/styles.css +151 -49
  92. package/index.ts +7 -6
  93. package/lib/artwork.ts +112 -0
  94. package/lib/geometry.ts +1 -1
  95. package/mock/activities.tsx +9 -32
  96. package/mock/artwork.tsx +13 -1
  97. package/mock/clipboard.tsx +113 -0
  98. package/mock/clock.tsx +77 -0
  99. package/mock/data.ts +78 -44
  100. package/mock/files.tsx +83 -0
  101. package/mock/island-content.tsx +79 -122
  102. package/mock/screen.tsx +76 -0
  103. package/mock/settings.tsx +370 -91
  104. package/mock/system.ts +49 -0
  105. package/mock/weather.tsx +135 -0
  106. package/package.json +7 -2
  107. package/blocks/activities/shelf/examples.mdx +0 -33
  108. package/blocks/activities/shelf/index.tsx +0 -289
  109. package/blocks/activities/timer/examples.mdx +0 -52
  110. package/blocks/activities/timer/index.tsx +0 -292
  111. package/blocks/system/controls/examples.mdx +0 -34
  112. package/blocks/system/controls/index.tsx +0 -167
  113. package/blocks/system/devices/examples.mdx +0 -25
  114. package/blocks/system/devices/index.tsx +0 -172
  115. package/blocks/system/power-alert/examples.mdx +0 -32
  116. package/blocks/system/power-alert/index.tsx +0 -89
  117. package/components/indicators/battery-glyph/examples.mdx +0 -22
  118. package/components/indicators/battery-glyph/index.tsx +0 -91
  119. package/dist/blocks/activities/shelf/index.d.ts +0 -2
  120. package/dist/blocks/activities/shelf/index.js +0 -14
  121. package/dist/blocks/activities/timer/index.d.ts +0 -2
  122. package/dist/blocks/activities/timer/index.js +0 -19
  123. package/dist/blocks/system/controls/index.d.ts +0 -2
  124. package/dist/blocks/system/controls/index.js +0 -10
  125. package/dist/blocks/system/devices/index.d.ts +0 -2
  126. package/dist/blocks/system/devices/index.js +0 -12
  127. package/dist/blocks/system/power-alert/index.d.ts +0 -2
  128. package/dist/blocks/system/power-alert/index.js +0 -9
  129. package/dist/components/indicators/battery-glyph/index.d.ts +0 -2
  130. package/dist/components/indicators/battery-glyph/index.js +0 -9
  131. package/dist/shared/chunk-2qpcsv5h.d.ts +0 -45
  132. package/dist/shared/chunk-45gytfr1.d.ts +0 -84
  133. package/dist/shared/chunk-50ffk4r7.d.ts +0 -69
  134. package/dist/shared/chunk-5w0yck07.d.ts +0 -32
  135. package/dist/shared/chunk-7hr53mby.js +0 -116
  136. package/dist/shared/chunk-b8jb1w72.js +0 -145
  137. package/dist/shared/chunk-cpewy6yg.js +0 -178
  138. package/dist/shared/chunk-e3e4s4ds.d.ts +0 -77
  139. package/dist/shared/chunk-enm6td0p.js +0 -280
  140. package/dist/shared/chunk-fvedaas2.d.ts +0 -33
  141. package/dist/shared/chunk-gex38j8x.d.ts +0 -82
  142. package/dist/shared/chunk-hwtxpzg0.js +0 -69
  143. package/dist/shared/chunk-phb53x1f.js +0 -252
  144. package/dist/shared/chunk-r8esmjfs.d.ts +0 -42
  145. package/dist/shared/chunk-rcp1g9ca.js +0 -70
  146. package/dist/shared/chunk-rx9sphz2.js +0 -266
  147. package/dist/shared/chunk-xdeek16r.d.ts +0 -58
  148. package/dist/shared/chunk-xkzjk1tq.js +0 -206
@@ -0,0 +1,135 @@
1
+ /*!
2
+ * Mock: a forecast in Open-Meteo's shape for the weather's docs, read at
3
+ * today 14:20, and the island scenes around it. Nothing here ships in the
4
+ * barrel.
5
+ */
6
+
7
+ 'use client'
8
+
9
+ import { useState } from 'react'
10
+ import Weather, { type WeatherDay, type WeatherHour, type WeatherNow } from '../blocks/activities/weather'
11
+ import { FlashIsland, WingsIsland } from './screen'
12
+
13
+ const MINUTE = 60_000
14
+ const HOUR = 60 * MINUTE
15
+
16
+ const today = (hours: number, minutes = 0) => new Date().setHours(hours, minutes, 0, 0)
17
+
18
+ /** The moment the forecast is read at: today, 14:20. */
19
+ export const WEATHER_NOW = today(14, 20)
20
+
21
+ export const WEATHER_LOCATION = 'Bratislava'
22
+
23
+ export const CURRENT: WeatherNow = {
24
+ time: WEATHER_NOW - 5 * MINUTE,
25
+ temperature: 18.4,
26
+ apparent: 16.2,
27
+ condition: 'partly-cloudy',
28
+ isDay: true,
29
+ wind: 12,
30
+ humidity: 64,
31
+ uv: 4,
32
+ }
33
+
34
+ // Temperature, condition and chance of rain for a day from 14:00 on: a dry afternoon that turns wet by
35
+ // evening, clears overnight and comes up bright.
36
+ const DAY_AHEAD: [number, WeatherHour['condition'], number][] = [
37
+ [18.4, 'partly-cloudy', 5],
38
+ [19.1, 'partly-cloudy', 10],
39
+ [18.6, 'cloudy', 20],
40
+ [17.2, 'cloudy', 45],
41
+ [15.8, 'rain', 70],
42
+ [14.9, 'rain', 80],
43
+ [14.1, 'drizzle', 40],
44
+ [13.5, 'cloudy', 20],
45
+ [13.0, 'cloudy', 15],
46
+ [12.6, 'partly-cloudy', 10],
47
+ [12.1, 'partly-cloudy', 5],
48
+ [11.7, 'clear', 0],
49
+ [11.4, 'clear', 0],
50
+ [11.0, 'clear', 0],
51
+ [10.6, 'clear', 0],
52
+ [10.3, 'clear', 0],
53
+ [10.1, 'partly-cloudy', 0],
54
+ [10.4, 'partly-cloudy', 5],
55
+ [11.6, 'partly-cloudy', 5],
56
+ [13.0, 'clear', 0],
57
+ [14.3, 'clear', 0],
58
+ [15.2, 'partly-cloudy', 5],
59
+ [15.9, 'partly-cloudy', 10],
60
+ [16.1, 'cloudy', 20],
61
+ ]
62
+
63
+ export const HOURS: WeatherHour[] = DAY_AHEAD.map(([temperature, condition, precipitation], i) => {
64
+ const hour = (14 + i) % 24
65
+ return { time: today(14) + i * HOUR, temperature, condition, isDay: hour >= 7 && hour < 17, precipitation }
66
+ })
67
+
68
+ /** A clear night: the same strip, read at 22:00. */
69
+ export const NIGHT: { current: WeatherNow; hours: WeatherHour[] } = {
70
+ current: { ...CURRENT, time: today(22), temperature: 9.2, apparent: 7.4, condition: 'clear', isDay: false, uv: 0 },
71
+ hours: Array.from({ length: 6 }, (_, i) => ({
72
+ time: today(22) + i * HOUR,
73
+ temperature: 9 - i * 0.6,
74
+ condition: i < 3 ? 'clear' : 'partly-cloudy',
75
+ isDay: false,
76
+ precipitation: 0,
77
+ })),
78
+ }
79
+
80
+ // The week ahead, today first.
81
+ const WEEK: [WeatherDay['condition'], number, number, number][] = [
82
+ ['rain', 19.6, 11.2, 80],
83
+ ['drizzle', 16.1, 9.4, 40],
84
+ ['partly-cloudy', 17.3, 8.1, 10],
85
+ ['clear', 19.8, 7.6, 0],
86
+ ['cloudy', 15.4, 9.9, 25],
87
+ ['heavy-rain', 12.2, 8.4, 90],
88
+ ['partly-cloudy', 14.6, 6.3, 15],
89
+ ]
90
+
91
+ export const DAYS: WeatherDay[] = WEEK.map(([condition, high, low, precipitation], i) => ({
92
+ date: today(i * 24),
93
+ condition,
94
+ high,
95
+ low,
96
+ precipitation,
97
+ sunrise: today(i * 24 + 6, 58 + i),
98
+ sunset: today(i * 24 + 16, 12 - i),
99
+ }))
100
+
101
+ /** The forecast for `Weather`'s props. */
102
+ export const FORECAST = { location: WEATHER_LOCATION, current: CURRENT, hours: HOURS, days: DAYS, now: WEATHER_NOW }
103
+
104
+ /** The weather in the compact island's wings. */
105
+ export function WeatherWings() {
106
+ return (
107
+ <WingsIsland leading={<Weather.Leading current={CURRENT} />} trailing={<Weather.Trailing current={CURRENT} />} />
108
+ )
109
+ }
110
+
111
+ /** The weather in the wings, a clear night's glyph on the bubble. */
112
+ export function WeatherSplit() {
113
+ return (
114
+ <WingsIsland
115
+ leading={<Weather.Leading current={CURRENT} />}
116
+ trailing={<Weather.Trailing current={CURRENT} />}
117
+ minimal={<Weather.Minimal current={NIGHT.current} />}
118
+ />
119
+ )
120
+ }
121
+
122
+ /** Rain a quarter of an hour out, made once. */
123
+ export function RainSoonFlash() {
124
+ const startsAt = useState(() => Date.now() + 15 * MINUTE)[0]
125
+ return (
126
+ <FlashIsland>
127
+ <Weather.Alert
128
+ condition="rain"
129
+ startsAt={startsAt}
130
+ caption="Light rain for about an hour · 70%"
131
+ onAction={() => {}}
132
+ />
133
+ </FlashIsland>
134
+ )
135
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justanarthur/modo-ui-notch",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.4.0",
5
5
  "description": "A macOS notch app kit on modo-ui: the island that grows out of the notch (idle, compact, split, expanded, flash), its tabs across the wings and the pieces its activities show. Documented with modo.",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -75,6 +75,11 @@
75
75
  "source": "./lib/island-context.tsx",
76
76
  "default": "./dist/lib/island-context.js"
77
77
  },
78
+ "./lib/artwork": {
79
+ "types": "./dist/lib/artwork.d.ts",
80
+ "source": "./lib/artwork.ts",
81
+ "default": "./dist/lib/artwork.js"
82
+ },
78
83
  "./lib/clock": {
79
84
  "types": "./dist/lib/clock.d.ts",
80
85
  "source": "./lib/clock.ts",
@@ -106,7 +111,7 @@
106
111
  },
107
112
  "devDependencies": {
108
113
  "@justanarthur/modo": "1.1.0",
109
- "@justanarthur/modo-ui": "2.1.0",
114
+ "@justanarthur/modo-ui": "2.2.0",
110
115
  "@types/react": "^18.3.0",
111
116
  "@types/react-dom": "^18.3.0",
112
117
  "bunup": "^0.16.0",
@@ -1,33 +0,0 @@
1
- import Shelf from './index'
2
- import { FlashIsland, SHELF, WidgetIsland, WingsIsland } from '../../../mock/island-content'
3
-
4
- # Shelf
5
-
6
- Right-click a tile for Open, Show in Finder and Remove; Clear empties the shelf.
7
-
8
- <WidgetIsland tab="shelf">
9
- <Shelf defaultValue={SHELF} onAirDrop={() => {}} />
10
- </WidgetIsland>
11
-
12
- # Empty
13
-
14
- <WidgetIsland tab="shelf">
15
- <Shelf />
16
- </WidgetIsland>
17
-
18
- # Dropping
19
-
20
- `Shelf.Drop` while files hover over the notch, a dashed target in the brand hue, then once they land.
21
-
22
- <div className="flex w-full flex-col gap-3">
23
- <FlashIsland activity="dragging">
24
- <Shelf.Drop phase="dragging" count={2} />
25
- </FlashIsland>
26
- <FlashIsland activity="added">
27
- <Shelf.Drop phase="added" count={2} total={6} />
28
- </FlashIsland>
29
- </div>
30
-
31
- # Compact
32
-
33
- <WingsIsland leading={<Shelf.Leading />} trailing={<Shelf.Trailing count={6} />} />
@@ -1,289 +0,0 @@
1
- /*!
2
- * Local addition: a notch app's file shelf, the files dragged onto the notch
3
- * to keep for later. Rebuilt from Just Notch's shelf plugin (`Shelf`, `Tile`,
4
- * `DropFlash`, `Count`) as presentational parts: the files and what to do
5
- * with them come in as props.
6
- */
7
-
8
- 'use client'
9
-
10
- import Button from '@justanarthur/modo-ui/components/actions/button'
11
- import EmptyState from '@justanarthur/modo-ui/components/feedback/empty-state'
12
- import ContextMenu from '@justanarthur/modo-ui/components/overlays/context-menu'
13
- import { useReduceMotion } from '@justanarthur/modo-ui/lib/reduced-motion'
14
- import { spring } from '@justanarthur/modo-ui/lib/springs'
15
- import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable-state'
16
- import { cn } from '@justanarthur/modo-ui/lib/utils'
17
- import FluidHover from '@justanarthur/modo-ui/primitives/systems/fluid-hover'
18
- import {
19
- ArrowDownToLine,
20
- Check,
21
- File,
22
- FileArchive,
23
- FileAudio,
24
- FileCode,
25
- FileImage,
26
- Files,
27
- FileText,
28
- FileVideo,
29
- type LucideIcon,
30
- Send,
31
- Trash2,
32
- } from 'lucide-react'
33
- import { AnimatePresence, motion } from 'motion/react'
34
- import { type ReactNode, useRef } from 'react'
35
-
36
- interface ShelfFile {
37
- /** What tells it apart: its path. */
38
- id: string
39
- /** Its name, shown under the tile. */
40
- name: string
41
- /** A preview: an image URL, or any element. Without one, an icon for the file's type. */
42
- thumbnail?: string | ReactNode
43
- }
44
-
45
- interface ShelfProps {
46
- /** The files on the shelf, in order (controlled). */
47
- value?: ShelfFile[]
48
- /** The files at first (uncontrolled). Defaults to `[]`. */
49
- defaultValue?: ShelfFile[]
50
- /** Called with the files left after Remove or Clear. */
51
- onValueChange?: (files: ShelfFile[]) => void
52
- /** Called on a double-click or the menu's Open. */
53
- onOpen?: (file: ShelfFile) => void
54
- /** Called on the menu's Show in Finder. */
55
- onReveal?: (file: ShelfFile) => void
56
- /** Called with every file on AirDrop; without it the button hides. */
57
- onAirDrop?: (files: ShelfFile[]) => void
58
- /** Called when a tile starts to be dragged out, for the host to start a native drag. */
59
- onDragOut?: (file: ShelfFile) => void
60
- /** Classes for the root, which fills its container. */
61
- className?: string
62
- }
63
-
64
- const DRAG_SLOP_PX = 4
65
-
66
- const TYPES: [RegExp, LucideIcon][] = [
67
- [/\.(png|jpe?g|gif|webp|heic|svg|tiff?)$/i, FileImage],
68
- [/\.(mov|mp4|m4v|avi|mkv|webm)$/i, FileVideo],
69
- [/\.(mp3|m4a|wav|aiff?|flac|ogg)$/i, FileAudio],
70
- [/\.(zip|tar|gz|tgz|rar|7z|dmg)$/i, FileArchive],
71
- [/\.(m?[jt]sx?|json|css|html|swift|rs|go|py|rb|sh|ya?ml|toml)$/i, FileCode],
72
- [/\.(pdf|md|txt|rtf|docx?|pages|key|numbers|csv)$/i, FileText],
73
- ]
74
-
75
- /** The icon for a file's type, from its name's extension. */
76
- const iconFor = (name: string) => TYPES.find(([pattern]) => pattern.test(name))?.[1] ?? File
77
-
78
- const count = (n: number) => `${n} ${n === 1 ? 'file' : 'files'}`
79
-
80
- interface TileProps {
81
- file: ShelfFile
82
- index: number
83
- onOpen?: (file: ShelfFile) => void
84
- onReveal?: (file: ShelfFile) => void
85
- onRemove: (file: ShelfFile) => void
86
- onDragOut?: (file: ShelfFile) => void
87
- }
88
-
89
- function Thumbnail({ file }: { file: ShelfFile }) {
90
- const Icon = iconFor(file.name)
91
- return (
92
- <span className="flex size-14 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-3 text-muted-foreground">
93
- {typeof file.thumbnail === 'string' ? (
94
- <img alt="" src={file.thumbnail} draggable={false} className="size-full object-cover" />
95
- ) : (
96
- (file.thumbnail ?? <Icon size={20} strokeWidth={1.5} />)
97
- )}
98
- </span>
99
- )
100
- }
101
-
102
- function Tile({ file, index, onOpen, onReveal, onRemove, onDragOut }: TileProps) {
103
- const reduced = useReduceMotion()
104
- // The drag starts once the pointer moves: started on press, it would swallow the click and double-click.
105
- const press = useRef<{ x: number; y: number }>(undefined)
106
- return (
107
- <motion.div
108
- layout={!reduced}
109
- initial={{ opacity: 0, scale: reduced ? 1 : 0.9 }}
110
- animate={{ opacity: 1, scale: 1 }}
111
- exit={{ opacity: 0, scale: reduced ? 1 : 0.9, transition: spring.moderate.exit }}
112
- transition={spring.moderate}
113
- >
114
- <ContextMenu size="compact">
115
- <ContextMenu.Trigger>
116
- <FluidHover.Item
117
- index={index}
118
- title={file.name}
119
- className="h-auto w-20 flex-col items-center justify-start gap-1.5 p-1.5"
120
- onPointerDown={event => {
121
- if (event.button === 0) press.current = { x: event.clientX, y: event.clientY }
122
- }}
123
- onPointerMove={event => {
124
- const start = press.current
125
- if (!start || Math.hypot(event.clientX - start.x, event.clientY - start.y) < DRAG_SLOP_PX) return
126
- press.current = undefined
127
- onDragOut?.(file)
128
- }}
129
- onPointerUp={() => {
130
- press.current = undefined
131
- }}
132
- onDoubleClick={() => onOpen?.(file)}
133
- >
134
- <Thumbnail file={file} />
135
- <span className="w-full truncate text-center text-micro text-foreground">{file.name}</span>
136
- </FluidHover.Item>
137
- </ContextMenu.Trigger>
138
- <ContextMenu.Content className="dark text-foreground">
139
- <ContextMenu.Item index={0} label="Open" onSelect={() => onOpen?.(file)} />
140
- <ContextMenu.Item index={1} label="Show in Finder" onSelect={() => onReveal?.(file)} />
141
- <ContextMenu.Separator />
142
- <ContextMenu.Item index={2} icon={Trash2} label="Remove from shelf" onSelect={() => onRemove(file)} />
143
- </ContextMenu.Content>
144
- </ContextMenu>
145
- </motion.div>
146
- )
147
- }
148
-
149
- /** The compact island's left wing: the shelf's glyph. */
150
- function ShelfLeading() {
151
- return <Files size={16} strokeWidth={1.5} className="text-foreground" />
152
- }
153
-
154
- /** The compact island's right wing: how many files are on the shelf. */
155
- function ShelfTrailing({ count: n }: { count: number }) {
156
- return <span className="text-caption weight-medium tabular-nums text-foreground">{n}</span>
157
- }
158
-
159
- interface ShelfDropProps {
160
- /** `dragging` while files hover over the notch, `added` once they dropped. */
161
- phase: 'dragging' | 'added'
162
- /** How many files are being dragged, or were added. */
163
- count: number
164
- /** How many files the shelf holds once they dropped. Defaults to `count`. */
165
- total?: number
166
- /** Classes for the target. */
167
- className?: string
168
- }
169
-
170
- /** The island's flash while files are dragged over the notch: a dashed drop target, then a check once they land. */
171
- function ShelfDrop({ phase, count: n, total = n, className }: ShelfDropProps) {
172
- const reduced = useReduceMotion()
173
- const added = phase === 'added'
174
- return (
175
- <div
176
- className={cn(
177
- 'flex h-10 items-center gap-3 rounded-xl border px-3 transition-[border-color] duration-moderate',
178
- added ? 'border-transparent' : 'border-dashed border-brand',
179
- className,
180
- )}
181
- >
182
- <AnimatePresence initial={false} mode="popLayout">
183
- <motion.span
184
- key={phase}
185
- className={cn('flex shrink-0', added ? 'text-status-success' : 'text-brand')}
186
- initial={{ opacity: 0, scale: reduced ? 1 : 0.6 }}
187
- animate={{ opacity: 1, scale: 1 }}
188
- exit={{ opacity: 0, scale: reduced ? 1 : 0.6, transition: spring.fast.exit }}
189
- transition={spring.moderate}
190
- >
191
- {added ? <Check size={16} strokeWidth={2} /> : <ArrowDownToLine size={16} strokeWidth={1.5} />}
192
- </motion.span>
193
- </AnimatePresence>
194
- <span className="min-w-0 flex-1 truncate text-body weight-semibold text-foreground">
195
- {added ? 'Added to shelf' : 'Drop to shelf'}
196
- </span>
197
- <span className="shrink-0 text-caption tabular-nums text-muted-foreground">
198
- {added ? `${total} on shelf` : count(n)}
199
- </span>
200
- </div>
201
- )
202
- }
203
-
204
- /**
205
- * A notch app's shelf: files dragged onto the notch, kept in a strip to drag
206
- * out again, open, AirDrop or clear.
207
- *
208
- * Each file is a tile with its thumbnail, or an icon for its type, and its
209
- * name. A double-click opens it; a right-click (a long press on touch) opens
210
- * a ContextMenu with Open, Show in Finder and Remove from shelf, grown from
211
- * the press point; one fluid hover highlight runs along the strip, which
212
- * scrolls sideways when it holds more than fits. Moving a pressed tile calls
213
- * `onDragOut`, for the host to start a native drag. A header counts the
214
- * files and holds AirDrop and Clear. Removing and clearing change the files
215
- * through `value` / `onValueChange`, or here from `defaultValue`; tiles fade
216
- * in and out as the strip closes up. An empty shelf says how to fill it.
217
- *
218
- * The other forms are parts: `Shelf.Drop`, the flash while files hover over
219
- * the notch (a dashed drop target in the brand hue) and once they land;
220
- * `Shelf.Leading` and `Shelf.Trailing` for the compact island's wings.
221
- *
222
- * @example {@include ./examples.mdx}
223
- */
224
- function Shelf({
225
- value,
226
- defaultValue = [],
227
- onValueChange,
228
- onOpen,
229
- onReveal,
230
- onAirDrop,
231
- onDragOut,
232
- className,
233
- }: ShelfProps) {
234
- const [files, setFiles] = useControllableState(value, defaultValue, onValueChange)
235
-
236
- if (files.length === 0)
237
- return (
238
- <div className={cn('flex size-full items-center justify-center', className)}>
239
- <EmptyState
240
- size="compact"
241
- icon={Files}
242
- title="Shelf is empty"
243
- description="Drag files onto the notch to keep them here."
244
- />
245
- </div>
246
- )
247
-
248
- return (
249
- <div className={cn('flex size-full flex-col gap-2', className)}>
250
- <div className="flex shrink-0 items-center justify-between gap-3">
251
- <span className="text-caption tabular-nums text-muted-foreground">{count(files.length)}</span>
252
- <div className="-mr-3 flex items-center gap-1">
253
- {onAirDrop && (
254
- <Button variant="ghost" size="compact" leadingIcon={Send} onClick={() => onAirDrop(files)}>
255
- AirDrop
256
- </Button>
257
- )}
258
- <Button variant="ghost" size="compact" leadingIcon={Trash2} onClick={() => setFiles([])}>
259
- Clear
260
- </Button>
261
- </div>
262
- </div>
263
- <FluidHover axis="x" className="-mx-3 flex min-h-0 flex-1 items-start overflow-x-auto overflow-y-hidden px-1.5">
264
- <AnimatePresence initial={false}>
265
- {files.map((file, i) => (
266
- <Tile
267
- key={file.id}
268
- file={file}
269
- index={i}
270
- onOpen={onOpen}
271
- onReveal={onReveal}
272
- onRemove={removed => setFiles(files.filter(f => f.id !== removed.id))}
273
- onDragOut={onDragOut}
274
- />
275
- ))}
276
- </AnimatePresence>
277
- </FluidHover>
278
- </div>
279
- )
280
- }
281
-
282
- Shelf.Drop = ShelfDrop
283
- Shelf.Leading = ShelfLeading
284
- Shelf.Trailing = ShelfTrailing
285
-
286
- export default Shelf
287
-
288
- export type { ShelfDropProps, ShelfFile, ShelfProps }
289
- export { Shelf, ShelfDrop, ShelfLeading, ShelfTrailing }
@@ -1,52 +0,0 @@
1
- import Timer from './index'
2
- import { FlashIsland, WidgetIsland } from '../../../mock/island-content'
3
- import { RunningTimer, TimerSplit, TimerWings } from '../../../mock/activities'
4
-
5
- # Picker
6
-
7
- Quick lengths, a Pomodoro focus run, or any number of minutes.
8
-
9
- <WidgetIsland tab="timer">
10
- <Timer />
11
- </WidgetIsland>
12
-
13
- # Running
14
-
15
- The ring and the time left, with +1 min, pause and cancel. Pause it: the time holds.
16
-
17
- <WidgetIsland tab="timer">
18
- <RunningTimer />
19
- </WidgetIsland>
20
-
21
- # Pomodoro
22
-
23
- With `pomodoro`, a focus run hands over to a break at zero, then back to focus.
24
-
25
- <WidgetIsland tab="timer">
26
- <Timer pomodoro />
27
- </WidgetIsland>
28
-
29
- # Compact
30
-
31
- `Timer.Leading` and `Timer.Trailing` in the wings.
32
-
33
- <TimerWings />
34
-
35
- # Minimal
36
-
37
- `Timer.Minimal`, a ring of the time left, in the split island's bubble.
38
-
39
- <TimerSplit />
40
-
41
- # Time's up
42
-
43
- `Timer.Done`, and what a Pomodoro cycle starts next.
44
-
45
- <div className="flex w-full flex-col gap-3">
46
- <FlashIsland activity="custom">
47
- <Timer.Done />
48
- </FlashIsland>
49
- <FlashIsland activity="focus">
50
- <Timer.Done kind="focus" next="break" minutes={5} />
51
- </FlashIsland>
52
- </div>