@ankhorage/surface 3.4.6 → 4.0.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.
Files changed (95) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -6
  3. package/dist/examples/DocsExamples.d.ts.map +1 -1
  4. package/dist/examples/DocsExamples.js +0 -6
  5. package/dist/examples/DocsExamples.js.map +1 -1
  6. package/dist/index.d.ts +0 -6
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +0 -3
  9. package/dist/index.js.map +1 -1
  10. package/package.json +1 -1
  11. package/src/examples/DocsExamples.tsx +0 -6
  12. package/src/index.test.ts +24 -13
  13. package/src/index.ts +0 -22
  14. package/dist/components/action-sheet/ActionSheet.d.ts +0 -4
  15. package/dist/components/action-sheet/ActionSheet.d.ts.map +0 -1
  16. package/dist/components/action-sheet/ActionSheet.js +0 -77
  17. package/dist/components/action-sheet/ActionSheet.js.map +0 -1
  18. package/dist/components/action-sheet/ActionSheetItem.d.ts +0 -4
  19. package/dist/components/action-sheet/ActionSheetItem.d.ts.map +0 -1
  20. package/dist/components/action-sheet/ActionSheetItem.js +0 -27
  21. package/dist/components/action-sheet/ActionSheetItem.js.map +0 -1
  22. package/dist/components/action-sheet/index.d.ts +0 -4
  23. package/dist/components/action-sheet/index.d.ts.map +0 -1
  24. package/dist/components/action-sheet/index.js +0 -3
  25. package/dist/components/action-sheet/index.js.map +0 -1
  26. package/dist/components/action-sheet/types.d.ts +0 -27
  27. package/dist/components/action-sheet/types.d.ts.map +0 -1
  28. package/dist/components/action-sheet/types.js +0 -2
  29. package/dist/components/action-sheet/types.js.map +0 -1
  30. package/dist/components/drawer/Drawer.d.ts +0 -4
  31. package/dist/components/drawer/Drawer.d.ts.map +0 -1
  32. package/dist/components/drawer/Drawer.js +0 -62
  33. package/dist/components/drawer/Drawer.js.map +0 -1
  34. package/dist/components/drawer/index.d.ts +0 -3
  35. package/dist/components/drawer/index.d.ts.map +0 -1
  36. package/dist/components/drawer/index.js +0 -2
  37. package/dist/components/drawer/index.js.map +0 -1
  38. package/dist/components/drawer/types.d.ts +0 -12
  39. package/dist/components/drawer/types.d.ts.map +0 -1
  40. package/dist/components/drawer/types.js +0 -2
  41. package/dist/components/drawer/types.js.map +0 -1
  42. package/dist/components/navigation/DrawerNavigation.d.ts +0 -4
  43. package/dist/components/navigation/DrawerNavigation.d.ts.map +0 -1
  44. package/dist/components/navigation/DrawerNavigation.js +0 -13
  45. package/dist/components/navigation/DrawerNavigation.js.map +0 -1
  46. package/dist/components/navigation/DrawerNavigationItem.d.ts +0 -4
  47. package/dist/components/navigation/DrawerNavigationItem.d.ts.map +0 -1
  48. package/dist/components/navigation/DrawerNavigationItem.js +0 -9
  49. package/dist/components/navigation/DrawerNavigationItem.js.map +0 -1
  50. package/dist/components/navigation/NavigationItem.d.ts +0 -4
  51. package/dist/components/navigation/NavigationItem.d.ts.map +0 -1
  52. package/dist/components/navigation/NavigationItem.js +0 -41
  53. package/dist/components/navigation/NavigationItem.js.map +0 -1
  54. package/dist/components/navigation/NavigationList.d.ts +0 -4
  55. package/dist/components/navigation/NavigationList.d.ts.map +0 -1
  56. package/dist/components/navigation/NavigationList.js +0 -9
  57. package/dist/components/navigation/NavigationList.js.map +0 -1
  58. package/dist/components/navigation/TabBar.d.ts +0 -4
  59. package/dist/components/navigation/TabBar.d.ts.map +0 -1
  60. package/dist/components/navigation/TabBar.js +0 -15
  61. package/dist/components/navigation/TabBar.js.map +0 -1
  62. package/dist/components/navigation/TabBarItem.d.ts +0 -4
  63. package/dist/components/navigation/TabBarItem.d.ts.map +0 -1
  64. package/dist/components/navigation/TabBarItem.js +0 -44
  65. package/dist/components/navigation/TabBarItem.js.map +0 -1
  66. package/dist/components/navigation/helpers.d.ts +0 -15
  67. package/dist/components/navigation/helpers.d.ts.map +0 -1
  68. package/dist/components/navigation/helpers.js +0 -48
  69. package/dist/components/navigation/helpers.js.map +0 -1
  70. package/dist/components/navigation/index.d.ts +0 -8
  71. package/dist/components/navigation/index.d.ts.map +0 -1
  72. package/dist/components/navigation/index.js +0 -7
  73. package/dist/components/navigation/index.js.map +0 -1
  74. package/dist/components/navigation/types.d.ts +0 -58
  75. package/dist/components/navigation/types.d.ts.map +0 -1
  76. package/dist/components/navigation/types.js +0 -2
  77. package/dist/components/navigation/types.js.map +0 -1
  78. package/src/components/action-sheet/ActionSheet.tsx +0 -130
  79. package/src/components/action-sheet/ActionSheetItem.tsx +0 -59
  80. package/src/components/action-sheet/index.ts +0 -3
  81. package/src/components/action-sheet/types.ts +0 -29
  82. package/src/components/drawer/Drawer.tsx +0 -100
  83. package/src/components/drawer/index.ts +0 -2
  84. package/src/components/drawer/types.ts +0 -13
  85. package/src/components/navigation/DrawerNavigation.tsx +0 -32
  86. package/src/components/navigation/DrawerNavigationItem.tsx +0 -23
  87. package/src/components/navigation/NavigationItem.tsx +0 -79
  88. package/src/components/navigation/NavigationList.tsx +0 -31
  89. package/src/components/navigation/TabBar.tsx +0 -31
  90. package/src/components/navigation/TabBarItem.tsx +0 -79
  91. package/src/components/navigation/helpers.test.ts +0 -74
  92. package/src/components/navigation/helpers.ts +0 -81
  93. package/src/components/navigation/index.ts +0 -16
  94. package/src/components/navigation/policy.test.ts +0 -140
  95. package/src/components/navigation/types.ts +0 -66
