@ankhorage/zora 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +59 -34
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/button/Button.js +3 -1
- package/dist/components/button/Button.js.map +1 -1
- package/dist/components/button/types.d.ts +2 -1
- package/dist/components/button/types.d.ts.map +1 -1
- package/dist/components/button/types.js.map +1 -1
- package/dist/components/card/Card.d.ts +1 -1
- package/dist/components/card/Card.d.ts.map +1 -1
- package/dist/components/card/Card.js +3 -1
- package/dist/components/card/Card.js.map +1 -1
- package/dist/components/card/types.d.ts +2 -1
- package/dist/components/card/types.d.ts.map +1 -1
- package/dist/components/card/types.js.map +1 -1
- package/dist/components/heading/Heading.d.ts +1 -1
- package/dist/components/heading/Heading.d.ts.map +1 -1
- package/dist/components/heading/Heading.js +3 -1
- package/dist/components/heading/Heading.js.map +1 -1
- package/dist/components/heading/types.d.ts +2 -2
- package/dist/components/heading/types.d.ts.map +1 -1
- package/dist/components/heading/types.js.map +1 -1
- package/dist/components/icon/Icon.d.ts +4 -2
- package/dist/components/icon/Icon.d.ts.map +1 -1
- package/dist/components/icon/Icon.js +3 -1
- package/dist/components/icon/Icon.js.map +1 -1
- package/dist/components/icon-button/IconButton.d.ts +1 -1
- package/dist/components/icon-button/IconButton.d.ts.map +1 -1
- package/dist/components/icon-button/IconButton.js +3 -1
- package/dist/components/icon-button/IconButton.js.map +1 -1
- package/dist/components/icon-button/types.d.ts +2 -1
- package/dist/components/icon-button/types.d.ts.map +1 -1
- package/dist/components/icon-button/types.js.map +1 -1
- package/dist/components/text/Text.d.ts +1 -1
- package/dist/components/text/Text.d.ts.map +1 -1
- package/dist/components/text/Text.js +3 -1
- package/dist/components/text/Text.js.map +1 -1
- package/dist/components/text/types.d.ts +2 -2
- package/dist/components/text/types.d.ts.map +1 -1
- package/dist/components/text/types.js.map +1 -1
- package/dist/patterns/panel/Panel.d.ts +1 -1
- package/dist/patterns/panel/Panel.d.ts.map +1 -1
- package/dist/patterns/panel/Panel.js +3 -1
- package/dist/patterns/panel/Panel.js.map +1 -1
- package/dist/patterns/panel/types.d.ts +2 -2
- package/dist/patterns/panel/types.d.ts.map +1 -1
- package/dist/patterns/panel/types.js.map +1 -1
- package/dist/theme/ZoraBaseProps.d.ts +18 -0
- package/dist/theme/ZoraBaseProps.d.ts.map +1 -0
- package/dist/theme/ZoraBaseProps.js +2 -0
- package/dist/theme/ZoraBaseProps.js.map +1 -0
- package/dist/theme/ZoraProvider.d.ts.map +1 -1
- package/dist/theme/ZoraProvider.js +8 -4
- package/dist/theme/ZoraProvider.js.map +1 -1
- package/dist/theme/ZoraThemeRuntimeContext.d.ts +9 -0
- package/dist/theme/ZoraThemeRuntimeContext.d.ts.map +1 -0
- package/dist/theme/ZoraThemeRuntimeContext.js +10 -0
- package/dist/theme/ZoraThemeRuntimeContext.js.map +1 -0
- package/dist/theme/ZoraThemeScope.d.ts +9 -0
- package/dist/theme/ZoraThemeScope.d.ts.map +1 -0
- package/dist/theme/ZoraThemeScope.js +41 -0
- package/dist/theme/ZoraThemeScope.js.map +1 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +2 -0
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/resolveZoraScopedThemeId.d.ts +6 -0
- package/dist/theme/resolveZoraScopedThemeId.d.ts.map +1 -0
- package/dist/theme/resolveZoraScopedThemeId.js +15 -0
- package/dist/theme/resolveZoraScopedThemeId.js.map +1 -0
- package/dist/theme/withZoraThemeScope.d.ts +4 -0
- package/dist/theme/withZoraThemeScope.d.ts.map +1 -0
- package/dist/theme/withZoraThemeScope.js +16 -0
- package/dist/theme/withZoraThemeScope.js.map +1 -0
- package/package.json +1 -1
- package/src/components/button/Button.tsx +11 -1
- package/src/components/button/types.ts +3 -4
- package/src/components/card/Card.tsx +6 -1
- package/src/components/card/types.ts +3 -1
- package/src/components/heading/Heading.tsx +6 -1
- package/src/components/heading/types.ts +3 -2
- package/src/components/icon/Icon.tsx +7 -2
- package/src/components/icon-button/IconButton.tsx +6 -1
- package/src/components/icon-button/types.ts +2 -1
- package/src/components/text/Text.tsx +6 -1
- package/src/components/text/types.ts +3 -2
- package/src/patterns/panel/Panel.tsx +4 -1
- package/src/patterns/panel/types.ts +2 -2
- package/src/theme/ZoraBaseProps.ts +20 -0
- package/src/theme/ZoraProvider.tsx +9 -4
- package/src/theme/ZoraThemeRuntimeContext.tsx +18 -0
- package/src/theme/ZoraThemeScope.tsx +74 -0
- package/src/theme/index.ts +4 -0
- package/src/theme/resolveZoraScopedThemeId.test.ts +47 -0
- package/src/theme/resolveZoraScopedThemeId.ts +25 -0
- package/src/theme/themeScopeStructure.test.ts +99 -0
- package/src/theme/withZoraThemeScope.tsx +25 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/text/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Responsive } from '@ankhorage/surface';\nimport type React from 'react';\nimport type { AccessibilityRole, TextStyle } from 'react-native';\n\nexport type TextVariant = 'body' | 'lead' | 'bodySmall' | 'caption' | 'label' | 'eyebrow' | 'code';\n\nexport type TextTone =\n | 'default'\n | 'muted'\n | 'subtle'\n | 'inverse'\n | 'primary'\n | 'danger'\n | 'success'\n | 'warning';\n\nexport type TextWeight = 'regular' | 'medium' | 'semiBold' | 'bold';\n\nexport type TextAlign = NonNullable<TextStyle['textAlign']>;\n\nexport interface TextProps {\n children?: React.ReactNode;\n text?: string;\n i18nKey?: string;\n variant?: Responsive<TextVariant>;\n tone?: Responsive<TextTone>;\n align?: Responsive<TextAlign>;\n weight?: Responsive<TextWeight>;\n italic?: boolean;\n numberOfLines?: number;\n ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip';\n selectable?: boolean;\n accessibilityLabel?: string;\n accessibilityHint?: string;\n accessibilityRole?: AccessibilityRole;\n nativeID?: string;\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/text/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Responsive } from '@ankhorage/surface';\nimport type React from 'react';\nimport type { AccessibilityRole, TextStyle } from 'react-native';\n\nimport type { ZoraBaseProps } from '../../theme/ZoraBaseProps';\n\nexport type TextVariant = 'body' | 'lead' | 'bodySmall' | 'caption' | 'label' | 'eyebrow' | 'code';\n\nexport type TextTone =\n | 'default'\n | 'muted'\n | 'subtle'\n | 'inverse'\n | 'primary'\n | 'danger'\n | 'success'\n | 'warning';\n\nexport type TextWeight = 'regular' | 'medium' | 'semiBold' | 'bold';\n\nexport type TextAlign = NonNullable<TextStyle['textAlign']>;\n\nexport interface TextProps extends ZoraBaseProps {\n children?: React.ReactNode;\n text?: string;\n i18nKey?: string;\n variant?: Responsive<TextVariant>;\n tone?: Responsive<TextTone>;\n align?: Responsive<TextAlign>;\n weight?: Responsive<TextWeight>;\n italic?: boolean;\n numberOfLines?: number;\n ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip';\n selectable?: boolean;\n accessibilityLabel?: string;\n accessibilityHint?: string;\n accessibilityRole?: AccessibilityRole;\n nativeID?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/patterns/panel/Panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/patterns/panel/Panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAM1C,eAAO,MAAM,KAAK,sBAAiC,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Card } from '../../components/card';
|
|
3
|
-
|
|
3
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
4
|
+
function PanelInner({ themeId: _themeId, mode: _mode, ...props }) {
|
|
4
5
|
return <Card {...props}/>;
|
|
5
6
|
}
|
|
7
|
+
export const Panel = withZoraThemeScope(PanelInner);
|
|
6
8
|
//# sourceMappingURL=Panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.js","sourceRoot":"","sources":["../../../src/patterns/panel/Panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"Panel.js","sourceRoot":"","sources":["../../../src/patterns/panel/Panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,SAAS,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,EAAc;IAC1E,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AAC7B,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import React from 'react';\n\nimport { Card } from '../../components/card';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport type { PanelProps } from './types';\n\nfunction PanelInner({ themeId: _themeId, mode: _mode, ...props }: PanelProps) {\n return <Card {...props} />;\n}\n\nexport const Panel = withZoraThemeScope(PanelInner);\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { ZoraCardTone } from '../../internal/recipes';
|
|
3
|
-
|
|
3
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
4
|
+
export interface PanelProps extends ZoraBaseProps {
|
|
4
5
|
title?: React.ReactNode;
|
|
5
6
|
description?: React.ReactNode;
|
|
6
7
|
eyebrow?: React.ReactNode;
|
|
@@ -9,6 +10,5 @@ export interface PanelProps {
|
|
|
9
10
|
children?: React.ReactNode;
|
|
10
11
|
tone?: ZoraCardTone;
|
|
11
12
|
compact?: boolean;
|
|
12
|
-
testID?: string;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/patterns/panel/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/patterns/panel/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/patterns/panel/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { ZoraCardTone } from '../../internal/recipes';\n\nexport interface PanelProps {\n title?: React.ReactNode;\n description?: React.ReactNode;\n eyebrow?: React.ReactNode;\n actions?: React.ReactNode;\n footer?: React.ReactNode;\n children?: React.ReactNode;\n tone?: ZoraCardTone;\n compact?: boolean;\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/patterns/panel/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { ZoraCardTone } from '../../internal/recipes';\nimport type { ZoraBaseProps } from '../../theme/ZoraBaseProps';\n\nexport interface PanelProps extends ZoraBaseProps {\n title?: React.ReactNode;\n description?: React.ReactNode;\n eyebrow?: React.ReactNode;\n actions?: React.ReactNode;\n footer?: React.ReactNode;\n children?: React.ReactNode;\n tone?: ZoraCardTone;\n compact?: boolean;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ZoraThemeId, ZoraThemeMode } from './types';
|
|
2
|
+
export interface ZoraBaseProps {
|
|
3
|
+
/**
|
|
4
|
+
* Overrides the active ZORA theme for this component and its subtree.
|
|
5
|
+
* If omitted, the nearest parent theme is inherited.
|
|
6
|
+
*
|
|
7
|
+
* Plan 2: theme registries are not available yet. Only the inherited theme id
|
|
8
|
+
* is valid; unknown ids throw in dev/test and warn+fallback in production.
|
|
9
|
+
*/
|
|
10
|
+
themeId?: ZoraThemeId;
|
|
11
|
+
/**
|
|
12
|
+
* Overrides the light/dark mode for this component and its subtree.
|
|
13
|
+
* If omitted, the nearest parent mode is inherited.
|
|
14
|
+
*/
|
|
15
|
+
mode?: ZoraThemeMode;
|
|
16
|
+
testID?: string;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ZoraBaseProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoraBaseProps.d.ts","sourceRoot":"","sources":["../../src/theme/ZoraBaseProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;IAErB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoraBaseProps.js","sourceRoot":"","sources":["../../src/theme/ZoraBaseProps.ts"],"names":[],"mappings":"","sourcesContent":["import type { ZoraThemeId, ZoraThemeMode } from './types';\n\nexport interface ZoraBaseProps {\n /**\n * Overrides the active ZORA theme for this component and its subtree.\n * If omitted, the nearest parent theme is inherited.\n *\n * Plan 2: theme registries are not available yet. Only the inherited theme id\n * is valid; unknown ids throw in dev/test and warn+fallback in production.\n */\n themeId?: ZoraThemeId;\n\n /**\n * Overrides the light/dark mode for this component and its subtree.\n * If omitted, the nearest parent mode is inherited.\n */\n mode?: ZoraThemeMode;\n\n testID?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZoraProvider.d.ts","sourceRoot":"","sources":["../../src/theme/ZoraProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ZoraProvider.d.ts","sourceRoot":"","sources":["../../src/theme/ZoraProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,KAAwB,EACxB,WAAqB,GACtB,EAAE,iBAAiB,qBAUnB"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ThemeProvider } from '@ankhorage/surface';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { createZoraThemeConfig } from './createZoraThemeConfig';
|
|
4
4
|
import { zoraDefaultTheme } from './zoraDefaultTheme';
|
|
5
|
+
import { ZoraThemeRuntimeContext } from './ZoraThemeRuntimeContext';
|
|
5
6
|
export function ZoraProvider({ children, theme = zoraDefaultTheme, initialMode = 'light', }) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const runtimeValue = React.useMemo(() => ({ sourceTheme: theme, themeId: theme.id }), [theme]);
|
|
8
|
+
return (<ZoraThemeRuntimeContext.Provider value={runtimeValue}>
|
|
9
|
+
<ThemeProvider initialConfig={createZoraThemeConfig(theme)} initialMode={initialMode}>
|
|
10
|
+
{children}
|
|
11
|
+
</ThemeProvider>
|
|
12
|
+
</ZoraThemeRuntimeContext.Provider>);
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=ZoraProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZoraProvider.js","sourceRoot":"","sources":["../../src/theme/ZoraProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ZoraProvider.js","sourceRoot":"","sources":["../../src/theme/ZoraProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAQpE,MAAM,UAAU,YAAY,CAAC,EAC3B,QAAQ,EACR,KAAK,GAAG,gBAAgB,EACxB,WAAW,GAAG,OAAO,GACH;IAClB,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAE/F,OAAO,CACL,CAAC,uBAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CACpD;MAAA,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CACnF;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,aAAa,CACjB;IAAA,EAAE,uBAAuB,CAAC,QAAQ,CAAC,CACpC,CAAC;AACJ,CAAC","sourcesContent":["import { ThemeProvider } from '@ankhorage/surface';\nimport React from 'react';\n\nimport { createZoraThemeConfig } from './createZoraThemeConfig';\nimport type { ZoraTheme, ZoraThemeMode } from './types';\nimport { zoraDefaultTheme } from './zoraDefaultTheme';\nimport { ZoraThemeRuntimeContext } from './ZoraThemeRuntimeContext';\n\nexport interface ZoraProviderProps {\n children: React.ReactNode;\n theme?: ZoraTheme;\n initialMode?: ZoraThemeMode;\n}\n\nexport function ZoraProvider({\n children,\n theme = zoraDefaultTheme,\n initialMode = 'light',\n}: ZoraProviderProps) {\n const runtimeValue = React.useMemo(() => ({ sourceTheme: theme, themeId: theme.id }), [theme]);\n\n return (\n <ZoraThemeRuntimeContext.Provider value={runtimeValue}>\n <ThemeProvider initialConfig={createZoraThemeConfig(theme)} initialMode={initialMode}>\n {children}\n </ThemeProvider>\n </ZoraThemeRuntimeContext.Provider>\n );\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ZoraTheme, ZoraThemeId } from './types';
|
|
2
|
+
interface ZoraThemeRuntime {
|
|
3
|
+
sourceTheme: ZoraTheme;
|
|
4
|
+
themeId: ZoraThemeId;
|
|
5
|
+
}
|
|
6
|
+
export declare const ZoraThemeRuntimeContext: import("react").Context<ZoraThemeRuntime>;
|
|
7
|
+
export declare function useZoraThemeRuntime(): ZoraThemeRuntime;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=ZoraThemeRuntimeContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoraThemeRuntimeContext.d.ts","sourceRoot":"","sources":["../../src/theme/ZoraThemeRuntimeContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtD,UAAU,gBAAgB;IACxB,WAAW,EAAE,SAAS,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,eAAO,MAAM,uBAAuB,2CAGlC,CAAC;AAEH,wBAAgB,mBAAmB,IAAI,gBAAgB,CAEtD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import { zoraDefaultTheme } from './zoraDefaultTheme';
|
|
3
|
+
export const ZoraThemeRuntimeContext = createContext({
|
|
4
|
+
sourceTheme: zoraDefaultTheme,
|
|
5
|
+
themeId: zoraDefaultTheme.id,
|
|
6
|
+
});
|
|
7
|
+
export function useZoraThemeRuntime() {
|
|
8
|
+
return useContext(ZoraThemeRuntimeContext);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ZoraThemeRuntimeContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoraThemeRuntimeContext.js","sourceRoot":"","sources":["../../src/theme/ZoraThemeRuntimeContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAOtD,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAmB;IACrE,WAAW,EAAE,gBAAgB;IAC7B,OAAO,EAAE,gBAAgB,CAAC,EAAE;CAC7B,CAAC,CAAC;AAEH,MAAM,UAAU,mBAAmB;IACjC,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { ZoraTheme, ZoraThemeId } from './types';\nimport { zoraDefaultTheme } from './zoraDefaultTheme';\n\ninterface ZoraThemeRuntime {\n sourceTheme: ZoraTheme;\n themeId: ZoraThemeId;\n}\n\nexport const ZoraThemeRuntimeContext = createContext<ZoraThemeRuntime>({\n sourceTheme: zoraDefaultTheme,\n themeId: zoraDefaultTheme.id,\n});\n\nexport function useZoraThemeRuntime(): ZoraThemeRuntime {\n return useContext(ZoraThemeRuntimeContext);\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ZoraThemeId, ZoraThemeMode } from './types';
|
|
3
|
+
export interface ZoraThemeScopeProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
themeId?: ZoraThemeId;
|
|
6
|
+
mode?: ZoraThemeMode;
|
|
7
|
+
}
|
|
8
|
+
export declare function ZoraThemeScope({ children, themeId, mode }: ZoraThemeScopeProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
9
|
+
//# sourceMappingURL=ZoraThemeScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoraThemeScope.d.ts","sourceRoot":"","sources":["../../src/theme/ZoraThemeScope.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG1D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAmDD,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,mBAAmB,mSAU9E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createTheme, ThemeContext, useFontContext, useTheme } from '@ankhorage/surface';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { createZoraThemeConfig } from './createZoraThemeConfig';
|
|
4
|
+
import { resolveZoraScopedThemeId } from './resolveZoraScopedThemeId';
|
|
5
|
+
import { useZoraThemeRuntime, ZoraThemeRuntimeContext } from './ZoraThemeRuntimeContext';
|
|
6
|
+
function ZoraThemeScopeInner({ children, themeId, mode }) {
|
|
7
|
+
const parentSurface = useTheme();
|
|
8
|
+
const parentRuntime = useZoraThemeRuntime();
|
|
9
|
+
const { activeFontId } = useFontContext();
|
|
10
|
+
const scopedThemeId = resolveZoraScopedThemeId({
|
|
11
|
+
desiredThemeId: themeId,
|
|
12
|
+
inheritedThemeId: parentRuntime.themeId,
|
|
13
|
+
});
|
|
14
|
+
const scopedMode = mode ?? parentSurface.mode;
|
|
15
|
+
// Plan 2: there is no multi-theme registry yet. Keep the active theme seed inherited.
|
|
16
|
+
const surfaceConfig = useMemo(() => createZoraThemeConfig(parentRuntime.sourceTheme), [parentRuntime.sourceTheme]);
|
|
17
|
+
const scopedTheme = useMemo(() => createTheme(surfaceConfig, scopedMode, activeFontId), [surfaceConfig, scopedMode, activeFontId]);
|
|
18
|
+
const scopedSurfaceValue = useMemo(() => ({
|
|
19
|
+
theme: scopedTheme,
|
|
20
|
+
mode: scopedMode,
|
|
21
|
+
setMode: parentSurface.setMode,
|
|
22
|
+
setThemeConfig: parentSurface.setThemeConfig,
|
|
23
|
+
_hasProvider: true,
|
|
24
|
+
}), [parentSurface.setMode, parentSurface.setThemeConfig, scopedMode, scopedTheme]);
|
|
25
|
+
const scopedRuntimeValue = useMemo(() => ({
|
|
26
|
+
sourceTheme: parentRuntime.sourceTheme,
|
|
27
|
+
themeId: scopedThemeId,
|
|
28
|
+
}), [parentRuntime.sourceTheme, scopedThemeId]);
|
|
29
|
+
return (<ZoraThemeRuntimeContext.Provider value={scopedRuntimeValue}>
|
|
30
|
+
<ThemeContext.Provider value={scopedSurfaceValue}>{children}</ThemeContext.Provider>
|
|
31
|
+
</ZoraThemeRuntimeContext.Provider>);
|
|
32
|
+
}
|
|
33
|
+
export function ZoraThemeScope({ children, themeId, mode }) {
|
|
34
|
+
if (mode === undefined && themeId === undefined) {
|
|
35
|
+
return children;
|
|
36
|
+
}
|
|
37
|
+
return (<ZoraThemeScopeInner mode={mode} themeId={themeId}>
|
|
38
|
+
{children}
|
|
39
|
+
</ZoraThemeScopeInner>);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=ZoraThemeScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoraThemeScope.js","sourceRoot":"","sources":["../../src/theme/ZoraThemeScope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAQzF,SAAS,mBAAmB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAuB;IAC3E,MAAM,aAAa,GAAG,QAAQ,EAAE,CAAC;IACjC,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAC;IAC5C,MAAM,EAAE,YAAY,EAAE,GAAG,cAAc,EAAE,CAAC;IAE1C,MAAM,aAAa,GAAG,wBAAwB,CAAC;QAC7C,cAAc,EAAE,OAAO;QACvB,gBAAgB,EAAE,aAAa,CAAC,OAAO;KACxC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC;IAE9C,sFAAsF;IACtF,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC,WAAW,CAAC,EACtD,CAAC,aAAa,CAAC,WAAW,CAAC,CAC5B,CAAC;IAEF,MAAM,WAAW,GAAG,OAAO,CACzB,GAAG,EAAE,CAAC,WAAW,CAAC,aAAa,EAAE,UAAU,EAAE,YAAY,CAAC,EAC1D,CAAC,aAAa,EAAE,UAAU,EAAE,YAAY,CAAC,CAC1C,CAAC;IAEF,MAAM,kBAAkB,GAAG,OAAO,CAChC,GAAG,EAAE,CAAC,CAAC;QACL,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,aAAa,CAAC,OAAO;QAC9B,cAAc,EAAE,aAAa,CAAC,cAAc;QAC5C,YAAY,EAAE,IAAI;KACnB,CAAC,EACF,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,cAAc,EAAE,UAAU,EAAE,WAAW,CAAC,CAC/E,CAAC;IAEF,MAAM,kBAAkB,GAAG,OAAO,CAChC,GAAG,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,aAAa,CAAC,WAAW;QACtC,OAAO,EAAE,aAAa;KACvB,CAAC,EACF,CAAC,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,CAC3C,CAAC;IAEF,OAAO,CACL,CAAC,uBAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAC1D;MAAA,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,QAAQ,CACrF;IAAA,EAAE,uBAAuB,CAAC,QAAQ,CAAC,CACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAuB;IAC7E,IAAI,IAAI,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAChD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,CACL,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAChD;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,mBAAmB,CAAC,CACvB,CAAC;AACJ,CAAC","sourcesContent":["import { createTheme, ThemeContext, useFontContext, useTheme } from '@ankhorage/surface';\nimport React, { useMemo } from 'react';\n\nimport { createZoraThemeConfig } from './createZoraThemeConfig';\nimport { resolveZoraScopedThemeId } from './resolveZoraScopedThemeId';\nimport type { ZoraThemeId, ZoraThemeMode } from './types';\nimport { useZoraThemeRuntime, ZoraThemeRuntimeContext } from './ZoraThemeRuntimeContext';\n\nexport interface ZoraThemeScopeProps {\n children: React.ReactNode;\n themeId?: ZoraThemeId;\n mode?: ZoraThemeMode;\n}\n\nfunction ZoraThemeScopeInner({ children, themeId, mode }: ZoraThemeScopeProps) {\n const parentSurface = useTheme();\n const parentRuntime = useZoraThemeRuntime();\n const { activeFontId } = useFontContext();\n\n const scopedThemeId = resolveZoraScopedThemeId({\n desiredThemeId: themeId,\n inheritedThemeId: parentRuntime.themeId,\n });\n\n const scopedMode = mode ?? parentSurface.mode;\n\n // Plan 2: there is no multi-theme registry yet. Keep the active theme seed inherited.\n const surfaceConfig = useMemo(\n () => createZoraThemeConfig(parentRuntime.sourceTheme),\n [parentRuntime.sourceTheme],\n );\n\n const scopedTheme = useMemo(\n () => createTheme(surfaceConfig, scopedMode, activeFontId),\n [surfaceConfig, scopedMode, activeFontId],\n );\n\n const scopedSurfaceValue = useMemo(\n () => ({\n theme: scopedTheme,\n mode: scopedMode,\n setMode: parentSurface.setMode,\n setThemeConfig: parentSurface.setThemeConfig,\n _hasProvider: true,\n }),\n [parentSurface.setMode, parentSurface.setThemeConfig, scopedMode, scopedTheme],\n );\n\n const scopedRuntimeValue = useMemo(\n () => ({\n sourceTheme: parentRuntime.sourceTheme,\n themeId: scopedThemeId,\n }),\n [parentRuntime.sourceTheme, scopedThemeId],\n );\n\n return (\n <ZoraThemeRuntimeContext.Provider value={scopedRuntimeValue}>\n <ThemeContext.Provider value={scopedSurfaceValue}>{children}</ThemeContext.Provider>\n </ZoraThemeRuntimeContext.Provider>\n );\n}\n\nexport function ZoraThemeScope({ children, themeId, mode }: ZoraThemeScopeProps) {\n if (mode === undefined && themeId === undefined) {\n return children;\n }\n\n return (\n <ZoraThemeScopeInner mode={mode} themeId={themeId}>\n {children}\n </ZoraThemeScopeInner>\n );\n}\n"]}
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export { createZoraThemeConfig } from './createZoraThemeConfig';
|
|
2
2
|
export type { ZoraColorHarmony, ZoraColorTone, ZoraComputedTheme, ZoraHexColor, ZoraTheme, ZoraThemeId, ZoraThemeMode, } from './types';
|
|
3
3
|
export { useZoraTheme } from './useZoraTheme';
|
|
4
|
+
export { withZoraThemeScope } from './withZoraThemeScope';
|
|
5
|
+
export type { ZoraBaseProps } from './ZoraBaseProps';
|
|
4
6
|
export { zoraDefaultTheme } from './zoraDefaultTheme';
|
|
5
7
|
export type { ZoraProviderProps } from './ZoraProvider';
|
|
6
8
|
export { ZoraProvider } from './ZoraProvider';
|
|
9
|
+
export type { ZoraThemeScopeProps } from './ZoraThemeScope';
|
|
10
|
+
export { ZoraThemeScope } from './ZoraThemeScope';
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,WAAW,EACX,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,WAAW,EACX,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/theme/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { createZoraThemeConfig } from './createZoraThemeConfig';
|
|
2
2
|
export { useZoraTheme } from './useZoraTheme';
|
|
3
|
+
export { withZoraThemeScope } from './withZoraThemeScope';
|
|
3
4
|
export { zoraDefaultTheme } from './zoraDefaultTheme';
|
|
4
5
|
export { ZoraProvider } from './ZoraProvider';
|
|
6
|
+
export { ZoraThemeScope } from './ZoraThemeScope';
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/dist/theme/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAUhE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { createZoraThemeConfig } from './createZoraThemeConfig';\nexport type {\n ZoraColorHarmony,\n ZoraColorTone,\n ZoraComputedTheme,\n ZoraHexColor,\n ZoraTheme,\n ZoraThemeId,\n ZoraThemeMode,\n} from './types';\nexport { useZoraTheme } from './useZoraTheme';\nexport { zoraDefaultTheme } from './zoraDefaultTheme';\nexport type { ZoraProviderProps } from './ZoraProvider';\nexport { ZoraProvider } from './ZoraProvider';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAUhE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { createZoraThemeConfig } from './createZoraThemeConfig';\nexport type {\n ZoraColorHarmony,\n ZoraColorTone,\n ZoraComputedTheme,\n ZoraHexColor,\n ZoraTheme,\n ZoraThemeId,\n ZoraThemeMode,\n} from './types';\nexport { useZoraTheme } from './useZoraTheme';\nexport { withZoraThemeScope } from './withZoraThemeScope';\nexport type { ZoraBaseProps } from './ZoraBaseProps';\nexport { zoraDefaultTheme } from './zoraDefaultTheme';\nexport type { ZoraProviderProps } from './ZoraProvider';\nexport { ZoraProvider } from './ZoraProvider';\nexport type { ZoraThemeScopeProps } from './ZoraThemeScope';\nexport { ZoraThemeScope } from './ZoraThemeScope';\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ZoraThemeId } from './types';
|
|
2
|
+
export declare function resolveZoraScopedThemeId({ desiredThemeId, inheritedThemeId, }: {
|
|
3
|
+
desiredThemeId: ZoraThemeId | undefined;
|
|
4
|
+
inheritedThemeId: ZoraThemeId;
|
|
5
|
+
}): ZoraThemeId;
|
|
6
|
+
//# sourceMappingURL=resolveZoraScopedThemeId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveZoraScopedThemeId.d.ts","sourceRoot":"","sources":["../../src/theme/resolveZoraScopedThemeId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,wBAAwB,CAAC,EACvC,cAAc,EACd,gBAAgB,GACjB,EAAE;IACD,cAAc,EAAE,WAAW,GAAG,SAAS,CAAC;IACxC,gBAAgB,EAAE,WAAW,CAAC;CAC/B,GAAG,WAAW,CAgBd"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function resolveZoraScopedThemeId({ desiredThemeId, inheritedThemeId, }) {
|
|
2
|
+
if (desiredThemeId === undefined || desiredThemeId === inheritedThemeId) {
|
|
3
|
+
return inheritedThemeId;
|
|
4
|
+
}
|
|
5
|
+
const message = [
|
|
6
|
+
`Unknown ZORA theme id '${desiredThemeId}'.`,
|
|
7
|
+
'Theme registries are not available yet; register the theme before using themeId scopes.',
|
|
8
|
+
].join(' ');
|
|
9
|
+
if (process.env.NODE_ENV === 'production') {
|
|
10
|
+
console.warn(message);
|
|
11
|
+
return inheritedThemeId;
|
|
12
|
+
}
|
|
13
|
+
throw new Error(message);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=resolveZoraScopedThemeId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveZoraScopedThemeId.js","sourceRoot":"","sources":["../../src/theme/resolveZoraScopedThemeId.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,wBAAwB,CAAC,EACvC,cAAc,EACd,gBAAgB,GAIjB;IACC,IAAI,cAAc,KAAK,SAAS,IAAI,cAAc,KAAK,gBAAgB,EAAE,CAAC;QACxE,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,MAAM,OAAO,GAAG;QACd,0BAA0B,cAAc,IAAI;QAC5C,yFAAyF;KAC1F,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QAC1C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import type { ZoraThemeId } from './types';\n\nexport function resolveZoraScopedThemeId({\n desiredThemeId,\n inheritedThemeId,\n}: {\n desiredThemeId: ZoraThemeId | undefined;\n inheritedThemeId: ZoraThemeId;\n}): ZoraThemeId {\n if (desiredThemeId === undefined || desiredThemeId === inheritedThemeId) {\n return inheritedThemeId;\n }\n\n const message = [\n `Unknown ZORA theme id '${desiredThemeId}'.`,\n 'Theme registries are not available yet; register the theme before using themeId scopes.',\n ].join(' ');\n\n if (process.env.NODE_ENV === 'production') {\n console.warn(message);\n return inheritedThemeId;\n }\n\n throw new Error(message);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withZoraThemeScope.d.ts","sourceRoot":"","sources":["../../src/theme/withZoraThemeScope.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,aAAa,EACxD,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAChC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAiBb"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ZoraThemeScope } from './ZoraThemeScope';
|
|
3
|
+
export function withZoraThemeScope(Component) {
|
|
4
|
+
const Wrapped = (props) => {
|
|
5
|
+
if (props.mode === undefined && props.themeId === undefined) {
|
|
6
|
+
return <Component {...props}/>;
|
|
7
|
+
}
|
|
8
|
+
return (<ZoraThemeScope mode={props.mode} themeId={props.themeId}>
|
|
9
|
+
<Component {...props}/>
|
|
10
|
+
</ZoraThemeScope>);
|
|
11
|
+
};
|
|
12
|
+
const name = Component.displayName ?? (Component.name || 'Component');
|
|
13
|
+
Wrapped.displayName = `withZoraThemeScope(${name})`;
|
|
14
|
+
return Wrapped;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=withZoraThemeScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withZoraThemeScope.js","sourceRoot":"","sources":["../../src/theme/withZoraThemeScope.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,UAAU,kBAAkB,CAChC,SAAiC;IAEjC,MAAM,OAAO,GAAgB,CAAC,KAAK,EAAE,EAAE;QACrC,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC5D,OAAO,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;QAClC,CAAC;QAED,OAAO,CACL,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CACvD;QAAA,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,EACvB;MAAA,EAAE,cAAc,CAAC,CAClB,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,WAAW,CAAC,CAAC;IACtE,OAAO,CAAC,WAAW,GAAG,sBAAsB,IAAI,GAAG,CAAC;IAEpD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import React from 'react';\n\nimport type { ZoraBaseProps } from './ZoraBaseProps';\nimport { ZoraThemeScope } from './ZoraThemeScope';\n\nexport function withZoraThemeScope<P extends ZoraBaseProps>(\n Component: React.ComponentType<P>,\n): React.FC<P> {\n const Wrapped: React.FC<P> = (props) => {\n if (props.mode === undefined && props.themeId === undefined) {\n return <Component {...props} />;\n }\n\n return (\n <ZoraThemeScope mode={props.mode} themeId={props.themeId}>\n <Component {...props} />\n </ZoraThemeScope>\n );\n };\n\n const name = Component.displayName ?? (Component.name || 'Component');\n Wrapped.displayName = `withZoraThemeScope(${name})`;\n\n return Wrapped;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/zora",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.0",
|
|
5
5
|
"description": "Opinionated React Native and React Native Web UI kit built on @ankhorage/surface.",
|
|
6
6
|
"homepage": "https://github.com/ankhorage/zora#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -2,12 +2,22 @@ import { Button as SurfaceButton } from '@ankhorage/surface';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
import { resolveButtonRecipe } from '../../internal/recipes';
|
|
5
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
5
6
|
import type { ButtonProps } from './types';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
function ButtonInner({
|
|
9
|
+
themeId: _themeId,
|
|
10
|
+
mode: _mode,
|
|
11
|
+
tone,
|
|
12
|
+
emphasis,
|
|
13
|
+
size,
|
|
14
|
+
...props
|
|
15
|
+
}: ButtonProps) {
|
|
8
16
|
const recipe = resolveButtonRecipe({ tone, emphasis, size });
|
|
9
17
|
|
|
10
18
|
return (
|
|
11
19
|
<SurfaceButton {...props} size={recipe.size} tone={recipe.tone} variant={recipe.variant} />
|
|
12
20
|
);
|
|
13
21
|
}
|
|
22
|
+
|
|
23
|
+
export const Button = withZoraThemeScope(ButtonInner);
|
|
@@ -2,11 +2,10 @@ import type { ButtonIconSpec, ButtonProps as SurfaceButtonProps } from '@ankhora
|
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
|
|
4
4
|
import type { ZoraControlSize, ZoraEmphasis, ZoraTone } from '../../internal/recipes';
|
|
5
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
5
6
|
|
|
6
|
-
export interface ButtonProps
|
|
7
|
-
SurfaceButtonProps,
|
|
8
|
-
'children' | 'size' | 'tone' | 'variant'
|
|
9
|
-
> {
|
|
7
|
+
export interface ButtonProps
|
|
8
|
+
extends ZoraBaseProps, Omit<SurfaceButtonProps, 'children' | 'size' | 'tone' | 'variant'> {
|
|
10
9
|
children?: React.ReactNode;
|
|
11
10
|
tone?: ZoraTone;
|
|
12
11
|
emphasis?: ZoraEmphasis;
|
|
@@ -2,11 +2,14 @@ import { Box, Card as SurfaceCard, Stack } from '@ankhorage/surface';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
import { resolveCardVariant } from '../../internal/recipes';
|
|
5
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
5
6
|
import { Heading } from '../heading';
|
|
6
7
|
import { Text } from '../text';
|
|
7
8
|
import type { CardProps } from './types';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
function CardInner({
|
|
11
|
+
themeId: _themeId,
|
|
12
|
+
mode: _mode,
|
|
10
13
|
children,
|
|
11
14
|
title,
|
|
12
15
|
description,
|
|
@@ -65,3 +68,5 @@ export function Card({
|
|
|
65
68
|
</SurfaceCard>
|
|
66
69
|
);
|
|
67
70
|
}
|
|
71
|
+
|
|
72
|
+
export const Card = withZoraThemeScope(CardInner);
|
|
@@ -2,8 +2,10 @@ import type { CardProps as SurfaceCardProps } from '@ankhorage/surface';
|
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
|
|
4
4
|
import type { ZoraCardTone } from '../../internal/recipes';
|
|
5
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
5
6
|
|
|
6
|
-
export interface CardProps
|
|
7
|
+
export interface CardProps
|
|
8
|
+
extends ZoraBaseProps, Omit<SurfaceCardProps, 'children' | 'p' | 'radius' | 'variant'> {
|
|
7
9
|
children?: React.ReactNode;
|
|
8
10
|
title?: React.ReactNode;
|
|
9
11
|
description?: React.ReactNode;
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { Text as ReactNativeText } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import { useZoraTheme } from '../../theme/useZoraTheme';
|
|
6
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
6
7
|
import { resolveHeadingRecipe, resolveHeadingSizeFromLevel } from './resolveHeadingRecipe';
|
|
7
8
|
import type { HeadingProps } from './types';
|
|
8
9
|
|
|
@@ -30,7 +31,9 @@ function resolveHeadingContent({
|
|
|
30
31
|
return i18nKey;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
function HeadingInner({
|
|
35
|
+
themeId: _themeId,
|
|
36
|
+
mode: _mode,
|
|
34
37
|
children,
|
|
35
38
|
text,
|
|
36
39
|
i18nKey,
|
|
@@ -84,3 +87,5 @@ export function Heading({
|
|
|
84
87
|
</ReactNativeText>
|
|
85
88
|
);
|
|
86
89
|
}
|
|
90
|
+
|
|
91
|
+
export const Heading = withZoraThemeScope(HeadingInner);
|
|
@@ -2,6 +2,8 @@ import type { Responsive } from '@ankhorage/surface';
|
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
import type { AccessibilityRole, TextStyle } from 'react-native';
|
|
4
4
|
|
|
5
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
6
|
+
|
|
5
7
|
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
6
8
|
|
|
7
9
|
export type HeadingSize = 'display' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
@@ -20,7 +22,7 @@ export type HeadingAlign = NonNullable<TextStyle['textAlign']>;
|
|
|
20
22
|
|
|
21
23
|
export type HeadingWeight = 'regular' | 'medium' | 'semiBold' | 'bold';
|
|
22
24
|
|
|
23
|
-
export interface HeadingProps {
|
|
25
|
+
export interface HeadingProps extends ZoraBaseProps {
|
|
24
26
|
children?: React.ReactNode;
|
|
25
27
|
text?: string;
|
|
26
28
|
i18nKey?: string;
|
|
@@ -37,5 +39,4 @@ export interface HeadingProps {
|
|
|
37
39
|
accessibilityHint?: string;
|
|
38
40
|
accessibilityRole?: AccessibilityRole;
|
|
39
41
|
nativeID?: string;
|
|
40
|
-
testID?: string;
|
|
41
42
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Icon as SurfaceIcon, type IconProps as SurfaceIconProps } from '@ankhorage/surface';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
5
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
+
export interface IconProps extends ZoraBaseProps, SurfaceIconProps {}
|
|
8
|
+
|
|
9
|
+
function IconInner({ themeId: _themeId, mode: _mode, ...props }: IconProps) {
|
|
7
10
|
return <SurfaceIcon {...props} />;
|
|
8
11
|
}
|
|
12
|
+
|
|
13
|
+
export const Icon = withZoraThemeScope(IconInner);
|
|
@@ -2,9 +2,12 @@ import { IconButton as SurfaceIconButton } from '@ankhorage/surface';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
import { resolveButtonRecipe } from '../../internal/recipes';
|
|
5
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
5
6
|
import type { IconButtonProps } from './types';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
function IconButtonInner({
|
|
9
|
+
themeId: _themeId,
|
|
10
|
+
mode: _mode,
|
|
8
11
|
icon,
|
|
9
12
|
label,
|
|
10
13
|
emphasis = 'ghost',
|
|
@@ -25,3 +28,5 @@ export function IconButton({
|
|
|
25
28
|
/>
|
|
26
29
|
);
|
|
27
30
|
}
|
|
31
|
+
|
|
32
|
+
export const IconButton = withZoraThemeScope(IconButtonInner);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ButtonIconSpec } from '@ankhorage/surface';
|
|
2
2
|
|
|
3
3
|
import type { ZoraControlSize, ZoraEmphasis, ZoraTone } from '../../internal/recipes';
|
|
4
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
4
5
|
|
|
5
|
-
export interface IconButtonProps {
|
|
6
|
+
export interface IconButtonProps extends ZoraBaseProps {
|
|
6
7
|
icon: ButtonIconSpec;
|
|
7
8
|
label: string;
|
|
8
9
|
emphasis?: ZoraEmphasis;
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { Text as ReactNativeText } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import { useZoraTheme } from '../../theme/useZoraTheme';
|
|
6
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
6
7
|
import { resolveTextStyle } from './resolveTextRecipe';
|
|
7
8
|
import type { TextProps } from './types';
|
|
8
9
|
|
|
@@ -30,7 +31,9 @@ function resolveTextContent({
|
|
|
30
31
|
return i18nKey;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
function TextInner({
|
|
35
|
+
themeId: _themeId,
|
|
36
|
+
mode: _mode,
|
|
34
37
|
children,
|
|
35
38
|
text,
|
|
36
39
|
i18nKey,
|
|
@@ -82,3 +85,5 @@ export function Text({
|
|
|
82
85
|
</ReactNativeText>
|
|
83
86
|
);
|
|
84
87
|
}
|
|
88
|
+
|
|
89
|
+
export const Text = withZoraThemeScope(TextInner);
|
|
@@ -2,6 +2,8 @@ import type { Responsive } from '@ankhorage/surface';
|
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
import type { AccessibilityRole, TextStyle } from 'react-native';
|
|
4
4
|
|
|
5
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
6
|
+
|
|
5
7
|
export type TextVariant = 'body' | 'lead' | 'bodySmall' | 'caption' | 'label' | 'eyebrow' | 'code';
|
|
6
8
|
|
|
7
9
|
export type TextTone =
|
|
@@ -18,7 +20,7 @@ export type TextWeight = 'regular' | 'medium' | 'semiBold' | 'bold';
|
|
|
18
20
|
|
|
19
21
|
export type TextAlign = NonNullable<TextStyle['textAlign']>;
|
|
20
22
|
|
|
21
|
-
export interface TextProps {
|
|
23
|
+
export interface TextProps extends ZoraBaseProps {
|
|
22
24
|
children?: React.ReactNode;
|
|
23
25
|
text?: string;
|
|
24
26
|
i18nKey?: string;
|
|
@@ -34,5 +36,4 @@ export interface TextProps {
|
|
|
34
36
|
accessibilityHint?: string;
|
|
35
37
|
accessibilityRole?: AccessibilityRole;
|
|
36
38
|
nativeID?: string;
|
|
37
|
-
testID?: string;
|
|
38
39
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { Card } from '../../components/card';
|
|
4
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
4
5
|
import type { PanelProps } from './types';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
function PanelInner({ themeId: _themeId, mode: _mode, ...props }: PanelProps) {
|
|
7
8
|
return <Card {...props} />;
|
|
8
9
|
}
|
|
10
|
+
|
|
11
|
+
export const Panel = withZoraThemeScope(PanelInner);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
|
|
3
3
|
import type { ZoraCardTone } from '../../internal/recipes';
|
|
4
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
4
5
|
|
|
5
|
-
export interface PanelProps {
|
|
6
|
+
export interface PanelProps extends ZoraBaseProps {
|
|
6
7
|
title?: React.ReactNode;
|
|
7
8
|
description?: React.ReactNode;
|
|
8
9
|
eyebrow?: React.ReactNode;
|
|
@@ -11,5 +12,4 @@ export interface PanelProps {
|
|
|
11
12
|
children?: React.ReactNode;
|
|
12
13
|
tone?: ZoraCardTone;
|
|
13
14
|
compact?: boolean;
|
|
14
|
-
testID?: string;
|
|
15
15
|
}
|