@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,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ContentCardProps } from './ContentCard.types';
|
|
3
|
+
import { getContentCardStyles } from './ContentCard.styles';
|
|
4
|
+
import { useTokens } from 'newtone-api';
|
|
5
|
+
import { Frame } from '../../../primitives/Frame/Frame';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ContentCard — A content container with three visual treatments.
|
|
9
|
+
*
|
|
10
|
+
* **Variants:**
|
|
11
|
+
* - `elevated` — raised surface with tinted background (hero cards, featured content)
|
|
12
|
+
* - `bordered` — outlined container (related items, previews)
|
|
13
|
+
* - `flat` — bottom-border only (list rows, compact items)
|
|
14
|
+
*
|
|
15
|
+
* Delegates to Frame for layout, elevation, appearance, and interactivity.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* // Elevated hero card
|
|
20
|
+
* <ContentCard variant="elevated" href="/articles/intro">
|
|
21
|
+
* <Text role="heading" weight="bold">Featured Article</Text>
|
|
22
|
+
* <Text role="body" color="secondary">Article excerpt...</Text>
|
|
23
|
+
* </ContentCard>
|
|
24
|
+
*
|
|
25
|
+
* // Bordered card
|
|
26
|
+
* <ContentCard variant="bordered" onPress={() => navigate(slug)}>
|
|
27
|
+
* <Text role="body" weight="bold">Related Article</Text>
|
|
28
|
+
* </ContentCard>
|
|
29
|
+
*
|
|
30
|
+
* // Flat list item
|
|
31
|
+
* <ContentCard variant="flat" href={`/articles/${slug}`}>
|
|
32
|
+
* <Text role="body" weight="bold">{title}</Text>
|
|
33
|
+
* </ContentCard>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function ContentCard({
|
|
37
|
+
children,
|
|
38
|
+
variant = 'bordered',
|
|
39
|
+
href,
|
|
40
|
+
onPress,
|
|
41
|
+
padding = 20,
|
|
42
|
+
gap = 8,
|
|
43
|
+
disabled = false,
|
|
44
|
+
style,
|
|
45
|
+
}: ContentCardProps) {
|
|
46
|
+
const tokens = useTokens();
|
|
47
|
+
const isInteractive = !!(href || onPress);
|
|
48
|
+
|
|
49
|
+
const variantStyles = React.useMemo(
|
|
50
|
+
() => getContentCardStyles(variant, isInteractive, tokens),
|
|
51
|
+
[variant, isInteractive, tokens]
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Frame
|
|
56
|
+
elevation={variant === 'elevated' ? 2 : undefined}
|
|
57
|
+
appearance={variant === 'elevated' ? 'tinted' : undefined}
|
|
58
|
+
href={href}
|
|
59
|
+
onPress={onPress}
|
|
60
|
+
disabled={disabled}
|
|
61
|
+
padding={padding}
|
|
62
|
+
gap={gap}
|
|
63
|
+
style={[
|
|
64
|
+
variantStyles,
|
|
65
|
+
...(Array.isArray(style) ? style : style ? [style] : []),
|
|
66
|
+
]}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
</Frame>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
import type { PaddingProp, GapProp } from '../../../primitives/Frame/Frame.types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Visual variant for the ContentCard component
|
|
6
|
+
*/
|
|
7
|
+
export type ContentCardVariant = 'elevated' | 'bordered' | 'flat';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Props for the ContentCard component
|
|
11
|
+
*/
|
|
12
|
+
export interface ContentCardProps {
|
|
13
|
+
/**
|
|
14
|
+
* Card content.
|
|
15
|
+
*/
|
|
16
|
+
readonly children: React.ReactNode;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Visual variant:
|
|
20
|
+
* - `'elevated'` — raised surface with tinted background and elevation shadow
|
|
21
|
+
* - `'bordered'` — outlined container with border and rounded corners
|
|
22
|
+
* - `'flat'` — minimal, bottom-border only (for list rows)
|
|
23
|
+
*
|
|
24
|
+
* @default 'bordered'
|
|
25
|
+
*/
|
|
26
|
+
readonly variant?: ContentCardVariant;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Navigation URL — makes the card a link.
|
|
30
|
+
*/
|
|
31
|
+
readonly href?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Press handler — makes the card interactive.
|
|
35
|
+
*/
|
|
36
|
+
readonly onPress?: () => void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Padding inside the card.
|
|
40
|
+
* @default 20
|
|
41
|
+
*/
|
|
42
|
+
readonly padding?: PaddingProp;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Gap between children.
|
|
46
|
+
* @default 8
|
|
47
|
+
*/
|
|
48
|
+
readonly gap?: GapProp;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Disabled state
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
readonly disabled?: boolean;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Custom style overrides
|
|
58
|
+
*/
|
|
59
|
+
readonly style?: ViewStyle | ViewStyle[];
|
|
60
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
import type { UseTokensResult } from 'newtone-api';
|
|
3
|
+
import type { DividerOrientation } from './Divider.types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Compute divider styles based on orientation, spacing, and tokens.
|
|
7
|
+
*/
|
|
8
|
+
export function getDividerStyles(
|
|
9
|
+
orientation: DividerOrientation,
|
|
10
|
+
spacing: number | undefined,
|
|
11
|
+
tokens: UseTokensResult
|
|
12
|
+
): ViewStyle {
|
|
13
|
+
const color = tokens.colors.primary.main.divider;
|
|
14
|
+
|
|
15
|
+
if (orientation === 'vertical') {
|
|
16
|
+
return {
|
|
17
|
+
width: 1,
|
|
18
|
+
height: '100%' as any,
|
|
19
|
+
backgroundColor: color,
|
|
20
|
+
...(spacing != null && { marginLeft: spacing, marginRight: spacing }),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
height: 1,
|
|
26
|
+
width: '100%' as any,
|
|
27
|
+
backgroundColor: color,
|
|
28
|
+
...(spacing != null && { marginTop: spacing, marginBottom: spacing }),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import type { DividerProps } from './Divider.types';
|
|
4
|
+
import { getDividerStyles } from './Divider.styles';
|
|
5
|
+
import { useTokens } from 'newtone-api';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Divider — A horizontal or vertical separator line.
|
|
9
|
+
*
|
|
10
|
+
* Uses the theme's divider color from tokens automatically.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* // Horizontal divider
|
|
15
|
+
* <Divider />
|
|
16
|
+
*
|
|
17
|
+
* // With spacing
|
|
18
|
+
* <Divider spacing={16} />
|
|
19
|
+
*
|
|
20
|
+
* // Vertical divider (inside a horizontal Wrapper)
|
|
21
|
+
* <Wrapper direction="horizontal" align="center">
|
|
22
|
+
* <Text>Left</Text>
|
|
23
|
+
* <Divider orientation="vertical" spacing={12} />
|
|
24
|
+
* <Text>Right</Text>
|
|
25
|
+
* </Wrapper>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function Divider({
|
|
29
|
+
orientation = 'horizontal',
|
|
30
|
+
spacing,
|
|
31
|
+
style,
|
|
32
|
+
}: DividerProps) {
|
|
33
|
+
const tokens = useTokens();
|
|
34
|
+
|
|
35
|
+
const dividerStyle = React.useMemo(
|
|
36
|
+
() => getDividerStyles(orientation, spacing, tokens),
|
|
37
|
+
[orientation, spacing, tokens]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<View
|
|
42
|
+
style={[dividerStyle, ...(Array.isArray(style) ? style : style ? [style] : [])]}
|
|
43
|
+
accessibilityRole="none"
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Orientation of the divider line
|
|
5
|
+
*/
|
|
6
|
+
export type DividerOrientation = 'horizontal' | 'vertical';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for the Divider component
|
|
10
|
+
*/
|
|
11
|
+
export interface DividerProps {
|
|
12
|
+
/**
|
|
13
|
+
* Orientation of the divider line.
|
|
14
|
+
* @default 'horizontal'
|
|
15
|
+
*/
|
|
16
|
+
readonly orientation?: DividerOrientation;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Spacing around the divider (margin above+below for horizontal, left+right for vertical).
|
|
20
|
+
* Accepts a pixel number.
|
|
21
|
+
*/
|
|
22
|
+
readonly spacing?: number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Custom style overrides
|
|
26
|
+
*/
|
|
27
|
+
readonly style?: ViewStyle | ViewStyle[];
|
|
28
|
+
}
|
|
@@ -1,15 +1,17 @@
|
|
|
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
|
interface NavbarStyleInput {
|
|
5
5
|
readonly tokens: ResolvedTokens;
|
|
6
|
-
readonly gamut: ColorGamut;
|
|
7
6
|
readonly height: number;
|
|
8
7
|
readonly bordered: boolean;
|
|
8
|
+
readonly theme?: ThemeName;
|
|
9
|
+
readonly appearance?: AppearanceName;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export function getNavbarStyles({ tokens,
|
|
12
|
-
const
|
|
12
|
+
export function getNavbarStyles({ tokens, height, bordered, theme = 'primary', appearance = 'main' }: NavbarStyleInput) {
|
|
13
|
+
const at: AppearanceTokens = tokens.colors[theme][appearance];
|
|
14
|
+
const borderColor = at.fontSecondary;
|
|
13
15
|
|
|
14
16
|
return StyleSheet.create({
|
|
15
17
|
container: {
|
|
@@ -18,7 +20,7 @@ export function getNavbarStyles({ tokens, gamut, height, bordered }: NavbarStyle
|
|
|
18
20
|
height,
|
|
19
21
|
flexShrink: 0,
|
|
20
22
|
paddingHorizontal: 24,
|
|
21
|
-
backgroundColor:
|
|
23
|
+
backgroundColor: at.background,
|
|
22
24
|
borderBottomWidth: bordered ? 1 : 0,
|
|
23
25
|
borderBottomColor: borderColor,
|
|
24
26
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import type { NavbarProps } from './Navbar.types';
|
|
4
|
-
import { useTokens } from 'newtone-api';
|
|
4
|
+
import { useTokens, useFrameContext } from 'newtone-api';
|
|
5
5
|
import { getNavbarStyles } from './Navbar.styles';
|
|
6
6
|
|
|
7
7
|
export function Navbar({
|
|
@@ -12,9 +12,10 @@ export function Navbar({
|
|
|
12
12
|
bordered = true,
|
|
13
13
|
}: NavbarProps) {
|
|
14
14
|
const tokens = useTokens();
|
|
15
|
+
const frameCtx = useFrameContext();
|
|
15
16
|
const styles = React.useMemo(
|
|
16
|
-
() => getNavbarStyles({ tokens,
|
|
17
|
-
[tokens, height, bordered]
|
|
17
|
+
() => getNavbarStyles({ tokens, height, bordered, theme: frameCtx?.theme, appearance: frameCtx?.appearance }),
|
|
18
|
+
[tokens, height, bordered, frameCtx?.theme, frameCtx?.appearance]
|
|
18
19
|
);
|
|
19
20
|
|
|
20
21
|
return (
|
|
@@ -1,22 +1,24 @@
|
|
|
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
|
interface SidebarStyleInput {
|
|
5
5
|
readonly tokens: ResolvedTokens;
|
|
6
|
-
readonly gamut: ColorGamut;
|
|
7
6
|
readonly width: number;
|
|
8
7
|
readonly bordered: boolean;
|
|
8
|
+
readonly theme?: ThemeName;
|
|
9
|
+
readonly appearance?: AppearanceName;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export function getSidebarStyles({ tokens,
|
|
12
|
-
const
|
|
12
|
+
export function getSidebarStyles({ tokens, width, bordered, theme = 'primary', appearance = 'main' }: SidebarStyleInput) {
|
|
13
|
+
const at: AppearanceTokens = tokens.colors[theme][appearance];
|
|
14
|
+
const borderColor = at.fontSecondary;
|
|
13
15
|
|
|
14
16
|
return StyleSheet.create({
|
|
15
17
|
container: {
|
|
16
18
|
width,
|
|
17
19
|
flexShrink: 0,
|
|
18
20
|
flexDirection: 'column',
|
|
19
|
-
backgroundColor:
|
|
21
|
+
backgroundColor: at.background,
|
|
20
22
|
borderRightWidth: bordered ? 1 : 0,
|
|
21
23
|
borderRightColor: borderColor,
|
|
22
24
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, ScrollView } from 'react-native';
|
|
3
3
|
import type { SidebarProps } from './Sidebar.types';
|
|
4
|
-
import { useTokens } from 'newtone-api';
|
|
4
|
+
import { useTokens, useFrameContext } from 'newtone-api';
|
|
5
5
|
import { getSidebarStyles } from './Sidebar.styles';
|
|
6
6
|
|
|
7
7
|
export function Sidebar({
|
|
@@ -12,9 +12,10 @@ export function Sidebar({
|
|
|
12
12
|
bordered = true,
|
|
13
13
|
}: SidebarProps) {
|
|
14
14
|
const tokens = useTokens();
|
|
15
|
+
const frameCtx = useFrameContext();
|
|
15
16
|
const styles = React.useMemo(
|
|
16
|
-
() => getSidebarStyles({ tokens,
|
|
17
|
-
[tokens, width, bordered]
|
|
17
|
+
() => getSidebarStyles({ tokens, width, bordered, theme: frameCtx?.theme, appearance: frameCtx?.appearance }),
|
|
18
|
+
[tokens, width, bordered, frameCtx?.theme, frameCtx?.appearance]
|
|
18
19
|
);
|
|
19
20
|
|
|
20
21
|
return (
|
|
@@ -1,15 +1,17 @@
|
|
|
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 getPopoverStyles(
|
|
5
5
|
tokens: ResolvedTokens,
|
|
6
|
-
gamut: ColorGamut,
|
|
7
6
|
triggerHeight: number,
|
|
8
7
|
offset: number,
|
|
9
8
|
maxHeight: number,
|
|
10
9
|
width: 'trigger' | 'auto' | number,
|
|
11
|
-
isOpen: boolean
|
|
10
|
+
isOpen: boolean,
|
|
11
|
+
theme: ThemeName = 'primary',
|
|
12
|
+
appearance: AppearanceName = 'main',
|
|
12
13
|
) {
|
|
14
|
+
const at: AppearanceTokens = tokens.colors[theme][appearance];
|
|
13
15
|
const widthStyle =
|
|
14
16
|
width === 'trigger'
|
|
15
17
|
? { left: 0 as const, right: 0 as const }
|
|
@@ -26,9 +28,9 @@ export function getPopoverStyles(
|
|
|
26
28
|
position: 'absolute',
|
|
27
29
|
top: triggerHeight + offset,
|
|
28
30
|
...widthStyle,
|
|
29
|
-
backgroundColor:
|
|
31
|
+
backgroundColor: at.fontPrimary,
|
|
30
32
|
borderWidth: 1,
|
|
31
|
-
borderColor:
|
|
33
|
+
borderColor: at.fontSecondary,
|
|
32
34
|
borderRadius: tokens.radius.md,
|
|
33
35
|
maxHeight,
|
|
34
36
|
zIndex: 1000,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import type { PopoverProps } from './Popover.types';
|
|
4
|
-
import { useTokens } from 'newtone-api';
|
|
4
|
+
import { useTokens, useFrameContext } from 'newtone-api';
|
|
5
5
|
import { getPopoverStyles } from './Popover.styles';
|
|
6
6
|
|
|
7
7
|
// Module-level: set of close callbacks for all open Popovers.
|
|
@@ -21,6 +21,7 @@ export function Popover({
|
|
|
21
21
|
contentStyle,
|
|
22
22
|
}: PopoverProps) {
|
|
23
23
|
const tokens = useTokens(1);
|
|
24
|
+
const frameCtx = useFrameContext();
|
|
24
25
|
const containerRef = useRef<View>(null);
|
|
25
26
|
const [triggerHeight, setTriggerHeight] = useState(0);
|
|
26
27
|
|
|
@@ -68,8 +69,8 @@ export function Popover({
|
|
|
68
69
|
);
|
|
69
70
|
|
|
70
71
|
const styles = useMemo(
|
|
71
|
-
() => getPopoverStyles(tokens,
|
|
72
|
-
[tokens, triggerHeight, offset, maxHeight, width, isOpen]
|
|
72
|
+
() => getPopoverStyles(tokens, triggerHeight, offset, maxHeight, width, isOpen, frameCtx?.theme, frameCtx?.appearance),
|
|
73
|
+
[tokens, triggerHeight, offset, maxHeight, width, isOpen, frameCtx?.theme, frameCtx?.appearance]
|
|
73
74
|
);
|
|
74
75
|
|
|
75
76
|
const containerStyles = useMemo(
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import type { ResolvedTokens
|
|
2
|
+
import type { ResolvedTokens } from 'newtone-api';
|
|
3
3
|
|
|
4
4
|
const TRACK_HEIGHT = 22;
|
|
5
5
|
export const THUMB_SIZE = 18;
|
|
6
6
|
|
|
7
|
-
export function getColorScaleSliderStyles(tokens: ResolvedTokens,
|
|
7
|
+
export function getColorScaleSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
|
|
8
8
|
return StyleSheet.create({
|
|
9
9
|
container: {
|
|
10
10
|
gap: tokens.spacing['04'],
|
|
@@ -19,7 +19,7 @@ export function getColorScaleSliderStyles(tokens: ResolvedTokens, gamut: ColorGa
|
|
|
19
19
|
fontFamily: tokens.typography.fonts.main.family,
|
|
20
20
|
fontSize: tokens.typography.fontSizes['04'],
|
|
21
21
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
22
|
-
color: tokens.
|
|
22
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
23
23
|
},
|
|
24
24
|
trackContainer: {
|
|
25
25
|
height: TRACK_HEIGHT + THUMB_SIZE,
|
|
@@ -45,13 +45,13 @@ export function getColorScaleSliderStyles(tokens: ResolvedTokens, gamut: ColorGa
|
|
|
45
45
|
borderRadius: THUMB_SIZE / 2,
|
|
46
46
|
backgroundColor: '#ffffff',
|
|
47
47
|
borderWidth: 2,
|
|
48
|
-
borderColor: tokens.
|
|
48
|
+
borderColor: tokens.colors.primary.main.fontSecondary,
|
|
49
49
|
},
|
|
50
50
|
warning: {
|
|
51
51
|
fontFamily: tokens.typography.fonts.main.family,
|
|
52
52
|
fontSize: tokens.typography.fontSizes['01'],
|
|
53
53
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
54
|
-
color: tokens.error.
|
|
54
|
+
color: tokens.colors.error.emphasis.divider,
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
57
|
}
|
|
@@ -4,7 +4,7 @@ import { srgbToHex } from 'newtone';
|
|
|
4
4
|
import { oklchToP3Css } from '@newtonedev/colors';
|
|
5
5
|
import type { Oklch } from '@newtonedev/colors';
|
|
6
6
|
import type { ColorScaleSliderProps } from './ColorScaleSlider.types';
|
|
7
|
-
import { useTokens } from 'newtone-api';
|
|
7
|
+
import { useTokens, useNewtoneTheme } from 'newtone-api';
|
|
8
8
|
import { getColorScaleSliderStyles, THUMB_SIZE } from './ColorScaleSlider.styles';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -30,9 +30,10 @@ export function ColorScaleSlider({
|
|
|
30
30
|
style,
|
|
31
31
|
}: ColorScaleSliderProps) {
|
|
32
32
|
const tokens = useTokens(1);
|
|
33
|
+
const { gamut } = useNewtoneTheme();
|
|
33
34
|
|
|
34
35
|
const styles = React.useMemo(
|
|
35
|
-
() => getColorScaleSliderStyles(tokens,
|
|
36
|
+
() => getColorScaleSliderStyles(tokens, disabled),
|
|
36
37
|
[tokens, disabled]
|
|
37
38
|
);
|
|
38
39
|
|
|
@@ -146,7 +147,7 @@ export function ColorScaleSlider({
|
|
|
146
147
|
>
|
|
147
148
|
<View style={styles.gradientTrack}>
|
|
148
149
|
{visibleColors.map((color, i) => (
|
|
149
|
-
<View key={i} style={[styles.segment, { backgroundColor:
|
|
150
|
+
<View key={i} style={[styles.segment, { backgroundColor: gamut === 'p3' ? oklchToP3Css(color.oklch) : srgbToHex(color.srgb) }]} />
|
|
150
151
|
))}
|
|
151
152
|
</View>
|
|
152
153
|
<Animated.View style={[styles.thumb, { left: thumbAnim }]} />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
2
|
import { srgbToHex, gamutMapToSrgb } from 'newtone';
|
|
3
|
-
import type { ResolvedTokens
|
|
3
|
+
import type { ResolvedTokens } from 'newtone-api';
|
|
4
4
|
|
|
5
5
|
const TRACK_HEIGHT = 22;
|
|
6
6
|
export const THUMB_SIZE = 18;
|
|
@@ -22,7 +22,7 @@ export function buildHueSegments(min: number, max: number): string[] {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export function getHueSliderStyles(tokens: ResolvedTokens,
|
|
25
|
+
export function getHueSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
|
|
26
26
|
return StyleSheet.create({
|
|
27
27
|
container: {
|
|
28
28
|
gap: tokens.spacing['04'],
|
|
@@ -37,23 +37,23 @@ export function getHueSliderStyles(tokens: ResolvedTokens, gamut: ColorGamut, di
|
|
|
37
37
|
fontFamily: tokens.typography.fonts.main.family,
|
|
38
38
|
fontSize: tokens.typography.fontSizes['04'],
|
|
39
39
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
40
|
-
color: tokens.
|
|
40
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
41
41
|
},
|
|
42
42
|
value: {
|
|
43
43
|
fontFamily: tokens.typography.fonts.main.family,
|
|
44
44
|
fontSize: tokens.typography.fontSizes['04'],
|
|
45
45
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
46
|
-
color: tokens.
|
|
46
|
+
color: tokens.colors.primary.main.divider,
|
|
47
47
|
},
|
|
48
48
|
valueInput: {
|
|
49
49
|
width: 48,
|
|
50
50
|
paddingVertical: 0,
|
|
51
51
|
paddingHorizontal: 4,
|
|
52
52
|
borderWidth: 1,
|
|
53
|
-
borderColor: tokens.
|
|
53
|
+
borderColor: tokens.colors.primary.main.fontSecondary,
|
|
54
54
|
borderRadius: 4,
|
|
55
55
|
backgroundColor: 'transparent',
|
|
56
|
-
color: tokens.
|
|
56
|
+
color: tokens.colors.primary.main.divider,
|
|
57
57
|
fontFamily: tokens.typography.fonts.main.family,
|
|
58
58
|
fontSize: tokens.typography.fontSizes['04'],
|
|
59
59
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
@@ -83,7 +83,7 @@ export function getHueSliderStyles(tokens: ResolvedTokens, gamut: ColorGamut, di
|
|
|
83
83
|
borderRadius: THUMB_SIZE / 2,
|
|
84
84
|
backgroundColor: '#ffffff',
|
|
85
85
|
borderWidth: 2,
|
|
86
|
-
borderColor: tokens.
|
|
86
|
+
borderColor: tokens.colors.primary.main.fontSecondary,
|
|
87
87
|
},
|
|
88
88
|
});
|
|
89
89
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import type { ResolvedTokens
|
|
2
|
+
import type { ResolvedTokens } from 'newtone-api';
|
|
3
3
|
|
|
4
4
|
const TRACK_HEIGHT = 6;
|
|
5
5
|
export const THUMB_SIZE = 16;
|
|
6
6
|
|
|
7
|
-
export function getSliderStyles(tokens: ResolvedTokens,
|
|
7
|
+
export function getSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
|
|
8
8
|
return StyleSheet.create({
|
|
9
9
|
container: {
|
|
10
10
|
gap: tokens.spacing['04'],
|
|
@@ -19,23 +19,23 @@ export function getSliderStyles(tokens: ResolvedTokens, gamut: ColorGamut, disab
|
|
|
19
19
|
fontFamily: tokens.typography.fonts.main.family,
|
|
20
20
|
fontSize: tokens.typography.fontSizes['04'],
|
|
21
21
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
22
|
-
color: tokens.
|
|
22
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
23
23
|
},
|
|
24
24
|
value: {
|
|
25
25
|
fontFamily: tokens.typography.fonts.main.family,
|
|
26
26
|
fontSize: tokens.typography.fontSizes['04'],
|
|
27
27
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
28
|
-
color: tokens.
|
|
28
|
+
color: tokens.colors.primary.main.divider,
|
|
29
29
|
},
|
|
30
30
|
valueInput: {
|
|
31
31
|
width: 48,
|
|
32
32
|
paddingVertical: 0,
|
|
33
33
|
paddingHorizontal: 4,
|
|
34
34
|
borderWidth: 1,
|
|
35
|
-
borderColor: tokens.
|
|
35
|
+
borderColor: tokens.colors.primary.main.fontSecondary,
|
|
36
36
|
borderRadius: 4,
|
|
37
37
|
backgroundColor: 'transparent',
|
|
38
|
-
color: tokens.
|
|
38
|
+
color: tokens.colors.primary.main.divider,
|
|
39
39
|
fontFamily: tokens.typography.fonts.main.family,
|
|
40
40
|
fontSize: tokens.typography.fontSizes['04'],
|
|
41
41
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
@@ -52,21 +52,21 @@ export function getSliderStyles(tokens: ResolvedTokens, gamut: ColorGamut, disab
|
|
|
52
52
|
right: 0,
|
|
53
53
|
height: TRACK_HEIGHT,
|
|
54
54
|
borderRadius: TRACK_HEIGHT / 2,
|
|
55
|
-
backgroundColor: tokens.
|
|
55
|
+
backgroundColor: tokens.colors.primary.main.fontSecondary,
|
|
56
56
|
},
|
|
57
57
|
trackFill: {
|
|
58
58
|
position: 'absolute',
|
|
59
59
|
left: 0,
|
|
60
60
|
height: TRACK_HEIGHT,
|
|
61
61
|
borderRadius: TRACK_HEIGHT / 2,
|
|
62
|
-
backgroundColor: tokens.
|
|
62
|
+
backgroundColor: tokens.colors.primary.emphasis.divider,
|
|
63
63
|
},
|
|
64
64
|
thumb: {
|
|
65
65
|
position: 'absolute',
|
|
66
66
|
width: THUMB_SIZE,
|
|
67
67
|
height: THUMB_SIZE,
|
|
68
68
|
borderRadius: THUMB_SIZE / 2,
|
|
69
|
-
backgroundColor: tokens.
|
|
69
|
+
backgroundColor: tokens.colors.primary.emphasis.divider,
|
|
70
70
|
},
|
|
71
71
|
});
|
|
72
72
|
}
|