gooee 0.41.1 → 0.42.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 CHANGED
@@ -89,7 +89,7 @@ Setup for other tools: [MCP server](https://gooee.dev/mcp).
89
89
 
90
90
  ## Pro
91
91
 
92
- 76 more components (such as DataGrid, Calendar, Chart, KanbanBoard, Combobox and WeekSchedule), page blocks, full templates and brand themes are coming as Gooee UI Pro. You can see them on the [docs site](https://gooee.dev).
92
+ 80 more components (such as the AI chat parts AssistantThread and PromptBar, DataGrid, Calendar, Chart, KanbanBoard and Combobox), page blocks, full templates and brand themes are coming as Gooee UI Pro. You can see them on the [docs site](https://gooee.dev).
93
93
 
94
94
  ## Licence
95
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gooee",
3
- "version": "0.41.1",
3
+ "version": "0.42.0",
4
4
  "description": "React components in black, white and grey with one blue accent. Copy them into your app with npx gooee add <name>.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://gooee.dev",
@@ -22,15 +22,15 @@
22
22
  z-index: -1;
23
23
  border-radius: var(--gooee-radius-control);
24
24
  background: var(--gooee-color-surface-raised);
25
- box-shadow: var(--gooee-shadow-2), 0 0 0 var(--gooee-line) var(--gooee-color-border);
25
+ box-shadow: var(--gooee-shadow-thumb), 0 0 0 var(--gooee-line) var(--gooee-color-border);
26
26
  }
27
27
 
28
28
  /* A resize slides the pill plainly. A new choice flows it (internal/liquidMatter.ts useFlow): while
29
29
  it flows the pill hides and .liquid draws it, then the pill is back in its place, exact. */
30
30
  .pill[data-ready] {
31
31
  transition:
32
- transform var(--gooee-motion-slow) var(--gooee-ease-out),
33
- width var(--gooee-motion-slow) var(--gooee-ease-out);
32
+ transform var(--gooee-motion-morph-out) var(--gooee-ease-out),
33
+ width var(--gooee-motion-morph-out) var(--gooee-ease-out);
34
34
  }
35
35
 
36
36
  .pill[data-flowing] {
@@ -76,7 +76,7 @@
76
76
  /* Both on and off pass 3:1 contrast */
77
77
  .track[data-on] .thumb {
78
78
  background: var(--gooee-color-accent-fg);
79
- box-shadow: var(--gooee-shadow-2);
79
+ box-shadow: var(--gooee-shadow-thumb);
80
80
  }
81
81
 
82
82
  .track[data-on] .thumb {
@@ -65,8 +65,8 @@
65
65
 
66
66
  .indicator[data-ready] {
67
67
  transition:
68
- transform var(--gooee-motion-slow) var(--gooee-ease-out),
69
- width var(--gooee-motion-slow) var(--gooee-ease-out);
68
+ transform var(--gooee-motion-morph-out) var(--gooee-ease-out),
69
+ width var(--gooee-motion-morph-out) var(--gooee-ease-out);
70
70
  }
71
71
 
72
72
  /* A new tab flows the underline instead (internal/liquidMatter.ts useFlow): .liquid draws it meanwhile. */
@@ -13,7 +13,7 @@ import {
13
13
  type ReactNode,
14
14
  } from 'react'
15
15
  import { CheckCircleIcon, ErrorIcon, InfoIcon, XIcon } from '../../internal/icons'
16
- import { frames, layer, morphEase, motionFor, shadowOf } from '../../internal/liquidMatter'
16
+ import { castShadow, frames, layer, morphEase, motionFor, shadowOf } from '../../internal/liquidMatter'
17
17
  import { BEND, body, budScene, exitToward, loopsPath, pincher, sdBox, trace, type Box, type Pt } from '../../internal/liquidPath'
18
18
  import { motionMs } from '../../internal/motion'
19
19
  import { release, speedTracker } from '../../internal/fling'
@@ -234,7 +234,7 @@ function bud(toast: HTMLElement, origin: ToastOptions['origin'], way: 'in' | 'ou
234
234
  path.style.fill = look.backgroundColor
235
235
  path.style.stroke = look.borderTopColor
236
236
  path.style.strokeWidth = `${line}px`
237
- svg.style.filter = shadowOf(toast).filter
237
+ castShadow(svg, shadowOf(toast).shadows)
238
238
  const inset = line / 2
239
239
  const T2: Box = { cx: T.cx, cy: T.cy, hw: T.hw - inset, hh: T.hh - inset, r: Math.max(0, T.r - inset) }
240
240
  // The origin keeps its own look: the drawing is cut out where it is.
@@ -13,21 +13,52 @@ export const morphEase = () => bezier(morphCurve())
13
13
  /** A duration token in ms, or 0 when motion is reduced. */
14
14
  export const motionFor = (token: MotionToken) => (prefersReducedMotion() ? 0 : motionMs(token))
15
15
 
16
- /**
17
- * An element's outer box shadows as drop-shadow filters, so a drawn shape casts the same shadow. A
18
- * shadow that is only a spread (a 1px ring) comes back as `ring`, to draw as a stroke.
19
- */
16
+ type Shadow = { x: number; y: number; blur: number; colour: string }
17
+
18
+ /** An element's outer box shadows. A shadow that is only a spread (a 1px ring) comes back as `ring`, to draw as a stroke. */
20
19
  export function shadowOf(el: Element) {
21
- const filters: string[] = []
20
+ const shadows: Shadow[] = []
22
21
  let ring: { colour: string; width: number } | null = null
23
22
  for (const part of getComputedStyle(el).boxShadow.split(/,(?![^(]*\))/)) {
24
23
  if (part.trim() === 'none' || part.includes('inset')) continue
25
24
  const colour = part.match(/rgba?\([^)]*\)|#[\da-f]+/i)?.[0] ?? 'currentColor'
26
25
  const [x = 0, y = 0, blur = 0, spread = 0] = (part.replace(colour, '').match(/-?[\d.]+px/g) ?? []).map(parseFloat)
27
26
  if (spread > 0 && !x && !y && !blur) ring = { colour, width: spread }
28
- else filters.push(`drop-shadow(${x}px ${y}px ${blur}px ${colour})`)
27
+ else shadows.push({ x, y, blur, colour })
28
+ }
29
+ return { shadows, ring }
30
+ }
31
+
32
+ let filterId = 0
33
+
34
+ /**
35
+ * Casts `shadows` from the layer's paths the way box-shadow does: each one blurred from the shape on its
36
+ * own, then merged. A chain of CSS drop-shadows would shadow the shadows too, so the drawing would come out
37
+ * darker than the part it stands in for and jump at the hand-over.
38
+ */
39
+ export function castShadow(svg: SVGSVGElement, shadows: Shadow[]) {
40
+ if (!shadows.length) return
41
+ const el = (tag: string, attrs: Record<string, string | number>, parent: Element) => {
42
+ const node = parent.appendChild(document.createElementNS(NS, tag))
43
+ for (const [k, v] of Object.entries(attrs)) node.setAttribute(k, String(v))
44
+ return node
29
45
  }
30
- return { filter: filters.join(' ') || 'none', ring }
46
+ const { width, height } = svg.getBoundingClientRect()
47
+ const m = Math.max(...shadows.map((s) => Math.max(Math.abs(s.x), Math.abs(s.y)) + s.blur * 1.5)) + 2
48
+ const id = `gooee-shadow-${++filterId}`
49
+ const filter = el('filter', { id, filterUnits: 'userSpaceOnUse', x: -m, y: -m, width: width + m * 2, height: height + m * 2, 'color-interpolation-filters': 'sRGB' }, el('defs', {}, svg))
50
+ shadows.forEach((s, i) => {
51
+ el('feGaussianBlur', { in: 'SourceAlpha', stdDeviation: s.blur / 2 }, filter)
52
+ el('feOffset', { dx: s.x, dy: s.y, result: `b${i}` }, filter)
53
+ el('feFlood', { 'flood-color': s.colour }, filter)
54
+ el('feComposite', { in2: `b${i}`, operator: 'in', result: `s${i}` }, filter)
55
+ })
56
+ // box-shadow paints its first shadow on top, so they merge last to first, under the shape.
57
+ const merge = el('feMerge', {}, filter)
58
+ for (let i = shadows.length - 1; i >= 0; i--) el('feMergeNode', { in: `s${i}` }, merge)
59
+ el('feMergeNode', { in: 'SourceGraphic' }, merge)
60
+ const g = el('g', { filter: `url(#${id})` }, svg)
61
+ for (const path of Array.from(svg.querySelectorAll(':scope > path'))) g.appendChild(path)
31
62
  }
32
63
 
33
64
  /** An SVG in `host`, before `before`, with `count` paths. It is marked data-gooee-liquid. */
@@ -105,7 +136,7 @@ export function useFlow(
105
136
  end()
106
137
  return
107
138
  }
108
- const ms = motionFor('slow')
139
+ const ms = motionFor('morph-out')
109
140
  if (!ms) {
110
141
  end()
111
142
  return
@@ -122,21 +153,21 @@ export function useFlow(
122
153
  else {
123
154
  const { svg, paths } = layer(root, cls, m.nextSibling)
124
155
  const look = getComputedStyle(m)
125
- const { filter, ring } = shadowOf(m)
156
+ const { shadows, ring } = shadowOf(m)
126
157
  paths[0].style.fill = look.backgroundColor
127
158
  if (ring && !line) {
128
159
  paths[0].style.stroke = ring.colour
129
160
  paths[0].style.strokeWidth = `${ring.width * 2}px`
130
161
  paths[0].style.paintOrder = 'stroke'
131
162
  }
132
- svg.style.filter = filter
163
+ castShadow(svg, shadows)
133
164
  f = { front: from.front, rest: from.rest, stop: () => {}, svg, pin: pincher(e, motionFor('fast')) }
134
165
  run.current = f
135
166
  m.dataset.flowing = ''
136
167
  root.dataset.flowing = ''
137
168
  }
138
169
  const flow = f
139
- const path = flow.svg.firstElementChild as SVGPathElement
170
+ const path = flow.svg.querySelector('path') as SVGPathElement
140
171
  const lift = Math.max(BEND + 0.5, hh / 2)
141
172
  const settle = Math.max(BEND + 0.5, hh / 3)
142
173
  const start = { front: from.front, rest: from.rest }
package/src/tokens.css CHANGED
@@ -165,6 +165,8 @@
165
165
  --gooee-shadow-2: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 12px rgb(0 0 0 / 0.06);
166
166
  --gooee-shadow-3: 0 2px 4px rgb(0 0 0 / 0.04), 0 12px 32px rgb(0 0 0 / 0.1);
167
167
  --gooee-shadow-4: 0 4px 8px rgb(0 0 0 / 0.05), 0 24px 64px rgb(0 0 0 / 0.16);
168
+ /* A thumb on its track. Every layer blurs at least twice its drop, so no hard edge shows */
169
+ --gooee-shadow-thumb: 0 1px 3px rgb(0 0 0 / 0.04), 0 3px 8px rgb(0 0 0 / 0.04), 0 6px 16px rgb(0 0 0 / 0.04);
168
170
 
169
171
  /* Motion. Every duration is its base times --gooee-motion-scale, so one value retimes the whole
170
172
  library (see Retime). 1 is normal, 1.5 is slower, 0 is no motion. Reduced motion still wins. */
@@ -190,8 +192,8 @@
190
192
  --gooee-motion-shimmer: 1400ms;
191
193
  --gooee-motion-spin: 800ms;
192
194
  --gooee-motion-indeterminate: 1500ms;
193
- /* Morph: the one curve for every move. Fast away, long soft landing, no overshoot, like an iPhone
194
- sheet. Opening and closing both play it forward */
195
+ /* Morph: the one curve for every move. A soft lift-off, then a long settle, with no overshoot.
196
+ Opening and closing both play it forward */
195
197
  --gooee-ease-morph: cubic-bezier(0.2, 0, 0, 1);
196
198
  /* Older names, kept so apps that use them still work. They are the morph now */
197
199
  --gooee-ease-out: var(--gooee-ease-morph);
@@ -277,6 +279,7 @@
277
279
  --gooee-shadow-2: 0 1px 2px rgb(0 0 0 / 0.2), 0 4px 12px rgb(0 0 0 / 0.15);
278
280
  --gooee-shadow-3: 0 2px 4px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.5);
279
281
  --gooee-shadow-4: 0 4px 8px rgb(0 0 0 / 0.4), 0 24px 64px rgb(0 0 0 / 0.6);
282
+ --gooee-shadow-thumb: 0 1px 3px rgb(0 0 0 / 0.12), 0 3px 8px rgb(0 0 0 / 0.12), 0 6px 16px rgb(0 0 0 / 0.12);
280
283
  color-scheme: dark;
281
284
  }
282
285
  }
@@ -318,6 +321,7 @@
318
321
  --gooee-shadow-2: 0 1px 2px rgb(0 0 0 / 0.2), 0 4px 12px rgb(0 0 0 / 0.15);
319
322
  --gooee-shadow-3: 0 2px 4px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.5);
320
323
  --gooee-shadow-4: 0 4px 8px rgb(0 0 0 / 0.4), 0 24px 64px rgb(0 0 0 / 0.6);
324
+ --gooee-shadow-thumb: 0 1px 3px rgb(0 0 0 / 0.12), 0 3px 8px rgb(0 0 0 / 0.12), 0 6px 16px rgb(0 0 0 / 0.12);
321
325
  color-scheme: dark;
322
326
  }
323
327