@justanarthur/modo-ui-notch 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +75 -2
- package/blocks/activities/agenda/examples.mdx +74 -0
- package/blocks/activities/agenda/index.tsx +441 -0
- package/blocks/activities/clock/examples.mdx +73 -0
- package/blocks/activities/clock/index.tsx +619 -0
- package/blocks/activities/now-playing/examples.mdx +68 -0
- package/blocks/activities/now-playing/index.tsx +411 -0
- package/blocks/activities/weather/examples.mdx +115 -0
- package/blocks/activities/weather/index.tsx +634 -0
- package/blocks/app/expanded-island/examples.mdx +46 -0
- package/blocks/app/expanded-island/index.tsx +143 -0
- package/blocks/app/settings-window/examples.mdx +34 -0
- package/blocks/app/settings-window/index.tsx +375 -0
- 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 +52 -0
- package/blocks/system/system-stats/index.tsx +312 -0
- package/components/indicators/countdown/examples.mdx +25 -0
- package/components/indicators/countdown/index.tsx +83 -0
- package/components/indicators/equalizer/examples.mdx +20 -0
- package/components/indicators/equalizer/index.tsx +116 -0
- package/components/indicators/media-scrubber/examples.mdx +29 -0
- package/components/indicators/media-scrubber/index.tsx +122 -0
- package/components/island/island/examples.mdx +57 -0
- package/components/island/island/index.tsx +415 -0
- package/components/island/island-flash/examples.mdx +52 -0
- package/components/island/island-flash/index.tsx +79 -0
- package/components/island/island-tabs/examples.mdx +53 -0
- package/components/island/island-tabs/index.tsx +285 -0
- package/components/island/widget/examples.mdx +76 -0
- package/components/island/widget/index.tsx +431 -0
- package/dist/blocks/activities/agenda/index.d.ts +2 -0
- package/dist/blocks/activities/agenda/index.js +21 -0
- 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 -0
- package/dist/blocks/activities/now-playing/index.js +24 -0
- 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 +3 -0
- package/dist/blocks/app/expanded-island/index.js +11 -0
- package/dist/blocks/app/settings-window/index.d.ts +2 -0
- package/dist/blocks/app/settings-window/index.js +7 -0
- 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 -0
- package/dist/blocks/system/system-stats/index.js +15 -0
- package/dist/components/indicators/countdown/index.d.ts +2 -0
- package/dist/components/indicators/countdown/index.js +8 -0
- package/dist/components/indicators/equalizer/index.d.ts +2 -0
- package/dist/components/indicators/equalizer/index.js +7 -0
- package/dist/components/indicators/media-scrubber/index.d.ts +2 -0
- package/dist/components/indicators/media-scrubber/index.js +8 -0
- package/dist/components/island/island/index.d.ts +3 -0
- package/dist/components/island/island/index.js +10 -0
- package/dist/components/island/island-flash/index.d.ts +2 -0
- package/dist/components/island/island-flash/index.js +7 -0
- package/dist/components/island/island-tabs/index.d.ts +2 -0
- package/dist/components/island/island-tabs/index.js +9 -0
- package/dist/components/island/widget/index.d.ts +2 -0
- package/dist/components/island/widget/index.js +30 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +195 -0
- package/dist/lib/artwork.d.ts +2 -0
- package/dist/lib/artwork.js +8 -0
- package/dist/lib/clock.d.ts +2 -0
- package/dist/lib/clock.js +14 -0
- package/dist/lib/geometry.d.ts +2 -0
- package/dist/lib/geometry.js +24 -0
- package/dist/lib/island-context.d.ts +3 -0
- package/dist/lib/island-context.js +8 -0
- package/dist/lib/motion.d.ts +21 -0
- package/dist/lib/motion.js +16 -0
- package/dist/shared/chunk-152gpyq3.d.ts +13 -0
- package/dist/shared/chunk-2818esrq.d.ts +140 -0
- package/dist/shared/chunk-2f7zxrbk.js +65 -0
- package/dist/shared/chunk-2m5dz8nf.d.ts +88 -0
- package/dist/shared/chunk-2s4q6mt0.js +27 -0
- package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
- package/dist/shared/chunk-416tsgbc.d.ts +175 -0
- package/dist/shared/chunk-502rmtap.js +54 -0
- package/dist/shared/chunk-52gb3g6r.d.ts +12 -0
- package/dist/shared/chunk-5en5aaj1.d.ts +33 -0
- package/dist/shared/chunk-61t2dfte.js +63 -0
- package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
- package/dist/shared/chunk-81fpptwp.d.ts +75 -0
- package/dist/shared/chunk-9c7ewvkk.js +381 -0
- package/dist/shared/chunk-9m0xbg5v.js +112 -0
- package/dist/shared/chunk-9xtcv3sy.js +88 -0
- package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
- package/dist/shared/chunk-cc9nwbtf.js +315 -0
- package/dist/shared/chunk-cfzmfnyh.d.ts +63 -0
- package/dist/shared/chunk-d5qm9cps.js +10 -0
- package/dist/shared/chunk-da177e8r.d.ts +114 -0
- package/dist/shared/chunk-fexwzycv.d.ts +36 -0
- package/dist/shared/chunk-gb56m10p.js +39 -0
- package/dist/shared/chunk-gejenfap.d.ts +25 -0
- package/dist/shared/chunk-hrpxbqmx.d.ts +28 -0
- package/dist/shared/chunk-j755a1a5.d.ts +41 -0
- package/dist/shared/chunk-j77cx8dp.js +498 -0
- package/dist/shared/chunk-mt0k6v8x.js +474 -0
- package/dist/shared/chunk-ndf79pv5.js +58 -0
- package/dist/shared/chunk-pfhy5e4q.d.ts +53 -0
- package/dist/shared/chunk-qdzemt2v.js +477 -0
- package/dist/shared/chunk-r471sknr.js +209 -0
- package/dist/shared/chunk-s2jeqqan.js +243 -0
- package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
- package/dist/shared/chunk-w48eyvfr.d.ts +56 -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-y0188bbn.js +331 -0
- package/dist/shared/chunk-ym0xbses.js +518 -0
- package/dist/styles.css +264 -0
- package/index.ts +22 -0
- package/lib/artwork.ts +112 -0
- package/lib/clock.ts +53 -0
- package/lib/geometry.ts +130 -0
- package/lib/island-context.tsx +24 -0
- package/lib/motion.ts +42 -0
- package/mock/activities.tsx +77 -0
- package/mock/artwork.tsx +37 -0
- package/mock/clipboard.tsx +79 -0
- package/mock/clock.tsx +77 -0
- package/mock/data.ts +139 -0
- package/mock/desktop.tsx +83 -0
- package/mock/files.tsx +70 -0
- package/mock/fit.ts +26 -0
- package/mock/island-content.tsx +142 -0
- package/mock/scene.tsx +52 -0
- package/mock/screen.tsx +76 -0
- package/mock/settings.tsx +489 -0
- package/mock/system.ts +46 -0
- package/mock/weather.tsx +105 -0
- package/package.json +122 -4
package/dist/styles.css
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/* @justanarthur/modo-ui-notch: load after @justanarthur/modo-ui/styles.css. */
|
|
2
|
+
@layer properties, default;
|
|
3
|
+
/* layer: properties */
|
|
4
|
+
@layer properties{
|
|
5
|
+
@property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
|
|
6
|
+
@property --un-outline-style{syntax:"*";inherits:false;initial-value:solid;}
|
|
7
|
+
@property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
|
|
8
|
+
@property --un-bg-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
|
|
9
|
+
@property --un-inset-ring-color{syntax:"*";inherits:false;}
|
|
10
|
+
@property --un-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000;}
|
|
11
|
+
@property --un-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000;}
|
|
12
|
+
@property --un-inset-shadow-color{syntax:"*";inherits:false;}
|
|
13
|
+
@property --un-ring-color{syntax:"*";inherits:false;}
|
|
14
|
+
@property --un-ring-inset{syntax:"*";inherits:false;}
|
|
15
|
+
@property --un-ring-offset-color{syntax:"*";inherits:false;}
|
|
16
|
+
@property --un-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000;}
|
|
17
|
+
@property --un-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0px;}
|
|
18
|
+
@property --un-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000;}
|
|
19
|
+
@property --un-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000;}
|
|
20
|
+
@property --un-shadow-color{syntax:"*";inherits:false;}
|
|
21
|
+
@property --un-ring-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
|
|
22
|
+
@property --un-ease{syntax:"*";inherits:false;}
|
|
23
|
+
@property --un-fill-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
|
|
24
|
+
@property --un-blur{syntax:"*";inherits:false;}
|
|
25
|
+
@property --un-brightness{syntax:"*";inherits:false;}
|
|
26
|
+
@property --un-contrast{syntax:"*";inherits:false;}
|
|
27
|
+
@property --un-drop-shadow{syntax:"*";inherits:false;}
|
|
28
|
+
@property --un-grayscale{syntax:"*";inherits:false;}
|
|
29
|
+
@property --un-hue-rotate{syntax:"*";inherits:false;}
|
|
30
|
+
@property --un-invert{syntax:"*";inherits:false;}
|
|
31
|
+
@property --un-saturate{syntax:"*";inherits:false;}
|
|
32
|
+
@property --un-sepia{syntax:"*";inherits:false;}
|
|
33
|
+
@property --un-numeric-figure{syntax:"*";inherits:false;}
|
|
34
|
+
@property --un-numeric-fraction{syntax:"*";inherits:false;}
|
|
35
|
+
@property --un-numeric-spacing{syntax:"*";inherits:false;}
|
|
36
|
+
@property --un-ordinal{syntax:"*";inherits:false;}
|
|
37
|
+
@property --un-slashed-zero{syntax:"*";inherits:false;}
|
|
38
|
+
}
|
|
39
|
+
/* layer: default */
|
|
40
|
+
@layer default{
|
|
41
|
+
.\[\&_circle\:last-child\]\:text-status-success circle:last-child,
|
|
42
|
+
.text-status-success{color:color-mix(in srgb, var(--status-success) var(--un-text-opacity), transparent);}
|
|
43
|
+
.\[\&_circle\:last-child\]\:text-status-warning circle:last-child,
|
|
44
|
+
.text-status-warning{color:color-mix(in srgb, var(--status-warning) var(--un-text-opacity), transparent);}
|
|
45
|
+
.text-border{color:color-mix(in srgb, var(--border) var(--un-text-opacity), transparent);}
|
|
46
|
+
.text-foreground{color:color-mix(in srgb, var(--foreground) var(--un-text-opacity), transparent);}
|
|
47
|
+
.text-muted-foreground{color:color-mix(in srgb, var(--muted-foreground) var(--un-text-opacity), transparent);}
|
|
48
|
+
.text-status-error{color:color-mix(in srgb, var(--status-error) var(--un-text-opacity), transparent);}
|
|
49
|
+
.text-status-info{color:color-mix(in srgb, var(--status-info) var(--un-text-opacity), transparent);}
|
|
50
|
+
.font-mono{font-family:var(--font-mono);}
|
|
51
|
+
.tab{-moz-tab-size:4;-o-tab-size:4;tab-size:4;}
|
|
52
|
+
.-m-1{margin:calc(var(--spacing) * -1);}
|
|
53
|
+
.m-0{margin:calc(var(--spacing) * 0);}
|
|
54
|
+
.-mx-2{margin-inline:calc(var(--spacing) * -2);}
|
|
55
|
+
.-my-1{margin-block:calc(var(--spacing) * -1);}
|
|
56
|
+
.mx-auto{margin-inline:auto;}
|
|
57
|
+
.-ml-2{margin-left:calc(var(--spacing) * -2);}
|
|
58
|
+
.-mr-1{margin-right:calc(var(--spacing) * -1);}
|
|
59
|
+
.-mr-2{margin-right:calc(var(--spacing) * -2);}
|
|
60
|
+
.mb-0{margin-bottom:calc(var(--spacing) * 0);}
|
|
61
|
+
.mb-1{margin-bottom:calc(var(--spacing) * 1);}
|
|
62
|
+
.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5);}
|
|
63
|
+
.ml-1{margin-left:calc(var(--spacing) * 1);}
|
|
64
|
+
.ml-1\.5{margin-left:calc(var(--spacing) * 1.5);}
|
|
65
|
+
.mt-1{margin-top:calc(var(--spacing) * 1);}
|
|
66
|
+
.mt-1\.5{margin-top:calc(var(--spacing) * 1.5);}
|
|
67
|
+
.mt-2{margin-top:calc(var(--spacing) * 2);}
|
|
68
|
+
.p-1{padding:calc(var(--spacing) * 1);}
|
|
69
|
+
.p-8{padding:calc(var(--spacing) * 8);}
|
|
70
|
+
.px{padding-inline:calc(var(--spacing) * 4);}
|
|
71
|
+
.px-2{padding-inline:calc(var(--spacing) * 2);}
|
|
72
|
+
.px-5{padding-inline:calc(var(--spacing) * 5);}
|
|
73
|
+
.py-1{padding-block:calc(var(--spacing) * 1);}
|
|
74
|
+
.pb{padding-bottom:calc(var(--spacing) * 4);}
|
|
75
|
+
.pb-1{padding-bottom:calc(var(--spacing) * 1);}
|
|
76
|
+
.pb-3{padding-bottom:calc(var(--spacing) * 3);}
|
|
77
|
+
.pl-17\.5{padding-left:calc(var(--spacing) * 17.5);}
|
|
78
|
+
.pl-4{padding-left:calc(var(--spacing) * 4);}
|
|
79
|
+
.pl-4\.5{padding-left:calc(var(--spacing) * 4.5);}
|
|
80
|
+
.pl-5{padding-left:calc(var(--spacing) * 5);}
|
|
81
|
+
.pr{padding-right:calc(var(--spacing) * 4);}
|
|
82
|
+
.pr-1{padding-right:calc(var(--spacing) * 1);}
|
|
83
|
+
.pr-3{padding-right:calc(var(--spacing) * 3);}
|
|
84
|
+
.text-right{text-align:right;}
|
|
85
|
+
.outline{outline-style:var(--un-outline-style);outline-width:1px;}
|
|
86
|
+
.outline-none{--un-outline-style:none;outline-style:none;}
|
|
87
|
+
.b{border-width:1px;}
|
|
88
|
+
.border-l{border-left-width:1px;}
|
|
89
|
+
.border-border{border-color:color-mix(in srgb, var(--border) var(--un-border-opacity), transparent);}
|
|
90
|
+
.rounded-\[inherit\]{border-radius:inherit;}
|
|
91
|
+
.rounded-2xl{border-radius:var(--radius-2xl);}
|
|
92
|
+
.rounded-full{border-radius:calc(infinity * 1px);}
|
|
93
|
+
.rounded-lg{border-radius:var(--radius-lg);}
|
|
94
|
+
.rounded-md{border-radius:var(--radius-md);}
|
|
95
|
+
.rounded-sm{border-radius:var(--radius-sm);}
|
|
96
|
+
.rounded-xl{border-radius:var(--radius-xl);}
|
|
97
|
+
.bg-active{background-color:color-mix(in srgb, var(--active) var(--un-bg-opacity), transparent);}
|
|
98
|
+
.bg-current{background-color:currentColor;}
|
|
99
|
+
.bg-foreground{background-color:color-mix(in srgb, var(--foreground) var(--un-bg-opacity), transparent);}
|
|
100
|
+
.bg-ink{background-color:color-mix(in srgb, var(--ink) var(--un-bg-opacity), transparent);}
|
|
101
|
+
.bg-status-error\/16{background-color:color-mix(in srgb, var(--status-error) 16%, transparent);}
|
|
102
|
+
.bg-status-info\/16{background-color:color-mix(in srgb, var(--status-info) 16%, transparent);}
|
|
103
|
+
.bg-status-success{background-color:color-mix(in srgb, var(--status-success) var(--un-bg-opacity), transparent);}
|
|
104
|
+
.bg-status-success\/16{background-color:color-mix(in srgb, var(--status-success) 16%, transparent);}
|
|
105
|
+
.bg-status-warning{background-color:color-mix(in srgb, var(--status-warning) var(--un-bg-opacity), transparent);}
|
|
106
|
+
.bg-status-warning\/16{background-color:color-mix(in srgb, var(--status-warning) 16%, transparent);}
|
|
107
|
+
.bg-transparent{background-color:transparent;}
|
|
108
|
+
.opacity-0,
|
|
109
|
+
.group\/scrub:focus-within .group-focus-within\/scrub\:opacity-0,
|
|
110
|
+
.group\/scrub:hover .group-hover\/scrub\:opacity-0{opacity:0%;}
|
|
111
|
+
.opacity-70{opacity:70%;}
|
|
112
|
+
.group\/scrub:focus-within .group-focus-within\/scrub\:opacity-100,
|
|
113
|
+
.group\/scrub:hover .group-hover\/scrub\:opacity-100{opacity:100%;}
|
|
114
|
+
.\@container{container-type:inline-size;}
|
|
115
|
+
.\[\&\>div\]\:flex>div,
|
|
116
|
+
.flex{display:flex;}
|
|
117
|
+
.inline-flex{display:inline-flex;}
|
|
118
|
+
.\[\&\>\*\]\:flex-1>*,
|
|
119
|
+
.flex-1{flex:1 1 0%;}
|
|
120
|
+
.shrink-0{flex-shrink:0;}
|
|
121
|
+
.last\:shrink-\[100\]:last-child{flex-shrink:100;}
|
|
122
|
+
.grow{flex-grow:1;}
|
|
123
|
+
.\[\&\>div\]\:flex-col>div,
|
|
124
|
+
.flex-col{flex-direction:column;}
|
|
125
|
+
.gap-0{gap:calc(var(--spacing) * 0);}
|
|
126
|
+
.gap-0\.5{gap:calc(var(--spacing) * 0.5);}
|
|
127
|
+
.gap-1{gap:calc(var(--spacing) * 1);}
|
|
128
|
+
.gap-1\.5{gap:calc(var(--spacing) * 1.5);}
|
|
129
|
+
.gap-2{gap:calc(var(--spacing) * 2);}
|
|
130
|
+
.gap-2\.5{gap:calc(var(--spacing) * 2.5);}
|
|
131
|
+
.gap-3{gap:calc(var(--spacing) * 3);}
|
|
132
|
+
.gap-4{gap:calc(var(--spacing) * 4);}
|
|
133
|
+
.gap-5{gap:calc(var(--spacing) * 5);}
|
|
134
|
+
.gap-8{gap:calc(var(--spacing) * 8);}
|
|
135
|
+
.grid{display:grid;}
|
|
136
|
+
.grid-cols-\[1fr_auto_1fr\]{grid-template-columns:1fr auto 1fr;}
|
|
137
|
+
.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr));}
|
|
138
|
+
.size-1\.5{width:calc(var(--spacing) * 1.5);height:calc(var(--spacing) * 1.5);}
|
|
139
|
+
.size-12{width:calc(var(--spacing) * 12);height:calc(var(--spacing) * 12);}
|
|
140
|
+
.size-2\.5{width:calc(var(--spacing) * 2.5);height:calc(var(--spacing) * 2.5);}
|
|
141
|
+
.size-20{width:calc(var(--spacing) * 20);height:calc(var(--spacing) * 20);}
|
|
142
|
+
.size-24{width:calc(var(--spacing) * 24);height:calc(var(--spacing) * 24);}
|
|
143
|
+
.size-28{width:calc(var(--spacing) * 28);height:calc(var(--spacing) * 28);}
|
|
144
|
+
.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5);}
|
|
145
|
+
.size-36{width:calc(var(--spacing) * 36);height:calc(var(--spacing) * 36);}
|
|
146
|
+
.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4);}
|
|
147
|
+
.size-5\.5{width:calc(var(--spacing) * 5.5);height:calc(var(--spacing) * 5.5);}
|
|
148
|
+
.size-6{width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6);}
|
|
149
|
+
.size-8{width:calc(var(--spacing) * 8);height:calc(var(--spacing) * 8);}
|
|
150
|
+
.size-9{width:calc(var(--spacing) * 9);height:calc(var(--spacing) * 9);}
|
|
151
|
+
.size-full{width:100%;height:100%;}
|
|
152
|
+
.\[\&\>div\]\:min-h-full>div{min-height:100%;}
|
|
153
|
+
.h-1{height:calc(var(--spacing) * 1);}
|
|
154
|
+
.h-14{height:calc(var(--spacing) * 14);}
|
|
155
|
+
.h-24{height:calc(var(--spacing) * 24);}
|
|
156
|
+
.h-3{height:calc(var(--spacing) * 3);}
|
|
157
|
+
.h-3\.5{height:calc(var(--spacing) * 3.5);}
|
|
158
|
+
.h-4{height:calc(var(--spacing) * 4);}
|
|
159
|
+
.h-5{height:calc(var(--spacing) * 5);}
|
|
160
|
+
.h-6{height:calc(var(--spacing) * 6);}
|
|
161
|
+
.h-7{height:calc(var(--spacing) * 7);}
|
|
162
|
+
.h-8{height:calc(var(--spacing) * 8);}
|
|
163
|
+
.h-9{height:calc(var(--spacing) * 9);}
|
|
164
|
+
.h-full{height:100%;}
|
|
165
|
+
.h2{height:calc(var(--spacing) * 2);}
|
|
166
|
+
.h23{height:calc(var(--spacing) * 23);}
|
|
167
|
+
.max-w-120{max-width:calc(var(--spacing) * 120);}
|
|
168
|
+
.max-w-160{max-width:calc(var(--spacing) * 160);}
|
|
169
|
+
.max-w-24{max-width:calc(var(--spacing) * 24);}
|
|
170
|
+
.min-h-0{min-height:calc(var(--spacing) * 0);}
|
|
171
|
+
.min-w-0{min-width:calc(var(--spacing) * 0);}
|
|
172
|
+
.min-w-full{min-width:100%;}
|
|
173
|
+
.w-\[42\%\]{width:42%;}
|
|
174
|
+
.w-0\.75{width:calc(var(--spacing) * 0.75);}
|
|
175
|
+
.w-10{width:calc(var(--spacing) * 10);}
|
|
176
|
+
.w-15{width:calc(var(--spacing) * 15);}
|
|
177
|
+
.w-20{width:calc(var(--spacing) * 20);}
|
|
178
|
+
.w-28{width:calc(var(--spacing) * 28);}
|
|
179
|
+
.w-36{width:calc(var(--spacing) * 36);}
|
|
180
|
+
.w-40{width:calc(var(--spacing) * 40);}
|
|
181
|
+
.w-56{width:calc(var(--spacing) * 56);}
|
|
182
|
+
.w-6{width:calc(var(--spacing) * 6);}
|
|
183
|
+
.w-7{width:calc(var(--spacing) * 7);}
|
|
184
|
+
.w-7\.5{width:calc(var(--spacing) * 7.5);}
|
|
185
|
+
.w-9{width:calc(var(--spacing) * 9);}
|
|
186
|
+
.w-full{width:100%;}
|
|
187
|
+
.w-max{width:max-content;}
|
|
188
|
+
.aspect-\[16\/10\]{aspect-ratio:16/10;}
|
|
189
|
+
.block{display:block;}
|
|
190
|
+
.hidden{display:none;}
|
|
191
|
+
.collapse{visibility:collapse;}
|
|
192
|
+
.cursor-pointer{cursor:pointer;}
|
|
193
|
+
.cursor-grab{cursor:grab;}
|
|
194
|
+
.pointer-events-auto{pointer-events:auto;}
|
|
195
|
+
.pointer-events-none{pointer-events:none;}
|
|
196
|
+
.whitespace-nowrap{white-space:nowrap;}
|
|
197
|
+
.break-words{overflow-wrap:break-word;}
|
|
198
|
+
.text-pretty{text-wrap:pretty;}
|
|
199
|
+
.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
|
200
|
+
.ring,
|
|
201
|
+
.ring-1{--un-ring-shadow:var(--un-ring-inset,) 0 0 0 calc(1px + var(--un-ring-offset-width)) var(--un-ring-color, currentColor);box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
|
|
202
|
+
.focus-visible\:ring-1:focus-visible{--un-ring-shadow:var(--un-ring-inset,) 0 0 0 calc(1px + var(--un-ring-offset-width)) var(--un-ring-color, currentColor);box-shadow:var(--un-inset-shadow), var(--un-inset-ring-shadow), var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
|
|
203
|
+
.ring-border{--un-ring-color:color-mix(in srgb, var(--border) var(--un-ring-opacity), transparent);}
|
|
204
|
+
.focus-visible\:ring-focus-ring:focus-visible{--un-ring-color:color-mix(in srgb, var(--focus-ring) var(--un-ring-opacity), transparent);}
|
|
205
|
+
.ring-inset{--un-ring-inset:inset;}
|
|
206
|
+
.-rotate-90{rotate:-90deg;}
|
|
207
|
+
.transform{transform:var(--un-rotate-x) var(--un-rotate-y) var(--un-rotate-z) var(--un-skew-x) var(--un-skew-y);}
|
|
208
|
+
.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,--un-gradient-from,--un-gradient-via,--un-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--un-ease, var(--default-transition-timingFunction));transition-duration:var(--un-duration, var(--default-transition-duration));}
|
|
209
|
+
.transition-\[color\]{transition-property:color;transition-timing-function:var(--un-ease, var(--default-transition-timingFunction));transition-duration:var(--un-duration, var(--default-transition-duration));}
|
|
210
|
+
.transition-\[opacity\]{transition-property:opacity;transition-timing-function:var(--un-ease, var(--default-transition-timingFunction));transition-duration:var(--un-duration, var(--default-transition-duration));}
|
|
211
|
+
.transition-\[stroke-width\]{transition-property:stroke-width;transition-timing-function:var(--un-ease, var(--default-transition-timingFunction));transition-duration:var(--un-duration, var(--default-transition-duration));}
|
|
212
|
+
.ease{--un-ease:var(--ease-DEFAULT);transition-timing-function:var(--ease-DEFAULT);}
|
|
213
|
+
.ease-in-out{--un-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out);}
|
|
214
|
+
.\[--scroll-fade-size\:16px\]{--scroll-fade-size:16px;}
|
|
215
|
+
.items-start{align-items:flex-start;}
|
|
216
|
+
.items-end{align-items:flex-end;}
|
|
217
|
+
.items-center{align-items:center;}
|
|
218
|
+
.items-baseline{align-items:baseline;}
|
|
219
|
+
.items-stretch{align-items:stretch;}
|
|
220
|
+
.inset-0{inset:calc(var(--spacing) * 0);}
|
|
221
|
+
.-inset-x-8{inset-inline:calc(var(--spacing) * -8);}
|
|
222
|
+
.-inset-y-4{inset-block:calc(var(--spacing) * -4);}
|
|
223
|
+
.inset-x-0{inset-inline:calc(var(--spacing) * 0);}
|
|
224
|
+
.inset-y-0{inset-block:calc(var(--spacing) * 0);}
|
|
225
|
+
.bottom-0{bottom:calc(var(--spacing) * 0);}
|
|
226
|
+
.left-0{left:calc(var(--spacing) * 0);}
|
|
227
|
+
.left-1\/2{left:50%;}
|
|
228
|
+
.right-0{right:calc(var(--spacing) * 0);}
|
|
229
|
+
.top-0{top:calc(var(--spacing) * 0);}
|
|
230
|
+
.justify-end{justify-content:flex-end;}
|
|
231
|
+
.justify-center{justify-content:center;}
|
|
232
|
+
.justify-between{justify-content:space-between;}
|
|
233
|
+
.absolute{position:absolute;}
|
|
234
|
+
.relative{position:relative;}
|
|
235
|
+
.-z-1{z-index:-1;}
|
|
236
|
+
.z-10{z-index:10;}
|
|
237
|
+
.overflow-hidden{overflow:hidden;}
|
|
238
|
+
.overflow-visible{overflow:visible;}
|
|
239
|
+
.overflow-x-auto{overflow-x:auto;}
|
|
240
|
+
.overflow-y-hidden{overflow-y:hidden;}
|
|
241
|
+
.fill-ink{fill:color-mix(in srgb, var(--ink) var(--un-fill-opacity), transparent);}
|
|
242
|
+
.stroke-current{stroke:currentColor;}
|
|
243
|
+
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0;}
|
|
244
|
+
.isolate{isolation:isolate;}
|
|
245
|
+
.object-cover{object-fit:cover;}
|
|
246
|
+
.blur{--un-blur:blur(8px);filter:var(--un-blur,) var(--un-brightness,) var(--un-contrast,) var(--un-grayscale,) var(--un-hue-rotate,) var(--un-invert,) var(--un-saturate,) var(--un-sepia,) var(--un-drop-shadow,);}
|
|
247
|
+
.filter{filter:var(--un-blur,) var(--un-brightness,) var(--un-contrast,) var(--un-grayscale,) var(--un-hue-rotate,) var(--un-invert,) var(--un-saturate,) var(--un-sepia,) var(--un-drop-shadow,);}
|
|
248
|
+
.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;}
|
|
249
|
+
.tabular-nums{--un-numeric-spacing:tabular-nums;font-variant-numeric:var(--un-ordinal,) var(--un-slashed-zero,) var(--un-numeric-figure,) var(--un-numeric-spacing,) var(--un-numeric-fraction,);}
|
|
250
|
+
.text-display{font-size:var(--text-display);line-height:var(--leading-display);}
|
|
251
|
+
.text-display-compact{font-size:var(--text-display-compact);line-height:var(--leading-display);}
|
|
252
|
+
.text-title{font-size:var(--text-title);line-height:var(--leading-title);}
|
|
253
|
+
.text-title-compact{font-size:var(--text-title-compact);line-height:var(--leading-title);}
|
|
254
|
+
.text-subtitle{font-size:var(--text-subtitle);line-height:var(--leading-subtitle);}
|
|
255
|
+
.text-body{font-size:var(--text-body);line-height:var(--leading-body);}
|
|
256
|
+
.text-body-compact{font-size:var(--text-body-compact);line-height:var(--leading-body);}
|
|
257
|
+
.text-caption{font-size:var(--text-caption);line-height:var(--leading-caption);}
|
|
258
|
+
.text-caption-compact{font-size:var(--text-caption-compact);line-height:var(--leading-caption);}
|
|
259
|
+
.text-micro{font-size:var(--text-micro);line-height:var(--leading-micro);}
|
|
260
|
+
.weight-medium{font-variation-settings:var(--weight-medium);}
|
|
261
|
+
.weight-semibold{font-variation-settings:var(--weight-semibold);}
|
|
262
|
+
.weight-bold{font-variation-settings:var(--weight-bold);}
|
|
263
|
+
.duration-fast{--un-duration:var(--duration-fast);transition-duration:var(--duration-fast);}
|
|
264
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from './blocks/activities/agenda'
|
|
2
|
+
export * from './blocks/activities/clock'
|
|
3
|
+
export * from './blocks/activities/now-playing'
|
|
4
|
+
export * from './blocks/activities/weather'
|
|
5
|
+
export * from './blocks/app/expanded-island'
|
|
6
|
+
export * from './blocks/app/settings-window'
|
|
7
|
+
export * from './blocks/system/clipboard'
|
|
8
|
+
export * from './blocks/system/recent-files'
|
|
9
|
+
export * from './blocks/system/system-stats'
|
|
10
|
+
export * from './components/indicators/countdown'
|
|
11
|
+
export * from './components/indicators/equalizer'
|
|
12
|
+
export * from './components/indicators/media-scrubber'
|
|
13
|
+
export * from './components/island/island'
|
|
14
|
+
export * from './components/island/island-flash'
|
|
15
|
+
export * from './components/island/island-tabs'
|
|
16
|
+
export * from './components/island/widget'
|
|
17
|
+
export type { Artwork, ShownArtwork } from './lib/artwork'
|
|
18
|
+
export { useArtworkTint, useStableArtwork } from './lib/artwork'
|
|
19
|
+
export { formatClock, formatShort, useEdgeClock } from './lib/clock'
|
|
20
|
+
export * from './lib/geometry'
|
|
21
|
+
export type { IslandContextValue } from './lib/island-context'
|
|
22
|
+
export { IslandContext, useIsland } from './lib/island-context'
|
package/lib/artwork.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Artwork that never blinks: the last good picture stays up while the next
|
|
3
|
+
* one loads, or while an update arrives without one for the same track, and
|
|
4
|
+
* only a track that truly has none falls back to the placeholder. Plus the
|
|
5
|
+
* tint a picture lends the widget around it.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use client'
|
|
9
|
+
|
|
10
|
+
import { type ReactNode, useEffect, useState } from 'react'
|
|
11
|
+
|
|
12
|
+
/** A track's picture: an image URL or any element; `null` when the track has none, `undefined` while it isn't known yet. */
|
|
13
|
+
export type Artwork = string | ReactNode
|
|
14
|
+
|
|
15
|
+
/** What the artwork tile shows: a picture, or the placeholder (`art: null`), under an `id` that changes only when the picture does. */
|
|
16
|
+
export interface ShownArtwork {
|
|
17
|
+
id: string
|
|
18
|
+
art: Artwork | null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const NONE = 'none'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The artwork to show for the track `trackKey` names, held across updates.
|
|
25
|
+
*
|
|
26
|
+
* A URL is decoded before it replaces what's shown, so the swap is never to
|
|
27
|
+
* a blank. An update without artwork (`undefined`, or `null` for the same
|
|
28
|
+
* track) keeps the last good picture. A new track with `null`, or a URL that
|
|
29
|
+
* fails to load for a new track, shows the placeholder.
|
|
30
|
+
*/
|
|
31
|
+
export function useStableArtwork(artwork: Artwork | null | undefined, trackKey: string): ShownArtwork {
|
|
32
|
+
const id = typeof artwork === 'string' ? artwork : `node:${trackKey}`
|
|
33
|
+
const [shown, setShown] = useState<ShownArtwork & { track: string }>(() =>
|
|
34
|
+
artwork == null ? { id: NONE, art: null, track: trackKey } : { id, art: artwork, track: trackKey },
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (artwork === undefined) return
|
|
39
|
+
if (artwork === null) {
|
|
40
|
+
setShown(prev => (prev.track === trackKey ? prev : { id: NONE, art: null, track: trackKey }))
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
if (typeof artwork !== 'string') {
|
|
44
|
+
setShown(prev => (prev.id === id ? prev : { id, art: artwork, track: trackKey }))
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
let live = true
|
|
48
|
+
const image = new Image()
|
|
49
|
+
image.src = artwork
|
|
50
|
+
image.decode().then(
|
|
51
|
+
() => live && setShown(prev => (prev.id === id ? prev : { id, art: artwork, track: trackKey })),
|
|
52
|
+
() => live && setShown(prev => (prev.track === trackKey ? prev : { id: NONE, art: null, track: trackKey })),
|
|
53
|
+
)
|
|
54
|
+
return () => {
|
|
55
|
+
live = false
|
|
56
|
+
}
|
|
57
|
+
// `artwork` is read through `id`: an element is a new object on every render.
|
|
58
|
+
}, [id, trackKey, artwork === null, artwork === undefined])
|
|
59
|
+
|
|
60
|
+
// The same picture as an element: render the current one, so its props stay fresh.
|
|
61
|
+
if (shown.id === id && artwork != null && typeof artwork !== 'string') return { id, art: artwork }
|
|
62
|
+
return shown
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const SAMPLE = 12
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The color an image URL leans to, as `rgb(…)`: its pixels averaged, the
|
|
69
|
+
* vivid ones weighted up, so a mostly grey cover still lends its accent.
|
|
70
|
+
* Read once per URL; `undefined` until then, or when the image can't be
|
|
71
|
+
* read (a cross-origin image without CORS).
|
|
72
|
+
*/
|
|
73
|
+
export function useArtworkTint(src?: string) {
|
|
74
|
+
const [tint, setTint] = useState<{ src: string; color?: string }>()
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!src) return
|
|
78
|
+
let live = true
|
|
79
|
+
const image = new Image()
|
|
80
|
+
image.crossOrigin = 'anonymous'
|
|
81
|
+
image.src = src
|
|
82
|
+
image
|
|
83
|
+
.decode()
|
|
84
|
+
.then(() => {
|
|
85
|
+
const canvas = document.createElement('canvas')
|
|
86
|
+
canvas.width = canvas.height = SAMPLE
|
|
87
|
+
const context = canvas.getContext('2d', { willReadFrequently: true })
|
|
88
|
+
if (!context) return
|
|
89
|
+
context.drawImage(image, 0, 0, SAMPLE, SAMPLE)
|
|
90
|
+
const { data } = context.getImageData(0, 0, SAMPLE, SAMPLE)
|
|
91
|
+
let r = 0
|
|
92
|
+
let g = 0
|
|
93
|
+
let b = 0
|
|
94
|
+
let total = 0
|
|
95
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
96
|
+
const [pr = 0, pg = 0, pb = 0] = [data[i], data[i + 1], data[i + 2]]
|
|
97
|
+
const weight = 0.1 + (Math.max(pr, pg, pb) - Math.min(pr, pg, pb)) / 255
|
|
98
|
+
r += pr * weight
|
|
99
|
+
g += pg * weight
|
|
100
|
+
b += pb * weight
|
|
101
|
+
total += weight
|
|
102
|
+
}
|
|
103
|
+
if (live) setTint({ src, color: `rgb(${r / total} ${g / total} ${b / total})` })
|
|
104
|
+
})
|
|
105
|
+
.catch(() => live && setTint({ src }))
|
|
106
|
+
return () => {
|
|
107
|
+
live = false
|
|
108
|
+
}
|
|
109
|
+
}, [src])
|
|
110
|
+
|
|
111
|
+
return tint && tint.src === src ? tint.color : undefined
|
|
112
|
+
}
|
package/lib/clock.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Time as a notch app shows it: a clock ("4:05"), a short span ("4m") and a
|
|
3
|
+
* re-render that lands only on the edges of what is shown.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use client'
|
|
7
|
+
|
|
8
|
+
import { useEffect, useState } from 'react'
|
|
9
|
+
|
|
10
|
+
const SECOND = 1000
|
|
11
|
+
const MINUTE = 60 * SECOND
|
|
12
|
+
|
|
13
|
+
/** Seconds as `m:ss`, or `h:mm:ss` from an hour. */
|
|
14
|
+
export function formatClock(seconds: number) {
|
|
15
|
+
const s = Math.max(0, Math.floor(seconds))
|
|
16
|
+
const ss = String(s % 60).padStart(2, '0')
|
|
17
|
+
if (s < 3600) return `${Math.floor(s / 60)}:${ss}`
|
|
18
|
+
return `${Math.floor(s / 3600)}:${String(Math.floor(s / 60) % 60).padStart(2, '0')}:${ss}`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Seconds as the one largest unit, rounded up: `"45s"`, `"4m"`, `"2h"`. */
|
|
22
|
+
export function formatShort(seconds: number) {
|
|
23
|
+
const s = Math.max(0, Math.ceil(seconds))
|
|
24
|
+
if (s < 60) return `${s}s`
|
|
25
|
+
if (s < 3600) return `${Math.ceil(s / 60)}m`
|
|
26
|
+
return `${Math.ceil(s / 3600)}h`
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The time now, re-read once per `unit` ms on the unit's edge counted from
|
|
31
|
+
* `anchor` (a countdown's end, a track's start), never in between. Stops
|
|
32
|
+
* while `running` is false.
|
|
33
|
+
*/
|
|
34
|
+
export function useEdgeClock(anchor: number, running: boolean, unit: number = SECOND) {
|
|
35
|
+
const [now, setNow] = useState(Date.now)
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!running) return
|
|
39
|
+
let timer: ReturnType<typeof setTimeout>
|
|
40
|
+
const tick = () => {
|
|
41
|
+
const t = Date.now()
|
|
42
|
+
setNow(t)
|
|
43
|
+
const offset = (((anchor - t) % unit) + unit) % unit
|
|
44
|
+
timer = setTimeout(tick, offset || unit)
|
|
45
|
+
}
|
|
46
|
+
tick()
|
|
47
|
+
return () => clearTimeout(timer)
|
|
48
|
+
}, [anchor, running, unit])
|
|
49
|
+
|
|
50
|
+
return running ? now : Date.now()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { MINUTE, SECOND }
|
package/lib/geometry.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The island's geometry, pure: its outline per state, the detached bubble of
|
|
3
|
+
* `split`, the path that draws it and how icon tabs share the wings around
|
|
4
|
+
* the notch. Ported from Just Notch's runtime (`island/geometry.ts`), with the
|
|
5
|
+
* screen geometry replaced by sizes a component takes as props.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** What the island shows: the bare notch, an activity in the wings, two activities, the open panel, or an alert. */
|
|
9
|
+
export type IslandState = 'idle' | 'compact' | 'split' | 'expanded' | 'flash'
|
|
10
|
+
|
|
11
|
+
export const ISLAND_STATES: IslandState[] = ['idle', 'compact', 'split', 'expanded', 'flash']
|
|
12
|
+
|
|
13
|
+
/** A width and a height in px. */
|
|
14
|
+
export interface Size {
|
|
15
|
+
width: number
|
|
16
|
+
height: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The sizes the island grows between: the hardware notch and the open panel. */
|
|
20
|
+
export interface IslandGeometry {
|
|
21
|
+
notch: Size
|
|
22
|
+
panel: Size
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The island's outline: a body of `w` × `h` hanging from the top edge, `radius` below, concave `shoulder`s into the edge. */
|
|
26
|
+
export interface Shape {
|
|
27
|
+
w: number
|
|
28
|
+
h: number
|
|
29
|
+
radius: number
|
|
30
|
+
shoulder: number
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const DEFAULT_NOTCH: Size = { width: 185, height: 32 }
|
|
34
|
+
export const DEFAULT_PANEL: Size = { width: 720, height: 240 }
|
|
35
|
+
|
|
36
|
+
/** The open island's one content inset: header, title and content all start here, clear of the bottom corners. */
|
|
37
|
+
export const INSET = 20
|
|
38
|
+
/** Kept free on each side of the notch. */
|
|
39
|
+
export const NOTCH_GAP = 8
|
|
40
|
+
/** How far a flash reaches past the compact wings, on each side. */
|
|
41
|
+
const FLASH_REACH = 64
|
|
42
|
+
/** How far a flash drops below the notch. */
|
|
43
|
+
const FLASH_DROP = 48
|
|
44
|
+
|
|
45
|
+
/** Room for one compact slot beside the notch: about as wide as the notch is tall. */
|
|
46
|
+
export const slotWidth = (notch: Size) => notch.height + 8
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The outline for `state`. `room` is the width the island may take (its
|
|
50
|
+
* container's); the open panel and the flash shrink to fit it, shoulders included.
|
|
51
|
+
*/
|
|
52
|
+
export function shapeFor(state: IslandState, { notch, panel }: IslandGeometry, room = Number.POSITIVE_INFINITY): Shape {
|
|
53
|
+
const slot = slotWidth(notch)
|
|
54
|
+
if (state === 'idle') return { w: notch.width, h: notch.height, radius: 10, shoulder: 6 }
|
|
55
|
+
if (state === 'compact' || state === 'split')
|
|
56
|
+
return { w: notch.width + 2 * slot, h: notch.height, radius: 13, shoulder: 8 }
|
|
57
|
+
if (state === 'flash')
|
|
58
|
+
return {
|
|
59
|
+
w: Math.min(notch.width + 2 * (slot + FLASH_REACH), room - 20),
|
|
60
|
+
h: notch.height + FLASH_DROP,
|
|
61
|
+
radius: 24,
|
|
62
|
+
shoulder: 10,
|
|
63
|
+
}
|
|
64
|
+
return { w: Math.max(notch.width, Math.min(panel.width, room - 28)), h: panel.height, radius: 32, shoulder: 14 }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The detached bubble of `split`: a circle as tall as the compact island, its center `x` from the island's center. */
|
|
68
|
+
export function bubbleFor(shape: Shape, notch: Size, detached: boolean) {
|
|
69
|
+
const r = notch.height / 2 - 1
|
|
70
|
+
return detached ? { x: shape.w / 2 + shape.shoulder + 14 + r, r } : { x: shape.w / 2 - r, r: r * 0.5 }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// A circle's quarter as a cubic has handles at 0.5523 of the radius. Stretching
|
|
74
|
+
// the corner over 1.28 r with longer handles spreads the curvature like Apple's
|
|
75
|
+
// continuous corners, so the bottom never reads as a plain rounded rectangle.
|
|
76
|
+
const CIRCLE = 0.5523
|
|
77
|
+
const SMOOTH_SPAN = 1.28
|
|
78
|
+
const SMOOTH_HANDLE = 0.64
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The outline as one SVG path, centered on `cx`. It starts a point above the
|
|
82
|
+
* top edge so no hairline shows where it meets the screen.
|
|
83
|
+
*/
|
|
84
|
+
export function islandPath(cx: number, { w, h, radius, shoulder }: Shape): string {
|
|
85
|
+
const s = Math.max(0, Math.min(shoulder, h / 2))
|
|
86
|
+
const span = Math.max(0, Math.min(radius * SMOOTH_SPAN, h - s, w / 2))
|
|
87
|
+
const k = span * (1 - SMOOTH_HANDLE)
|
|
88
|
+
const q = s * (1 - CIRCLE)
|
|
89
|
+
const l = cx - w / 2
|
|
90
|
+
const r = cx + w / 2
|
|
91
|
+
return [
|
|
92
|
+
`M${l - s} -1`,
|
|
93
|
+
`L${l - s} 0`,
|
|
94
|
+
`C${l - q} 0 ${l} ${q} ${l} ${s}`,
|
|
95
|
+
`L${l} ${h - span}`,
|
|
96
|
+
`C${l} ${h - k} ${l + k} ${h} ${l + span} ${h}`,
|
|
97
|
+
`L${r - span} ${h}`,
|
|
98
|
+
`C${r - k} ${h} ${r} ${h - k} ${r} ${h - span}`,
|
|
99
|
+
`L${r} ${s}`,
|
|
100
|
+
`C${r} ${q} ${r + q} 0 ${r + s} 0`,
|
|
101
|
+
`L${r + s} -1`,
|
|
102
|
+
'Z',
|
|
103
|
+
].join('')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface StripLayout {
|
|
107
|
+
/** Tabs in the left wing; the rest follow in the right one. */
|
|
108
|
+
before: number
|
|
109
|
+
/** More tabs than both wings hold: the strip scrolls, behind the notch. */
|
|
110
|
+
overflow: boolean
|
|
111
|
+
/** The notch and its gaps in the strip's coordinates. */
|
|
112
|
+
hole: { start: number; end: number }
|
|
113
|
+
/** Least width of the gap between the wings, so the right wing starts past the notch. */
|
|
114
|
+
spacer: number
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Tabs of `tab` px across a strip of `width` centered under a notch of
|
|
119
|
+
* `notchWidth`, flowing from the left wing into the right one, balanced.
|
|
120
|
+
* `reserve` is kept free at the right wing's far end (a settings button).
|
|
121
|
+
*/
|
|
122
|
+
export function stripLayout(count: number, width: number, notchWidth: number, tab: number, reserve = 0): StripLayout {
|
|
123
|
+
const left = Math.max(0, (width - notchWidth) / 2 - NOTCH_GAP)
|
|
124
|
+
const leftCap = Math.floor(left / tab)
|
|
125
|
+
const rightCap = Math.max(0, Math.floor((left - reserve) / tab))
|
|
126
|
+
const overflow = count > leftCap + rightCap
|
|
127
|
+
const before = overflow ? leftCap : Math.min(leftCap, Math.max(Math.ceil(count / 2), count - rightCap))
|
|
128
|
+
const hole = { start: left, end: width - left }
|
|
129
|
+
return { before, overflow, hole, spacer: hole.end - before * tab }
|
|
130
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* What an Island tells the content inside it: its state, the notch and panel
|
|
3
|
+
* it grows between, and its current outline, so a tab strip can leave the
|
|
4
|
+
* notch free and a layout can start below it.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use client'
|
|
8
|
+
|
|
9
|
+
import { createContext, useContext } from 'react'
|
|
10
|
+
import type { IslandGeometry, IslandState, Shape } from './geometry'
|
|
11
|
+
|
|
12
|
+
export interface IslandContextValue {
|
|
13
|
+
state: IslandState
|
|
14
|
+
geometry: IslandGeometry
|
|
15
|
+
/** The outline of `state`, fitted to the room the island has. */
|
|
16
|
+
shape: Shape
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const IslandContext = createContext<IslandContextValue | null>(null)
|
|
20
|
+
|
|
21
|
+
/** The enclosing Island's state and geometry, or `null` outside one. */
|
|
22
|
+
export function useIsland() {
|
|
23
|
+
return useContext(IslandContext)
|
|
24
|
+
}
|
package/lib/motion.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The island's motion, on modo-ui's spring tiers: which tier moves the shape
|
|
3
|
+
* between two states, the bubble's goo, and Apple's content swap (arriving
|
|
4
|
+
* content sharpens and grows into place, leaving content blurs out).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { spring, springEnter } from '@justanarthur/modo-ui/lib/springs'
|
|
8
|
+
import type { Transition } from 'motion/react'
|
|
9
|
+
import type { IslandState } from './geometry'
|
|
10
|
+
|
|
11
|
+
type Tier = (typeof spring)[keyof typeof spring]
|
|
12
|
+
|
|
13
|
+
const SIZE: Record<IslandState, number> = { idle: 0, compact: 1, split: 1, flash: 2, expanded: 3 }
|
|
14
|
+
const TIER: Record<IslandState, Tier> = {
|
|
15
|
+
idle: spring.moderate,
|
|
16
|
+
compact: spring.moderate,
|
|
17
|
+
split: spring.moderate,
|
|
18
|
+
flash: spring.slow,
|
|
19
|
+
expanded: spring.goo,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The bigger the move, the slower the tier: grow on the target's spring, shrink on the source's exit tween. */
|
|
23
|
+
export function shapeTransition(from: IslandState, to: IslandState): Transition {
|
|
24
|
+
if (SIZE[to] >= SIZE[from]) return springEnter(TIER[to])
|
|
25
|
+
return from === 'expanded' ? spring.slow.exit : TIER[from].exit
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const bubbleTransition = (detaching: boolean): Transition =>
|
|
29
|
+
detaching ? springEnter(spring.goo) : spring.goo.exit
|
|
30
|
+
|
|
31
|
+
// Blur is a filter string a spring can't drive, so the swap tweens on a tier's
|
|
32
|
+
// duration, as modo-ui's icon swaps. At rest the filter is dropped (`none`, not
|
|
33
|
+
// `blur(0px)`): any filter keeps an offscreen buffer alive.
|
|
34
|
+
export const contentShown = { opacity: 1, scale: 1, filter: 'blur(0px)', transitionEnd: { filter: 'none' } }
|
|
35
|
+
export const contentHidden = { opacity: 0, scale: 0.94, filter: 'blur(6px)' }
|
|
36
|
+
export const contentEnter: Transition = {
|
|
37
|
+
type: 'tween',
|
|
38
|
+
duration: spring.slow.duration,
|
|
39
|
+
ease: 'easeOut',
|
|
40
|
+
delay: spring.fast.duration,
|
|
41
|
+
}
|
|
42
|
+
export const contentLeave: Transition = { type: 'tween', ...spring.fast.exit, ease: 'easeIn' }
|