@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.
- package/CHANGELOG.md +14 -0
- package/README.md +91 -59
- 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 +4 -4
- package/dist/theme/ZoraProvider.d.ts.map +1 -1
- package/dist/theme/ZoraProvider.js +11 -6
- 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/createZoraThemeConfig.d.ts +4 -0
- package/dist/theme/createZoraThemeConfig.d.ts.map +1 -0
- package/dist/theme/createZoraThemeConfig.js +23 -0
- package/dist/theme/createZoraThemeConfig.js.map +1 -0
- package/dist/theme/index.d.ts +7 -3
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +4 -2
- 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/types.d.ts +21 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +2 -0
- package/dist/theme/types.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/dist/theme/zoraDefaultTheme.d.ts +3 -0
- package/dist/theme/zoraDefaultTheme.d.ts.map +1 -0
- package/dist/theme/zoraDefaultTheme.js +8 -0
- package/dist/theme/zoraDefaultTheme.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 +15 -8
- package/src/theme/ZoraThemeRuntimeContext.tsx +18 -0
- package/src/theme/ZoraThemeScope.tsx +74 -0
- package/src/theme/createZoraThemeConfig.test.ts +36 -0
- package/src/theme/createZoraThemeConfig.ts +27 -0
- package/src/theme/index.ts +15 -3
- 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/types.ts +33 -0
- package/src/theme/withZoraThemeScope.tsx +25 -0
- package/src/theme/zoraDefaultTheme.ts +9 -0
- package/dist/internal/deepMerge.d.ts +0 -2
- package/dist/internal/deepMerge.d.ts.map +0 -1
- package/dist/internal/deepMerge.js +0 -20
- package/dist/internal/deepMerge.js.map +0 -1
- package/dist/theme/createZoraTheme.d.ts +0 -4
- package/dist/theme/createZoraTheme.d.ts.map +0 -1
- package/dist/theme/createZoraTheme.js +0 -6
- package/dist/theme/createZoraTheme.js.map +0 -1
- package/dist/theme/zoraTheme.d.ts +0 -3
- package/dist/theme/zoraTheme.d.ts.map +0 -1
- package/dist/theme/zoraTheme.js +0 -15
- package/dist/theme/zoraTheme.js.map +0 -1
- package/src/internal/deepMerge.ts +0 -23
- package/src/theme/createZoraTheme.test.ts +0 -25
- package/src/theme/createZoraTheme.ts +0 -10
- 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
|
+
}
|
|
@@ -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 +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 +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 +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"}
|
package/dist/theme/zoraTheme.js
DELETED
|
@@ -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
|
-
}
|
package/src/theme/zoraTheme.ts
DELETED
|
@@ -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
|
-
};
|