@justanarthur/modo-ui-notch 0.2.0 → 0.3.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.
- package/README.md +11 -11
- package/blocks/activities/agenda/examples.mdx +21 -5
- package/blocks/activities/agenda/index.tsx +291 -182
- package/blocks/activities/clock/examples.mdx +73 -0
- package/blocks/activities/clock/index.tsx +619 -0
- package/blocks/activities/now-playing/examples.mdx +32 -13
- package/blocks/activities/now-playing/index.tsx +319 -126
- package/blocks/activities/weather/examples.mdx +115 -0
- package/blocks/activities/weather/index.tsx +634 -0
- package/blocks/app/expanded-island/examples.mdx +8 -7
- package/blocks/app/expanded-island/index.tsx +19 -3
- package/blocks/app/settings-window/examples.mdx +6 -2
- package/blocks/app/settings-window/index.tsx +25 -7
- package/blocks/system/clipboard/examples.mdx +83 -0
- package/blocks/system/clipboard/index.tsx +563 -0
- package/blocks/system/recent-files/examples.mdx +66 -0
- package/blocks/system/recent-files/index.tsx +542 -0
- package/blocks/system/system-stats/examples.mdx +38 -9
- package/blocks/system/system-stats/index.tsx +241 -107
- package/components/indicators/media-scrubber/examples.mdx +8 -0
- package/components/indicators/media-scrubber/index.tsx +37 -13
- package/components/island/island/examples.mdx +4 -4
- package/components/island/island/index.tsx +2 -2
- package/components/island/island-flash/examples.mdx +15 -18
- package/components/island/island-flash/index.tsx +4 -4
- package/components/island/island-tabs/examples.mdx +5 -5
- package/components/island/widget/examples.mdx +76 -0
- package/components/island/widget/index.tsx +431 -0
- package/dist/blocks/activities/agenda/index.d.ts +1 -1
- package/dist/blocks/activities/agenda/index.js +3 -3
- package/dist/blocks/activities/clock/index.d.ts +2 -0
- package/dist/blocks/activities/clock/index.js +25 -0
- package/dist/blocks/activities/now-playing/index.d.ts +3 -2
- package/dist/blocks/activities/now-playing/index.js +5 -3
- package/dist/blocks/activities/weather/index.d.ts +2 -0
- package/dist/blocks/activities/weather/index.js +21 -0
- package/dist/blocks/app/expanded-island/index.d.ts +1 -1
- package/dist/blocks/app/expanded-island/index.js +4 -3
- 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 -0
- package/dist/blocks/system/clipboard/index.js +17 -0
- package/dist/blocks/system/recent-files/index.d.ts +2 -0
- package/dist/blocks/system/recent-files/index.js +19 -0
- package/dist/blocks/system/system-stats/index.d.ts +2 -2
- package/dist/blocks/system/system-stats/index.js +4 -1
- package/dist/components/indicators/media-scrubber/index.d.ts +1 -1
- package/dist/components/indicators/media-scrubber/index.js +1 -1
- package/dist/components/island/island/index.d.ts +1 -1
- package/dist/components/island/island/index.js +2 -2
- package/dist/components/island/island-flash/index.d.ts +1 -1
- package/dist/components/island/island-flash/index.js +1 -1
- package/dist/components/island/island-tabs/index.js +2 -2
- package/dist/components/island/widget/index.d.ts +2 -0
- package/dist/components/island/widget/index.js +30 -0
- package/dist/index.d.ts +15 -15
- package/dist/index.js +102 -58
- package/dist/lib/artwork.d.ts +2 -0
- package/dist/lib/artwork.js +8 -0
- package/dist/lib/geometry.js +1 -1
- package/dist/shared/chunk-2818esrq.d.ts +140 -0
- package/dist/shared/{chunk-yngkkxz2.d.ts → chunk-2m5dz8nf.d.ts} +4 -4
- package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
- package/dist/shared/chunk-416tsgbc.d.ts +175 -0
- package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
- package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
- package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
- package/dist/shared/chunk-9c7ewvkk.js +381 -0
- package/dist/shared/{chunk-mp1nx0ez.js → chunk-9m0xbg5v.js} +14 -3
- package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
- package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
- package/dist/shared/{chunk-s33y1pcq.js → chunk-cc9nwbtf.js} +20 -10
- package/dist/shared/chunk-da177e8r.d.ts +114 -0
- package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
- package/dist/shared/chunk-gejenfap.d.ts +25 -0
- package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
- package/dist/shared/chunk-j77cx8dp.js +498 -0
- package/dist/shared/chunk-mt0k6v8x.js +474 -0
- package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
- package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-pfhy5e4q.d.ts} +7 -1
- package/dist/shared/chunk-qdzemt2v.js +477 -0
- package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
- package/dist/shared/chunk-s2jeqqan.js +243 -0
- package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
- package/dist/shared/chunk-w5h6ay93.js +72 -0
- package/dist/shared/chunk-wkg17nxs.d.ts +101 -0
- package/dist/shared/chunk-x7f3g82r.js +285 -0
- package/dist/shared/chunk-xq5hc5gv.js +333 -0
- package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
- package/dist/shared/chunk-ym0xbses.js +518 -0
- package/dist/styles.css +97 -55
- package/index.ts +7 -6
- package/lib/artwork.ts +112 -0
- package/lib/geometry.ts +1 -1
- package/mock/activities.tsx +9 -32
- package/mock/artwork.tsx +13 -1
- package/mock/clipboard.tsx +79 -0
- package/mock/clock.tsx +77 -0
- package/mock/data.ts +30 -44
- package/mock/files.tsx +70 -0
- package/mock/island-content.tsx +43 -118
- package/mock/screen.tsx +76 -0
- package/mock/settings.tsx +370 -91
- package/mock/system.ts +46 -0
- package/mock/weather.tsx +105 -0
- package/package.json +7 -2
- package/blocks/activities/shelf/examples.mdx +0 -33
- package/blocks/activities/shelf/index.tsx +0 -289
- package/blocks/activities/timer/examples.mdx +0 -52
- package/blocks/activities/timer/index.tsx +0 -292
- package/blocks/system/controls/examples.mdx +0 -34
- package/blocks/system/controls/index.tsx +0 -167
- package/blocks/system/devices/examples.mdx +0 -25
- package/blocks/system/devices/index.tsx +0 -172
- package/blocks/system/power-alert/examples.mdx +0 -32
- package/blocks/system/power-alert/index.tsx +0 -89
- package/components/indicators/battery-glyph/examples.mdx +0 -22
- package/components/indicators/battery-glyph/index.tsx +0 -91
- package/dist/blocks/activities/shelf/index.d.ts +0 -2
- package/dist/blocks/activities/shelf/index.js +0 -14
- package/dist/blocks/activities/timer/index.d.ts +0 -2
- package/dist/blocks/activities/timer/index.js +0 -19
- package/dist/blocks/system/controls/index.d.ts +0 -2
- package/dist/blocks/system/controls/index.js +0 -10
- package/dist/blocks/system/devices/index.d.ts +0 -2
- package/dist/blocks/system/devices/index.js +0 -12
- package/dist/blocks/system/power-alert/index.d.ts +0 -2
- package/dist/blocks/system/power-alert/index.js +0 -9
- package/dist/components/indicators/battery-glyph/index.d.ts +0 -2
- package/dist/components/indicators/battery-glyph/index.js +0 -9
- package/dist/shared/chunk-2qpcsv5h.d.ts +0 -45
- package/dist/shared/chunk-45gytfr1.d.ts +0 -84
- package/dist/shared/chunk-50ffk4r7.d.ts +0 -69
- package/dist/shared/chunk-5w0yck07.d.ts +0 -32
- package/dist/shared/chunk-7hr53mby.js +0 -116
- package/dist/shared/chunk-b8jb1w72.js +0 -145
- package/dist/shared/chunk-cpewy6yg.js +0 -178
- package/dist/shared/chunk-e3e4s4ds.d.ts +0 -77
- package/dist/shared/chunk-enm6td0p.js +0 -280
- package/dist/shared/chunk-fvedaas2.d.ts +0 -33
- package/dist/shared/chunk-gex38j8x.d.ts +0 -82
- package/dist/shared/chunk-hwtxpzg0.js +0 -69
- package/dist/shared/chunk-phb53x1f.js +0 -252
- package/dist/shared/chunk-r8esmjfs.d.ts +0 -42
- package/dist/shared/chunk-rcp1g9ca.js +0 -70
- package/dist/shared/chunk-rx9sphz2.js +0 -266
- package/dist/shared/chunk-xdeek16r.d.ts +0 -58
- package/dist/shared/chunk-xkzjk1tq.js +0 -206
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justanarthur/modo-ui-notch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.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.
|
|
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>
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Local addition: a notch app's timer, from picking a length to "Time's up".
|
|
3
|
-
* Rebuilt from Just Notch's timer plugin (`Picker`, `Running`, `Ring`,
|
|
4
|
-
* `TimeUp`) as presentational parts: the run is a value the host may own.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
'use client'
|
|
8
|
-
|
|
9
|
-
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
10
|
-
import Meter from '@justanarthur/modo-ui/components/feedback/meter'
|
|
11
|
-
import NumberInput from '@justanarthur/modo-ui/components/inputs/number-input'
|
|
12
|
-
import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable-state'
|
|
13
|
-
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
14
|
-
import { Pause, Play, Plus, Timer as TimerIcon, X } from 'lucide-react'
|
|
15
|
-
import { type FormEvent, useState } from 'react'
|
|
16
|
-
import Countdown from '../../../components/indicators/countdown'
|
|
17
|
-
import IslandFlash from '../../../components/island/island-flash'
|
|
18
|
-
import { formatClock, MINUTE, SECOND, useEdgeClock } from '../../../lib/clock'
|
|
19
|
-
|
|
20
|
-
type TimerKind = 'focus' | 'break' | 'custom'
|
|
21
|
-
|
|
22
|
-
/** A run: running while it has `endsAt`, paused while it has `remaining`. */
|
|
23
|
-
interface TimerRun {
|
|
24
|
-
kind: TimerKind
|
|
25
|
-
/** Its whole length, in ms. */
|
|
26
|
-
total: number
|
|
27
|
-
/** When it ends, in epoch ms, while it runs. */
|
|
28
|
-
endsAt?: number
|
|
29
|
-
/** The time left, in ms, while it is paused. */
|
|
30
|
-
remaining?: number
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface TimerProps {
|
|
34
|
-
/** The run (controlled); `null` shows the picker. */
|
|
35
|
-
value?: TimerRun | null
|
|
36
|
-
/** The run at first (uncontrolled). Defaults to `null`. */
|
|
37
|
-
defaultValue?: TimerRun | null
|
|
38
|
-
/** Called with the run a start, pause, resume, +1 min or cancel leaves, and `null` when it ends. */
|
|
39
|
-
onValueChange?: (run: TimerRun | null) => void
|
|
40
|
-
/** Called when a run reaches zero, with the kind that starts next in a Pomodoro cycle. */
|
|
41
|
-
onEnd?: (run: TimerRun, next?: TimerKind) => void
|
|
42
|
-
/** The picker's quick lengths, in minutes, before the Pomodoro preset. Defaults to `[1, 5, 10]`. */
|
|
43
|
-
presets?: number[]
|
|
44
|
-
/** Pomodoro cycles: when a focus run ends a break starts on its own, then focus again. Defaults to `false`. */
|
|
45
|
-
pomodoro?: boolean
|
|
46
|
-
/** A focus run's length, in minutes. Defaults to `25`. */
|
|
47
|
-
focusMinutes?: number
|
|
48
|
-
/** A break's length, in minutes. Defaults to `5`. */
|
|
49
|
-
breakMinutes?: number
|
|
50
|
-
/** Classes for the root, which fills its container. */
|
|
51
|
-
className?: string
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const LABEL: Record<TimerKind, string> = { focus: 'Focus', break: 'Break', custom: 'Timer' }
|
|
55
|
-
|
|
56
|
-
const start = (minutes: number, kind: TimerKind): TimerRun => ({
|
|
57
|
-
kind,
|
|
58
|
-
total: minutes * MINUTE,
|
|
59
|
-
endsAt: Date.now() + minutes * MINUTE,
|
|
60
|
-
})
|
|
61
|
-
const pause = (run: TimerRun): TimerRun => ({ kind: run.kind, total: run.total, remaining: timeLeft(run, Date.now()) })
|
|
62
|
-
const resume = (run: TimerRun): TimerRun => ({
|
|
63
|
-
kind: run.kind,
|
|
64
|
-
total: run.total,
|
|
65
|
-
endsAt: Date.now() + (run.remaining ?? 0),
|
|
66
|
-
})
|
|
67
|
-
const addMinute = (run: TimerRun): TimerRun =>
|
|
68
|
-
run.endsAt === undefined
|
|
69
|
-
? { ...run, total: run.total + MINUTE, remaining: (run.remaining ?? 0) + MINUTE }
|
|
70
|
-
: { ...run, total: run.total + MINUTE, endsAt: run.endsAt + MINUTE }
|
|
71
|
-
|
|
72
|
-
/** The time a run has left at `now`, in ms. */
|
|
73
|
-
function timeLeft(run: TimerRun, now: number) {
|
|
74
|
-
return run.endsAt === undefined ? (run.remaining ?? 0) : Math.max(0, run.endsAt - now)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** The time left, re-read on each second's edge while the run runs, never in between. */
|
|
78
|
-
function useTimeLeft(run: TimerRun) {
|
|
79
|
-
const end = run.endsAt ?? 0
|
|
80
|
-
const now = useEdgeClock(end, run.endsAt !== undefined && Date.now() < end + SECOND)
|
|
81
|
-
return timeLeft(run, now)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function Ring({ run, className }: { run: TimerRun; className: string }) {
|
|
85
|
-
const left = useTimeLeft(run)
|
|
86
|
-
return (
|
|
87
|
-
<Meter
|
|
88
|
-
variant="ring"
|
|
89
|
-
label={`${LABEL[run.kind]}, ${formatClock(Math.ceil(left / SECOND))} left`}
|
|
90
|
-
value={run.total ? left / run.total : 0}
|
|
91
|
-
tone="default"
|
|
92
|
-
animate={false}
|
|
93
|
-
className={className}
|
|
94
|
-
/>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function Clock({ run, className, onEnd }: { run: TimerRun; className: string; onEnd?: () => void }) {
|
|
99
|
-
const paused = run.endsAt === undefined
|
|
100
|
-
return (
|
|
101
|
-
<Countdown
|
|
102
|
-
endsAt={run.endsAt}
|
|
103
|
-
paused={paused}
|
|
104
|
-
remaining={run.remaining}
|
|
105
|
-
onEnd={onEnd}
|
|
106
|
-
className={cn(className, paused ? 'text-muted-foreground' : 'text-status-warning')}
|
|
107
|
-
/>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** The compact island's left wing: the timer's glyph. */
|
|
112
|
-
function TimerLeading() {
|
|
113
|
-
return <TimerIcon size={16} strokeWidth={1.5} className="text-status-warning" />
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** The compact island's right wing: the time left, muted while paused. */
|
|
117
|
-
function TimerTrailing({ run }: { run: TimerRun }) {
|
|
118
|
-
return <Clock run={run} className="text-caption weight-medium" />
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** The split island's bubble: a ring of the time left. */
|
|
122
|
-
function TimerMinimal({ run }: { run: TimerRun }) {
|
|
123
|
-
return <Ring run={run} className="size-5.5" />
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
interface TimerDoneProps {
|
|
127
|
-
/** The run that ended. Defaults to `'custom'`. */
|
|
128
|
-
kind?: TimerKind
|
|
129
|
-
/** The kind a Pomodoro cycle starts next. */
|
|
130
|
-
next?: TimerKind
|
|
131
|
-
/** The next run's length, in minutes. */
|
|
132
|
-
minutes?: number
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** The island's flash when a run reaches zero: "Time's up", and what starts next in a Pomodoro cycle. */
|
|
136
|
-
function TimerDone({ kind = 'custom', next, minutes }: TimerDoneProps) {
|
|
137
|
-
const detail = next ? `${LABEL[next]} starts now${minutes ? ` · ${minutes} min` : ''}` : `${LABEL[kind]} finished`
|
|
138
|
-
return (
|
|
139
|
-
<IslandFlash icon={<TimerIcon size={20} strokeWidth={1.5} />} tone="warning" title="Time's up" caption={detail} />
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
interface PickerProps {
|
|
144
|
-
presets: number[]
|
|
145
|
-
focusMinutes: number
|
|
146
|
-
onStart: (run: TimerRun) => void
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function Picker({ presets, focusMinutes, onStart }: PickerProps) {
|
|
150
|
-
const [minutes, setMinutes] = useState<number | null>(null)
|
|
151
|
-
const valid = minutes !== null && Number.isInteger(minutes) && minutes >= 1 && minutes <= 99
|
|
152
|
-
const submit = (event: FormEvent) => {
|
|
153
|
-
event.preventDefault()
|
|
154
|
-
if (valid) onStart(start(minutes, 'custom'))
|
|
155
|
-
}
|
|
156
|
-
return (
|
|
157
|
-
<div className="flex size-full flex-col justify-center gap-3">
|
|
158
|
-
<div className="grid grid-cols-4 gap-2">
|
|
159
|
-
{presets.map(m => (
|
|
160
|
-
<Button key={m} variant="tertiary" onClick={() => onStart(start(m, 'custom'))}>
|
|
161
|
-
{m} min
|
|
162
|
-
</Button>
|
|
163
|
-
))}
|
|
164
|
-
<Button variant="tertiary" onClick={() => onStart(start(focusMinutes, 'focus'))}>
|
|
165
|
-
Pomodoro
|
|
166
|
-
</Button>
|
|
167
|
-
</div>
|
|
168
|
-
<form className="flex items-center gap-2" onSubmit={submit}>
|
|
169
|
-
<div className="min-w-0 flex-1">
|
|
170
|
-
<NumberInput
|
|
171
|
-
className="w-full"
|
|
172
|
-
variant="bordered"
|
|
173
|
-
min={1}
|
|
174
|
-
max={99}
|
|
175
|
-
placeholder="Custom minutes"
|
|
176
|
-
aria-label="Custom minutes"
|
|
177
|
-
endAdornment="min"
|
|
178
|
-
value={minutes}
|
|
179
|
-
onValueChange={setMinutes}
|
|
180
|
-
/>
|
|
181
|
-
</div>
|
|
182
|
-
<Button type="submit" variant="primary" leadingIcon={Play} disabled={!valid}>
|
|
183
|
-
Start
|
|
184
|
-
</Button>
|
|
185
|
-
</form>
|
|
186
|
-
</div>
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
interface RunningProps {
|
|
191
|
-
run: TimerRun
|
|
192
|
-
onChange: (run: TimerRun | null) => void
|
|
193
|
-
onEnd: () => void
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function Running({ run, onChange, onEnd }: RunningProps) {
|
|
197
|
-
const paused = run.endsAt === undefined
|
|
198
|
-
return (
|
|
199
|
-
<div className="flex size-full items-center gap-5">
|
|
200
|
-
<Ring run={run} className="size-16" />
|
|
201
|
-
<div className="flex min-w-0 flex-1 flex-col">
|
|
202
|
-
<span className="truncate text-caption text-muted-foreground">
|
|
203
|
-
{LABEL[run.kind]} · {Math.round(run.total / MINUTE)} min{paused ? ' · Paused' : ''}
|
|
204
|
-
</span>
|
|
205
|
-
<Clock run={run} className="text-display" onEnd={onEnd} />
|
|
206
|
-
</div>
|
|
207
|
-
<div className="flex shrink-0 items-center gap-2">
|
|
208
|
-
<Button variant="tertiary" leadingIcon={Plus} onClick={() => onChange(addMinute(run))}>
|
|
209
|
-
1 min
|
|
210
|
-
</Button>
|
|
211
|
-
<Button
|
|
212
|
-
variant="tertiary"
|
|
213
|
-
size="icon"
|
|
214
|
-
className="text-status-warning"
|
|
215
|
-
aria-label={paused ? 'Resume' : 'Pause'}
|
|
216
|
-
onClick={() => onChange(paused ? resume(run) : pause(run))}
|
|
217
|
-
>
|
|
218
|
-
{paused ? (
|
|
219
|
-
<Play size={16} strokeWidth={1.5} fill="currentColor" />
|
|
220
|
-
) : (
|
|
221
|
-
<Pause size={16} strokeWidth={1.5} fill="currentColor" />
|
|
222
|
-
)}
|
|
223
|
-
</Button>
|
|
224
|
-
<Button variant="tertiary" size="icon" aria-label="Cancel" onClick={() => onChange(null)}>
|
|
225
|
-
<X size={16} strokeWidth={1.5} />
|
|
226
|
-
</Button>
|
|
227
|
-
</div>
|
|
228
|
-
</div>
|
|
229
|
-
)
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* A notch app's timer: pick a length, watch it run down, hear when it's up.
|
|
234
|
-
*
|
|
235
|
-
* Without a run it shows the picker: quick lengths (`presets`), a Pomodoro
|
|
236
|
-
* focus run and a custom length in minutes on a NumberInput. A run shows a
|
|
237
|
-
* Meter ring of the time left beside the time itself in display type, with
|
|
238
|
-
* +1 min, pause / resume and cancel. The run is a value (`value` /
|
|
239
|
-
* `onValueChange`, or kept here from `defaultValue`): a running one carries
|
|
240
|
-
* when it ends, a paused one the time it had left, so a host can persist it
|
|
241
|
-
* and resume after a reload. The time re-renders once a second, on the
|
|
242
|
-
* second's edge, and nothing runs while it is paused.
|
|
243
|
-
*
|
|
244
|
-
* At zero it calls `onEnd` and clears the run, unless `pomodoro` cycles:
|
|
245
|
-
* then a focus run hands over to a break and a break back to focus.
|
|
246
|
-
*
|
|
247
|
-
* The other forms are parts: `Timer.Leading` and `Timer.Trailing` for the
|
|
248
|
-
* compact island's wings (the glyph and the time left), `Timer.Minimal` for
|
|
249
|
-
* the split island's bubble (the ring) and `Timer.Done`, the "Time's up"
|
|
250
|
-
* flash.
|
|
251
|
-
*
|
|
252
|
-
* @example {@include ./examples.mdx}
|
|
253
|
-
*/
|
|
254
|
-
function Timer({
|
|
255
|
-
value,
|
|
256
|
-
defaultValue = null,
|
|
257
|
-
onValueChange,
|
|
258
|
-
onEnd,
|
|
259
|
-
presets = [1, 5, 10],
|
|
260
|
-
pomodoro = false,
|
|
261
|
-
focusMinutes = 25,
|
|
262
|
-
breakMinutes = 5,
|
|
263
|
-
className,
|
|
264
|
-
}: TimerProps) {
|
|
265
|
-
const [run, setRun] = useControllableState(value, defaultValue, onValueChange)
|
|
266
|
-
|
|
267
|
-
const complete = (ended: TimerRun) => {
|
|
268
|
-
const next = pomodoro && ended.kind !== 'custom' ? (ended.kind === 'focus' ? 'break' : 'focus') : undefined
|
|
269
|
-
onEnd?.(ended, next)
|
|
270
|
-
setRun(next ? start(next === 'break' ? breakMinutes : focusMinutes, next) : null)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return (
|
|
274
|
-
<div className={cn('size-full', className)}>
|
|
275
|
-
{run ? (
|
|
276
|
-
<Running run={run} onChange={setRun} onEnd={() => complete(run)} />
|
|
277
|
-
) : (
|
|
278
|
-
<Picker presets={presets} focusMinutes={focusMinutes} onStart={setRun} />
|
|
279
|
-
)}
|
|
280
|
-
</div>
|
|
281
|
-
)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
Timer.Leading = TimerLeading
|
|
285
|
-
Timer.Trailing = TimerTrailing
|
|
286
|
-
Timer.Minimal = TimerMinimal
|
|
287
|
-
Timer.Done = TimerDone
|
|
288
|
-
|
|
289
|
-
export default Timer
|
|
290
|
-
|
|
291
|
-
export type { TimerDoneProps, TimerKind, TimerProps, TimerRun }
|
|
292
|
-
export { Timer, TimerDone, TimerLeading, TimerMinimal, TimerTrailing }
|