|
| 1 | +--- |
| 2 | +"@equinor/fusion-react-styles": minor |
| 3 | +--- |
| 4 | + |
| 5 | +Enhanced theme system with support for extending `FusionTheme` with custom properties, improved nested theme composition, and comprehensive documentation. |
| 6 | + |
| 7 | +### Added |
| 8 | + |
| 9 | +- **Theme Extension Support**: `FusionTheme` now supports extending with custom properties using generics: |
| 10 | + ```typescript |
| 11 | + type MyTheme = FusionTheme<{ colors: { primary: ColorStyleProperty } }>; |
| 12 | + ``` |
| 13 | +- **Custom Base Theme Merging**: `createTheme` now accepts an optional `baseTheme` parameter for merging with custom base themes: |
| 14 | + ```typescript |
| 15 | + const extendedTheme = createTheme( |
| 16 | + { colors: { ui: { background__danger: newColor } } }, |
| 17 | + outerTheme |
| 18 | + ); |
| 19 | + ``` |
| 20 | +- **Deep Merging Improvements**: Enhanced `deepMerge` function properly handles nested theme properties, `Record` types, and `StyleProperty` instances |
| 21 | +- **Type Exports**: Explicitly exported `ThemeProviderProps`, `StylesProviderProps`, `FusionTheme`, `StyleDefinition`, and `createTheme` for better TypeScript support |
| 22 | +- **Complete TSDoc Documentation**: All exported functions, types, and interfaces now have comprehensive TSDoc comments with examples, parameter descriptions, and usage patterns |
| 23 | +- **Theme Extension Storybook Story**: New `ThemeExtension` story demonstrating how to extend themes with custom properties, including step-by-step examples for type definition, theme creation, and usage with `useTheme` and `makeStyles` |
| 24 | + |
| 25 | +### Changed |
| 26 | + |
| 27 | +- `createTheme` signature now accepts optional `baseTheme` parameter (backward compatible) |
| 28 | +- Improved type inference for extended themes in `ThemeProvider`, `useTheme`, and `makeStyles` |
| 29 | +- Better handling of nested theme composition when using theme functions in nested `ThemeProvider` components |
| 30 | +- **Storybook Stories Updated**: All stories now consistently use the `.getVariable()` method for accessing theme CSS values (e.g., `theme.colors.*.getVariable('color')`, `theme.spacing.*.getVariable('padding')`). Direct usage of the `.css` property has been replaced to ensure proper integration with Fusion design system tokens and to match the documented API usage. |
| 31 | +- **README Updated**: Updated all documentation examples to use correct `getVariable()` API for theme properties |
| 32 | + |
| 33 | +### Technical Details |
| 34 | + |
| 35 | +- Deep merging now correctly handles `StyleProperty` instances (replaces instead of merging) |
| 36 | +- Theme composition works correctly with nested `ThemeProvider` components |
| 37 | +- All types are properly exported and documented with complete TSDoc comments |
| 38 | +- Typography properties accessed via `.style.fontSize`, `.style.fontWeight`, etc. for proper CSS value extraction |
| 39 | +- Color properties accessed via `.getVariable('color')` method to get CSS variable strings |
| 40 | +- Spacing properties accessed via `.getVariable('padding')` method to get CSS variable strings |
| 41 | +- `makeStyles` now returns `Record<ClassKey, string>` where `ClassKey` is inferred from style rules, providing type-safe access to class names when using `createStyles` |
0 commit comments