@newtonedev/components 0.1.13 → 0.1.14
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/_COMPONENT_TEMPLATE/ComponentName.styles.d.ts +1 -1
- package/dist/composites/actions/Button/Button.d.ts +11 -1
- package/dist/composites/actions/Button/Button.d.ts.map +1 -1
- package/dist/composites/actions/Button/Button.styles.d.ts.map +1 -1
- package/dist/composites/actions/Button/Button.types.d.ts +11 -1
- package/dist/composites/actions/Button/Button.types.d.ts.map +1 -1
- package/dist/composites/branding/LogoMonogram/LogoMonogram.d.ts +10 -0
- package/dist/composites/branding/LogoMonogram/LogoMonogram.d.ts.map +1 -0
- package/dist/composites/branding/LogoMonogram/LogoMonogram.types.d.ts +35 -0
- package/dist/composites/branding/LogoMonogram/LogoMonogram.types.d.ts.map +1 -0
- package/dist/composites/branding/LogoMonogram/index.d.ts +3 -0
- package/dist/composites/branding/LogoMonogram/index.d.ts.map +1 -0
- package/dist/composites/branding/LogoWordmark/LogoWordmark.d.ts +9 -0
- package/dist/composites/branding/LogoWordmark/LogoWordmark.d.ts.map +1 -0
- package/dist/composites/branding/LogoWordmark/LogoWordmark.types.d.ts +26 -0
- package/dist/composites/branding/LogoWordmark/LogoWordmark.types.d.ts.map +1 -0
- package/dist/composites/branding/LogoWordmark/index.d.ts +3 -0
- package/dist/composites/branding/LogoWordmark/index.d.ts.map +1 -0
- package/dist/composites/display/Chip/Chip.d.ts +25 -0
- package/dist/composites/display/Chip/Chip.d.ts.map +1 -0
- package/dist/composites/display/Chip/Chip.styles.d.ts +29 -0
- package/dist/composites/display/Chip/Chip.styles.d.ts.map +1 -0
- package/dist/composites/display/Chip/Chip.types.d.ts +63 -0
- package/dist/composites/display/Chip/Chip.types.d.ts.map +1 -0
- package/dist/composites/display/Chip/index.d.ts +3 -0
- package/dist/composites/display/Chip/index.d.ts.map +1 -0
- package/dist/composites/form-controls/Select/Select.d.ts.map +1 -1
- package/dist/composites/form-controls/Select/Select.styles.d.ts +2 -2
- package/dist/composites/form-controls/Select/Select.styles.d.ts.map +1 -1
- package/dist/composites/form-controls/Select/SelectOption.d.ts.map +1 -1
- package/dist/composites/form-controls/TextInput/TextInput.d.ts.map +1 -1
- package/dist/composites/form-controls/TextInput/TextInput.styles.d.ts +2 -2
- package/dist/composites/form-controls/TextInput/TextInput.styles.d.ts.map +1 -1
- package/dist/composites/form-controls/Toggle/Toggle.d.ts.map +1 -1
- package/dist/composites/form-controls/Toggle/Toggle.styles.d.ts +2 -2
- package/dist/composites/form-controls/Toggle/Toggle.styles.d.ts.map +1 -1
- package/dist/composites/layout/AppShell/AppShell.d.ts.map +1 -1
- package/dist/composites/layout/AppShell/AppShell.styles.d.ts +2 -2
- package/dist/composites/layout/AppShell/AppShell.styles.d.ts.map +1 -1
- package/dist/composites/layout/Card/Card.d.ts.map +1 -1
- package/dist/composites/layout/Card/Card.styles.d.ts +2 -2
- package/dist/composites/layout/Card/Card.styles.d.ts.map +1 -1
- package/dist/composites/layout/ContentCard/ContentCard.d.ts +33 -0
- package/dist/composites/layout/ContentCard/ContentCard.d.ts.map +1 -0
- package/dist/composites/layout/ContentCard/ContentCard.styles.d.ts +10 -0
- package/dist/composites/layout/ContentCard/ContentCard.styles.d.ts.map +1 -0
- package/dist/composites/layout/ContentCard/ContentCard.types.d.ts +52 -0
- package/dist/composites/layout/ContentCard/ContentCard.types.d.ts.map +1 -0
- package/dist/composites/layout/ContentCard/index.d.ts +3 -0
- package/dist/composites/layout/ContentCard/index.d.ts.map +1 -0
- package/dist/composites/layout/Divider/Divider.d.ts +25 -0
- package/dist/composites/layout/Divider/Divider.d.ts.map +1 -0
- package/dist/composites/layout/Divider/Divider.styles.d.ts +8 -0
- package/dist/composites/layout/Divider/Divider.styles.d.ts.map +1 -0
- package/dist/composites/layout/Divider/Divider.types.d.ts +25 -0
- package/dist/composites/layout/Divider/Divider.types.d.ts.map +1 -0
- package/dist/composites/layout/Divider/index.d.ts +3 -0
- package/dist/composites/layout/Divider/index.d.ts.map +1 -0
- package/dist/composites/layout/Navbar/Navbar.d.ts.map +1 -1
- package/dist/composites/layout/Navbar/Navbar.styles.d.ts +4 -3
- package/dist/composites/layout/Navbar/Navbar.styles.d.ts.map +1 -1
- package/dist/composites/layout/Sidebar/Sidebar.d.ts.map +1 -1
- package/dist/composites/layout/Sidebar/Sidebar.styles.d.ts +4 -3
- package/dist/composites/layout/Sidebar/Sidebar.styles.d.ts.map +1 -1
- package/dist/composites/overlays/Popover/Popover.d.ts.map +1 -1
- package/dist/composites/overlays/Popover/Popover.styles.d.ts +2 -2
- package/dist/composites/overlays/Popover/Popover.styles.d.ts.map +1 -1
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.d.ts.map +1 -1
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.d.ts +2 -2
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.d.ts.map +1 -1
- package/dist/composites/range-inputs/HueSlider/HueSlider.styles.d.ts +2 -2
- package/dist/composites/range-inputs/HueSlider/HueSlider.styles.d.ts.map +1 -1
- package/dist/composites/range-inputs/Slider/Slider.styles.d.ts +2 -2
- package/dist/composites/range-inputs/Slider/Slider.styles.d.ts.map +1 -1
- package/dist/index.cjs +903 -396
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +830 -344
- package/dist/index.js.map +1 -1
- package/dist/primitives/Frame/Frame.d.ts +1 -35
- package/dist/primitives/Frame/Frame.d.ts.map +1 -1
- package/dist/primitives/Frame/Frame.styles.d.ts +13 -4
- package/dist/primitives/Frame/Frame.styles.d.ts.map +1 -1
- package/dist/primitives/Frame/Frame.types.d.ts +99 -1
- package/dist/primitives/Frame/Frame.types.d.ts.map +1 -1
- package/dist/primitives/Frame/index.d.ts +1 -1
- package/dist/primitives/Frame/index.d.ts.map +1 -1
- package/dist/primitives/Icon/Icon.d.ts.map +1 -1
- package/dist/primitives/Icon/Icon.types.d.ts +2 -2
- package/dist/primitives/Icon/Icon.types.d.ts.map +1 -1
- package/dist/primitives/Text/Text.d.ts +5 -3
- package/dist/primitives/Text/Text.d.ts.map +1 -1
- package/dist/primitives/Text/Text.spans.d.ts.map +1 -1
- package/dist/primitives/Text/Text.types.d.ts +3 -6
- package/dist/primitives/Text/Text.types.d.ts.map +1 -1
- package/dist/primitives/Wrapper/Wrapper.d.ts +1 -1
- package/dist/primitives/Wrapper/Wrapper.d.ts.map +1 -1
- package/dist/primitives/Wrapper/Wrapper.styles.d.ts +9 -1
- package/dist/primitives/Wrapper/Wrapper.styles.d.ts.map +1 -1
- package/dist/primitives/Wrapper/Wrapper.types.d.ts +31 -1
- package/dist/primitives/Wrapper/Wrapper.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/composites/actions/Button/Button.styles.ts +71 -55
- package/src/composites/actions/Button/Button.tsx +34 -13
- package/src/composites/actions/Button/Button.types.ts +13 -1
- package/src/composites/branding/LogoMonogram/LogoMonogram.tsx +29 -0
- package/src/composites/branding/LogoMonogram/LogoMonogram.types.ts +35 -0
- package/src/composites/branding/LogoMonogram/index.ts +2 -0
- package/src/composites/branding/LogoWordmark/LogoWordmark.tsx +29 -0
- package/src/composites/branding/LogoWordmark/LogoWordmark.types.ts +25 -0
- package/src/composites/branding/LogoWordmark/index.ts +2 -0
- package/src/composites/display/Chip/Chip.styles.ts +189 -0
- package/src/composites/display/Chip/Chip.tsx +97 -0
- package/src/composites/display/Chip/Chip.types.ts +74 -0
- package/src/composites/display/Chip/index.ts +2 -0
- package/src/composites/form-controls/Select/Select.styles.ts +10 -10
- package/src/composites/form-controls/Select/Select.tsx +9 -6
- package/src/composites/form-controls/Select/SelectOption.tsx +10 -7
- package/src/composites/form-controls/TextInput/TextInput.styles.ts +12 -8
- package/src/composites/form-controls/TextInput/TextInput.tsx +7 -4
- package/src/composites/form-controls/Toggle/Toggle.styles.ts +10 -7
- package/src/composites/form-controls/Toggle/Toggle.tsx +4 -3
- package/src/composites/layout/AppShell/AppShell.styles.ts +8 -3
- package/src/composites/layout/AppShell/AppShell.tsx +6 -2
- package/src/composites/layout/Card/Card.styles.ts +10 -4
- package/src/composites/layout/Card/Card.tsx +4 -3
- package/src/composites/layout/ContentCard/ContentCard.styles.ts +44 -0
- package/src/composites/layout/ContentCard/ContentCard.tsx +71 -0
- package/src/composites/layout/ContentCard/ContentCard.types.ts +60 -0
- package/src/composites/layout/ContentCard/index.ts +2 -0
- package/src/composites/layout/Divider/Divider.styles.ts +30 -0
- package/src/composites/layout/Divider/Divider.tsx +46 -0
- package/src/composites/layout/Divider/Divider.types.ts +28 -0
- package/src/composites/layout/Divider/index.ts +2 -0
- package/src/composites/layout/Navbar/Navbar.styles.ts +7 -5
- package/src/composites/layout/Navbar/Navbar.tsx +4 -3
- package/src/composites/layout/Sidebar/Sidebar.styles.ts +7 -5
- package/src/composites/layout/Sidebar/Sidebar.tsx +4 -3
- package/src/composites/overlays/Popover/Popover.styles.ts +7 -5
- package/src/composites/overlays/Popover/Popover.tsx +4 -3
- package/src/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.ts +5 -5
- package/src/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.tsx +4 -3
- package/src/composites/range-inputs/HueSlider/HueSlider.styles.ts +7 -7
- package/src/composites/range-inputs/HueSlider/HueSlider.tsx +1 -1
- package/src/composites/range-inputs/Slider/Slider.styles.ts +9 -9
- package/src/composites/range-inputs/Slider/Slider.tsx +1 -1
- package/src/index.ts +43 -9
- package/src/primitives/Frame/Frame.styles.ts +55 -12
- package/src/primitives/Frame/Frame.tsx +138 -140
- package/src/primitives/Frame/Frame.types.ts +119 -1
- package/src/primitives/Frame/index.ts +4 -0
- package/src/primitives/Icon/Icon.tsx +9 -6
- package/src/primitives/Icon/Icon.types.ts +2 -2
- package/src/primitives/Text/Text.spans.ts +9 -5
- package/src/primitives/Text/Text.tsx +26 -15
- package/src/primitives/Text/Text.types.ts +3 -6
- package/src/primitives/Wrapper/Wrapper.styles.ts +32 -0
- package/src/primitives/Wrapper/Wrapper.tsx +22 -3
- package/src/primitives/Wrapper/Wrapper.types.ts +45 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pressable } from 'react-native';
|
|
3
|
+
import type { ChipProps } from './Chip.types';
|
|
4
|
+
import { getChipConfig } from './Chip.styles';
|
|
5
|
+
import { useTokens } from 'newtone-api';
|
|
6
|
+
import { Icon } from '../../../primitives/Icon/Icon';
|
|
7
|
+
import { Text } from '../../../primitives/Text';
|
|
8
|
+
import { Wrapper } from '../../../primitives/Wrapper/Wrapper';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Chip — A pill-shaped label for tags, filters, badges, and status indicators.
|
|
12
|
+
*
|
|
13
|
+
* **Composition Architecture:**
|
|
14
|
+
* - Pressable (RN primitive) — handles interaction (when onPress is provided)
|
|
15
|
+
* - Wrapper (primitive) — handles layout (direction, gap, padding, alignment)
|
|
16
|
+
* - Icon (primitive) — handles optional leading icon
|
|
17
|
+
* - Text (primitive) — handles typography with theme tokens
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // Static label
|
|
22
|
+
* <Chip>Design Systems</Chip>
|
|
23
|
+
*
|
|
24
|
+
* // Interactive filter chip
|
|
25
|
+
* <Chip selected={isActive} onPress={() => toggle()}>Color Science</Chip>
|
|
26
|
+
*
|
|
27
|
+
* // With icon
|
|
28
|
+
* <Chip icon="check" semantic="success">Verified</Chip>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function Chip({
|
|
32
|
+
children,
|
|
33
|
+
variant = 'tinted',
|
|
34
|
+
size = 'md',
|
|
35
|
+
semantic = 'neutral',
|
|
36
|
+
selected = false,
|
|
37
|
+
onPress,
|
|
38
|
+
disabled = false,
|
|
39
|
+
icon,
|
|
40
|
+
style,
|
|
41
|
+
}: ChipProps) {
|
|
42
|
+
const tokens = useTokens();
|
|
43
|
+
|
|
44
|
+
const { colors, sizeTokens } = React.useMemo(
|
|
45
|
+
() => getChipConfig(variant, semantic, size, selected, disabled, tokens),
|
|
46
|
+
[variant, semantic, size, selected, disabled, tokens]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const content = (state?: { pressed: boolean; hovered?: boolean }) => (
|
|
50
|
+
<Wrapper
|
|
51
|
+
direction="horizontal"
|
|
52
|
+
align="center"
|
|
53
|
+
gap={sizeTokens.gap}
|
|
54
|
+
style={[
|
|
55
|
+
{
|
|
56
|
+
paddingLeft: sizeTokens.paddingX,
|
|
57
|
+
paddingRight: sizeTokens.paddingX,
|
|
58
|
+
paddingTop: sizeTokens.paddingY,
|
|
59
|
+
paddingBottom: sizeTokens.paddingY,
|
|
60
|
+
backgroundColor: state?.pressed && !disabled
|
|
61
|
+
? colors.pressedBg
|
|
62
|
+
: state?.hovered && !disabled
|
|
63
|
+
? colors.hoveredBg
|
|
64
|
+
: colors.bg,
|
|
65
|
+
borderRadius: 99,
|
|
66
|
+
borderWidth: colors.borderWidth,
|
|
67
|
+
borderColor: colors.borderColor || 'transparent',
|
|
68
|
+
opacity: disabled ? 0.4 : 1,
|
|
69
|
+
},
|
|
70
|
+
...(Array.isArray(style) ? style : style ? [style] : []),
|
|
71
|
+
]}
|
|
72
|
+
>
|
|
73
|
+
{icon && (
|
|
74
|
+
<Icon name={icon} size={sizeTokens.iconSize} color={colors.iconColor} />
|
|
75
|
+
)}
|
|
76
|
+
<Text
|
|
77
|
+
role={sizeTokens.textRole}
|
|
78
|
+
weight={selected ? 'bold' : 'medium'}
|
|
79
|
+
style={{ color: colors.textColor }}
|
|
80
|
+
>
|
|
81
|
+
{children}
|
|
82
|
+
</Text>
|
|
83
|
+
</Wrapper>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
if (onPress) {
|
|
87
|
+
return (
|
|
88
|
+
<Pressable onPress={onPress} disabled={disabled}>
|
|
89
|
+
{({ pressed, hovered }: { pressed: boolean; hovered?: boolean }) =>
|
|
90
|
+
content({ pressed, hovered })
|
|
91
|
+
}
|
|
92
|
+
</Pressable>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return content();
|
|
97
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Visual variant for the Chip component
|
|
5
|
+
*/
|
|
6
|
+
export type ChipVariant = 'filled' | 'tinted' | 'outlined';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Semantic meaning for the Chip component (describes color purpose)
|
|
10
|
+
*/
|
|
11
|
+
export type ChipSemantic = 'neutral' | 'accent' | 'success' | 'error' | 'warning';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Size presets for the Chip component
|
|
15
|
+
*/
|
|
16
|
+
export type ChipSize = 'sm' | 'md';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Props for the Chip component
|
|
20
|
+
*/
|
|
21
|
+
export interface ChipProps {
|
|
22
|
+
/**
|
|
23
|
+
* Chip label content.
|
|
24
|
+
*/
|
|
25
|
+
readonly children: React.ReactNode;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Visual variant (describes visual treatment)
|
|
29
|
+
* @default 'tinted'
|
|
30
|
+
*/
|
|
31
|
+
readonly variant?: ChipVariant;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Size preset
|
|
35
|
+
* @default 'md'
|
|
36
|
+
*/
|
|
37
|
+
readonly size?: ChipSize;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Semantic meaning (describes color purpose)
|
|
41
|
+
* @default 'neutral'
|
|
42
|
+
*/
|
|
43
|
+
readonly semantic?: ChipSemantic;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Selected state — overrides appearance to "strong" with bold weight.
|
|
47
|
+
* Useful for filter bars and toggle groups.
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
readonly selected?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Press handler — makes the chip interactive.
|
|
54
|
+
* When provided, the chip renders as a Pressable.
|
|
55
|
+
*/
|
|
56
|
+
readonly onPress?: () => void;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Disabled state
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
readonly disabled?: boolean;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Material Symbol icon name (e.g. 'check', 'close').
|
|
66
|
+
* Renders a leading icon before the label.
|
|
67
|
+
*/
|
|
68
|
+
readonly icon?: string;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Custom style overrides for container
|
|
72
|
+
*/
|
|
73
|
+
readonly style?: ViewStyle | ViewStyle[];
|
|
74
|
+
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import type { ResolvedTokens,
|
|
2
|
+
import type { ResolvedTokens, AppearanceTokens, ThemeName, AppearanceName } from 'newtone-api';
|
|
3
3
|
|
|
4
4
|
export function getSelectStyles(
|
|
5
5
|
tokens: ResolvedTokens,
|
|
6
|
-
gamut: ColorGamut,
|
|
7
6
|
disabled: boolean,
|
|
8
7
|
size: 'sm' | 'md',
|
|
9
|
-
isOpen: boolean
|
|
8
|
+
isOpen: boolean,
|
|
9
|
+
theme: ThemeName = 'primary',
|
|
10
|
+
appearance: AppearanceName = 'main',
|
|
10
11
|
) {
|
|
12
|
+
const at: AppearanceTokens = tokens.colors[theme][appearance];
|
|
11
13
|
const isSm = size === 'sm';
|
|
12
14
|
const fontSize = isSm ? tokens.typography.fontSizes['04'] : tokens.typography.fontSizes['05'];
|
|
13
15
|
const iconSize = fontSize + 2;
|
|
@@ -24,14 +26,14 @@ export function getSelectStyles(
|
|
|
24
26
|
fontFamily: tokens.typography.fonts.main.family,
|
|
25
27
|
fontSize: tokens.typography.fontSizes['04'],
|
|
26
28
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
27
|
-
color:
|
|
29
|
+
color: at.fontTertiary,
|
|
28
30
|
},
|
|
29
31
|
trigger: {
|
|
30
32
|
flexDirection: 'row',
|
|
31
33
|
alignItems: 'center',
|
|
32
|
-
backgroundColor:
|
|
34
|
+
backgroundColor: at.fontSecondary,
|
|
33
35
|
borderWidth: 1,
|
|
34
|
-
borderColor:
|
|
36
|
+
borderColor: at.fontSecondary,
|
|
35
37
|
borderRadius: tokens.radius.md,
|
|
36
38
|
paddingVertical,
|
|
37
39
|
paddingLeft: paddingHorizontal,
|
|
@@ -42,9 +44,7 @@ export function getSelectStyles(
|
|
|
42
44
|
flex: 1,
|
|
43
45
|
fontFamily: tokens.typography.fonts.main.family,
|
|
44
46
|
fontSize,
|
|
45
|
-
color: disabled
|
|
46
|
-
? tokens.textSecondary[gamut]
|
|
47
|
-
: tokens.textPrimary[gamut],
|
|
47
|
+
color: disabled ? at.fontTertiary : at.divider,
|
|
48
48
|
},
|
|
49
49
|
iconWrapper: {
|
|
50
50
|
position: 'absolute',
|
|
@@ -57,7 +57,7 @@ export function getSelectStyles(
|
|
|
57
57
|
fontFamily: tokens.typography.fonts.main.family,
|
|
58
58
|
fontSize: tokens.typography.fontSizes['01'],
|
|
59
59
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
60
|
-
color:
|
|
60
|
+
color: at.fontTertiary,
|
|
61
61
|
textTransform: 'uppercase',
|
|
62
62
|
letterSpacing: 0.5,
|
|
63
63
|
paddingVertical: tokens.spacing['04'],
|
|
@@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
|
|
|
2
2
|
import { View, Text, Pressable, ScrollView } from 'react-native';
|
|
3
3
|
import type { SelectProps, SelectOption } from './Select.types';
|
|
4
4
|
import { isOptionGroup } from './Select.types';
|
|
5
|
-
import { useTokens } from 'newtone-api';
|
|
5
|
+
import { useTokens, useFrameContext } from 'newtone-api';
|
|
6
6
|
import { getSelectStyles } from './Select.styles';
|
|
7
7
|
import { Icon } from '../../../primitives/Icon/Icon';
|
|
8
8
|
import { Popover } from '../../overlays/Popover/Popover';
|
|
@@ -35,6 +35,7 @@ export function Select({
|
|
|
35
35
|
style,
|
|
36
36
|
}: SelectProps) {
|
|
37
37
|
const tokens = useTokens(1);
|
|
38
|
+
const frameCtx = useFrameContext();
|
|
38
39
|
const { isOpen, open, close, toggle } = usePopover();
|
|
39
40
|
|
|
40
41
|
const flatOptions = useMemo(() => flattenOptions(options), [options]);
|
|
@@ -51,17 +52,19 @@ export function Select({
|
|
|
51
52
|
onOpen: open,
|
|
52
53
|
});
|
|
53
54
|
|
|
55
|
+
const inheritedTheme = frameCtx?.theme;
|
|
56
|
+
const inheritedAppearance = frameCtx?.appearance;
|
|
57
|
+
|
|
54
58
|
const styles = useMemo(
|
|
55
|
-
() => getSelectStyles(tokens,
|
|
56
|
-
[tokens, disabled, size, isOpen]
|
|
59
|
+
() => getSelectStyles(tokens, disabled, size, isOpen, inheritedTheme, inheritedAppearance),
|
|
60
|
+
[tokens, disabled, size, isOpen, inheritedTheme, inheritedAppearance]
|
|
57
61
|
);
|
|
58
62
|
|
|
59
63
|
const selectedOption = flatOptions.find((o) => o.value === value);
|
|
60
64
|
const displayLabel = selectedOption?.label ?? placeholder ?? value;
|
|
61
65
|
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
: tokens.textPrimary[tokens.gamut];
|
|
66
|
+
const at = tokens.colors[inheritedTheme ?? 'primary'][inheritedAppearance ?? 'main'];
|
|
67
|
+
const iconColor = disabled ? at.fontTertiary : at.divider;
|
|
65
68
|
|
|
66
69
|
// onKeyDown is a web-only prop supported by react-native-web but not in RN types
|
|
67
70
|
const triggerWebProps = { onKeyDown: handleKeyDown } as any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Pressable, Text, View } from 'react-native';
|
|
3
3
|
import type { SelectOption as SelectOptionType, SelectProps } from './Select.types';
|
|
4
|
-
import { useTokens } from 'newtone-api';
|
|
4
|
+
import { useTokens, useFrameContext } from 'newtone-api';
|
|
5
5
|
import { Icon } from '../../../primitives/Icon/Icon';
|
|
6
6
|
|
|
7
7
|
interface SelectOptionRowProps {
|
|
@@ -22,6 +22,9 @@ export function SelectOptionRow({
|
|
|
22
22
|
size,
|
|
23
23
|
}: SelectOptionRowProps) {
|
|
24
24
|
const tokens = useTokens(1);
|
|
25
|
+
const frameCtx = useFrameContext();
|
|
26
|
+
const at = tokens.colors[frameCtx?.theme ?? 'primary'][frameCtx?.appearance ?? 'main'];
|
|
27
|
+
const emphasisAt = tokens.colors[frameCtx?.theme ?? 'primary'].emphasis;
|
|
25
28
|
|
|
26
29
|
const paddingVertical = size === 'sm' ? tokens.spacing['04'] : tokens.spacing['08'];
|
|
27
30
|
const paddingHorizontal = size === 'sm' ? tokens.spacing['08'] : tokens.spacing['12'];
|
|
@@ -55,11 +58,11 @@ export function SelectOptionRow({
|
|
|
55
58
|
paddingHorizontal,
|
|
56
59
|
},
|
|
57
60
|
isSelected && {
|
|
58
|
-
backgroundColor:
|
|
61
|
+
backgroundColor: at.fontSecondary,
|
|
59
62
|
},
|
|
60
63
|
isFocused &&
|
|
61
64
|
!isSelected && {
|
|
62
|
-
backgroundColor: `${
|
|
65
|
+
backgroundColor: `${at.fontSecondary}20`,
|
|
63
66
|
},
|
|
64
67
|
option.disabled && {
|
|
65
68
|
opacity: 0.5,
|
|
@@ -75,14 +78,14 @@ export function SelectOptionRow({
|
|
|
75
78
|
flex: 1,
|
|
76
79
|
fontFamily: tokens.typography.fonts.main.family,
|
|
77
80
|
fontSize,
|
|
78
|
-
color:
|
|
81
|
+
color: at.divider,
|
|
79
82
|
},
|
|
80
83
|
isSelected && {
|
|
81
84
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
82
|
-
color:
|
|
85
|
+
color: emphasisAt.divider,
|
|
83
86
|
},
|
|
84
87
|
option.disabled && {
|
|
85
|
-
color:
|
|
88
|
+
color: at.fontTertiary,
|
|
86
89
|
},
|
|
87
90
|
]}
|
|
88
91
|
numberOfLines={1}
|
|
@@ -94,7 +97,7 @@ export function SelectOptionRow({
|
|
|
94
97
|
<Icon
|
|
95
98
|
name="check"
|
|
96
99
|
size={fontSize}
|
|
97
|
-
color={
|
|
100
|
+
color={emphasisAt.divider}
|
|
98
101
|
/>
|
|
99
102
|
</View>
|
|
100
103
|
)}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import type { ResolvedTokens,
|
|
2
|
+
import type { ResolvedTokens, AppearanceTokens, ThemeName, AppearanceName } from 'newtone-api';
|
|
3
3
|
|
|
4
|
-
export function getTextInputStyles(
|
|
4
|
+
export function getTextInputStyles(
|
|
5
|
+
tokens: ResolvedTokens,
|
|
6
|
+
disabled: boolean,
|
|
7
|
+
theme: ThemeName = 'primary',
|
|
8
|
+
appearance: AppearanceName = 'main',
|
|
9
|
+
) {
|
|
10
|
+
const at: AppearanceTokens = tokens.colors[theme][appearance];
|
|
5
11
|
return StyleSheet.create({
|
|
6
12
|
container: {
|
|
7
13
|
gap: tokens.spacing['04'],
|
|
@@ -10,20 +16,18 @@ export function getTextInputStyles(tokens: ResolvedTokens, gamut: ColorGamut, di
|
|
|
10
16
|
fontFamily: tokens.typography.fonts.main.family,
|
|
11
17
|
fontSize: tokens.typography.fontSizes['04'],
|
|
12
18
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
13
|
-
color:
|
|
19
|
+
color: at.fontTertiary,
|
|
14
20
|
},
|
|
15
21
|
input: {
|
|
16
22
|
fontFamily: tokens.typography.fonts.main.family,
|
|
17
|
-
backgroundColor:
|
|
23
|
+
backgroundColor: at.fontSecondary,
|
|
18
24
|
borderWidth: 1,
|
|
19
|
-
borderColor:
|
|
25
|
+
borderColor: at.fontSecondary,
|
|
20
26
|
borderRadius: tokens.radius.md,
|
|
21
27
|
paddingVertical: tokens.spacing['08'],
|
|
22
28
|
paddingHorizontal: tokens.spacing['12'],
|
|
23
29
|
fontSize: tokens.typography.fontSizes['05'],
|
|
24
|
-
color: disabled
|
|
25
|
-
? tokens.textSecondary[gamut]
|
|
26
|
-
: tokens.textPrimary[gamut],
|
|
30
|
+
color: disabled ? at.fontTertiary : at.divider,
|
|
27
31
|
opacity: disabled ? 0.5 : 1,
|
|
28
32
|
},
|
|
29
33
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, Text, TextInput as RNTextInput } from 'react-native';
|
|
3
3
|
import type { TextInputProps } from './TextInput.types';
|
|
4
|
-
import { useTokens } from 'newtone-api';
|
|
4
|
+
import { useTokens, useFrameContext } from 'newtone-api';
|
|
5
5
|
import { getTextInputStyles } from './TextInput.styles';
|
|
6
6
|
|
|
7
7
|
export function TextInput({
|
|
@@ -11,10 +11,13 @@ export function TextInput({
|
|
|
11
11
|
...textInputProps
|
|
12
12
|
}: TextInputProps) {
|
|
13
13
|
const tokens = useTokens(1);
|
|
14
|
+
const frameCtx = useFrameContext();
|
|
15
|
+
const theme = frameCtx?.theme ?? 'primary';
|
|
16
|
+
const appearance = frameCtx?.appearance ?? 'main';
|
|
14
17
|
|
|
15
18
|
const styles = React.useMemo(
|
|
16
|
-
() => getTextInputStyles(tokens,
|
|
17
|
-
[tokens, disabled]
|
|
19
|
+
() => getTextInputStyles(tokens, disabled, theme, appearance),
|
|
20
|
+
[tokens, disabled, theme, appearance]
|
|
18
21
|
);
|
|
19
22
|
|
|
20
23
|
return (
|
|
@@ -23,7 +26,7 @@ export function TextInput({
|
|
|
23
26
|
<RNTextInput
|
|
24
27
|
style={styles.input}
|
|
25
28
|
editable={!disabled}
|
|
26
|
-
placeholderTextColor={tokens.
|
|
29
|
+
placeholderTextColor={tokens.colors[theme][appearance].fontTertiary}
|
|
27
30
|
{...textInputProps}
|
|
28
31
|
/>
|
|
29
32
|
</View>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import type { ResolvedTokens,
|
|
2
|
+
import type { ResolvedTokens, AppearanceTokens, ThemeName, AppearanceName } from 'newtone-api';
|
|
3
3
|
|
|
4
4
|
const TRACK_WIDTH = 40;
|
|
5
5
|
const TRACK_HEIGHT = 22;
|
|
@@ -8,10 +8,13 @@ const THUMB_OFFSET = 2;
|
|
|
8
8
|
|
|
9
9
|
export function getToggleStyles(
|
|
10
10
|
tokens: ResolvedTokens,
|
|
11
|
-
gamut: ColorGamut,
|
|
12
11
|
value: boolean,
|
|
13
|
-
disabled: boolean
|
|
12
|
+
disabled: boolean,
|
|
13
|
+
theme: ThemeName = 'primary',
|
|
14
|
+
appearance: AppearanceName = 'main',
|
|
14
15
|
) {
|
|
16
|
+
const at: AppearanceTokens = tokens.colors[theme][appearance];
|
|
17
|
+
const emphasisAt: AppearanceTokens = tokens.colors[theme].emphasis;
|
|
15
18
|
return StyleSheet.create({
|
|
16
19
|
container: {
|
|
17
20
|
flexDirection: 'row',
|
|
@@ -23,15 +26,15 @@ export function getToggleStyles(
|
|
|
23
26
|
fontFamily: tokens.typography.fonts.main.family,
|
|
24
27
|
fontSize: tokens.typography.fontSizes['04'],
|
|
25
28
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
26
|
-
color:
|
|
29
|
+
color: at.fontTertiary,
|
|
27
30
|
},
|
|
28
31
|
track: {
|
|
29
32
|
width: TRACK_WIDTH,
|
|
30
33
|
height: TRACK_HEIGHT,
|
|
31
34
|
borderRadius: TRACK_HEIGHT / 2,
|
|
32
35
|
backgroundColor: value
|
|
33
|
-
?
|
|
34
|
-
:
|
|
36
|
+
? emphasisAt.divider
|
|
37
|
+
: at.fontSecondary,
|
|
35
38
|
justifyContent: 'center',
|
|
36
39
|
paddingHorizontal: THUMB_OFFSET,
|
|
37
40
|
},
|
|
@@ -39,7 +42,7 @@ export function getToggleStyles(
|
|
|
39
42
|
width: THUMB_SIZE,
|
|
40
43
|
height: THUMB_SIZE,
|
|
41
44
|
borderRadius: THUMB_SIZE / 2,
|
|
42
|
-
backgroundColor:
|
|
45
|
+
backgroundColor: at.background,
|
|
43
46
|
alignSelf: value ? 'flex-end' : 'flex-start',
|
|
44
47
|
},
|
|
45
48
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, Text, Pressable } from 'react-native';
|
|
3
3
|
import type { ToggleProps } from './Toggle.types';
|
|
4
|
-
import { useTokens } from 'newtone-api';
|
|
4
|
+
import { useTokens, useFrameContext } from 'newtone-api';
|
|
5
5
|
import { getToggleStyles } from './Toggle.styles';
|
|
6
6
|
|
|
7
7
|
export function Toggle({
|
|
@@ -12,10 +12,11 @@ export function Toggle({
|
|
|
12
12
|
style,
|
|
13
13
|
}: ToggleProps) {
|
|
14
14
|
const tokens = useTokens(1);
|
|
15
|
+
const frameCtx = useFrameContext();
|
|
15
16
|
|
|
16
17
|
const styles = React.useMemo(
|
|
17
|
-
() => getToggleStyles(tokens,
|
|
18
|
-
[tokens, value, disabled]
|
|
18
|
+
() => getToggleStyles(tokens, value, disabled, frameCtx?.theme, frameCtx?.appearance),
|
|
19
|
+
[tokens, value, disabled, frameCtx?.theme, frameCtx?.appearance]
|
|
19
20
|
);
|
|
20
21
|
|
|
21
22
|
const handlePress = React.useCallback(() => {
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import type { ResolvedTokens,
|
|
2
|
+
import type { ResolvedTokens, AppearanceTokens, ThemeName, AppearanceName } from 'newtone-api';
|
|
3
3
|
|
|
4
|
-
export function getAppShellStyles(
|
|
4
|
+
export function getAppShellStyles(
|
|
5
|
+
tokens: ResolvedTokens,
|
|
6
|
+
theme: ThemeName = 'primary',
|
|
7
|
+
appearance: AppearanceName = 'main',
|
|
8
|
+
) {
|
|
9
|
+
const at: AppearanceTokens = tokens.colors[theme][appearance];
|
|
5
10
|
return StyleSheet.create({
|
|
6
11
|
container: {
|
|
7
12
|
flex: 1,
|
|
8
13
|
flexDirection: 'row',
|
|
9
14
|
overflow: 'hidden',
|
|
10
|
-
backgroundColor:
|
|
15
|
+
backgroundColor: at.background,
|
|
11
16
|
},
|
|
12
17
|
main: {
|
|
13
18
|
flex: 1,
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import type { AppShellProps } from './AppShell.types';
|
|
4
|
-
import { useTokens } from 'newtone-api';
|
|
4
|
+
import { useTokens, useFrameContext } from 'newtone-api';
|
|
5
5
|
import { getAppShellStyles } from './AppShell.styles';
|
|
6
6
|
|
|
7
7
|
export function AppShell({ sidebar, children }: AppShellProps) {
|
|
8
8
|
const tokens = useTokens();
|
|
9
|
-
const
|
|
9
|
+
const frameCtx = useFrameContext();
|
|
10
|
+
const styles = React.useMemo(
|
|
11
|
+
() => getAppShellStyles(tokens, frameCtx?.theme, frameCtx?.appearance),
|
|
12
|
+
[tokens, frameCtx?.theme, frameCtx?.appearance]
|
|
13
|
+
);
|
|
10
14
|
|
|
11
15
|
return (
|
|
12
16
|
<View style={styles.container}>
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import type { ResolvedTokens,
|
|
2
|
+
import type { ResolvedTokens, AppearanceTokens, ThemeName, AppearanceName } from 'newtone-api';
|
|
3
3
|
|
|
4
|
-
export function getCardStyles(
|
|
4
|
+
export function getCardStyles(
|
|
5
|
+
tokens: ResolvedTokens,
|
|
6
|
+
disabled: boolean,
|
|
7
|
+
theme: ThemeName = 'primary',
|
|
8
|
+
appearance: AppearanceName = 'main',
|
|
9
|
+
) {
|
|
10
|
+
const at: AppearanceTokens = tokens.colors[theme][appearance];
|
|
5
11
|
return StyleSheet.create({
|
|
6
12
|
container: {
|
|
7
|
-
backgroundColor:
|
|
13
|
+
backgroundColor: at.background,
|
|
8
14
|
borderWidth: 1,
|
|
9
|
-
borderColor:
|
|
15
|
+
borderColor: at.fontSecondary,
|
|
10
16
|
borderRadius: tokens.radius.lg,
|
|
11
17
|
padding: tokens.spacing['16'],
|
|
12
18
|
opacity: disabled ? 0.5 : 1,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import type { CardProps } from './Card.types';
|
|
4
|
-
import { useTokens } from 'newtone-api';
|
|
4
|
+
import { useTokens, useFrameContext } from 'newtone-api';
|
|
5
5
|
import { getCardStyles } from './Card.styles';
|
|
6
6
|
|
|
7
7
|
export function Card({
|
|
@@ -11,10 +11,11 @@ export function Card({
|
|
|
11
11
|
disabled = false,
|
|
12
12
|
}: CardProps) {
|
|
13
13
|
const tokens = useTokens(elevation);
|
|
14
|
+
const frameCtx = useFrameContext();
|
|
14
15
|
|
|
15
16
|
const styles = React.useMemo(
|
|
16
|
-
() => getCardStyles(tokens,
|
|
17
|
-
[tokens, disabled]
|
|
17
|
+
() => getCardStyles(tokens, disabled, frameCtx?.theme, frameCtx?.appearance),
|
|
18
|
+
[tokens, disabled, frameCtx?.theme, frameCtx?.appearance]
|
|
18
19
|
);
|
|
19
20
|
|
|
20
21
|
return (
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
import type { UseTokensResult } from 'newtone-api';
|
|
3
|
+
import type { ContentCardVariant } from './ContentCard.types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Compute variant-specific styles for ContentCard.
|
|
7
|
+
* Uses `as ViewStyle` for web-only properties (cursor, borderBottomStyle)
|
|
8
|
+
* that react-native-web supports but RN types don't include.
|
|
9
|
+
*/
|
|
10
|
+
export function getContentCardStyles(
|
|
11
|
+
variant: ContentCardVariant,
|
|
12
|
+
isInteractive: boolean,
|
|
13
|
+
tokens: UseTokensResult
|
|
14
|
+
): ViewStyle {
|
|
15
|
+
const dividerColor = tokens.colors.primary.main.divider;
|
|
16
|
+
|
|
17
|
+
const interactiveStyles = isInteractive
|
|
18
|
+
? { cursor: 'pointer', textDecorationLine: 'none' } as ViewStyle
|
|
19
|
+
: {} as ViewStyle;
|
|
20
|
+
|
|
21
|
+
if (variant === 'elevated') {
|
|
22
|
+
return {
|
|
23
|
+
borderRadius: 12,
|
|
24
|
+
...interactiveStyles,
|
|
25
|
+
} as ViewStyle;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (variant === 'bordered') {
|
|
29
|
+
return {
|
|
30
|
+
borderWidth: 1,
|
|
31
|
+
borderColor: dividerColor,
|
|
32
|
+
borderStyle: 'solid',
|
|
33
|
+
borderRadius: 12,
|
|
34
|
+
...interactiveStyles,
|
|
35
|
+
} as ViewStyle;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// flat variant — bottom border only
|
|
39
|
+
return {
|
|
40
|
+
borderBottomWidth: 1,
|
|
41
|
+
borderBottomColor: dividerColor,
|
|
42
|
+
...interactiveStyles,
|
|
43
|
+
} as ViewStyle;
|
|
44
|
+
}
|