@@ -1,130 +0,0 @@
1
- import React from 'react';
2
- import { Pressable, View } from 'react-native';
3
-
4
- import { FocusScope } from '../../internal/focus/FocusScope';
5
- import { Portal } from '../../internal/overlay/Portal';
6
- import { resolvePointerEvents } from '../../internal/resolvePointerEvents';
7
- import { resolveOverlayAnimation } from '../../internal/resolvers';
8
- import { Box, Stack, Surface } from '../../layout';
9
- import { Text } from '../../primitives/text';
10
- import { useTheme } from '../../theme/ThemeContext';
11
- import { ActionSheetItem } from './ActionSheetItem';
12
- import type { ActionSheetProps } from './types';
13
-
14
- const boxNonePointerEvents = resolvePointerEvents('box-none');
15
-
16
- export function ActionSheet({
17
- visible,
18
- onDismiss,
19
- title,
20
- description,
21
- children,
22
- cancelLabel = 'Cancel',
23
- closeOnBackdrop = true,
24
- interactionPolicy = 'enabled',
25
- testID,
26
- }: ActionSheetProps) {
27
- const { theme } = useTheme();
28
- const animation = resolveOverlayAnimation('modal');
29
- const passive = interactionPolicy === 'passive';
30
-
31
- if (!visible) {
32
- return null;
33
- }
34
-
35
- return (
36
- <Portal layer="modal" visible={visible}>
37
- <View
38
- {...boxNonePointerEvents.props}
39
- style={[
40
- boxNonePointerEvents.style,
41
- {
42
- bottom: 0,
43
- left: 0,
44
- position: 'absolute',
45
- right: 0,
46
- top: 0,
47
- },
48
- ]}
49
- >
50
- <Pressable
51
- onPress={passive ? undefined : closeOnBackdrop ? onDismiss : undefined}
52
- style={{
53
- backgroundColor: theme.semantics.neutral.text,
54
- bottom: 0,
55
- left: 0,
56
- opacity: animation.backdropOpacity,
57
- position: 'absolute',
58
- right: 0,
59
- top: 0,
60
- }}
61
- testID={testID ? `${testID}-backdrop` : undefined}
62
- />
63
- <FocusScope
64
- active={visible}
65
- onEscape={passive ? undefined : onDismiss}
66
- testID={testID ? `${testID}-focus` : undefined}
67
- >
68
- <Box
69
- pointerEvents="box-none"
70
- style={{
71
- flex: 1,
72
- justifyContent: 'flex-end',
73
- }}
74
- >
75
- <View
76
- accessible
77
- accessibilityViewIsModal
78
- style={{
79
- alignSelf: 'center',
80
- maxWidth: 560,
81
- padding: 16,
82
- width: '100%',
83
- }}
84
- >
85
- <Surface
86
- p="m"
87
- style={{
88
- borderRadius: 24,
89
- shadowOpacity: 0.16,
90
- shadowRadius: 18,
91
- shadowOffset: { width: 0, height: -8 },
92
- }}
93
- testID={testID}
94
- variant="raised"
95
- >
96
- <Stack gap="s">
97
- {title || description ? (
98
- <Box px="m" py="s">
99
- <Stack gap="xxs">
100
- {title ? (
101
- <Text align="center" variant="label" weight="semiBold">
102
- {title}
103
- </Text>
104
- ) : null}
105
- {description ? (
106
- <Text align="center" emphasis="muted" variant="bodySmall">
107
- {description}
108
- </Text>
109
- ) : null}
110
- </Stack>
111
- </Box>
112
- ) : null}
113
- <Stack gap="xxs">{children}</Stack>
114
- {onDismiss ? (
115
- <ActionSheetItem
116
- label={cancelLabel}
117
- interactionPolicy={interactionPolicy}
118
- onPress={onDismiss}
119
- testID={testID ? `${testID}-cancel` : undefined}
120
- />
121
- ) : null}
122
- </Stack>
123
- </Surface>
124
- </View>
125
- </Box>
126
- </FocusScope>
127
- </View>
128
- </Portal>
129
- );
130
- }
@@ -1,59 +0,0 @@
1
- import React from 'react';
2
-
3
- import { Box, Inline, Stack } from '../../layout';
4
- import { ButtonBase } from '../../primitives/button-base';
5
- import { Text } from '../../primitives/text';
6
- import type { ActionSheetItemProps } from './types';
7
-
8
- export function ActionSheetItem({
9
- label,
10
- description,
11
- leading,
12
- trailing,
13
- color,
14
- disabled = false,
15
- selected = false,
16
- interactionPolicy = 'enabled',
17
- onPress,
18
- testID,
19
- }: ActionSheetItemProps) {
20
- return (
21
- <ButtonBase
22
- accessibilityRole="button"
23
- accessibilityState={{ disabled, selected }}
24
- disabled={disabled}
25
- interactionPolicy={interactionPolicy}
26
- onPress={onPress}
27
- radius="m"
28
- testID={testID}
29
- >
30
- {(state) => (
31
- <Box
32
- px="m"
33
- py="m"
34
- radius="m"
35
- style={{
36
- opacity: state.disabled ? 0.56 : 1,
37
- }}
38
- >
39
- <Inline align="center" gap="m" justify="space-between" wrap="nowrap">
40
- {leading ? <Box>{leading}</Box> : null}
41
- <Box flex={1}>
42
- <Stack gap="xxs">
43
- <Text color={color} variant="body" weight={selected ? 'semiBold' : 'medium'}>
44
- {label}
45
- </Text>
46
- {description ? (
47
- <Text emphasis="muted" variant="bodySmall">
48
- {description}
49
- </Text>
50
- ) : null}
51
- </Stack>
52
- </Box>
53
- {trailing ? <Box>{trailing}</Box> : null}
54
- </Inline>
55
- </Box>
56
- )}
57
- </ButtonBase>
58
- );
59
- }
@@ -1,3 +0,0 @@
1
- export { ActionSheet } from './ActionSheet';
2
- export { ActionSheetItem } from './ActionSheetItem';
3
- export type { ActionSheetItemProps, ActionSheetProps } from './types';
@@ -1,29 +0,0 @@
1
- import type React from 'react';
2
-
3
- import type { InteractionPolicy } from '../../interactionPolicy';
4
- import type { SurfaceColor } from '../../surfaceColor';
5
-
6
- export interface ActionSheetProps {
7
- visible: boolean;
8
- onDismiss?: (() => void) | undefined;
9
- title?: React.ReactNode;
10
- description?: React.ReactNode;
11
- children?: React.ReactNode;
12
- cancelLabel?: React.ReactNode;
13
- closeOnBackdrop?: boolean;
14
- interactionPolicy?: InteractionPolicy;
15
- testID?: string;
16
- }
17
-
18
- export interface ActionSheetItemProps {
19
- label: React.ReactNode;
20
- description?: React.ReactNode;
21
- leading?: React.ReactNode;
22
- trailing?: React.ReactNode;
23
- color?: SurfaceColor;
24
- disabled?: boolean;
25
- selected?: boolean;
26
- interactionPolicy?: InteractionPolicy;
27
- onPress?: (() => void) | undefined;
28
- testID?: string;
29
- }
@@ -1,100 +0,0 @@
1
- import React from 'react';
2
- import { Pressable, View } from 'react-native';
3
-
4
- import { FocusScope } from '../../internal/focus/FocusScope';
5
- import { Portal } from '../../internal/overlay/Portal';
6
- import { resolvePointerEvents } from '../../internal/resolvePointerEvents';
7
- import { resolveOverlayAnimation } from '../../internal/resolvers';
8
- import { Box, Surface } from '../../layout';
9
- import { useTheme } from '../../theme/ThemeContext';
10
- import type { DrawerProps } from './types';
11
-
12
- const boxNonePointerEvents = resolvePointerEvents('box-none');
13
-
14
- export function Drawer({
15
- visible,
16
- onDismiss,
17
- position = 'right',
18
- children,
19
- closeOnBackdrop = true,
20
- interactionPolicy = 'enabled',
21
- testID,
22
- }: DrawerProps) {
23
- const { theme } = useTheme();
24
- const animation = resolveOverlayAnimation('drawer');
25
- const passive = interactionPolicy === 'passive';
26
-
27
- if (!visible) {
28
- return null;
29
- }
30
-
31
- return (
32
- <Portal layer="drawer" visible={visible}>
33
- <View
34
- {...boxNonePointerEvents.props}
35
- style={[
36
- boxNonePointerEvents.style,
37
- {
38
- bottom: 0,
39
- left: 0,
40
- position: 'absolute',
41
- right: 0,
42
- top: 0,
43
- },
44
- ]}
45
- >
46
- <Pressable
47
- onPress={passive ? undefined : closeOnBackdrop ? onDismiss : undefined}
48
- style={{
49
- backgroundColor: theme.semantics.neutral.text,
50
- bottom: 0,
51
- left: 0,
52
- opacity: animation.backdropOpacity,
53
- position: 'absolute',
54
- right: 0,
55
- top: 0,
56
- }}
57
- testID={testID ? `${testID}-backdrop` : undefined}
58
- />
59
- <FocusScope
60
- active={visible}
61
- onEscape={passive ? undefined : onDismiss}
62
- testID={testID ? `${testID}-focus` : undefined}
63
- >
64
- <Box
65
- pointerEvents="box-none"
66
- style={{
67
- flex: 1,
68
- justifyContent: 'flex-start',
69
- }}
70
- >
71
- <View
72
- accessible
73
- accessibilityViewIsModal
74
- style={{
75
- alignSelf: position === 'left' ? 'flex-start' : 'flex-end',
76
- height: '100%',
77
- maxWidth: 420,
78
- width: '88%',
79
- }}
80
- >
81
- <Surface
82
- p="l"
83
- style={{
84
- height: '100%',
85
- shadowOpacity: 0.14,
86
- shadowRadius: 14,
87
- shadowOffset: { width: position === 'left' ? 4 : -4, height: 0 },
88
- }}
89
- testID={testID}
90
- variant="raised"
91
- >
92
- {children}
93
- </Surface>
94
- </View>
95
- </Box>
96
- </FocusScope>
97
- </View>
98
- </Portal>
99
- );
100
- }
@@ -1,2 +0,0 @@
1
- export { Drawer } from './Drawer';
2
- export type { DrawerProps } from './types';
@@ -1,13 +0,0 @@
1
- import type React from 'react';
2
-
3
- import type { InteractionPolicy } from '../../interactionPolicy';
4
-
5
- export interface DrawerProps {
6
- visible: boolean;
7
- onDismiss?: (() => void) | undefined;
8
- position?: 'left' | 'right';
9
- children?: React.ReactNode;
10
- closeOnBackdrop?: boolean;
11
- interactionPolicy?: InteractionPolicy;
12
- testID?: string;
13
- }
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
-
3
- import { Stack } from '../../layout';
4
- import { DrawerNavigationItem } from './DrawerNavigationItem';
5
- import type { DrawerNavigationProps } from './types';
6
-
7
- export function DrawerNavigation({
8
- items,
9
- header,
10
- footer,
11
- compact = false,
12
- testID,
13
- interactionPolicy,
14
- }: DrawerNavigationProps) {
15
- return (
16
- <Stack gap={compact ? 's' : 'm'} testID={testID}>
17
- {header}
18
- <Stack gap={compact ? 'xs' : 's'}>
19
- {items.map((item) => (
20
- <DrawerNavigationItem
21
- compact={compact}
22
- interactionPolicy={interactionPolicy}
23
- item={item}
24
- key={item.id}
25
- testID={testID}
26
- />
27
- ))}
28
- </Stack>
29
- {footer}
30
- </Stack>
31
- );
32
- }
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
-
3
- import { NavigationItem } from './NavigationItem';
4
- import type { DrawerNavigationItemProps } from './types';
5
-
6
- export function DrawerNavigationItem({
7
- item,
8
- compact = false,
9
- testID,
10
- interactionPolicy,
11
- }: DrawerNavigationItemProps) {
12
- return (
13
- <NavigationItem
14
- compact={compact}
15
- interactionPolicy={interactionPolicy}
16
- item={{
17
- ...item,
18
- accessibilityRole: item.accessibilityRole ?? 'button',
19
- }}
20
- testID={testID}
21
- />
22
- );
23
- }
@@ -1,79 +0,0 @@
1
- import React from 'react';
2
- import { View } from 'react-native';
3
-
4
- import { Box } from '../../layout';
5
- import { ButtonBase } from '../../primitives/button-base';
6
- import { Icon } from '../../primitives/icon';
7
- import { Text } from '../../primitives/text';
8
- import { useTheme } from '../../theme/ThemeContext';
9
- import { resolveNavigationAccessibilityState, resolveNavigationItemPresentation } from './helpers';
10
- import type { NavigationItemProps } from './types';
11
-
12
- export function NavigationItem({
13
- item,
14
- compact = false,
15
- testID,
16
- interactionPolicy,
17
- }: NavigationItemProps) {
18
- const { theme } = useTheme();
19
- const active = Boolean(item.active);
20
- const disabled = Boolean(item.disabled);
21
- const resolvedTestID = item.testID ?? (testID ? `${testID}-item-${item.id}` : undefined);
22
- const resolvedAccessibilityState = resolveNavigationAccessibilityState(
23
- active,
24
- disabled,
25
- item.accessibilityState,
26
- );
27
-
28
- return (
29
- <ButtonBase
30
- accessibilityLabel={item.accessibilityLabel}
31
- accessibilityRole={item.accessibilityRole ?? 'button'}
32
- accessibilityState={resolvedAccessibilityState}
33
- disabled={disabled}
34
- interactionPolicy={interactionPolicy}
35
- onPress={item.onPress}
36
- testID={resolvedTestID}
37
- >
38
- {(state) => {
39
- const presentation = resolveNavigationItemPresentation(theme, {
40
- active,
41
- disabled,
42
- state,
43
- });
44
-
45
- return (
46
- <Box
47
- px="m"
48
- py={compact ? 's' : 'm'}
49
- radius="m"
50
- style={{
51
- backgroundColor: presentation.backgroundColor,
52
- flexDirection: 'row',
53
- alignItems: 'center',
54
- opacity: presentation.opacity,
55
- }}
56
- >
57
- {item.icon ? (
58
- <View style={{ marginRight: theme.spacing.s }}>
59
- <Icon {...item.icon} color={presentation.contentColor} size={compact ? 's' : 'm'} />
60
- </View>
61
- ) : null}
62
- <Box flex={1}>
63
- <Text
64
- color={active && !disabled ? 'primary' : undefined}
65
- emphasis={disabled ? 'muted' : 'default'}
66
- numberOfLines={1}
67
- variant={compact ? 'bodySmall' : 'body'}
68
- weight="medium"
69
- >
70
- {item.label}
71
- </Text>
72
- </Box>
73
- {item.badge ? <View style={{ marginLeft: theme.spacing.s }}>{item.badge}</View> : null}
74
- </Box>
75
- );
76
- }}
77
- </ButtonBase>
78
- );
79
- }
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
-
3
- import { Stack } from '../../layout';
4
- import { NavigationItem } from './NavigationItem';
5
- import type { NavigationListProps } from './types';
6
-
7
- export function NavigationList({
8
- items,
9
- orientation = 'vertical',
10
- compact = false,
11
- testID,
12
- interactionPolicy,
13
- }: NavigationListProps) {
14
- return (
15
- <Stack
16
- direction={orientation === 'horizontal' ? 'row' : 'column'}
17
- gap={compact ? 'xs' : 's'}
18
- testID={testID}
19
- >
20
- {items.map((item) => (
21
- <NavigationItem
22
- compact={compact}
23
- interactionPolicy={interactionPolicy}
24
- item={item}
25
- key={item.id}
26
- testID={testID}
27
- />
28
- ))}
29
- </Stack>
30
- );
31
- }
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
-
3
- import { Box } from '../../layout';
4
- import { useTheme } from '../../theme/ThemeContext';
5
- import { TabBarItem } from './TabBarItem';
6
- import type { TabBarProps } from './types';
7
-
8
- export function TabBar({ items, compact = false, testID, interactionPolicy }: TabBarProps) {
9
- const { theme } = useTheme();
10
-
11
- return (
12
- <Box
13
- style={{
14
- flexDirection: 'row',
15
- borderTopColor: theme.semantics.border.default,
16
- borderTopWidth: 1,
17
- }}
18
- testID={testID}
19
- >
20
- {items.map((item) => (
21
- <TabBarItem
22
- compact={compact}
23
- interactionPolicy={interactionPolicy}
24
- item={item}
25
- key={item.id}
26
- testID={testID}
27
- />
28
- ))}
29
- </Box>
30
- );
31
- }
@@ -1,79 +0,0 @@
1
- import React from 'react';
2
- import { View } from 'react-native';
3
-
4
- import { Box } from '../../layout';
5
- import { ButtonBase } from '../../primitives/button-base';
6
- import { Icon } from '../../primitives/icon';
7
- import { Text } from '../../primitives/text';
8
- import { useTheme } from '../../theme/ThemeContext';
9
- import { resolveNavigationAccessibilityState, resolveNavigationItemPresentation } from './helpers';
10
- import type { TabBarItemProps } from './types';
11
-
12
- export function TabBarItem({ item, compact = false, testID, interactionPolicy }: TabBarItemProps) {
13
- const { theme } = useTheme();
14
- const active = Boolean(item.active);
15
- const disabled = Boolean(item.disabled);
16
- const resolvedTestID = item.testID ?? (testID ? `${testID}-item-${item.id}` : undefined);
17
- const resolvedAccessibilityState = resolveNavigationAccessibilityState(
18
- active,
19
- disabled,
20
- item.accessibilityState,
21
- );
22
-
23
- return (
24
- <ButtonBase
25
- accessibilityLabel={item.accessibilityLabel}
26
- accessibilityRole={item.accessibilityRole ?? 'tab'}
27
- accessibilityState={resolvedAccessibilityState}
28
- disabled={disabled}
29
- interactionPolicy={interactionPolicy}
30
- onPress={item.onPress}
31
- style={{ flex: 1 }}
32
- testID={resolvedTestID}
33
- >
34
- {(state) => {
35
- const presentation = resolveNavigationItemPresentation(theme, {
36
- active,
37
- disabled,
38
- state,
39
- });
40
- const contentColor = disabled
41
- ? theme.semantics.content.muted
42
- : active
43
- ? theme.semantics.action.primary.base
44
- : theme.semantics.content.muted;
45
-
46
- return (
47
- <Box
48
- px="m"
49
- py={compact ? 's' : 'm'}
50
- style={{
51
- flex: 1,
52
- alignItems: 'center',
53
- justifyContent: 'center',
54
- backgroundColor: presentation.backgroundColor,
55
- opacity: presentation.opacity,
56
- }}
57
- >
58
- {item.icon ? (
59
- <View style={{ marginBottom: item.label ? theme.spacing.xs : 0 }}>
60
- <Icon {...item.icon} color={contentColor} size={compact ? 's' : 'm'} />
61
- </View>
62
- ) : null}
63
- {item.label ? (
64
- <Text
65
- color={active && !disabled ? 'primary' : undefined}
66
- emphasis={active && !disabled ? 'default' : 'muted'}
67
- numberOfLines={1}
68
- variant={compact ? 'bodySmall' : 'label'}
69
- weight="medium"
70
- >
71
- {item.label}
72
- </Text>
73
- ) : null}
74
- </Box>
75
- );
76
- }}
77
- </ButtonBase>
78
- );
79
- }