@blotch/dolan 22.2.2 → 22.2.4
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/dist/commands/add.d.ts +6 -2
- package/dist/commands/add.js +41 -11
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/add.test.js +162 -9
- package/dist/commands/add.test.js.map +1 -1
- package/dist/commands/diff.d.ts +2 -1
- package/dist/commands/diff.js +38 -25
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/diff.test.js +72 -11
- package/dist/commands/diff.test.js.map +1 -1
- package/dist/commands/doctor.js +228 -34
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/doctor.test.js +367 -10
- package/dist/commands/doctor.test.js.map +1 -1
- package/dist/commands/eject.js +7 -0
- package/dist/commands/eject.js.map +1 -1
- package/dist/commands/eject.test.js +39 -0
- package/dist/commands/eject.test.js.map +1 -1
- package/dist/commands/info.js +3 -2
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/init.d.ts +37 -1
- package/dist/commands/init.js +169 -40
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/init.test.js +392 -27
- package/dist/commands/init.test.js.map +1 -1
- package/dist/commands/install-packages.d.ts +6 -0
- package/dist/commands/install-packages.js +20 -0
- package/dist/commands/install-packages.js.map +1 -0
- package/dist/commands/install-packages.test.d.ts +1 -0
- package/dist/commands/install-packages.test.js +55 -0
- package/dist/commands/install-packages.test.js.map +1 -0
- package/dist/commands/list.js +21 -14
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/list.test.js +62 -5
- package/dist/commands/list.test.js.map +1 -1
- package/dist/commands/outdated.js +11 -10
- package/dist/commands/outdated.js.map +1 -1
- package/dist/commands/outdated.test.js +20 -5
- package/dist/commands/outdated.test.js.map +1 -1
- package/dist/commands/remove.d.ts +4 -0
- package/dist/commands/remove.js +17 -4
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/remove.test.js +53 -2
- package/dist/commands/remove.test.js.map +1 -1
- package/dist/commands/theme.js +1 -1
- package/dist/commands/theme.js.map +1 -1
- package/dist/commands/update.d.ts +11 -0
- package/dist/commands/update.js +174 -58
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/update.test.js +587 -33
- package/dist/commands/update.test.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/lockfile.d.ts +7 -0
- package/dist/lockfile.js +36 -0
- package/dist/lockfile.js.map +1 -1
- package/dist/lockfile.test.d.ts +1 -0
- package/dist/lockfile.test.js +25 -0
- package/dist/lockfile.test.js.map +1 -0
- package/dist/registry.d.ts +14 -0
- package/dist/registry.js +78 -24
- package/dist/registry.js.map +1 -1
- package/dist/registry.test.js +119 -38
- package/dist/registry.test.js.map +1 -1
- package/dist/test-utils.d.ts +5 -0
- package/dist/test-utils.js +6 -1
- package/dist/test-utils.js.map +1 -1
- package/dist/testing/fire-lynx-event.d.ts +14 -0
- package/dist/testing/fire-lynx-event.js +19 -0
- package/dist/testing/fire-lynx-event.js.map +1 -0
- package/dist/testing/fire-lynx-event.test.d.ts +1 -0
- package/dist/testing/fire-lynx-event.test.js +44 -0
- package/dist/testing/fire-lynx-event.test.js.map +1 -0
- package/dist/testing/lynx-main-thread.d.ts +22 -0
- package/dist/testing/lynx-main-thread.js +11 -0
- package/dist/testing/lynx-main-thread.js.map +1 -0
- package/dist/testing/lynx-main-thread.test.d.ts +1 -0
- package/dist/testing/lynx-main-thread.test.js +24 -0
- package/dist/testing/lynx-main-thread.test.js.map +1 -0
- package/dist/testing/set-input-signal.d.ts +14 -0
- package/dist/testing/set-input-signal.js +21 -0
- package/dist/testing/set-input-signal.js.map +1 -0
- package/dist/testing/set-input-signal.test.d.ts +1 -0
- package/dist/testing/set-input-signal.test.js +20 -0
- package/dist/testing/set-input-signal.test.js.map +1 -0
- package/dist/ui/components/accordion/accordion.test.ts +158 -144
- package/dist/ui/components/accordion/accordion.ts +19 -14
- package/dist/ui/components/action-sheet/action-sheet.test.ts +283 -151
- package/dist/ui/components/action-sheet/action-sheet.ts +77 -43
- package/dist/ui/components/alert/alert.test.ts +67 -19
- package/dist/ui/components/alert/alert.ts +14 -16
- package/dist/ui/components/alert-dialog/alert-dialog.test.ts +208 -94
- package/dist/ui/components/alert-dialog/alert-dialog.ts +75 -38
- package/dist/ui/components/area-chart/area-chart.test.ts +134 -119
- package/dist/ui/components/area-chart/area-chart.ts +100 -315
- package/dist/ui/components/area-chart/index.ts +2 -3
- package/dist/ui/components/avatar/avatar.test.ts +89 -45
- package/dist/ui/components/badge/badge.test.ts +57 -23
- package/dist/ui/components/badge/badge.ts +12 -14
- package/dist/ui/components/bar-chart/bar-chart.test.ts +172 -45
- package/dist/ui/components/bar-chart/bar-chart.ts +140 -294
- package/dist/ui/components/bar-chart/index.ts +3 -3
- package/dist/ui/components/bottom-sheet/bottom-sheet.test.ts +386 -128
- package/dist/ui/components/bottom-sheet/bottom-sheet.ts +170 -53
- package/dist/ui/components/button/button.test.ts +611 -2
- package/dist/ui/components/button/button.ts +434 -49
- package/dist/ui/components/button/index.ts +2 -0
- package/dist/ui/components/button-group/button-group.test.ts +484 -2
- package/dist/ui/components/button-group/button-group.ts +380 -68
- package/dist/ui/components/button-group/index.ts +3 -0
- package/dist/ui/components/candlestick-chart/candlestick-chart.test.ts +183 -58
- package/dist/ui/components/candlestick-chart/candlestick-chart.ts +150 -323
- package/dist/ui/components/candlestick-chart/index.ts +3 -4
- package/dist/ui/components/card/card.test.ts +82 -62
- package/dist/ui/components/chart/chart-focus.test.ts +132 -0
- package/dist/ui/components/chart/chart-focus.ts +115 -0
- package/dist/ui/components/chart/chart-presets.test.ts +335 -0
- package/dist/ui/components/chart/chart-presets.ts +278 -0
- package/dist/ui/components/chart/chart-scene.test.ts +589 -0
- package/dist/ui/components/chart/chart-scene.ts +483 -0
- package/dist/ui/components/chart/chart-theme.test.ts +85 -0
- package/dist/ui/components/chart/chart-theme.ts +210 -0
- package/dist/ui/components/chart/chart-zoom.test.ts +159 -0
- package/dist/ui/components/chart/chart-zoom.ts +162 -0
- package/dist/ui/components/chart/chart.test.ts +1017 -0
- package/dist/ui/components/chart/chart.ts +934 -0
- package/dist/ui/components/chart/index.ts +24 -0
- package/dist/ui/components/checkbox/checkbox.test.ts +124 -42
- package/dist/ui/components/checkbox/checkbox.ts +23 -23
- package/dist/ui/components/collapsible/collapsible.test.ts +158 -81
- package/dist/ui/components/collapsible/collapsible.ts +19 -14
- package/dist/ui/components/context-menu/context-menu.test.ts +224 -0
- package/dist/ui/components/context-menu/context-menu.ts +110 -0
- package/dist/ui/components/context-menu/index.ts +1 -0
- package/dist/ui/components/dialog/dialog.test.ts +213 -108
- package/dist/ui/components/dialog/dialog.ts +72 -35
- package/dist/ui/components/dock/dock-scroll.test.ts +130 -0
- package/dist/ui/components/dock/dock-scroll.ts +133 -0
- package/dist/ui/components/dock/dock.test.ts +749 -0
- package/dist/ui/components/dock/dock.ts +960 -0
- package/dist/ui/components/dock/index.ts +2 -0
- package/dist/ui/components/empty-state/empty-state.test.ts +28 -39
- package/dist/ui/components/glass/concentric-radius.test.ts +13 -0
- package/dist/ui/components/glass/concentric-radius.ts +17 -0
- package/dist/ui/components/glass/glass-design.test.ts +78 -0
- package/dist/ui/components/glass/glass-design.ts +119 -0
- package/dist/ui/components/glass/glass.test.ts +338 -0
- package/dist/ui/components/glass/glass.ts +360 -0
- package/dist/ui/components/glass/index.ts +18 -0
- package/dist/ui/components/icon/icon-theme.test.ts +169 -0
- package/dist/ui/components/icon/icon-theme.ts +227 -0
- package/dist/ui/components/icon/icon.test.ts +85 -25
- package/dist/ui/components/icon/icon.ts +38 -21
- package/dist/ui/components/input/input.test.ts +178 -101
- package/dist/ui/components/input/input.ts +15 -12
- package/dist/ui/components/label/label.test.ts +11 -24
- package/dist/ui/components/line-chart/index.ts +2 -3
- package/dist/ui/components/line-chart/line-chart.test.ts +149 -56
- package/dist/ui/components/line-chart/line-chart.ts +83 -241
- package/dist/ui/components/list/list.test.ts +119 -21
- package/dist/ui/components/list/list.ts +21 -15
- package/dist/ui/components/menu/index.ts +25 -0
- package/dist/ui/components/menu/menu-placement.test.ts +153 -0
- package/dist/ui/components/menu/menu-placement.ts +159 -0
- package/dist/ui/components/menu/menu-popup.test.ts +632 -0
- package/dist/ui/components/menu/menu-popup.ts +544 -0
- package/dist/ui/components/menu/menu.test.ts +429 -0
- package/dist/ui/components/menu/menu.ts +415 -0
- package/dist/ui/components/nav-drawer/nav-drawer.test.ts +435 -191
- package/dist/ui/components/nav-drawer/nav-drawer.ts +127 -56
- package/dist/ui/components/pagination/pagination.test.ts +177 -65
- package/dist/ui/components/pagination/pagination.ts +55 -8
- package/dist/ui/components/progress/progress.test.ts +102 -46
- package/dist/ui/components/progress/progress.ts +52 -54
- package/dist/ui/components/radio-group/radio-group.test.ts +128 -83
- package/dist/ui/components/radio-group/radio-group.ts +24 -24
- package/dist/ui/components/scatter-chart/index.ts +2 -3
- package/dist/ui/components/scatter-chart/scatter-chart.test.ts +131 -26
- package/dist/ui/components/scatter-chart/scatter-chart.ts +104 -250
- package/dist/ui/components/scroll-area/scroll-area.test.ts +95 -24
- package/dist/ui/components/scroll-area/scroll-area.ts +8 -8
- package/dist/ui/components/select/select.test.ts +138 -78
- package/dist/ui/components/select/select.ts +17 -11
- package/dist/ui/components/separator/separator.test.ts +18 -17
- package/dist/ui/components/sheet/sheet.test.ts +64 -11
- package/dist/ui/components/sheet/sheet.ts +9 -1
- package/dist/ui/components/skeleton/skeleton.test.ts +24 -7
- package/dist/ui/components/skeleton/skeleton.ts +10 -16
- package/dist/ui/components/spinner/spinner.test.ts +67 -22
- package/dist/ui/components/spinner/spinner.ts +48 -41
- package/dist/ui/components/switch/switch.test.ts +116 -46
- package/dist/ui/components/switch/switch.ts +8 -13
- package/dist/ui/components/tab-bar/index.ts +1 -0
- package/dist/ui/components/tab-bar/tab-bar.test.ts +280 -0
- package/dist/ui/components/tab-bar/tab-bar.ts +230 -0
- package/dist/ui/components/tabs/tabs.test.ts +215 -157
- package/dist/ui/components/tabs/tabs.ts +110 -118
- package/dist/ui/components/textarea/textarea.test.ts +206 -100
- package/dist/ui/components/textarea/textarea.ts +14 -12
- package/dist/ui/components/toast/toast.test.ts +436 -315
- package/dist/ui/components/toast/toast.ts +62 -55
- package/dist/ui/components/toggle/toggle.test.ts +247 -140
- package/dist/ui/theme/chart-colors.test.ts +35 -0
- package/dist/ui/theme/dark.css +46 -2
- package/dist/ui/theme/default.css +63 -7
- package/dist/ui/theme/icon-colors.test.ts +35 -0
- package/dist/ui/theme/rgb-channels.test.ts +84 -0
- package/dist/ui/theme/tailwind-build.test.ts +114 -0
- package/dist/ui/theme/tailwind-css.test.ts +83 -0
- package/dist/ui/theme/tailwind-plugin.test.ts +42 -2
- package/dist/ui/theme/tailwind-plugin.ts +98 -25
- package/dist/ui/theme/tailwind.css +113 -0
- package/dist/ui/utils/animate.test.ts +13 -1
- package/dist/utils/analyze.d.ts +14 -0
- package/dist/utils/analyze.js +15 -0
- package/dist/utils/analyze.js.map +1 -1
- package/dist/utils/analyze.test.js +14 -1
- package/dist/utils/analyze.test.js.map +1 -1
- package/dist/utils/installed.d.ts +29 -0
- package/dist/utils/installed.js +43 -0
- package/dist/utils/installed.js.map +1 -0
- package/dist/utils/installed.test.d.ts +1 -0
- package/dist/utils/installed.test.js +57 -0
- package/dist/utils/installed.test.js.map +1 -0
- package/dist/utils/interactive.d.ts +9 -0
- package/dist/utils/interactive.js +10 -0
- package/dist/utils/interactive.js.map +1 -0
- package/dist/utils/interactive.test.d.ts +1 -0
- package/dist/utils/interactive.test.js +24 -0
- package/dist/utils/interactive.test.js.map +1 -0
- package/dist/utils/packages.d.ts +36 -0
- package/dist/utils/packages.js +70 -0
- package/dist/utils/packages.js.map +1 -0
- package/dist/utils/packages.test.d.ts +1 -0
- package/dist/utils/packages.test.js +89 -0
- package/dist/utils/packages.test.js.map +1 -0
- package/dist/utils/resolve-paths.d.ts +17 -1
- package/dist/utils/resolve-paths.js +21 -3
- package/dist/utils/resolve-paths.js.map +1 -1
- package/dist/utils/resolve-paths.test.js +38 -2
- package/dist/utils/resolve-paths.test.js.map +1 -1
- package/dist/utils/tailwind.d.ts +25 -0
- package/dist/utils/tailwind.js +51 -0
- package/dist/utils/tailwind.js.map +1 -0
- package/dist/utils/tailwind.test.d.ts +1 -0
- package/dist/utils/tailwind.test.js +71 -0
- package/dist/utils/tailwind.test.js.map +1 -0
- package/package.json +13 -1
- package/dist/ui/components/area-chart/area-chart-render.test.ts +0 -121
- package/dist/ui/components/bar-chart/bar-chart-render.test.ts +0 -174
- package/dist/ui/components/button/button-render.test.ts +0 -113
- package/dist/ui/components/button-group/button-group-render.test.ts +0 -146
- package/dist/ui/components/candlestick-chart/candlestick-chart-render.test.ts +0 -174
- package/dist/ui/components/cartesian-chart/cartesian-chart-render.test.ts +0 -188
- package/dist/ui/components/cartesian-chart/cartesian-chart.test.ts +0 -525
- package/dist/ui/components/cartesian-chart/cartesian-chart.ts +0 -1140
- package/dist/ui/components/cartesian-chart/index.ts +0 -18
- package/dist/ui/components/line-chart/line-chart-render.test.ts +0 -121
- package/dist/ui/components/scatter-chart/scatter-chart-render.test.ts +0 -157
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import {
|
|
2
|
+
booleanAttribute,
|
|
3
|
+
Component,
|
|
4
|
+
computed,
|
|
5
|
+
effect,
|
|
6
|
+
ElementRef,
|
|
7
|
+
inject,
|
|
8
|
+
input,
|
|
9
|
+
numberAttribute,
|
|
10
|
+
ViewEncapsulation,
|
|
11
|
+
} from '@angular/core';
|
|
12
|
+
import { LYNX_ELEMENTS, LynxAccessibilitySettings } from '@blotch/angular-lynx';
|
|
13
|
+
|
|
14
|
+
import { cn } from '../../utils/cn';
|
|
15
|
+
import {
|
|
16
|
+
injectColorScheme,
|
|
17
|
+
resolveIconColor,
|
|
18
|
+
UI_ICON_COLOR,
|
|
19
|
+
UI_ICON_THEME,
|
|
20
|
+
} from '../icon/icon-theme';
|
|
21
|
+
import { injectGlassDesign, injectSystemDrawsGlass } from './glass-design';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `'regular'` glass, the default, frosts what's behind it and suits most
|
|
25
|
+
* controls. `'clear'` glass barely frosts it, for controls over photos and
|
|
26
|
+
* video; put a dimming layer under it when what's behind is bright (see
|
|
27
|
+
* `bg-glass-dim`). Don't mix the two on one screen.
|
|
28
|
+
*/
|
|
29
|
+
export type GlassVariant = 'regular' | 'clear';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A capsule (fully rounded ends, the default for controls), a circle (give
|
|
33
|
+
* it equal width and height) or a rectangle with `radius` corners.
|
|
34
|
+
*/
|
|
35
|
+
export type GlassShape = 'capsule' | 'circle' | 'rounded';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* What a glass element draws:
|
|
39
|
+
*
|
|
40
|
+
* - `'glass'`: Liquid Glass.
|
|
41
|
+
* - `'frosted'`: a blur material, on iOS 15 to 25.
|
|
42
|
+
* - `'solid'`: an opaque surface. That's Material on Android, unless the app
|
|
43
|
+
* opted into glass there, and glass under Reduce Transparency on Android
|
|
44
|
+
* and the web, which can't adapt the glass they draw. iOS adapts its own.
|
|
45
|
+
*/
|
|
46
|
+
export type GlassSurface = 'glass' | 'frosted' | 'solid';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* How much the glass blurs where the blur is drawn by the runtime: Android's
|
|
50
|
+
* approximation, and the web before WebGL takes over. iOS's glass ignores it.
|
|
51
|
+
* Clear glass barely blurs.
|
|
52
|
+
*/
|
|
53
|
+
const GLASS_BLUR: Readonly<Record<GlassVariant, string>> = {
|
|
54
|
+
regular: '16px',
|
|
55
|
+
clear: '6px',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** The blur of the frosted materials before iOS 26. */
|
|
59
|
+
const FROSTED_BLUR = '20px';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A solid surface floats over the content as glass does, so it gets
|
|
63
|
+
* Material's elevation shadow (level 2). An inline style, because Tailwind's
|
|
64
|
+
* shadow classes draw nothing on Lynx.
|
|
65
|
+
*/
|
|
66
|
+
const SOLID_ELEVATION =
|
|
67
|
+
'0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.15)';
|
|
68
|
+
|
|
69
|
+
/** AngularLynx's wrapper of the native `blur-view` the component sits on. */
|
|
70
|
+
type BlurViewElement = { setAttribute(name: string, value: unknown): void };
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The color an icon projected into the glass draws with when it's given
|
|
74
|
+
* none: the glass's foreground (see UI_ICON_COLOR), the way text there reads
|
|
75
|
+
* `text-glass-foreground`. A named function, not an inline factory: the
|
|
76
|
+
* component's metadata keeps its own copy of an inline one, which nothing
|
|
77
|
+
* calls, so an app's coverage report would show it as uncovered.
|
|
78
|
+
*/
|
|
79
|
+
const glassIconColor = () => {
|
|
80
|
+
const glass = inject(UiGlass);
|
|
81
|
+
return computed(() => glass.foreground());
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Liquid Glass, for the controls and bars that float above an app's content:
|
|
86
|
+
* a `<blur-view>` that draws the right material on each platform.
|
|
87
|
+
*
|
|
88
|
+
* ```html
|
|
89
|
+
* <blur-view ui-glass class="flex-row items-center gap-2 px-4 py-2">
|
|
90
|
+
* <text class="text-glass-foreground">Now playing</text>
|
|
91
|
+
* </blur-view>
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* It sits on the `<blur-view>` itself rather than wrapping one, so the
|
|
95
|
+
* element you lay out and style is the glass, and what you put in it is
|
|
96
|
+
* inside the glass. That matters on iOS: interactive glass reacts only to
|
|
97
|
+
* touches on itself and what's in it, not on views stacked over it.
|
|
98
|
+
*
|
|
99
|
+
* What it draws follows the platform (see GlassDesign): UIKit's Liquid Glass
|
|
100
|
+
* on iOS 26 and later, a frosted blur material on iOS 15 to 25, an opaque
|
|
101
|
+
* Material surface on Android unless the app opts into glass with
|
|
102
|
+
* `provideGlass({ android: 'glass' })`, and the runtime's WebGL glass in the
|
|
103
|
+
* web preview. It also follows the user's accessibility settings where the
|
|
104
|
+
* platform doesn't: see {@link surface}.
|
|
105
|
+
*
|
|
106
|
+
* Text and icons inside read `text-glass-foreground` (and
|
|
107
|
+
* `text-glass-muted-foreground`), which the glass points at the right color
|
|
108
|
+
* for its variant and the user's contrast setting. Glass belongs to the
|
|
109
|
+
* layer above content, and shouldn't be layered on glass.
|
|
110
|
+
*/
|
|
111
|
+
@Component({
|
|
112
|
+
selector: 'blur-view[ui-glass]',
|
|
113
|
+
imports: [LYNX_ELEMENTS],
|
|
114
|
+
encapsulation: ViewEncapsulation.None,
|
|
115
|
+
// Icons projected into the glass inject this through its element injector,
|
|
116
|
+
// which content projection keeps them under.
|
|
117
|
+
providers: [{ provide: UI_ICON_COLOR, useFactory: glassIconColor }],
|
|
118
|
+
host: {
|
|
119
|
+
'[class]': 'surfaceClass()',
|
|
120
|
+
'[style.border-radius.px]': 'cornerRadius()',
|
|
121
|
+
'[style.background-color]': 'solidTint()',
|
|
122
|
+
'[style.box-shadow]': 'elevation()',
|
|
123
|
+
},
|
|
124
|
+
// iOS draws no background on a blur view, so a frosted material takes its
|
|
125
|
+
// tint from a fill under the content, the shape of the glass: the filled
|
|
126
|
+
// button of the design before Liquid Glass.
|
|
127
|
+
template: `
|
|
128
|
+
@if (frostedTint(); as color) {
|
|
129
|
+
<view
|
|
130
|
+
[class]="fillClass()"
|
|
131
|
+
[style.background-color]="color"
|
|
132
|
+
[style.border-radius.px]="cornerRadius()"
|
|
133
|
+
></view>
|
|
134
|
+
}
|
|
135
|
+
<ng-content />
|
|
136
|
+
`,
|
|
137
|
+
})
|
|
138
|
+
export class UiGlass {
|
|
139
|
+
/** `'regular'` or `'clear'`; see GlassVariant. */
|
|
140
|
+
readonly variant = input<GlassVariant>('regular');
|
|
141
|
+
/** `'capsule'`, `'circle'` or `'rounded'`; see GlassShape. */
|
|
142
|
+
readonly shape = input<GlassShape>('capsule');
|
|
143
|
+
/**
|
|
144
|
+
* The corner radius of a `'rounded'` shape, in px. For a shape nested in
|
|
145
|
+
* it, see `concentricRadius()`.
|
|
146
|
+
*/
|
|
147
|
+
readonly radius = input(20, { transform: numberAttribute });
|
|
148
|
+
/**
|
|
149
|
+
* A color the glass takes on, such as `var(--glass-tint)` for the theme's
|
|
150
|
+
* tint or `#2563eb`: a theme token or any CSS color. Use it sparingly, for
|
|
151
|
+
* the screen's main action. It fills a solid surface or a frosted
|
|
152
|
+
* material, as Material, and iOS before Liquid Glass, fill a button.
|
|
153
|
+
*/
|
|
154
|
+
readonly tint = input<string | undefined>(undefined);
|
|
155
|
+
/**
|
|
156
|
+
* The glass reacts to touch, swelling and brightening under the finger as
|
|
157
|
+
* a Liquid Glass control does: on iOS 26 and later, and in the web preview.
|
|
158
|
+
*/
|
|
159
|
+
readonly interactive = input(false, { transform: booleanAttribute });
|
|
160
|
+
|
|
161
|
+
readonly #settings = inject(LynxAccessibilitySettings);
|
|
162
|
+
readonly #systemDrawsGlass = injectSystemDrawsGlass();
|
|
163
|
+
readonly #scheme = injectColorScheme();
|
|
164
|
+
readonly #theme = inject(UI_ICON_THEME);
|
|
165
|
+
readonly #host = inject<ElementRef<BlurViewElement>>(ElementRef);
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The design on this platform, which components built on the glass follow
|
|
169
|
+
* for their own form (see GlassDesign).
|
|
170
|
+
*/
|
|
171
|
+
readonly design = injectGlassDesign();
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* What the glass draws (see GlassSurface): the design's material, or an
|
|
175
|
+
* opaque surface. Where the runtime draws the glass (Android's opt-in and
|
|
176
|
+
* the web), Reduce Transparency turns it opaque, as UIKit turns its own.
|
|
177
|
+
*/
|
|
178
|
+
readonly surface = computed<GlassSurface>(() => {
|
|
179
|
+
const design = this.design();
|
|
180
|
+
if (design === 'material') return 'solid';
|
|
181
|
+
if (!this.#systemDrawsGlass && this.#settings.reduceTransparency()) {
|
|
182
|
+
return 'solid';
|
|
183
|
+
}
|
|
184
|
+
return design;
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
/** Whether what's behind shows through clear glass. */
|
|
188
|
+
readonly #seeThrough = computed(
|
|
189
|
+
() => this.variant() === 'clear' && this.surface() !== 'solid',
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The color of text and icons on this glass, as a `var()`: the clear
|
|
194
|
+
* foreground on see-through clear glass, which sits over photos and video,
|
|
195
|
+
* and the glass foreground otherwise. Projected `<ui-icon>`s get it, and an
|
|
196
|
+
* SVG of your own can resolve it the way icons do (see icon-theme.ts).
|
|
197
|
+
*/
|
|
198
|
+
readonly foreground = computed(() =>
|
|
199
|
+
this.#seeThrough()
|
|
200
|
+
? 'var(--glass-clear-foreground)'
|
|
201
|
+
: 'var(--glass-foreground)',
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The tint as a color the native element can parse: an attribute can't
|
|
206
|
+
* read CSS variables, so a theme token is swapped for its value in the
|
|
207
|
+
* active scheme, as icons do.
|
|
208
|
+
*/
|
|
209
|
+
readonly #tintColor = computed(() => {
|
|
210
|
+
const tint = this.tint();
|
|
211
|
+
return tint ? resolveIconColor(tint, this.#theme[this.#scheme()]) : null;
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* A tinted solid surface is filled with the tint, as Material's filled
|
|
216
|
+
* buttons are, and as iOS draws tinted glass under Reduce Transparency.
|
|
217
|
+
*/
|
|
218
|
+
protected readonly solidTint = computed(() =>
|
|
219
|
+
this.surface() === 'solid' ? this.#tintColor() : null,
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
protected readonly frostedTint = computed(() =>
|
|
223
|
+
this.surface() === 'frosted' ? this.#tintColor() : null,
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
protected readonly fillClass = computed(() =>
|
|
227
|
+
cn(
|
|
228
|
+
'h-full w-full absolute left-0 top-0',
|
|
229
|
+
this.shape() !== 'rounded' && 'rounded-full',
|
|
230
|
+
),
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
protected readonly elevation = computed(() =>
|
|
234
|
+
this.surface() === 'solid' ? SOLID_ELEVATION : null,
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
protected readonly cornerRadius = computed(() =>
|
|
238
|
+
this.shape() === 'rounded' ? this.radius() : null,
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
protected readonly surfaceClass = computed(() => {
|
|
242
|
+
const increaseContrast = this.#settings.increaseContrast();
|
|
243
|
+
return cn(
|
|
244
|
+
this.shape() !== 'rounded' && 'rounded-full',
|
|
245
|
+
// Material's tonal surface, and the opaque glass of Reduce
|
|
246
|
+
// Transparency, unless a tint fills it (see solidTint). iOS ignores a
|
|
247
|
+
// blur-view's background, but never draws a solid surface.
|
|
248
|
+
this.surface() === 'solid' && !this.tint() && 'bg-secondary',
|
|
249
|
+
// Increase Contrast gives the glass a visible edge, as UIKit gives its
|
|
250
|
+
// own glass one.
|
|
251
|
+
increaseContrast &&
|
|
252
|
+
!this.#systemDrawsGlass &&
|
|
253
|
+
'border border-glass-foreground',
|
|
254
|
+
// The glass points the foreground tokens its content reads at the
|
|
255
|
+
// right color (a variable redefined here reaches the projected text,
|
|
256
|
+
// since variables inherit and `color` doesn't): white on see-through
|
|
257
|
+
// clear glass, and full strength for muted text under Increase
|
|
258
|
+
// Contrast.
|
|
259
|
+
this.#seeThrough()
|
|
260
|
+
? '[--glass-foreground:var(--glass-clear-foreground)] [--glass-muted-foreground:var(--glass-clear-foreground)]'
|
|
261
|
+
: increaseContrast &&
|
|
262
|
+
'[--glass-muted-foreground:var(--glass-foreground)]',
|
|
263
|
+
);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* The blur-view's attributes for the surface. Glass is forced to the app's
|
|
268
|
+
* color scheme (`ios-user-interface-style`), which iOS would otherwise take
|
|
269
|
+
* from the device: an app in its light theme on a phone in dark mode would
|
|
270
|
+
* get dark glass under dark text. The frosted materials before iOS 26 don't
|
|
271
|
+
* adapt to dark mode, so the scheme picks one. A solid surface turns the
|
|
272
|
+
* blur off, and on Android stops the blur-view redrawing the page behind it
|
|
273
|
+
* on every frame (`enable-auto-blur`), which it does even with no radius.
|
|
274
|
+
*/
|
|
275
|
+
readonly #attributes = computed(() => {
|
|
276
|
+
const surface = this.surface();
|
|
277
|
+
const variant = this.variant();
|
|
278
|
+
const dark = this.#scheme() === 'dark';
|
|
279
|
+
let effect = 'light';
|
|
280
|
+
let radius = '0px';
|
|
281
|
+
if (surface === 'glass') {
|
|
282
|
+
effect = 'glass';
|
|
283
|
+
radius = GLASS_BLUR[variant];
|
|
284
|
+
} else if (surface === 'frosted') {
|
|
285
|
+
// Apple's controls over media used the dark material in either theme.
|
|
286
|
+
effect = dark || variant === 'clear' ? 'dark' : 'extra-light';
|
|
287
|
+
radius = FROSTED_BLUR;
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
'blur-effect': effect,
|
|
291
|
+
'blur-radius': radius,
|
|
292
|
+
'enable-auto-blur': surface !== 'solid',
|
|
293
|
+
'glass-style': variant,
|
|
294
|
+
'glass-tint-color': this.#tintColor(),
|
|
295
|
+
'glass-interactive': this.interactive() || null,
|
|
296
|
+
'ios-user-interface-style': dark ? 'dark' : 'light',
|
|
297
|
+
};
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// Set on the element as they are, rather than through host attribute
|
|
301
|
+
// bindings, which turn every value into a string: Lynx reads
|
|
302
|
+
// `glass-interactive` and `enable-auto-blur` as booleans. `null` removes an
|
|
303
|
+
// attribute, which restores Lynx's default.
|
|
304
|
+
protected readonly material = effect(() => {
|
|
305
|
+
const element = this.#host.nativeElement;
|
|
306
|
+
for (const [name, value] of Object.entries(this.#attributes())) {
|
|
307
|
+
element.setAttribute(name, value);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Merges the glass elements inside it, as iOS 26 draws a group of glass
|
|
314
|
+
* controls: shapes closer than `spacing` flow into each other like droplets,
|
|
315
|
+
* and the group draws them in one pass. Put a `<blur-view ui-glass>` directly
|
|
316
|
+
* inside it for each shape: iOS merges the glass in the group's own content,
|
|
317
|
+
* and a wrapper that draws anything of its own comes between them.
|
|
318
|
+
*
|
|
319
|
+
* ```html
|
|
320
|
+
* <blur-view ui-glass-group [spacing]="16" class="flex-row gap-2">
|
|
321
|
+
* <blur-view ui-glass shape="circle" class="h-12 w-12">…</blur-view>
|
|
322
|
+
* <blur-view ui-glass shape="circle" class="h-12 w-12">…</blur-view>
|
|
323
|
+
* </blur-view>
|
|
324
|
+
* ```
|
|
325
|
+
*
|
|
326
|
+
* The group draws nothing itself. Shapes merge on iOS 26 and later and in
|
|
327
|
+
* the web preview. Android's glass doesn't merge, and the frosted and
|
|
328
|
+
* Material designs have no glass to merge.
|
|
329
|
+
*
|
|
330
|
+
* Moving or resizing a shape, with a CSS transition for example, morphs the
|
|
331
|
+
* merged glass with it. A shape that's added or removed appears or
|
|
332
|
+
* disappears at once: iOS's glass doesn't animate that in Lynx.
|
|
333
|
+
*/
|
|
334
|
+
@Component({
|
|
335
|
+
selector: 'blur-view[ui-glass-group]',
|
|
336
|
+
encapsulation: ViewEncapsulation.None,
|
|
337
|
+
template: `<ng-content />`,
|
|
338
|
+
})
|
|
339
|
+
export class UiGlassGroup {
|
|
340
|
+
/** How close two glass shapes come before they merge, in px. */
|
|
341
|
+
readonly spacing = input(0, { transform: numberAttribute });
|
|
342
|
+
|
|
343
|
+
readonly #design = injectGlassDesign();
|
|
344
|
+
readonly #host = inject<ElementRef<BlurViewElement>>(ElementRef);
|
|
345
|
+
|
|
346
|
+
// As UiGlass sets its own (see there). A container that isn't merging
|
|
347
|
+
// glass is a plain transparent view: `light` with no radius draws nothing,
|
|
348
|
+
// where `glass-container` would log an error before iOS 26. It never blurs,
|
|
349
|
+
// so on Android it never redraws the page behind it either.
|
|
350
|
+
protected readonly material = effect(() => {
|
|
351
|
+
const element = this.#host.nativeElement;
|
|
352
|
+
element.setAttribute(
|
|
353
|
+
'blur-effect',
|
|
354
|
+
this.#design() === 'glass' ? 'glass-container' : 'light',
|
|
355
|
+
);
|
|
356
|
+
element.setAttribute('blur-radius', '0px');
|
|
357
|
+
element.setAttribute('enable-auto-blur', false);
|
|
358
|
+
element.setAttribute('spacing', this.spacing());
|
|
359
|
+
});
|
|
360
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export {
|
|
2
|
+
UiGlass,
|
|
3
|
+
UiGlassGroup,
|
|
4
|
+
type GlassShape,
|
|
5
|
+
type GlassSurface,
|
|
6
|
+
type GlassVariant,
|
|
7
|
+
} from './glass';
|
|
8
|
+
export {
|
|
9
|
+
FIRST_GLASS_IOS,
|
|
10
|
+
UI_GLASS_OPTIONS,
|
|
11
|
+
glassDesignFor,
|
|
12
|
+
injectGlassDesign,
|
|
13
|
+
injectSystemDrawsGlass,
|
|
14
|
+
provideGlass,
|
|
15
|
+
type GlassDesign,
|
|
16
|
+
type GlassOptions,
|
|
17
|
+
} from './glass-design';
|
|
18
|
+
export { concentricRadius } from './concentric-radius';
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Injector,
|
|
3
|
+
type Provider,
|
|
4
|
+
runInInjectionContext,
|
|
5
|
+
signal,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
import { LynxTheme } from '@blotch/angular-lynx';
|
|
8
|
+
import { describe, expect, it } from 'vitest';
|
|
9
|
+
import {
|
|
10
|
+
ICON_DARK_COLORS,
|
|
11
|
+
ICON_LIGHT_COLORS,
|
|
12
|
+
UI_ICON_COLOR,
|
|
13
|
+
UI_ICON_THEME,
|
|
14
|
+
injectColorScheme,
|
|
15
|
+
injectIconColor,
|
|
16
|
+
provideIconTheme,
|
|
17
|
+
resolveIconColor,
|
|
18
|
+
} from './icon-theme';
|
|
19
|
+
|
|
20
|
+
const LIGHT_FOREGROUND = ICON_LIGHT_COLORS['foreground'];
|
|
21
|
+
const DARK_FOREGROUND = ICON_DARK_COLORS['foreground'];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Runs injectIconColor() against a device appearance and extra providers. A
|
|
25
|
+
* plain Injector has no root scope, so it gets the default theme explicitly;
|
|
26
|
+
* the token's own factory is covered by the component tests.
|
|
27
|
+
*/
|
|
28
|
+
const setup = (providers: Provider[] = [], dark = signal(false)) => {
|
|
29
|
+
const injector = Injector.create({
|
|
30
|
+
providers: [
|
|
31
|
+
{ provide: LynxTheme, useValue: { isDarkMode: dark } },
|
|
32
|
+
{
|
|
33
|
+
provide: UI_ICON_THEME,
|
|
34
|
+
useValue: { light: ICON_LIGHT_COLORS, dark: ICON_DARK_COLORS },
|
|
35
|
+
},
|
|
36
|
+
...providers,
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
return runInInjectionContext(injector, () => injectIconColor());
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
describe('resolveIconColor', () => {
|
|
43
|
+
it('passes a literal color through', () => {
|
|
44
|
+
expect(resolveIconColor('#2563eb', ICON_LIGHT_COLORS)).toBe('#2563eb');
|
|
45
|
+
expect(resolveIconColor(' rgba(1, 2, 3, 1) ', ICON_LIGHT_COLORS)).toBe(
|
|
46
|
+
'rgba(1, 2, 3, 1)',
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('swaps a theme token for its value', () => {
|
|
51
|
+
expect(resolveIconColor('var(--primary)', ICON_LIGHT_COLORS)).toBe(
|
|
52
|
+
ICON_LIGHT_COLORS['primary'],
|
|
53
|
+
);
|
|
54
|
+
expect(resolveIconColor('var( --destructive )', ICON_DARK_COLORS)).toBe(
|
|
55
|
+
ICON_DARK_COLORS['destructive'],
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("falls back to the var()'s fallback for an unknown token", () => {
|
|
60
|
+
expect(resolveIconColor('var(--brand, #ff0000)', ICON_LIGHT_COLORS)).toBe(
|
|
61
|
+
'#ff0000',
|
|
62
|
+
);
|
|
63
|
+
// The fallback may itself be a token.
|
|
64
|
+
expect(
|
|
65
|
+
resolveIconColor('var(--brand, var(--primary))', ICON_LIGHT_COLORS),
|
|
66
|
+
).toBe(ICON_LIGHT_COLORS['primary']);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('falls back to the foreground for an unknown token with no fallback', () => {
|
|
70
|
+
expect(resolveIconColor('var(--brand)', ICON_LIGHT_COLORS)).toBe(
|
|
71
|
+
LIGHT_FOREGROUND,
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('leaves an unknown token as it is when the table has no foreground', () => {
|
|
76
|
+
expect(resolveIconColor('var(--brand)', {})).toBe('var(--brand)');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('provideIconTheme', () => {
|
|
81
|
+
it('merges the overrides over the default tables', () => {
|
|
82
|
+
const provider = provideIconTheme({
|
|
83
|
+
light: { primary: '#123456' },
|
|
84
|
+
colorScheme: 'dark',
|
|
85
|
+
}) as { provide: unknown; useValue: Record<string, unknown> };
|
|
86
|
+
expect(provider.provide).toBe(UI_ICON_THEME);
|
|
87
|
+
expect(provider.useValue['light']).toEqual({
|
|
88
|
+
...ICON_LIGHT_COLORS,
|
|
89
|
+
primary: '#123456',
|
|
90
|
+
});
|
|
91
|
+
expect(provider.useValue['dark']).toEqual(ICON_DARK_COLORS);
|
|
92
|
+
expect(provider.useValue['colorScheme']).toBe('dark');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('injectColorScheme', () => {
|
|
97
|
+
const scheme = (providers: Provider[], dark = signal(false)) =>
|
|
98
|
+
runInInjectionContext(
|
|
99
|
+
Injector.create({
|
|
100
|
+
providers: [
|
|
101
|
+
{ provide: LynxTheme, useValue: { isDarkMode: dark } },
|
|
102
|
+
{
|
|
103
|
+
provide: UI_ICON_THEME,
|
|
104
|
+
useValue: { light: ICON_LIGHT_COLORS, dark: ICON_DARK_COLORS },
|
|
105
|
+
},
|
|
106
|
+
...providers,
|
|
107
|
+
],
|
|
108
|
+
}),
|
|
109
|
+
() => injectColorScheme(),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
it("is light unless the theme says otherwise, whatever the device's appearance", () => {
|
|
113
|
+
expect(scheme([], signal(true))()).toBe('light');
|
|
114
|
+
expect(scheme([provideIconTheme({ colorScheme: 'dark' })])()).toBe('dark');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("follows the device with 'system', or the app's own state", () => {
|
|
118
|
+
const dark = signal(false);
|
|
119
|
+
const system = scheme([provideIconTheme({ colorScheme: 'system' })], dark);
|
|
120
|
+
expect(system()).toBe('light');
|
|
121
|
+
dark.set(true);
|
|
122
|
+
expect(system()).toBe('dark');
|
|
123
|
+
|
|
124
|
+
const own = signal<'light' | 'dark'>('dark');
|
|
125
|
+
expect(scheme([provideIconTheme({ colorScheme: () => own() })])()).toBe(
|
|
126
|
+
'dark',
|
|
127
|
+
);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe('injectIconColor', () => {
|
|
132
|
+
it('draws with the light foreground by default, even on a dark device', () => {
|
|
133
|
+
const resolve = setup([], signal(true));
|
|
134
|
+
expect(resolve(undefined)).toBe(LIGHT_FOREGROUND);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('resolves an explicit color against the active table', () => {
|
|
138
|
+
const resolve = setup([provideIconTheme({ colorScheme: 'dark' })]);
|
|
139
|
+
expect(resolve('var(--primary)')).toBe(ICON_DARK_COLORS['primary']);
|
|
140
|
+
expect(resolve('#00ff00')).toBe('#00ff00');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("follows the device appearance with 'system'", () => {
|
|
144
|
+
const dark = signal(false);
|
|
145
|
+
const resolve = setup([provideIconTheme({ colorScheme: 'system' })], dark);
|
|
146
|
+
expect(resolve(undefined)).toBe(LIGHT_FOREGROUND);
|
|
147
|
+
dark.set(true);
|
|
148
|
+
expect(resolve(undefined)).toBe(DARK_FOREGROUND);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("reads the app's own theme state from a function", () => {
|
|
152
|
+
const scheme = signal<'light' | 'dark'>('dark');
|
|
153
|
+
const resolve = setup([provideIconTheme({ colorScheme: () => scheme() })]);
|
|
154
|
+
expect(resolve(undefined)).toBe(DARK_FOREGROUND);
|
|
155
|
+
scheme.set('light');
|
|
156
|
+
expect(resolve(undefined)).toBe(LIGHT_FOREGROUND);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("uses the container's color when the icon sets none", () => {
|
|
160
|
+
const inherited = signal<string | undefined>('var(--destructive)');
|
|
161
|
+
const resolve = setup([{ provide: UI_ICON_COLOR, useValue: inherited }]);
|
|
162
|
+
expect(resolve(undefined)).toBe(ICON_LIGHT_COLORS['destructive']);
|
|
163
|
+
// The icon's own color still wins.
|
|
164
|
+
expect(resolve('var(--primary)')).toBe(ICON_LIGHT_COLORS['primary']);
|
|
165
|
+
// A container that sets no color leaves the foreground.
|
|
166
|
+
inherited.set(undefined);
|
|
167
|
+
expect(resolve(undefined)).toBe(LIGHT_FOREGROUND);
|
|
168
|
+
});
|
|
169
|
+
});
|