@easemate/web-kit 0.3.1 → 0.3.2
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/README.md +104 -2
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +2 -2
- package/build/index.d.ts +2 -2
- package/build/index.js.map +1 -1
- package/build/{init-B7gNNyTd.d.ts → init-CaP7khA2.d.ts} +1 -1
- package/build/{init-DwVGVxkx.d.cts → init-DmqoRv6_.d.cts} +1 -1
- package/build/jsx.cjs.map +1 -1
- package/build/jsx.d.cts +1 -0
- package/build/jsx.d.ts +1 -0
- package/build/jsx.js.map +1 -1
- package/build/react.cjs.map +1 -1
- package/build/react.d.cts +2 -2
- package/build/react.d.ts +2 -2
- package/build/react.js.map +1 -1
- package/build/{registry-9GX9KTG1.d.cts → registry-YCv1Ctoe.d.cts} +32 -24
- package/build/{registry-9GX9KTG1.d.ts → registry-YCv1Ctoe.d.ts} +32 -24
- package/build/theme.cjs.map +1 -1
- package/build/theme.d.cts +2 -2
- package/build/theme.d.ts +2 -2
- package/build/theme.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,6 +48,10 @@ A modern, framework-agnostic UI kit of web components for building animation con
|
|
|
48
48
|
- [Configuration](#configuration)
|
|
49
49
|
- [initWebKit Options](#initwebkit-options)
|
|
50
50
|
- [Theme Configuration](#theme-configuration)
|
|
51
|
+
- [Custom Theme Registration](#custom-theme-registration)
|
|
52
|
+
- [Theme Inheritance](#theme-inheritance)
|
|
53
|
+
- [Creating a Theme from Scratch](#creating-a-theme-from-scratch)
|
|
54
|
+
- [Theme Utilities](#theme-utilities)
|
|
51
55
|
- [Font Configuration](#font-configuration)
|
|
52
56
|
- [Lazy Loading](#lazy-loading)
|
|
53
57
|
- [Component Replacement](#component-replacement)
|
|
@@ -785,12 +789,18 @@ interface ThemeModeConfig {
|
|
|
785
789
|
dark: ThemeInput;
|
|
786
790
|
persist?: { key: string }; // Coming soon
|
|
787
791
|
}
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
#### Custom Theme Registration
|
|
788
795
|
|
|
789
|
-
|
|
796
|
+
Register custom themes using `registerTheme()`. No TypeScript declaration files needed - custom theme names are fully supported:
|
|
797
|
+
|
|
798
|
+
```typescript
|
|
790
799
|
import { initWebKit, registerTheme } from '@easemate/web-kit';
|
|
791
800
|
|
|
801
|
+
// Register a custom theme - returns a typed theme ref
|
|
792
802
|
const brandTheme = registerTheme('brand', {
|
|
793
|
-
base: 'default', // Inherit from default
|
|
803
|
+
base: 'default', // Inherit from built-in theme ('default' or 'dark')
|
|
794
804
|
config: {
|
|
795
805
|
typography: {
|
|
796
806
|
fontFamily: '"Inter", system-ui, sans-serif'
|
|
@@ -802,7 +812,99 @@ const brandTheme = registerTheme('brand', {
|
|
|
802
812
|
}
|
|
803
813
|
});
|
|
804
814
|
|
|
815
|
+
// Use the theme ref (type-safe)
|
|
805
816
|
initWebKit({ theme: brandTheme });
|
|
817
|
+
|
|
818
|
+
// Or use the string name directly (also works!)
|
|
819
|
+
initWebKit({ theme: 'brand' });
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
#### Theme Inheritance
|
|
823
|
+
|
|
824
|
+
Themes can extend other themes using the `base` option:
|
|
825
|
+
|
|
826
|
+
```typescript
|
|
827
|
+
// Create a base brand theme
|
|
828
|
+
const brandBase = registerTheme('brand-base', {
|
|
829
|
+
base: 'default',
|
|
830
|
+
config: {
|
|
831
|
+
typography: { fontFamily: '"Inter", sans-serif' },
|
|
832
|
+
vars: { '--ease-panel-radius': '16px' }
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
// Create variants that extend brand-base
|
|
837
|
+
const brandLight = registerTheme('brand-light', {
|
|
838
|
+
base: brandBase, // Can use theme ref or string name
|
|
839
|
+
config: {
|
|
840
|
+
colors: {
|
|
841
|
+
gray: { 900: 'oklab(98% 0 0)', 0: 'oklab(20% 0 0)' }
|
|
842
|
+
},
|
|
843
|
+
vars: { '--ease-panel-background': 'white' }
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
const brandDark = registerTheme('brand-dark', {
|
|
848
|
+
base: 'brand-base', // String name works too
|
|
849
|
+
config: {
|
|
850
|
+
vars: { '--ease-panel-background': 'var(--color-gray-1000)' }
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
// Use with theme mode switching
|
|
855
|
+
initWebKit({
|
|
856
|
+
theme: {
|
|
857
|
+
mode: 'system',
|
|
858
|
+
light: brandLight,
|
|
859
|
+
dark: brandDark
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
#### Creating a Theme from Scratch
|
|
865
|
+
|
|
866
|
+
Use `base: null` to create a theme without inheriting defaults:
|
|
867
|
+
|
|
868
|
+
```typescript
|
|
869
|
+
const minimalTheme = registerTheme('minimal', {
|
|
870
|
+
base: null, // Start fresh, no inheritance
|
|
871
|
+
config: {
|
|
872
|
+
colors: {
|
|
873
|
+
gray: { 900: '#f5f5f5', 0: '#171717' },
|
|
874
|
+
blue: { 500: '#3b82f6' }
|
|
875
|
+
},
|
|
876
|
+
vars: {
|
|
877
|
+
'--ease-panel-background': 'white',
|
|
878
|
+
'--ease-panel-border-color': '#e5e5e5'
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
#### Theme Utilities
|
|
885
|
+
|
|
886
|
+
```typescript
|
|
887
|
+
import {
|
|
888
|
+
registerTheme,
|
|
889
|
+
getTheme,
|
|
890
|
+
hasTheme,
|
|
891
|
+
getThemeNames,
|
|
892
|
+
themeRef
|
|
893
|
+
} from '@easemate/web-kit';
|
|
894
|
+
|
|
895
|
+
// Check if a theme exists
|
|
896
|
+
if (hasTheme('brand')) {
|
|
897
|
+
console.log('Brand theme is registered');
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// Get all registered theme names
|
|
901
|
+
const themes = getThemeNames(); // ['default', 'dark', 'brand', ...]
|
|
902
|
+
|
|
903
|
+
// Get resolved theme config (with inheritance applied)
|
|
904
|
+
const config = getTheme('brand');
|
|
905
|
+
|
|
906
|
+
// Get a theme ref for an already-registered theme
|
|
907
|
+
const ref = themeRef('brand');
|
|
806
908
|
```
|
|
807
909
|
|
|
808
910
|
### Font Configuration
|