@newtonedev/components 0.1.12 → 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 +4 -3
- package/dist/_COMPONENT_TEMPLATE/ComponentName.styles.d.ts.map +1 -1
- package/dist/_COMPONENT_TEMPLATE/ComponentName.types.d.ts +1 -1
- package/dist/_COMPONENT_TEMPLATE/ComponentName.types.d.ts.map +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 +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/Card/Card.types.d.ts +1 -1
- package/dist/composites/layout/Card/Card.types.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 -2
- 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 -2
- 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 +1 -1
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.d.ts.map +1 -1
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.d.ts +1 -1
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.d.ts.map +1 -1
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.types.d.ts +2 -0
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.types.d.ts.map +1 -1
- package/dist/composites/range-inputs/HueSlider/HueSlider.d.ts +3 -4
- package/dist/composites/range-inputs/HueSlider/HueSlider.d.ts.map +1 -1
- package/dist/composites/range-inputs/HueSlider/HueSlider.styles.d.ts +3 -3
- package/dist/composites/range-inputs/HueSlider/HueSlider.styles.d.ts.map +1 -1
- package/dist/composites/range-inputs/Slider/Slider.styles.d.ts +1 -1
- package/dist/composites/range-inputs/Slider/Slider.styles.d.ts.map +1 -1
- package/dist/index.cjs +1609 -1693
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +22 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1454 -1621
- 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 -3
- 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/Frame.utils.d.ts +1 -1
- package/dist/primitives/Frame/Frame.utils.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 +6 -4
- 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 +4 -7
- 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 +10 -2
- 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 +3 -2
- package/src/_COMPONENT_TEMPLATE/ComponentName.styles.ts +4 -4
- package/src/_COMPONENT_TEMPLATE/ComponentName.tsx +2 -2
- package/src/_COMPONENT_TEMPLATE/ComponentName.types.ts +1 -1
- package/src/composites/actions/Button/Button.styles.ts +72 -55
- package/src/composites/actions/Button/Button.tsx +35 -14
- 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 -7
- package/src/composites/form-controls/Select/SelectOption.tsx +10 -8
- package/src/composites/form-controls/TextInput/TextInput.styles.ts +12 -9
- package/src/composites/form-controls/TextInput/TextInput.tsx +7 -5
- 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 -4
- package/src/composites/layout/AppShell/AppShell.tsx +6 -2
- package/src/composites/layout/Card/Card.styles.ts +10 -5
- package/src/composites/layout/Card/Card.tsx +4 -3
- package/src/composites/layout/Card/Card.types.ts +1 -1
- 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 +4 -5
- package/src/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.tsx +6 -2
- package/src/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.types.ts +2 -0
- package/src/composites/range-inputs/HueSlider/HueSlider.styles.ts +13 -20
- package/src/composites/range-inputs/HueSlider/HueSlider.tsx +7 -8
- package/src/composites/range-inputs/Slider/Slider.styles.ts +8 -9
- package/src/composites/range-inputs/Slider/Slider.tsx +1 -1
- package/src/index.ts +108 -61
- package/src/primitives/Frame/Frame.styles.ts +55 -11
- package/src/primitives/Frame/Frame.tsx +140 -142
- package/src/primitives/Frame/Frame.types.ts +119 -1
- package/src/primitives/Frame/Frame.utils.ts +1 -1
- package/src/primitives/Frame/index.ts +4 -0
- package/src/primitives/Icon/Icon.tsx +9 -7
- package/src/primitives/Icon/Icon.types.ts +2 -2
- package/src/primitives/Text/Text.spans.ts +9 -5
- package/src/primitives/Text/Text.tsx +33 -22
- package/src/primitives/Text/Text.types.ts +4 -7
- package/src/primitives/Wrapper/Wrapper.styles.ts +33 -1
- package/src/primitives/Wrapper/Wrapper.tsx +23 -4
- package/src/primitives/Wrapper/Wrapper.types.ts +45 -0
- package/dist/fonts/GoogleFontLoader.d.ts +0 -20
- package/dist/fonts/GoogleFontLoader.d.ts.map +0 -1
- package/dist/fonts/IconFontLoader.d.ts +0 -13
- package/dist/fonts/IconFontLoader.d.ts.map +0 -1
- package/dist/fonts/SelfHostedFontLoader.d.ts +0 -14
- package/dist/fonts/SelfHostedFontLoader.d.ts.map +0 -1
- package/dist/fonts/buildGoogleFontsUrl.d.ts +0 -2
- package/dist/fonts/buildGoogleFontsUrl.d.ts.map +0 -1
- package/dist/fonts/measureFont.d.ts +0 -19
- package/dist/fonts/measureFont.d.ts.map +0 -1
- package/dist/fonts/reportQueue.d.ts +0 -7
- package/dist/fonts/reportQueue.d.ts.map +0 -1
- package/dist/fonts/useLocalCalibration.d.ts +0 -19
- package/dist/fonts/useLocalCalibration.d.ts.map +0 -1
- package/dist/fonts/useTypographyCalibrations.d.ts +0 -11
- package/dist/fonts/useTypographyCalibrations.d.ts.map +0 -1
- package/dist/theme/FrameContext.d.ts +0 -26
- package/dist/theme/FrameContext.d.ts.map +0 -1
- package/dist/theme/NewtoneProvider.d.ts +0 -40
- package/dist/theme/NewtoneProvider.d.ts.map +0 -1
- package/dist/theme/defaults.d.ts +0 -8
- package/dist/theme/defaults.d.ts.map +0 -1
- package/dist/theme/types.d.ts +0 -156
- package/dist/theme/types.d.ts.map +0 -1
- package/dist/theme/useBreakpoint.d.ts +0 -9
- package/dist/theme/useBreakpoint.d.ts.map +0 -1
- package/dist/tokens/computeTokens.d.ts +0 -151
- package/dist/tokens/computeTokens.d.ts.map +0 -1
- package/dist/tokens/types.d.ts +0 -162
- package/dist/tokens/types.d.ts.map +0 -1
- package/dist/tokens/useTokens.d.ts +0 -26
- package/dist/tokens/useTokens.d.ts.map +0 -1
- package/src/fonts/GoogleFontLoader.tsx +0 -80
- package/src/fonts/IconFontLoader.tsx +0 -51
- package/src/fonts/SelfHostedFontLoader.tsx +0 -44
- package/src/fonts/buildGoogleFontsUrl.ts +0 -2
- package/src/fonts/measureFont.ts +0 -55
- package/src/fonts/reportQueue.ts +0 -54
- package/src/fonts/useLocalCalibration.ts +0 -97
- package/src/fonts/useTypographyCalibrations.ts +0 -15
- package/src/theme/FrameContext.tsx +0 -31
- package/src/theme/NewtoneProvider.tsx +0 -84
- package/src/theme/defaults.ts +0 -71
- package/src/theme/types.ts +0 -191
- package/src/theme/useBreakpoint.ts +0 -14
- package/src/tokens/computeTokens.ts +0 -516
- package/src/tokens/types.ts +0 -146
- package/src/tokens/useTokens.ts +0 -62
|
@@ -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 {
|
|
3
|
-
import type { ResolvedTokens } from '../../../tokens/types';
|
|
2
|
+
import type { ResolvedTokens, AppearanceTokens, ThemeName, AppearanceName } from 'newtone-api';
|
|
4
3
|
|
|
5
4
|
interface NavbarStyleInput {
|
|
6
5
|
readonly tokens: ResolvedTokens;
|
|
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, height, bordered }: NavbarStyleInput) {
|
|
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, height, bordered }: NavbarStyleInput)
|
|
|
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 '
|
|
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, height, bordered }),
|
|
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 {
|
|
3
|
-
import type { ResolvedTokens } from '../../../tokens/types';
|
|
2
|
+
import type { ResolvedTokens, AppearanceTokens, ThemeName, AppearanceName } from 'newtone-api';
|
|
4
3
|
|
|
5
4
|
interface SidebarStyleInput {
|
|
6
5
|
readonly tokens: ResolvedTokens;
|
|
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, width, bordered }: SidebarStyleInput) {
|
|
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 '
|
|
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, width, bordered }),
|
|
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,6 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
import type { ResolvedTokens } from '../../../tokens/types';
|
|
2
|
+
import type { ResolvedTokens, AppearanceTokens, ThemeName, AppearanceName } from 'newtone-api';
|
|
4
3
|
|
|
5
4
|
export function getPopoverStyles(
|
|
6
5
|
tokens: ResolvedTokens,
|
|
@@ -8,8 +7,11 @@ export function getPopoverStyles(
|
|
|
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 '
|
|
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, triggerHeight, offset, maxHeight, width, isOpen),
|
|
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,6 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
import type { ResolvedTokens } from '../../../tokens/types';
|
|
2
|
+
import type { ResolvedTokens } from 'newtone-api';
|
|
4
3
|
|
|
5
4
|
const TRACK_HEIGHT = 22;
|
|
6
5
|
export const THUMB_SIZE = 18;
|
|
@@ -20,7 +19,7 @@ export function getColorScaleSliderStyles(tokens: ResolvedTokens, disabled: bool
|
|
|
20
19
|
fontFamily: tokens.typography.fonts.main.family,
|
|
21
20
|
fontSize: tokens.typography.fontSizes['04'],
|
|
22
21
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
23
|
-
color:
|
|
22
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
24
23
|
},
|
|
25
24
|
trackContainer: {
|
|
26
25
|
height: TRACK_HEIGHT + THUMB_SIZE,
|
|
@@ -46,13 +45,13 @@ export function getColorScaleSliderStyles(tokens: ResolvedTokens, disabled: bool
|
|
|
46
45
|
borderRadius: THUMB_SIZE / 2,
|
|
47
46
|
backgroundColor: '#ffffff',
|
|
48
47
|
borderWidth: 2,
|
|
49
|
-
borderColor:
|
|
48
|
+
borderColor: tokens.colors.primary.main.fontSecondary,
|
|
50
49
|
},
|
|
51
50
|
warning: {
|
|
52
51
|
fontFamily: tokens.typography.fonts.main.family,
|
|
53
52
|
fontSize: tokens.typography.fontSizes['01'],
|
|
54
53
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
55
|
-
color:
|
|
54
|
+
color: tokens.colors.error.emphasis.divider,
|
|
56
55
|
},
|
|
57
56
|
});
|
|
58
57
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, Text, PanResponder, Animated } from 'react-native';
|
|
3
3
|
import { srgbToHex } from 'newtone';
|
|
4
|
+
import { oklchToP3Css } from '@newtonedev/colors';
|
|
5
|
+
import type { Oklch } from '@newtonedev/colors';
|
|
4
6
|
import type { ColorScaleSliderProps } from './ColorScaleSlider.types';
|
|
5
|
-
import { useTokens } from '
|
|
7
|
+
import { useTokens, useNewtoneTheme } from 'newtone-api';
|
|
6
8
|
import { getColorScaleSliderStyles, THUMB_SIZE } from './ColorScaleSlider.styles';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -24,9 +26,11 @@ export function ColorScaleSlider({
|
|
|
24
26
|
snap = false,
|
|
25
27
|
disabled = false,
|
|
26
28
|
animateValue = false,
|
|
29
|
+
useP3: _useP3,
|
|
27
30
|
style,
|
|
28
31
|
}: ColorScaleSliderProps) {
|
|
29
32
|
const tokens = useTokens(1);
|
|
33
|
+
const { gamut } = useNewtoneTheme();
|
|
30
34
|
|
|
31
35
|
const styles = React.useMemo(
|
|
32
36
|
() => getColorScaleSliderStyles(tokens, disabled),
|
|
@@ -143,7 +147,7 @@ export function ColorScaleSlider({
|
|
|
143
147
|
>
|
|
144
148
|
<View style={styles.gradientTrack}>
|
|
145
149
|
{visibleColors.map((color, i) => (
|
|
146
|
-
<View key={i} style={[styles.segment, { backgroundColor: srgbToHex(color.srgb) }]} />
|
|
150
|
+
<View key={i} style={[styles.segment, { backgroundColor: gamut === 'p3' ? oklchToP3Css(color.oklch) : srgbToHex(color.srgb) }]} />
|
|
147
151
|
))}
|
|
148
152
|
</View>
|
|
149
153
|
<Animated.View style={[styles.thumb, { left: thumbAnim }]} />
|
|
@@ -20,6 +20,8 @@ export interface ColorScaleSliderProps {
|
|
|
20
20
|
readonly disabled?: boolean;
|
|
21
21
|
/** Animate thumb position on prop-driven value changes (e.g., mode switch). Default: false */
|
|
22
22
|
readonly animateValue?: boolean;
|
|
23
|
+
/** @deprecated Gamut is now read from context via `useTokens().gamut`. This prop is ignored. */
|
|
24
|
+
readonly useP3?: boolean;
|
|
23
25
|
/** Optional style override */
|
|
24
26
|
readonly style?: ViewStyle | ViewStyle[];
|
|
25
27
|
}
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { srgbToHex } from 'newtone';
|
|
3
|
-
import type { ResolvedTokens } from '
|
|
2
|
+
import { srgbToHex, gamutMapToSrgb } from 'newtone';
|
|
3
|
+
import type { ResolvedTokens } from 'newtone-api';
|
|
4
4
|
|
|
5
5
|
const TRACK_HEIGHT = 22;
|
|
6
6
|
export const THUMB_SIZE = 18;
|
|
7
7
|
const SEGMENT_COUNT = 48;
|
|
8
|
+
const OKLCH_L = 0.7;
|
|
9
|
+
const OKLCH_C = 0.4;
|
|
8
10
|
|
|
9
|
-
/** Convert an
|
|
10
|
-
export function hueToHex(
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
let r: number, g: number, b: number;
|
|
14
|
-
if (h < 60) { r = 1; g = x; b = 0; }
|
|
15
|
-
else if (h < 120) { r = x; g = 1; b = 0; }
|
|
16
|
-
else if (h < 180) { r = 0; g = 1; b = x; }
|
|
17
|
-
else if (h < 240) { r = 0; g = x; b = 1; }
|
|
18
|
-
else if (h < 300) { r = x; g = 0; b = 1; }
|
|
19
|
-
else { r = 1; g = 0; b = x; }
|
|
20
|
-
const toHex = (v: number) => Math.round(v * 255).toString(16).padStart(2, '0');
|
|
21
|
-
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
11
|
+
/** Convert an OKLCH hue [0, 360) to a hex string via gamut-mapped rendering. */
|
|
12
|
+
export function hueToHex(oklchHue: number): string {
|
|
13
|
+
const { color } = gamutMapToSrgb({ L: OKLCH_L, C: OKLCH_C, h: oklchHue });
|
|
14
|
+
return srgbToHex(color);
|
|
22
15
|
}
|
|
23
16
|
|
|
24
17
|
/** Build an array of hex colors for the gradient track segments. */
|
|
@@ -44,23 +37,23 @@ export function getHueSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
|
|
|
44
37
|
fontFamily: tokens.typography.fonts.main.family,
|
|
45
38
|
fontSize: tokens.typography.fontSizes['04'],
|
|
46
39
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
47
|
-
color:
|
|
40
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
48
41
|
},
|
|
49
42
|
value: {
|
|
50
43
|
fontFamily: tokens.typography.fonts.main.family,
|
|
51
44
|
fontSize: tokens.typography.fontSizes['04'],
|
|
52
45
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
53
|
-
color:
|
|
46
|
+
color: tokens.colors.primary.main.divider,
|
|
54
47
|
},
|
|
55
48
|
valueInput: {
|
|
56
49
|
width: 48,
|
|
57
50
|
paddingVertical: 0,
|
|
58
51
|
paddingHorizontal: 4,
|
|
59
52
|
borderWidth: 1,
|
|
60
|
-
borderColor:
|
|
53
|
+
borderColor: tokens.colors.primary.main.fontSecondary,
|
|
61
54
|
borderRadius: 4,
|
|
62
55
|
backgroundColor: 'transparent',
|
|
63
|
-
color:
|
|
56
|
+
color: tokens.colors.primary.main.divider,
|
|
64
57
|
fontFamily: tokens.typography.fonts.main.family,
|
|
65
58
|
fontSize: tokens.typography.fontSizes['04'],
|
|
66
59
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
@@ -90,7 +83,7 @@ export function getHueSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
|
|
|
90
83
|
borderRadius: THUMB_SIZE / 2,
|
|
91
84
|
backgroundColor: '#ffffff',
|
|
92
85
|
borderWidth: 2,
|
|
93
|
-
borderColor:
|
|
86
|
+
borderColor: tokens.colors.primary.main.fontSecondary,
|
|
94
87
|
},
|
|
95
88
|
});
|
|
96
89
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, Text, TextInput, PanResponder } from 'react-native';
|
|
3
3
|
import type { HueSliderProps } from './HueSlider.types';
|
|
4
|
-
import { useTokens } from '
|
|
4
|
+
import { useTokens } from 'newtone-api';
|
|
5
5
|
import {
|
|
6
6
|
getHueSliderStyles,
|
|
7
7
|
buildHueSegments,
|
|
@@ -11,18 +11,17 @@ import {
|
|
|
11
11
|
/**
|
|
12
12
|
* Hue slider with rainbow gradient track.
|
|
13
13
|
*
|
|
14
|
-
* Value range:
|
|
15
|
-
* 0=red, 60=yellow, 120=green, 180=cyan, 240=blue, 300=magenta.
|
|
14
|
+
* Value range: OKLCH hue [0, 360).
|
|
16
15
|
*
|
|
17
16
|
* Optional min/max constrain the selectable range.
|
|
18
|
-
* For wrapping ranges
|
|
19
|
-
* the returned value is always normalized to [0,
|
|
17
|
+
* For wrapping ranges, max may exceed 360;
|
|
18
|
+
* the returned value is always normalized to [0, 360).
|
|
20
19
|
*/
|
|
21
20
|
export function HueSlider({
|
|
22
21
|
value,
|
|
23
22
|
onValueChange,
|
|
24
23
|
min = 0,
|
|
25
|
-
max =
|
|
24
|
+
max = 360,
|
|
26
25
|
label,
|
|
27
26
|
showValue = false,
|
|
28
27
|
editableValue = false,
|
|
@@ -78,8 +77,8 @@ export function HueSlider({
|
|
|
78
77
|
})
|
|
79
78
|
).current;
|
|
80
79
|
|
|
81
|
-
// For wrapping ranges (max >
|
|
82
|
-
const sliderValue = max >
|
|
80
|
+
// For wrapping ranges (max > 360), convert stored value to slider range
|
|
81
|
+
const sliderValue = max > 360 && value < min ? value + 360 : value;
|
|
83
82
|
const ratio = max > min ? (sliderValue - min) / (max - min) : 0;
|
|
84
83
|
const usableWidth = Math.max(0, layoutWidth - THUMB_SIZE);
|
|
85
84
|
const thumbLeft = ratio * usableWidth;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
import type { ResolvedTokens } from '../../../tokens/types';
|
|
2
|
+
import type { ResolvedTokens } from 'newtone-api';
|
|
4
3
|
|
|
5
4
|
const TRACK_HEIGHT = 6;
|
|
6
5
|
export const THUMB_SIZE = 16;
|
|
@@ -20,23 +19,23 @@ export function getSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
|
|
|
20
19
|
fontFamily: tokens.typography.fonts.main.family,
|
|
21
20
|
fontSize: tokens.typography.fontSizes['04'],
|
|
22
21
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
23
|
-
color:
|
|
22
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
24
23
|
},
|
|
25
24
|
value: {
|
|
26
25
|
fontFamily: tokens.typography.fonts.main.family,
|
|
27
26
|
fontSize: tokens.typography.fontSizes['04'],
|
|
28
27
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
29
|
-
color:
|
|
28
|
+
color: tokens.colors.primary.main.divider,
|
|
30
29
|
},
|
|
31
30
|
valueInput: {
|
|
32
31
|
width: 48,
|
|
33
32
|
paddingVertical: 0,
|
|
34
33
|
paddingHorizontal: 4,
|
|
35
34
|
borderWidth: 1,
|
|
36
|
-
borderColor:
|
|
35
|
+
borderColor: tokens.colors.primary.main.fontSecondary,
|
|
37
36
|
borderRadius: 4,
|
|
38
37
|
backgroundColor: 'transparent',
|
|
39
|
-
color:
|
|
38
|
+
color: tokens.colors.primary.main.divider,
|
|
40
39
|
fontFamily: tokens.typography.fonts.main.family,
|
|
41
40
|
fontSize: tokens.typography.fontSizes['04'],
|
|
42
41
|
fontWeight: tokens.typography.fonts.main.weights.medium as any,
|
|
@@ -53,21 +52,21 @@ export function getSliderStyles(tokens: ResolvedTokens, disabled: boolean) {
|
|
|
53
52
|
right: 0,
|
|
54
53
|
height: TRACK_HEIGHT,
|
|
55
54
|
borderRadius: TRACK_HEIGHT / 2,
|
|
56
|
-
backgroundColor:
|
|
55
|
+
backgroundColor: tokens.colors.primary.main.fontSecondary,
|
|
57
56
|
},
|
|
58
57
|
trackFill: {
|
|
59
58
|
position: 'absolute',
|
|
60
59
|
left: 0,
|
|
61
60
|
height: TRACK_HEIGHT,
|
|
62
61
|
borderRadius: TRACK_HEIGHT / 2,
|
|
63
|
-
backgroundColor:
|
|
62
|
+
backgroundColor: tokens.colors.primary.emphasis.divider,
|
|
64
63
|
},
|
|
65
64
|
thumb: {
|
|
66
65
|
position: 'absolute',
|
|
67
66
|
width: THUMB_SIZE,
|
|
68
67
|
height: THUMB_SIZE,
|
|
69
68
|
borderRadius: THUMB_SIZE / 2,
|
|
70
|
-
backgroundColor:
|
|
69
|
+
backgroundColor: tokens.colors.primary.emphasis.divider,
|
|
71
70
|
},
|
|
72
71
|
});
|
|
73
72
|
}
|