@lotics/ui 45.8.0 → 45.8.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/docs/catalog.md +12 -7
- package/package.json +1 -1
- package/src/back_button.tsx +79 -28
package/docs/catalog.md
CHANGED
|
@@ -835,13 +835,18 @@ source (`src/<module>.tsx`/`.ts`) is the API reference.
|
|
|
835
835
|
rather than a value). Throws when the clipboard is unreachable — never resolve a write
|
|
836
836
|
that did not happen, or the caller confirms a lie. Web-only (native has no
|
|
837
837
|
`navigator.clipboard`).
|
|
838
|
-
- **`back_button`** — `BackButton`: the
|
|
839
|
-
`arrow-left` `MenuButton` reads as another nav ITEM, not
|
|
840
|
-
`accessibilityLabel` (defaults to `label`, else the locale's
|
|
841
|
-
"Quay lại"). Bare
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
838
|
+
- **`back_button`** — `BackButton`: the CIRCULAR go-back control that HEADS a screen or
|
|
839
|
+
panel — don't hand-roll it (an `arrow-left` `MenuButton` reads as another nav ITEM, not
|
|
840
|
+
an exit). `onPress` + `accessibilityLabel` (defaults to `label`, else the locale's
|
|
841
|
+
`nav.back` — "Back" / "Quay lại"). Bare it is the 40px chevron-left disc; pass
|
|
842
|
+
**`label`** to name where back GOES ("Danh sách") — the SAME disc with the destination
|
|
843
|
+
beside it, ONE pressable over disc + words, never an icon button beside unclickable
|
|
844
|
+
prose. It takes no size or colour: one purpose, one look, and both variants draw the
|
|
845
|
+
one disc so they cannot drift.
|
|
846
|
+
**A back affordance INSIDE a header row is not this** — beside a drawer's title a 40px
|
|
847
|
+
disc outweighs the name it belongs to, so that one is a small `IconButton` (see
|
|
848
|
+
`screen_router` below). The distinction is prominence: this HEADS a surface, that
|
|
849
|
+
annotates a title.
|
|
845
850
|
- **`link`** — `Link`: the EXTERNAL hyperlink — fixed underline+blue + `role="link"`;
|
|
846
851
|
`onPress` only (the consumer wires the opener).
|
|
847
852
|
- **`text_link`** — `TextLink`: underlined text that NAVIGATES — `href` renders a real
|
package/package.json
CHANGED
package/src/back_button.tsx
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { IconButton } from "./icon_button";
|
|
2
1
|
import { View } from "react-native";
|
|
3
2
|
import { Icon } from "./icon";
|
|
4
3
|
import { Text } from "./text";
|
|
5
4
|
import { colors } from "./colors";
|
|
6
|
-
import { CURSOR_ACTION } from "./control_surface";
|
|
5
|
+
import { CONTROL_HEIGHT, CURSOR_ACTION } from "./control_surface";
|
|
7
6
|
import { PressableHighlight } from "./pressable_highlight";
|
|
8
7
|
import { useLoticsLocale } from "./locale";
|
|
9
8
|
|
|
@@ -18,26 +17,66 @@ interface BackButtonProps {
|
|
|
18
17
|
accessibilityLabel?: string;
|
|
19
18
|
}
|
|
20
19
|
|
|
20
|
+
/**
|
|
21
|
+
* THE DISC, drawn ONCE for both variants and pressable in neither.
|
|
22
|
+
*
|
|
23
|
+
* It used to exist twice: the bare variant delegated to an `IconButton`, the
|
|
24
|
+
* labelled one hand-rolled the identical circle and restated that component's
|
|
25
|
+
* spec in a comment — "mirrors IconButton lg/secondary (40px, zinc-100, 20px
|
|
26
|
+
* zinc-900 glyph)". A spec copied into a comment is a spec that drifts: change
|
|
27
|
+
* `secondary` and one variant of ONE component follows while the other does not.
|
|
28
|
+
*
|
|
29
|
+
* Delegating both to `IconButton` is not the fix and never was. The labelled
|
|
30
|
+
* form is ONE pressable over the disc AND the words — an `IconButton` inside it
|
|
31
|
+
* is a button nested in a button, which is why the copy got written in the first
|
|
32
|
+
* place. So the shared thing is the SURFACE, not the control: inert here, and
|
|
33
|
+
* whichever pressable wraps it owns the gesture.
|
|
34
|
+
*
|
|
35
|
+
* IT BORROWS NOTHING FROM ANOTHER CONTROL. An earlier pass took the glyph ink
|
|
36
|
+
* from `getButtonIconColor("secondary")`, which reads as sharing until you say it
|
|
37
|
+
* out loud: this is not a secondary BUTTON, and tying its ink to that ladder
|
|
38
|
+
* means a change to the button palette silently restyles the back affordance for
|
|
39
|
+
* a reason no one would connect. The ink is `zinc-900` because that is what this
|
|
40
|
+
* glyph is.
|
|
41
|
+
*
|
|
42
|
+
* `CONTROL_HEIGHT` stays, and is not the same kind of borrowing: it is the
|
|
43
|
+
* SYSTEM's band height — the promise every 40px control aligns to — not another
|
|
44
|
+
* component's opinion. Typing `40` here would be the drift, not the reuse.
|
|
45
|
+
*/
|
|
46
|
+
const GLYPH = 20;
|
|
47
|
+
|
|
48
|
+
function Disc() {
|
|
49
|
+
return (
|
|
50
|
+
<View
|
|
51
|
+
style={{
|
|
52
|
+
width: CONTROL_HEIGHT,
|
|
53
|
+
height: CONTROL_HEIGHT,
|
|
54
|
+
borderRadius: 999,
|
|
55
|
+
backgroundColor: colors.zinc[100],
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
justifyContent: "center",
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<Icon name="chevron-left" size={GLYPH} color={colors.zinc[900]} />
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* THE go-back control: a circular glyph that leaves the current screen or panel,
|
|
67
|
+
* optionally naming where it goes.
|
|
68
|
+
*
|
|
69
|
+
* It is one purpose, so it takes no size or colour — a caller reaching for those
|
|
70
|
+
* wants a different control. In particular a drawer header's small inline arrow
|
|
71
|
+
* is NOT this: that sits beside a title inside a header row, where a 40px disc
|
|
72
|
+
* would outweigh the name it belongs to. That one is an `IconButton`, and the
|
|
73
|
+
* distinction is prominence — this one HEADS a surface, that one annotates a
|
|
74
|
+
* title.
|
|
75
|
+
*/
|
|
21
76
|
export function BackButton(props: BackButtonProps) {
|
|
22
77
|
const locale = useLoticsLocale();
|
|
23
78
|
const { onPress, label, accessibilityLabel = label ?? locale.nav.back } = props;
|
|
24
|
-
|
|
25
|
-
if (label === undefined) {
|
|
26
|
-
return (
|
|
27
|
-
<IconButton
|
|
28
|
-
icon="chevron-left"
|
|
29
|
-
size="lg"
|
|
30
|
-
color="secondary"
|
|
31
|
-
accessibilityLabel={accessibilityLabel}
|
|
32
|
-
onPress={onPress}
|
|
33
|
-
style={{ alignSelf: "flex-start" }}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
// Labelled — the SAME circular glyph, the destination named beside it, ONE
|
|
38
|
-
// pressable pill over both (words you can't press are a lie). The disc
|
|
39
|
-
// mirrors IconButton lg/secondary (40px, zinc-100, 20px zinc-900 glyph); the
|
|
40
|
-
// pill takes PressableHighlight's default hover/press wash + focus ring.
|
|
79
|
+
|
|
41
80
|
return (
|
|
42
81
|
<PressableHighlight
|
|
43
82
|
focusRing
|
|
@@ -45,16 +84,28 @@ export function BackButton(props: BackButtonProps) {
|
|
|
45
84
|
accessibilityLabel={accessibilityLabel}
|
|
46
85
|
userSelect="none"
|
|
47
86
|
onPress={onPress}
|
|
48
|
-
// Going back ACTS
|
|
49
|
-
//
|
|
50
|
-
|
|
87
|
+
// Going back ACTS. One cursor for both variants — a label must not decide
|
|
88
|
+
// whether the same control looks pressable.
|
|
89
|
+
//
|
|
90
|
+
// The pill's own padding exists only when there are words to seat: bare,
|
|
91
|
+
// the disc IS the target and any padding would inflate it past the 40px
|
|
92
|
+
// every other control in the band is aligned to.
|
|
93
|
+
style={{
|
|
94
|
+
cursor: CURSOR_ACTION,
|
|
95
|
+
flexDirection: "row",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
gap: 8,
|
|
98
|
+
alignSelf: "flex-start",
|
|
99
|
+
borderRadius: 999,
|
|
100
|
+
paddingRight: label === undefined ? 0 : 14,
|
|
101
|
+
}}
|
|
51
102
|
>
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
103
|
+
<Disc />
|
|
104
|
+
{label === undefined ? null : (
|
|
105
|
+
<Text size="sm" weight="medium" color="muted" numberOfLines={1}>
|
|
106
|
+
{label}
|
|
107
|
+
</Text>
|
|
108
|
+
)}
|
|
58
109
|
</PressableHighlight>
|
|
59
110
|
);
|
|
60
111
|
}
|