react-native-terra-ui 0.10.2 → 0.11.1
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/CHANGELOG.md +28 -0
- package/README.md +8 -4
- package/lib/module/components/badge/Badge.js +174 -0
- package/lib/module/components/badge/Badge.js.map +1 -0
- package/lib/module/components/badge/index.js +4 -0
- package/lib/module/components/badge/index.js.map +1 -0
- package/lib/module/components/badge/parts/BadgeIndicator.js +191 -0
- package/lib/module/components/badge/parts/BadgeIndicator.js.map +1 -0
- package/lib/module/components/badge/types.js +4 -0
- package/lib/module/components/badge/types.js.map +1 -0
- package/lib/module/components/badge/utils.js +25 -0
- package/lib/module/components/badge/utils.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/context/ThemeProvider.js +5 -5
- package/lib/module/context/ThemeProvider.js.map +1 -1
- package/lib/module/theme/define-config.js +5 -5
- package/lib/module/theme/define-config.js.map +1 -1
- package/lib/module/theme/errors.js +1 -1
- package/lib/module/theme/index.js +2 -2
- package/lib/module/theme/index.js.map +1 -1
- package/lib/module/theme/registry.js +15 -21
- package/lib/module/theme/registry.js.map +1 -1
- package/lib/module/theme/resolve-config.js +68 -68
- package/lib/module/theme/resolve-config.js.map +1 -1
- package/lib/module/theme/runtime.js +11 -11
- package/lib/module/theme/runtime.js.map +1 -1
- package/lib/module/theme/selection-store.js +7 -7
- package/lib/module/theme/selection-store.js.map +1 -1
- package/lib/module/theme/unistyles-adapter.js +1 -1
- package/lib/module/utils/accent-utils.js +24 -24
- package/lib/module/utils/accent-utils.js.map +1 -1
- package/lib/typescript/src/components/badge/Badge.d.ts +16 -0
- package/lib/typescript/src/components/badge/Badge.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/index.d.ts +3 -0
- package/lib/typescript/src/components/badge/index.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/parts/BadgeIndicator.d.ts +19 -0
- package/lib/typescript/src/components/badge/parts/BadgeIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/types.d.ts +48 -0
- package/lib/typescript/src/components/badge/types.d.ts.map +1 -0
- package/lib/typescript/src/components/badge/utils.d.ts +13 -0
- package/lib/typescript/src/components/badge/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +1 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/context/ThemeProvider.d.ts +7 -7
- package/lib/typescript/src/context/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/src/theme/define-config.d.ts +11 -8
- package/lib/typescript/src/theme/define-config.d.ts.map +1 -1
- package/lib/typescript/src/theme/errors.d.ts +1 -1
- package/lib/typescript/src/theme/index.d.ts +3 -3
- package/lib/typescript/src/theme/index.d.ts.map +1 -1
- package/lib/typescript/src/theme/registry.d.ts +5 -5
- package/lib/typescript/src/theme/registry.d.ts.map +1 -1
- package/lib/typescript/src/theme/resolve-config.d.ts +25 -25
- package/lib/typescript/src/theme/resolve-config.d.ts.map +1 -1
- package/lib/typescript/src/theme/runtime.d.ts +5 -5
- package/lib/typescript/src/theme/runtime.d.ts.map +1 -1
- package/lib/typescript/src/theme/selection-store.d.ts +5 -5
- package/lib/typescript/src/theme/selection-store.d.ts.map +1 -1
- package/lib/typescript/src/theme/types.d.ts +20 -47
- package/lib/typescript/src/theme/types.d.ts.map +1 -1
- package/lib/typescript/src/theme/unistyles-adapter.d.ts +1 -1
- package/lib/typescript/src/utils/accent-utils.d.ts +6 -7
- package/lib/typescript/src/utils/accent-utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/badge/Badge.tsx +111 -0
- package/src/components/badge/index.ts +2 -0
- package/src/components/badge/parts/BadgeIndicator.tsx +166 -0
- package/src/components/badge/types.ts +58 -0
- package/src/components/badge/utils.ts +24 -0
- package/src/components/index.ts +1 -0
- package/src/context/ThemeProvider.tsx +10 -10
- package/src/theme/define-config.ts +12 -7
- package/src/theme/errors.ts +1 -1
- package/src/theme/index.ts +6 -8
- package/src/theme/registry.ts +15 -23
- package/src/theme/resolve-config.ts +88 -95
- package/src/theme/runtime.ts +11 -11
- package/src/theme/selection-store.ts +9 -9
- package/src/theme/types.ts +21 -47
- package/src/theme/unistyles-adapter.ts +1 -1
- package/src/utils/accent-utils.ts +25 -25
|
@@ -139,10 +139,10 @@ declare global {
|
|
|
139
139
|
namespace TerraUI {
|
|
140
140
|
/**
|
|
141
141
|
* Augment to declare app-specific semantic color keys. Declared keys become
|
|
142
|
-
* valid in `shared` /
|
|
142
|
+
* valid in `shared` / named theme tokens, `theme.color`, and
|
|
143
143
|
* component color props. Keys must not collide with built-in canonical or
|
|
144
144
|
* deprecated names. Type augmentation alone cannot prove a value exists at
|
|
145
|
-
* runtime — provide every declared color through `shared` or
|
|
145
|
+
* runtime — provide every declared color through `shared` or each theme's light/dark entries.
|
|
146
146
|
*
|
|
147
147
|
* @example
|
|
148
148
|
* declare global {
|
|
@@ -229,41 +229,19 @@ export type Scheme = "light" | "dark";
|
|
|
229
229
|
* `light` / `dark` pin a scheme and stop following the system.
|
|
230
230
|
*/
|
|
231
231
|
export type ThemeMode = "system" | "light" | "dark";
|
|
232
|
-
/**
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
* `accent.solid.bg` in `overrides` when an exact fill is required.
|
|
236
|
-
*/
|
|
237
|
-
export interface AccentSeed {
|
|
238
|
-
/** Opaque six-digit sRGB hex (`#rrggbb`). Other formats are rejected at configure time. */
|
|
232
|
+
/** Explicit theme tokens plus a seed-generated accent palette. */
|
|
233
|
+
export type ThemeSeed = TerraThemeOverride & {
|
|
234
|
+
/** Opaque six-digit hex color. Explicit `color` values win over generation. */
|
|
239
235
|
seed: string;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
* override beats every generated value.
|
|
244
|
-
*/
|
|
245
|
-
overrides?: Partial<ThemeColor>;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* One scheme's accent input:
|
|
249
|
-
* - a color string — equivalent to `{ seed: value }`;
|
|
250
|
-
* - `{ seed, overrides }` — generation with explicit exceptions;
|
|
251
|
-
* - a full {@link TerraThemeOverride} — skips generation (expert path).
|
|
252
|
-
*/
|
|
253
|
-
export type AccentSchemeInput = string | AccentSeed | TerraThemeOverride;
|
|
254
|
-
/**
|
|
255
|
-
* A named, runtime-switchable overlay on each scheme. A missing scheme leaves
|
|
256
|
-
* that scheme unmodified; the other scheme's seed is never copied implicitly.
|
|
257
|
-
*/
|
|
258
|
-
export type Accent = Partial<Record<Scheme, AccentSchemeInput>>;
|
|
259
|
-
/** @deprecated Use {@link Accent} — a color string per scheme. */
|
|
260
|
-
export type AccentShorthand = Record<Scheme, string>;
|
|
261
|
-
/** @deprecated Use {@link Accent} — a {@link TerraThemeOverride} per scheme. */
|
|
262
|
-
export type AccentOverride = Partial<Record<Scheme, TerraThemeOverride>>;
|
|
236
|
+
};
|
|
237
|
+
/** A seed shorthand, explicit theme tokens, or both via `{ seed, color, ... }`. */
|
|
238
|
+
export type ThemeSchemeInput = string | ThemeSeed | TerraThemeOverride;
|
|
263
239
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
240
|
+
* A complete named light/dark theme. Missing schemes inherit defaults + shared;
|
|
241
|
+
* seeds are never copied from the other scheme.
|
|
266
242
|
*/
|
|
243
|
+
export type NamedTheme = Partial<Record<Scheme, ThemeSchemeInput>>;
|
|
244
|
+
/** Output of the legacy normalizeAccent helper. */
|
|
267
245
|
export interface NormalizedAccent {
|
|
268
246
|
light: DeepPartial<TerraTheme>;
|
|
269
247
|
dark: DeepPartial<TerraTheme>;
|
|
@@ -357,13 +335,8 @@ export interface ComponentDefaults {
|
|
|
357
335
|
export interface TerraConfig {
|
|
358
336
|
/** Scheme-agnostic token overrides, applied to both light and dark themes. */
|
|
359
337
|
shared?: TerraThemeOverride;
|
|
360
|
-
/**
|
|
361
|
-
|
|
362
|
-
light?: TerraThemeOverride;
|
|
363
|
-
dark?: TerraThemeOverride;
|
|
364
|
-
};
|
|
365
|
-
/** Runtime-switchable named overrides (hue shorthand or full partial). */
|
|
366
|
-
accents?: Record<string, Accent>;
|
|
338
|
+
/** Named light/dark themes applied over defaults + shared. */
|
|
339
|
+
themes?: Record<string, NamedTheme>;
|
|
367
340
|
/**
|
|
368
341
|
* App-provided icon overrides. Semantic icons (`navigation.*`, `status.*`)
|
|
369
342
|
* fall back to the built-in defaults when omitted; app icons (`add`, etc.)
|
|
@@ -376,8 +349,8 @@ export interface TerraConfig {
|
|
|
376
349
|
* `resizeMode`. Wrap third-party components to match `TerraImageProps`.
|
|
377
350
|
*/
|
|
378
351
|
image?: TerraImageComponent;
|
|
379
|
-
/** Name of the
|
|
380
|
-
|
|
352
|
+
/** Name of the theme (from `themes`) to apply by default. */
|
|
353
|
+
defaultTheme?: string;
|
|
381
354
|
/** Per-component default props (e.g. `{ button: { radius: 'full' } }`). */
|
|
382
355
|
components?: ComponentDefaults;
|
|
383
356
|
/**
|
|
@@ -392,13 +365,13 @@ export interface TerraConfig {
|
|
|
392
365
|
initialScheme?: Scheme;
|
|
393
366
|
}
|
|
394
367
|
/** The subset of {@link TerraConfig} that affects resolved theme tokens. */
|
|
395
|
-
export type TerraThemeInput = Pick<TerraConfig, "shared" | "
|
|
368
|
+
export type TerraThemeInput = Pick<TerraConfig, "shared" | "themes" | "defaultTheme">;
|
|
396
369
|
/** Options for pure theme creation. */
|
|
397
370
|
export interface CreateTerraThemesOptions {
|
|
398
371
|
/**
|
|
399
|
-
*
|
|
400
|
-
* with no
|
|
372
|
+
* Named theme to select. Omitted → `defaultTheme`; `null` → the base themes
|
|
373
|
+
* with no named theme. An unknown name throws.
|
|
401
374
|
*/
|
|
402
|
-
|
|
375
|
+
theme?: string | null;
|
|
403
376
|
}
|
|
404
377
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/theme/types.ts"],"names":[],"mappings":"AAAA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EAAE,YAAY,CAAC;CAC1B;AAED,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,8EAA8E;IAC9E,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACpC;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAC3D;;;;OAIG;IACH,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,QAAQ,GAAG,cAAc,CAAC,CAAC;AAEtF,uCAAuC;AACvC,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB"}
|
|
@@ -20,7 +20,7 @@ export declare function configureUnistyles({ themes, mode, }: {
|
|
|
20
20
|
* runtime holds the new `light` theme and the previous `dark` theme. Callers
|
|
21
21
|
* publish registry/selection state only after this returns, so on a throw Terra
|
|
22
22
|
* still reports the previous selection; calling the same command again with the
|
|
23
|
-
* previous selection (e.g. `
|
|
23
|
+
* previous selection (e.g. `setTheme(getCurrentTheme() ?? null)`) rewrites
|
|
24
24
|
* both themes and restores consistency. No automatic rollback is attempted.
|
|
25
25
|
*/
|
|
26
26
|
export declare function updateThemes(themes: Record<Scheme, TerraTheme>): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NamedTheme, NormalizedAccent, Scheme } from "../theme/types";
|
|
2
2
|
import { type AccentGenerationContext } from "./accent-generator.js";
|
|
3
3
|
/**
|
|
4
4
|
* The generation context of a built-in default theme: its four ordinary
|
|
@@ -7,11 +7,10 @@ import { type AccentGenerationContext } from "./accent-generator.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function defaultAccentContext(scheme: Scheme): AccentGenerationContext;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* pass through unchanged. Pure and independent of the registry.
|
|
10
|
+
* @deprecated Prefer createTerraThemes for complete theme resolution.
|
|
11
|
+
* Generates per-scheme patches without shared config. Explicit unseeded patches
|
|
12
|
+
* pass through unchanged; seeded entries generate against their own surface and
|
|
13
|
+
* color tokens and carry the remainder of the patch through unresolved.
|
|
15
14
|
*/
|
|
16
|
-
export declare function normalizeAccent(accent:
|
|
15
|
+
export declare function normalizeAccent(accent: NamedTheme): NormalizedAccent;
|
|
17
16
|
//# sourceMappingURL=accent-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accent-utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/accent-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"accent-utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/accent-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,MAAM,EAIP,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,uBAAuB,EAG7B,MAAM,uBAAoB,CAAC;AAG5B;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,uBAAuB,CAK5E;AAmCD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,CAKpE"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { type ComponentRef, forwardRef } from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
5
|
+
|
|
6
|
+
import { BadgeIndicator } from "./parts/BadgeIndicator";
|
|
7
|
+
import type { BadgeProps } from "./types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Overlays a count or status indicator on one corner of the element it wraps.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <Badge placement="top-right" color="danger" label={3}>
|
|
14
|
+
* <Toolbar.Button icon="bell" accessibilityLabel="Notifications" />
|
|
15
|
+
* </Badge>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The child renders untouched — `Badge` contributes the positioning context and
|
|
19
|
+
* the overlay, nothing else.
|
|
20
|
+
*/
|
|
21
|
+
const Badge = forwardRef<ComponentRef<typeof View>, BadgeProps>(function Badge(
|
|
22
|
+
{
|
|
23
|
+
children,
|
|
24
|
+
placement = "top-right",
|
|
25
|
+
label,
|
|
26
|
+
color = "danger",
|
|
27
|
+
size = "md",
|
|
28
|
+
isVisible = true,
|
|
29
|
+
fullWidth = false,
|
|
30
|
+
accessibilityLabel,
|
|
31
|
+
style,
|
|
32
|
+
...rest
|
|
33
|
+
},
|
|
34
|
+
ref
|
|
35
|
+
) {
|
|
36
|
+
styles.useVariants({ placement, size, fullWidth });
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
// `style` last so an explicit `alignSelf` beats `fullWidth`.
|
|
40
|
+
<View ref={ref} style={[styles.wrapper, style]} {...rest}>
|
|
41
|
+
{children}
|
|
42
|
+
{isVisible ? (
|
|
43
|
+
<View pointerEvents="box-none" style={styles.anchor}>
|
|
44
|
+
<BadgeIndicator label={label} color={color} size={size} accessibilityLabel={accessibilityLabel} />
|
|
45
|
+
</View>
|
|
46
|
+
) : null}
|
|
47
|
+
</View>
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export { Badge };
|
|
52
|
+
|
|
53
|
+
// ─── Styles ───────────────────────────────────────────────────────────────────
|
|
54
|
+
//
|
|
55
|
+
// The indicator is positioned by absolute insets picked from `size`, never by
|
|
56
|
+
// measuring the child — its overhang is a function of its own size, not the
|
|
57
|
+
// child's. Which edges those insets land on is `placement`, and the magnitude
|
|
58
|
+
// is `size`, so the two interact and the offsets are compound variants.
|
|
59
|
+
//
|
|
60
|
+
// The inset equals the dot's radius, which puts a dot's centre exactly on the
|
|
61
|
+
// child's corner. A pill keeps the same anchored edges and grows inward from
|
|
62
|
+
// them, so a longer label extends across the child rather than away from it.
|
|
63
|
+
const styles = StyleSheet.create(() => ({
|
|
64
|
+
wrapper: {
|
|
65
|
+
position: "relative",
|
|
66
|
+
variants: {
|
|
67
|
+
// `alignSelf: 'flex-start'` hugs the child, so the indicator anchors to
|
|
68
|
+
// the child's bounds rather than the surrounding container's. A child
|
|
69
|
+
// that was stretching needs `fullWidth` to go on doing so.
|
|
70
|
+
fullWidth: {
|
|
71
|
+
true: { alignSelf: "stretch" },
|
|
72
|
+
false: { alignSelf: "flex-start" },
|
|
73
|
+
},
|
|
74
|
+
placement: {
|
|
75
|
+
"top-right": {},
|
|
76
|
+
"top-left": {},
|
|
77
|
+
"bottom-right": {},
|
|
78
|
+
"bottom-left": {},
|
|
79
|
+
},
|
|
80
|
+
size: {
|
|
81
|
+
sm: {},
|
|
82
|
+
md: {},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
anchor: {
|
|
87
|
+
position: "absolute",
|
|
88
|
+
variants: {
|
|
89
|
+
placement: {
|
|
90
|
+
"top-right": {},
|
|
91
|
+
"top-left": {},
|
|
92
|
+
"bottom-right": {},
|
|
93
|
+
"bottom-left": {},
|
|
94
|
+
},
|
|
95
|
+
size: {
|
|
96
|
+
sm: {},
|
|
97
|
+
md: {},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
compoundVariants: [
|
|
101
|
+
{ placement: "top-right", size: "sm", styles: { top: -5, right: -5 } },
|
|
102
|
+
{ placement: "top-right", size: "md", styles: { top: -6, right: -6 } },
|
|
103
|
+
{ placement: "top-left", size: "sm", styles: { top: -5, left: -5 } },
|
|
104
|
+
{ placement: "top-left", size: "md", styles: { top: -6, left: -6 } },
|
|
105
|
+
{ placement: "bottom-right", size: "sm", styles: { bottom: -5, right: -5 } },
|
|
106
|
+
{ placement: "bottom-right", size: "md", styles: { bottom: -6, right: -6 } },
|
|
107
|
+
{ placement: "bottom-left", size: "sm", styles: { bottom: -5, left: -5 } },
|
|
108
|
+
{ placement: "bottom-left", size: "md", styles: { bottom: -6, left: -6 } },
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
}));
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Text as RNText, View } from "react-native";
|
|
2
|
+
|
|
3
|
+
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
4
|
+
|
|
5
|
+
import type { ColorToken, RoleTextVariant } from "#theme/types";
|
|
6
|
+
import { resolveThemeColor } from "#utils/resolve-theme-color";
|
|
7
|
+
import { FONT_WEIGHT_VALUE, SYSTEM_FONT } from "#utils/typography";
|
|
8
|
+
import type { BadgeColor, BadgeSize } from "../types";
|
|
9
|
+
import { getCustomBadgeColors, hasLabel } from "../utils";
|
|
10
|
+
|
|
11
|
+
const SCHEME_NAMES = new Set(["primary", "secondary", "success", "warning", "danger"]);
|
|
12
|
+
|
|
13
|
+
type BadgeScheme = "primary" | "secondary" | "success" | "warning" | "danger";
|
|
14
|
+
|
|
15
|
+
/** Label foreground per scheme — mirrors the spec's token table. */
|
|
16
|
+
const FG_TOKEN: Record<BadgeScheme, ColorToken> = {
|
|
17
|
+
primary: "accent.solid.fg",
|
|
18
|
+
secondary: "neutral.solid.fg",
|
|
19
|
+
success: "success.solid.fg",
|
|
20
|
+
warning: "warning.solid.fg",
|
|
21
|
+
danger: "danger.solid.fg",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const LABEL_VARIANT: Record<BadgeSize, RoleTextVariant> = {
|
|
25
|
+
sm: "label-sm",
|
|
26
|
+
md: "label-md",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export interface BadgeIndicatorProps {
|
|
30
|
+
label?: string | number;
|
|
31
|
+
color: BadgeColor;
|
|
32
|
+
size: BadgeSize;
|
|
33
|
+
accessibilityLabel?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The overlay itself: a dot, or a pill carrying the label. Owns the paint, the
|
|
38
|
+
* legibility ring, and the accessibility node — the wrapper owns only position.
|
|
39
|
+
*
|
|
40
|
+
* `useUnistyles` is called unconditionally, which is what subscribes this
|
|
41
|
+
* component to theme changes. The background below comes from a variant, which
|
|
42
|
+
* unistyles applies straight to the native node on a theme switch; without a
|
|
43
|
+
* re-render React would go on believing the node holds the previous theme's
|
|
44
|
+
* value. `Chip` documents the same hazard on its root.
|
|
45
|
+
*/
|
|
46
|
+
export const BadgeIndicator = ({ label, color, size, accessibilityLabel }: BadgeIndicatorProps) => {
|
|
47
|
+
const { theme } = useUnistyles();
|
|
48
|
+
// A literal never matches one of the five variant options, so it's cast to
|
|
49
|
+
// satisfy `useVariants`'s literal-union type while still being compared
|
|
50
|
+
// against the real value below.
|
|
51
|
+
styles.useVariants({ color: color as BadgeScheme, size });
|
|
52
|
+
|
|
53
|
+
const custom = SCHEME_NAMES.has(color) ? null : getCustomBadgeColors(color);
|
|
54
|
+
const labelled = hasLabel(label);
|
|
55
|
+
const foreground = custom ? custom.fg : FG_TOKEN[color as BadgeScheme];
|
|
56
|
+
|
|
57
|
+
// An explicit label wins even on a dot; a dot with nothing to announce is
|
|
58
|
+
// decorative and hidden rather than read out as an unlabelled element.
|
|
59
|
+
const announced = accessibilityLabel ?? (labelled ? String(label) : undefined);
|
|
60
|
+
const accessibility = announced
|
|
61
|
+
? { accessible: true, accessibilityLabel: announced }
|
|
62
|
+
: {
|
|
63
|
+
accessibilityElementsHidden: true,
|
|
64
|
+
importantForAccessibility: "no-hide-descendants" as const,
|
|
65
|
+
"aria-hidden": true,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<View
|
|
70
|
+
style={[
|
|
71
|
+
styles.indicator,
|
|
72
|
+
labelled ? styles.pill : styles.dot,
|
|
73
|
+
custom ? { backgroundColor: custom.bg } : null,
|
|
74
|
+
]}
|
|
75
|
+
{...accessibility}
|
|
76
|
+
>
|
|
77
|
+
{labelled ? (
|
|
78
|
+
<RNText
|
|
79
|
+
style={[styles.label, { color: resolveThemeColor(foreground, theme) }]}
|
|
80
|
+
maxFontSizeMultiplier={theme.typography.variants[LABEL_VARIANT[size]].maxFontSizeMultiplier}
|
|
81
|
+
numberOfLines={1}
|
|
82
|
+
>
|
|
83
|
+
{label}
|
|
84
|
+
</RNText>
|
|
85
|
+
) : null}
|
|
86
|
+
</View>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// ─── Styles ───────────────────────────────────────────────────────────────────
|
|
91
|
+
//
|
|
92
|
+
// `color` is a plain variant rather than a compound one: `Badge` renders solid
|
|
93
|
+
// only, so there is no second paint axis for it to interact with.
|
|
94
|
+
//
|
|
95
|
+
// React Native's box model is border-box, so the ring below eats into the
|
|
96
|
+
// indicator rather than growing it — the dot's outer diameter stays exactly
|
|
97
|
+
// what `size` declares, with no compensation arithmetic.
|
|
98
|
+
const styles = StyleSheet.create((theme) => {
|
|
99
|
+
const c = theme.color;
|
|
100
|
+
// A custom font encodes its weight in the family name, so only the system
|
|
101
|
+
// font takes a numeric `fontWeight` — the same branch `Chip` makes. Inlined
|
|
102
|
+
// rather than extracted: the unistyles Babel plugin rewrites this factory,
|
|
103
|
+
// and an imported function called from inside it is not in scope at runtime.
|
|
104
|
+
const labelFont = theme.typography.fonts.semibold;
|
|
105
|
+
const isSystemLabelFont = labelFont === SYSTEM_FONT;
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
indicator: {
|
|
109
|
+
alignItems: "center",
|
|
110
|
+
justifyContent: "center",
|
|
111
|
+
borderRadius: theme.radius.full,
|
|
112
|
+
borderColor: c["surface.canvas"],
|
|
113
|
+
variants: {
|
|
114
|
+
size: {
|
|
115
|
+
sm: { borderWidth: 1.5 },
|
|
116
|
+
md: { borderWidth: 2 },
|
|
117
|
+
},
|
|
118
|
+
color: {
|
|
119
|
+
primary: { backgroundColor: c["accent.solid.bg"] },
|
|
120
|
+
secondary: { backgroundColor: c["neutral.solid.bg"] },
|
|
121
|
+
success: { backgroundColor: c["success.solid.bg"] },
|
|
122
|
+
warning: { backgroundColor: c["warning.solid.bg"] },
|
|
123
|
+
danger: { backgroundColor: c["danger.solid.bg"] },
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
dot: {
|
|
128
|
+
variants: {
|
|
129
|
+
size: {
|
|
130
|
+
sm: { width: 10, height: 10 },
|
|
131
|
+
md: { width: 12, height: 12 },
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
pill: {
|
|
136
|
+
variants: {
|
|
137
|
+
size: {
|
|
138
|
+
sm: { height: 16, minWidth: 16, paddingHorizontal: 4 },
|
|
139
|
+
md: { height: 20, minWidth: 20, paddingHorizontal: 6 },
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
// Spelled out rather than derived from `LABEL_VARIANT`: the unistyles Babel
|
|
144
|
+
// plugin reads this object statically, so computed variant keys are not
|
|
145
|
+
// safe here even though they would resolve correctly under test.
|
|
146
|
+
label: {
|
|
147
|
+
textAlign: "center",
|
|
148
|
+
fontFamily: isSystemLabelFont ? undefined : labelFont,
|
|
149
|
+
fontWeight: isSystemLabelFont ? FONT_WEIGHT_VALUE.semibold : undefined,
|
|
150
|
+
variants: {
|
|
151
|
+
size: {
|
|
152
|
+
sm: {
|
|
153
|
+
fontSize: theme.typography.variants["label-sm"].fontSize,
|
|
154
|
+
lineHeight: theme.typography.variants["label-sm"].lineHeight,
|
|
155
|
+
letterSpacing: theme.typography.variants["label-sm"].letterSpacing,
|
|
156
|
+
},
|
|
157
|
+
md: {
|
|
158
|
+
fontSize: theme.typography.variants["label-md"].fontSize,
|
|
159
|
+
lineHeight: theme.typography.variants["label-md"].lineHeight,
|
|
160
|
+
letterSpacing: theme.typography.variants["label-md"].letterSpacing,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ViewProps } from "react-native";
|
|
3
|
+
|
|
4
|
+
/** Corner of the wrapped child the indicator is anchored to. */
|
|
5
|
+
export type BadgePlacement = "top-right" | "top-left" | "bottom-right" | "bottom-left";
|
|
6
|
+
|
|
7
|
+
/** Scale of the dot, pill, and label. */
|
|
8
|
+
export type BadgeSize = "sm" | "md";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Semantic color scheme, or a raw CSS color literal (`#fff`, `rgb(...)`, `hsl(...)`).
|
|
12
|
+
* A literal paints the indicator with that exact value and derives a readable
|
|
13
|
+
* foreground for the label.
|
|
14
|
+
*/
|
|
15
|
+
export type BadgeColor =
|
|
16
|
+
| "primary"
|
|
17
|
+
| "secondary"
|
|
18
|
+
| "success"
|
|
19
|
+
| "warning"
|
|
20
|
+
| "danger"
|
|
21
|
+
// literals last so scheme-name autocomplete still surfaces
|
|
22
|
+
| (string & {});
|
|
23
|
+
|
|
24
|
+
export interface BadgeProps extends ViewProps {
|
|
25
|
+
/** The element being badged. Rendered untouched; `Badge` only adds the overlay. */
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Corner the indicator sits on. Defaults to `'top-right'`.
|
|
29
|
+
*
|
|
30
|
+
* The indicator overhangs the child, so an ancestor that clips — a `Surface`
|
|
31
|
+
* with a radius, or a `Screen` list row — will cut it off. Pad that container
|
|
32
|
+
* by the overhang, or lift the `Badge` outside it.
|
|
33
|
+
*/
|
|
34
|
+
placement?: BadgePlacement;
|
|
35
|
+
/**
|
|
36
|
+
* Text in the indicator. Omit it (or pass an empty string) for a dot.
|
|
37
|
+
* `0` renders as a label — use `isVisible` to suppress a zero count.
|
|
38
|
+
*/
|
|
39
|
+
label?: string | number;
|
|
40
|
+
/** Semantic scheme or raw color literal. Defaults to `'danger'`. */
|
|
41
|
+
color?: BadgeColor;
|
|
42
|
+
/** Scale of the indicator. Defaults to `'md'`. */
|
|
43
|
+
size?: BadgeSize;
|
|
44
|
+
/** Renders the indicator. The child renders either way. Defaults to `true`. */
|
|
45
|
+
isVisible?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Stretches the wrapper along its parent's cross axis, so a child that
|
|
48
|
+
* stretches unwrapped keeps stretching. Defaults to `false`, which hugs the
|
|
49
|
+
* child — what an icon, avatar, or toolbar button needs. An explicit
|
|
50
|
+
* `alignSelf` in `style` beats both.
|
|
51
|
+
*/
|
|
52
|
+
fullWidth?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Announced in place of the label. Defaults to the label's own text; an
|
|
55
|
+
* unlabelled dot is hidden from assistive technology.
|
|
56
|
+
*/
|
|
57
|
+
accessibilityLabel?: string;
|
|
58
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readableOn } from "#utils/color-utils";
|
|
2
|
+
|
|
3
|
+
// A custom color literal (hex/rgb/hsl) isn't a bounded set of options, so it
|
|
4
|
+
// can't be a unistyles variant condition — it's derived here instead, the same
|
|
5
|
+
// way `chip/utils.ts` handles the equivalent case on `Chip`.
|
|
6
|
+
|
|
7
|
+
export interface CustomBadgeColors {
|
|
8
|
+
bg: string;
|
|
9
|
+
fg: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The indicator's paint for a raw literal: the literal itself, plus a readable label. */
|
|
13
|
+
export function getCustomBadgeColors(literal: string): CustomBadgeColors {
|
|
14
|
+
return { bg: literal, fg: readableOn(literal) };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `true` when `label` should render as a pill. An empty string and `undefined`
|
|
19
|
+
* are a dot; `0` is a label, since a caller suppressing a zero count uses
|
|
20
|
+
* `isVisible` rather than relying on falsiness.
|
|
21
|
+
*/
|
|
22
|
+
export function hasLabel(label: string | number | undefined): label is string | number {
|
|
23
|
+
return label !== undefined && label !== "";
|
|
24
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { useUnistyles } from "react-native-unistyles";
|
|
|
5
5
|
|
|
6
6
|
import { bootstrapTerraUI } from "../theme/registry";
|
|
7
7
|
import {
|
|
8
|
-
applyAccent,
|
|
9
8
|
applyScheme,
|
|
10
9
|
getThemeSelection,
|
|
10
|
+
setTheme,
|
|
11
11
|
setThemeMode,
|
|
12
12
|
subscribeThemeSelection,
|
|
13
13
|
} from "../theme/runtime";
|
|
@@ -41,13 +41,13 @@ export interface UseThemeResult {
|
|
|
41
41
|
scheme: Scheme;
|
|
42
42
|
/** Pin a scheme (stops following the system). Same as `setMode(scheme)`. */
|
|
43
43
|
setScheme: (scheme: Scheme) => void;
|
|
44
|
-
/** Applied
|
|
45
|
-
|
|
44
|
+
/** Applied theme name, or `undefined` for the base themes. */
|
|
45
|
+
themeName: string | undefined;
|
|
46
46
|
/**
|
|
47
|
-
* Apply a registered
|
|
48
|
-
* name warns in development and leaves the
|
|
47
|
+
* Apply a registered theme; `null` restores the base themes. An unknown
|
|
48
|
+
* name warns in development and leaves the theme unchanged.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
setTheme: (name: string | null) => void;
|
|
51
51
|
/**
|
|
52
52
|
* How the active scheme is chosen: `system` follows the OS appearance,
|
|
53
53
|
* `light` / `dark` pin a scheme. A system appearance change updates
|
|
@@ -59,8 +59,8 @@ export interface UseThemeResult {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* Access the active theme and switch scheme / mode /
|
|
63
|
-
* comes from the runtime store, so changes made imperatively (`
|
|
62
|
+
* Access the active theme and switch scheme / mode / theme. Selection state
|
|
63
|
+
* comes from the runtime store, so changes made imperatively (`setTheme`,
|
|
64
64
|
* `setThemeMode`) and through this hook are observed by every consumer.
|
|
65
65
|
*/
|
|
66
66
|
export function useTheme(): UseThemeResult {
|
|
@@ -71,8 +71,8 @@ export function useTheme(): UseThemeResult {
|
|
|
71
71
|
theme,
|
|
72
72
|
scheme: (rt.themeName ?? "light") as Scheme,
|
|
73
73
|
setScheme: applyScheme,
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
themeName: selection.themeName,
|
|
75
|
+
setTheme,
|
|
76
76
|
mode: selection.mode,
|
|
77
77
|
setMode: setThemeMode,
|
|
78
78
|
};
|