@lotics/ui 1.3.1 → 1.4.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/package.json +2 -1
- package/src/icon_button.tsx +5 -0
- package/src/info_popover.tsx +49 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lotics/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./tokens": "./src/tokens.ts",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"./menu_list_item": "./src/menu_list_item.tsx",
|
|
31
31
|
"./pressable_highlight": "./src/pressable_highlight.tsx",
|
|
32
32
|
"./icon_button": "./src/icon_button.tsx",
|
|
33
|
+
"./info_popover": "./src/info_popover.tsx",
|
|
33
34
|
"./badge": "./src/badge.tsx",
|
|
34
35
|
"./divider": "./src/divider.tsx",
|
|
35
36
|
"./spacer": "./src/spacer.tsx",
|
package/src/icon_button.tsx
CHANGED
|
@@ -13,6 +13,8 @@ export interface IconButtonProps {
|
|
|
13
13
|
iconColor?: string;
|
|
14
14
|
tooltip?: string;
|
|
15
15
|
tooltipSide?: TooltipSide;
|
|
16
|
+
/** Accessible name for the button. Falls back to `tooltip` when omitted. */
|
|
17
|
+
accessibilityLabel?: string;
|
|
16
18
|
onPress?: (event: GestureResponderEvent) => void;
|
|
17
19
|
style?: StyleProp<ViewStyle>;
|
|
18
20
|
disabled?: boolean;
|
|
@@ -28,6 +30,7 @@ export function IconButton(props: IconButtonProps) {
|
|
|
28
30
|
color = "none",
|
|
29
31
|
tooltip,
|
|
30
32
|
tooltipSide,
|
|
33
|
+
accessibilityLabel,
|
|
31
34
|
disabled,
|
|
32
35
|
style,
|
|
33
36
|
} = props;
|
|
@@ -45,6 +48,8 @@ export function IconButton(props: IconButtonProps) {
|
|
|
45
48
|
testID={testID}
|
|
46
49
|
tooltip={tooltip}
|
|
47
50
|
tooltipSide={tooltipSide}
|
|
51
|
+
accessibilityRole="button"
|
|
52
|
+
accessibilityLabel={accessibilityLabel ?? tooltip}
|
|
48
53
|
style={[styles.button, styles[color], disabled && styles.disabled, style]}
|
|
49
54
|
onPress={handlePress}
|
|
50
55
|
disabled={disabled}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { Popover, PopoverTrigger, PopoverContent } from "./popover";
|
|
3
|
+
import type { PopoverSide, PopoverAlign } from "./popover";
|
|
4
|
+
import { IconButton } from "./icon_button";
|
|
5
|
+
import { Text } from "./text";
|
|
6
|
+
import { colors } from "./colors";
|
|
7
|
+
|
|
8
|
+
export interface InfoPopoverProps {
|
|
9
|
+
/** Explanatory text shown when the popover opens. */
|
|
10
|
+
text: string;
|
|
11
|
+
/** Accessible name for the trigger button. */
|
|
12
|
+
accessibilityLabel?: string;
|
|
13
|
+
/** Popover placement relative to the trigger. */
|
|
14
|
+
side?: PopoverSide;
|
|
15
|
+
/** Popover alignment along the trigger edge. */
|
|
16
|
+
align?: PopoverAlign;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A "?" icon button that opens a popover explaining something — a metric, a
|
|
21
|
+
* field, a setting. The middle ground between Tooltip (a short hover label)
|
|
22
|
+
* and composing Popover directly (rich, interactive content): a labeled,
|
|
23
|
+
* keyboard-accessible help affordance for a sentence or two of text.
|
|
24
|
+
*/
|
|
25
|
+
export function InfoPopover(props: InfoPopoverProps) {
|
|
26
|
+
const { text, accessibilityLabel = "More information", side = "bottom", align = "end" } = props;
|
|
27
|
+
return (
|
|
28
|
+
<Popover side={side} align={align}>
|
|
29
|
+
<PopoverTrigger>
|
|
30
|
+
<IconButton
|
|
31
|
+
icon="message-circle-question-mark"
|
|
32
|
+
iconColor={colors.zinc[500]}
|
|
33
|
+
accessibilityLabel={accessibilityLabel}
|
|
34
|
+
/>
|
|
35
|
+
</PopoverTrigger>
|
|
36
|
+
<PopoverContent style={styles.content} disableBodyScroll>
|
|
37
|
+
<Text size="sm" color="muted">
|
|
38
|
+
{text}
|
|
39
|
+
</Text>
|
|
40
|
+
</PopoverContent>
|
|
41
|
+
</Popover>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const styles = StyleSheet.create({
|
|
46
|
+
content: {
|
|
47
|
+
width: 280,
|
|
48
|
+
},
|
|
49
|
+
});
|