@ankhorage/zora 0.8.1 → 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.
Files changed (131) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +91 -59
  3. package/dist/components/button/Button.d.ts +1 -1
  4. package/dist/components/button/Button.d.ts.map +1 -1
  5. package/dist/components/button/Button.js +3 -1
  6. package/dist/components/button/Button.js.map +1 -1
  7. package/dist/components/button/types.d.ts +2 -1
  8. package/dist/components/button/types.d.ts.map +1 -1
  9. package/dist/components/button/types.js.map +1 -1
  10. package/dist/components/card/Card.d.ts +1 -1
  11. package/dist/components/card/Card.d.ts.map +1 -1
  12. package/dist/components/card/Card.js +3 -1
  13. package/dist/components/card/Card.js.map +1 -1
  14. package/dist/components/card/types.d.ts +2 -1
  15. package/dist/components/card/types.d.ts.map +1 -1
  16. package/dist/components/card/types.js.map +1 -1
  17. package/dist/components/heading/Heading.d.ts +1 -1
  18. package/dist/components/heading/Heading.d.ts.map +1 -1
  19. package/dist/components/heading/Heading.js +3 -1
  20. package/dist/components/heading/Heading.js.map +1 -1
  21. package/dist/components/heading/types.d.ts +2 -2
  22. package/dist/components/heading/types.d.ts.map +1 -1
  23. package/dist/components/heading/types.js.map +1 -1
  24. package/dist/components/icon/Icon.d.ts +4 -2
  25. package/dist/components/icon/Icon.d.ts.map +1 -1
  26. package/dist/components/icon/Icon.js +3 -1
  27. package/dist/components/icon/Icon.js.map +1 -1
  28. package/dist/components/icon-button/IconButton.d.ts +1 -1
  29. package/dist/components/icon-button/IconButton.d.ts.map +1 -1
  30. package/dist/components/icon-button/IconButton.js +3 -1
  31. package/dist/components/icon-button/IconButton.js.map +1 -1
  32. package/dist/components/icon-button/types.d.ts +2 -1
  33. package/dist/components/icon-button/types.d.ts.map +1 -1
  34. package/dist/components/icon-button/types.js.map +1 -1
  35. package/dist/components/text/Text.d.ts +1 -1
  36. package/dist/components/text/Text.d.ts.map +1 -1
  37. package/dist/components/text/Text.js +3 -1
  38. package/dist/components/text/Text.js.map +1 -1
  39. package/dist/components/text/types.d.ts +2 -2
  40. package/dist/components/text/types.d.ts.map +1 -1
  41. package/dist/components/text/types.js.map +1 -1
  42. package/dist/patterns/panel/Panel.d.ts +1 -1
  43. package/dist/patterns/panel/Panel.d.ts.map +1 -1
  44. package/dist/patterns/panel/Panel.js +3 -1
  45. package/dist/patterns/panel/Panel.js.map +1 -1
  46. package/dist/patterns/panel/types.d.ts +2 -2
  47. package/dist/patterns/panel/types.d.ts.map +1 -1
  48. package/dist/patterns/panel/types.js.map +1 -1
  49. package/dist/theme/ZoraBaseProps.d.ts +18 -0
  50. package/dist/theme/ZoraBaseProps.d.ts.map +1 -0
  51. package/dist/theme/ZoraBaseProps.js +2 -0
  52. package/dist/theme/ZoraBaseProps.js.map +1 -0
  53. package/dist/theme/ZoraProvider.d.ts +4 -4
  54. package/dist/theme/ZoraProvider.d.ts.map +1 -1
  55. package/dist/theme/ZoraProvider.js +11 -6
  56. package/dist/theme/ZoraProvider.js.map +1 -1
  57. package/dist/theme/ZoraThemeRuntimeContext.d.ts +9 -0
  58. package/dist/theme/ZoraThemeRuntimeContext.d.ts.map +1 -0
  59. package/dist/theme/ZoraThemeRuntimeContext.js +10 -0
  60. package/dist/theme/ZoraThemeRuntimeContext.js.map +1 -0
  61. package/dist/theme/ZoraThemeScope.d.ts +9 -0
  62. package/dist/theme/ZoraThemeScope.d.ts.map +1 -0
  63. package/dist/theme/ZoraThemeScope.js +41 -0
  64. package/dist/theme/ZoraThemeScope.js.map +1 -0
  65. package/dist/theme/createZoraThemeConfig.d.ts +4 -0
  66. package/dist/theme/createZoraThemeConfig.d.ts.map +1 -0
  67. package/dist/theme/createZoraThemeConfig.js +23 -0
  68. package/dist/theme/createZoraThemeConfig.js.map +1 -0
  69. package/dist/theme/index.d.ts +7 -3
  70. package/dist/theme/index.d.ts.map +1 -1
  71. package/dist/theme/index.js +4 -2
  72. package/dist/theme/index.js.map +1 -1
  73. package/dist/theme/resolveZoraScopedThemeId.d.ts +6 -0
  74. package/dist/theme/resolveZoraScopedThemeId.d.ts.map +1 -0
  75. package/dist/theme/resolveZoraScopedThemeId.js +15 -0
  76. package/dist/theme/resolveZoraScopedThemeId.js.map +1 -0
  77. package/dist/theme/types.d.ts +21 -0
  78. package/dist/theme/types.d.ts.map +1 -0
  79. package/dist/theme/types.js +2 -0
  80. package/dist/theme/types.js.map +1 -0
  81. package/dist/theme/withZoraThemeScope.d.ts +4 -0
  82. package/dist/theme/withZoraThemeScope.d.ts.map +1 -0
  83. package/dist/theme/withZoraThemeScope.js +16 -0
  84. package/dist/theme/withZoraThemeScope.js.map +1 -0
  85. package/dist/theme/zoraDefaultTheme.d.ts +3 -0
  86. package/dist/theme/zoraDefaultTheme.d.ts.map +1 -0
  87. package/dist/theme/zoraDefaultTheme.js +8 -0
  88. package/dist/theme/zoraDefaultTheme.js.map +1 -0
  89. package/package.json +1 -1
  90. package/src/components/button/Button.tsx +11 -1
  91. package/src/components/button/types.ts +3 -4
  92. package/src/components/card/Card.tsx +6 -1
  93. package/src/components/card/types.ts +3 -1
  94. package/src/components/heading/Heading.tsx +6 -1
  95. package/src/components/heading/types.ts +3 -2
  96. package/src/components/icon/Icon.tsx +7 -2
  97. package/src/components/icon-button/IconButton.tsx +6 -1
  98. package/src/components/icon-button/types.ts +2 -1
  99. package/src/components/text/Text.tsx +6 -1
  100. package/src/components/text/types.ts +3 -2
  101. package/src/patterns/panel/Panel.tsx +4 -1
  102. package/src/patterns/panel/types.ts +2 -2
  103. package/src/theme/ZoraBaseProps.ts +20 -0
  104. package/src/theme/ZoraProvider.tsx +15 -8
  105. package/src/theme/ZoraThemeRuntimeContext.tsx +18 -0
  106. package/src/theme/ZoraThemeScope.tsx +74 -0
  107. package/src/theme/createZoraThemeConfig.test.ts +36 -0
  108. package/src/theme/createZoraThemeConfig.ts +27 -0
  109. package/src/theme/index.ts +15 -3
  110. package/src/theme/resolveZoraScopedThemeId.test.ts +47 -0
  111. package/src/theme/resolveZoraScopedThemeId.ts +25 -0
  112. package/src/theme/themeScopeStructure.test.ts +99 -0
  113. package/src/theme/types.ts +33 -0
  114. package/src/theme/withZoraThemeScope.tsx +25 -0
  115. package/src/theme/zoraDefaultTheme.ts +9 -0
  116. package/dist/internal/deepMerge.d.ts +0 -2
  117. package/dist/internal/deepMerge.d.ts.map +0 -1
  118. package/dist/internal/deepMerge.js +0 -20
  119. package/dist/internal/deepMerge.js.map +0 -1
  120. package/dist/theme/createZoraTheme.d.ts +0 -4
  121. package/dist/theme/createZoraTheme.d.ts.map +0 -1
  122. package/dist/theme/createZoraTheme.js +0 -6
  123. package/dist/theme/createZoraTheme.js.map +0 -1
  124. package/dist/theme/zoraTheme.d.ts +0 -3
  125. package/dist/theme/zoraTheme.d.ts.map +0 -1
  126. package/dist/theme/zoraTheme.js +0 -15
  127. package/dist/theme/zoraTheme.js.map +0 -1
  128. package/src/internal/deepMerge.ts +0 -23
  129. package/src/theme/createZoraTheme.test.ts +0 -25
  130. package/src/theme/createZoraTheme.ts +0 -10
  131. package/src/theme/zoraTheme.ts +0 -16
@@ -0,0 +1,33 @@
1
+ import type { ThemeConfig } from '@ankhorage/surface';
2
+
3
+ export type ZoraThemeId = string;
4
+
5
+ export type ZoraThemeMode = 'light' | 'dark';
6
+
7
+ export type ZoraHexColor = `#${string}`;
8
+
9
+ export type ZoraColorHarmony =
10
+ | 'monochromatic'
11
+ | 'analogous'
12
+ | 'complementary'
13
+ | 'splitComplementary'
14
+ | 'triadic'
15
+ | 'tetradic';
16
+
17
+ export type ZoraColorTone = 'neutral' | 'pastel' | 'earth' | 'jewel' | 'fluorescent';
18
+
19
+ export interface ZoraTheme {
20
+ id: ZoraThemeId;
21
+ name?: string;
22
+ primaryColor: ZoraHexColor;
23
+ harmony: ZoraColorHarmony;
24
+ tone: ZoraColorTone;
25
+ }
26
+
27
+ export interface ZoraComputedTheme {
28
+ id: ZoraThemeId;
29
+ name: string;
30
+ mode: ZoraThemeMode;
31
+ source: ZoraTheme;
32
+ surfaceConfig: ThemeConfig;
33
+ }
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+
3
+ import type { ZoraBaseProps } from './ZoraBaseProps';
4
+ import { ZoraThemeScope } from './ZoraThemeScope';
5
+
6
+ export function withZoraThemeScope<P extends ZoraBaseProps>(
7
+ Component: React.ComponentType<P>,
8
+ ): React.FC<P> {
9
+ const Wrapped: React.FC<P> = (props) => {
10
+ if (props.mode === undefined && props.themeId === undefined) {
11
+ return <Component {...props} />;
12
+ }
13
+
14
+ return (
15
+ <ZoraThemeScope mode={props.mode} themeId={props.themeId}>
16
+ <Component {...props} />
17
+ </ZoraThemeScope>
18
+ );
19
+ };
20
+
21
+ const name = Component.displayName ?? (Component.name || 'Component');
22
+ Wrapped.displayName = `withZoraThemeScope(${name})`;
23
+
24
+ return Wrapped;
25
+ }
@@ -0,0 +1,9 @@
1
+ import type { ZoraTheme } from './types';
2
+
3
+ export const zoraDefaultTheme: ZoraTheme = {
4
+ id: 'zora',
5
+ name: 'ZORA',
6
+ primaryColor: '#0f766e',
7
+ harmony: 'analogous',
8
+ tone: 'jewel',
9
+ };
@@ -1,2 +0,0 @@
1
- export declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
2
- //# sourceMappingURL=deepMerge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deepMerge.d.ts","sourceRoot":"","sources":["../../src/internal/deepMerge.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAsB5E"}
@@ -1,20 +0,0 @@
1
- export function deepMerge(target, source) {
2
- const result = { ...target };
3
- Object.keys(source).forEach((key) => {
4
- const sourceValue = source[key];
5
- const targetValue = target[key];
6
- if (sourceValue &&
7
- typeof sourceValue === 'object' &&
8
- !Array.isArray(sourceValue) &&
9
- targetValue &&
10
- typeof targetValue === 'object' &&
11
- !Array.isArray(targetValue)) {
12
- result[key] = deepMerge(targetValue, sourceValue);
13
- }
14
- else if (sourceValue !== undefined) {
15
- result[key] = sourceValue;
16
- }
17
- });
18
- return result;
19
- }
20
- //# sourceMappingURL=deepMerge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deepMerge.js","sourceRoot":"","sources":["../../src/internal/deepMerge.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAmB,MAAS,EAAE,MAAkB;IACvE,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAE5B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAiB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACnD,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAEhC,IACE,WAAW;YACX,OAAO,WAAW,KAAK,QAAQ;YAC/B,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YAC3B,WAAW;YACX,OAAO,WAAW,KAAK,QAAQ;YAC/B,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAC3B,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,WAAqB,EAAE,WAAqB,CAAe,CAAC;QACtF,CAAC;aAAM,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,CAAC,GAAG,CAAC,GAAG,WAAyB,CAAC;QAC1C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["export function deepMerge<T extends object>(target: T, source: Partial<T>): T {\n const result = { ...target };\n\n (Object.keys(source) as (keyof T)[]).forEach((key) => {\n const sourceValue = source[key];\n const targetValue = target[key];\n\n if (\n sourceValue &&\n typeof sourceValue === 'object' &&\n !Array.isArray(sourceValue) &&\n targetValue &&\n typeof targetValue === 'object' &&\n !Array.isArray(targetValue)\n ) {\n result[key] = deepMerge(targetValue as object, sourceValue as object) as T[keyof T];\n } else if (sourceValue !== undefined) {\n result[key] = sourceValue as T[keyof T];\n }\n });\n\n return result;\n}\n"]}
@@ -1,4 +0,0 @@
1
- import type { ThemeConfig } from '@ankhorage/surface';
2
- export type ZoraThemeOverride = Partial<ThemeConfig>;
3
- export declare function createZoraTheme(overrides?: ZoraThemeOverride): ThemeConfig;
4
- //# sourceMappingURL=createZoraTheme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createZoraTheme.d.ts","sourceRoot":"","sources":["../../src/theme/createZoraTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKtD,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAErD,wBAAgB,eAAe,CAAC,SAAS,GAAE,iBAAsB,GAAG,WAAW,CAE9E"}
@@ -1,6 +0,0 @@
1
- import { deepMerge } from '../internal/deepMerge';
2
- import { zoraTheme } from './zoraTheme';
3
- export function createZoraTheme(overrides = {}) {
4
- return deepMerge(zoraTheme, overrides);
5
- }
6
- //# sourceMappingURL=createZoraTheme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createZoraTheme.js","sourceRoot":"","sources":["../../src/theme/createZoraTheme.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,MAAM,UAAU,eAAe,CAAC,YAA+B,EAAE;IAC/D,OAAO,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import type { ThemeConfig } from '@ankhorage/surface';\n\nimport { deepMerge } from '../internal/deepMerge';\nimport { zoraTheme } from './zoraTheme';\n\nexport type ZoraThemeOverride = Partial<ThemeConfig>;\n\nexport function createZoraTheme(overrides: ZoraThemeOverride = {}): ThemeConfig {\n return deepMerge(zoraTheme, overrides);\n}\n"]}
@@ -1,3 +0,0 @@
1
- import type { ThemeConfig } from '@ankhorage/surface';
2
- export declare const zoraTheme: ThemeConfig;
3
- //# sourceMappingURL=zoraTheme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zoraTheme.d.ts","sourceRoot":"","sources":["../../src/theme/zoraTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,eAAO,MAAM,SAAS,EAAE,WAavB,CAAC"}
@@ -1,15 +0,0 @@
1
- export const zoraTheme = {
2
- id: 'zora',
3
- name: 'ZORA',
4
- light: {
5
- primaryColor: '#0f766e',
6
- harmony: 'analogous',
7
- systemTone: 'jewel',
8
- },
9
- dark: {
10
- primaryColor: '#2dd4bf',
11
- harmony: 'analogous',
12
- systemTone: 'jewel',
13
- },
14
- };
15
- //# sourceMappingURL=zoraTheme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zoraTheme.js","sourceRoot":"","sources":["../../src/theme/zoraTheme.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAgB;IACpC,EAAE,EAAE,MAAM;IACV,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE;QACL,YAAY,EAAE,SAAS;QACvB,OAAO,EAAE,WAAW;QACpB,UAAU,EAAE,OAAO;KACpB;IACD,IAAI,EAAE;QACJ,YAAY,EAAE,SAAS;QACvB,OAAO,EAAE,WAAW;QACpB,UAAU,EAAE,OAAO;KACpB;CACF,CAAC","sourcesContent":["import type { ThemeConfig } from '@ankhorage/surface';\n\nexport const zoraTheme: ThemeConfig = {\n id: 'zora',\n name: 'ZORA',\n light: {\n primaryColor: '#0f766e',\n harmony: 'analogous',\n systemTone: 'jewel',\n },\n dark: {\n primaryColor: '#2dd4bf',\n harmony: 'analogous',\n systemTone: 'jewel',\n },\n};\n"]}
@@ -1,23 +0,0 @@
1
- export function deepMerge<T extends object>(target: T, source: Partial<T>): T {
2
- const result = { ...target };
3
-
4
- (Object.keys(source) as (keyof T)[]).forEach((key) => {
5
- const sourceValue = source[key];
6
- const targetValue = target[key];
7
-
8
- if (
9
- sourceValue &&
10
- typeof sourceValue === 'object' &&
11
- !Array.isArray(sourceValue) &&
12
- targetValue &&
13
- typeof targetValue === 'object' &&
14
- !Array.isArray(targetValue)
15
- ) {
16
- result[key] = deepMerge(targetValue as object, sourceValue as object) as T[keyof T];
17
- } else if (sourceValue !== undefined) {
18
- result[key] = sourceValue as T[keyof T];
19
- }
20
- });
21
-
22
- return result;
23
- }
@@ -1,25 +0,0 @@
1
- import { describe, expect, test } from 'bun:test';
2
-
3
- import { createZoraTheme } from './createZoraTheme';
4
-
5
- describe('createZoraTheme', () => {
6
- test('keeps the default preset stable', () => {
7
- const theme = createZoraTheme();
8
-
9
- expect(theme.id).toBe('zora');
10
- expect(theme.light.primaryColor).toBe('#0f766e');
11
- expect(theme.dark.primaryColor).toBe('#2dd4bf');
12
- });
13
-
14
- test('merges overrides without dropping the preset identity', () => {
15
- const theme = createZoraTheme({
16
- light: {
17
- primaryColor: '#1d4ed8',
18
- },
19
- });
20
-
21
- expect(theme.id).toBe('zora');
22
- expect(theme.light.primaryColor).toBe('#1d4ed8');
23
- expect(theme.dark.primaryColor).toBe('#2dd4bf');
24
- });
25
- });
@@ -1,10 +0,0 @@
1
- import type { ThemeConfig } from '@ankhorage/surface';
2
-
3
- import { deepMerge } from '../internal/deepMerge';
4
- import { zoraTheme } from './zoraTheme';
5
-
6
- export type ZoraThemeOverride = Partial<ThemeConfig>;
7
-
8
- export function createZoraTheme(overrides: ZoraThemeOverride = {}): ThemeConfig {
9
- return deepMerge(zoraTheme, overrides);
10
- }
@@ -1,16 +0,0 @@
1
- import type { ThemeConfig } from '@ankhorage/surface';
2
-
3
- export const zoraTheme: ThemeConfig = {
4
- id: 'zora',
5
- name: 'ZORA',
6
- light: {
7
- primaryColor: '#0f766e',
8
- harmony: 'analogous',
9
- systemTone: 'jewel',
10
- },
11
- dark: {
12
- primaryColor: '#2dd4bf',
13
- harmony: 'analogous',
14
- systemTone: 'jewel',
15
- },
16
- };