@databricks/design-system 1.1.0 → 1.2.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.
@@ -1,2 +1,3 @@
1
1
  export { useDesignSystemTheme, WithDesignSystemThemeHoc } from './useDesignSystemTheme';
2
+ export { useThemedStyles } from './useThemedStyles';
2
3
  export type { DesignSystemHocProps, DesignSystemThemeInterface } from './useDesignSystemTheme';
@@ -0,0 +1,28 @@
1
+ import { Theme } from '../../theme';
2
+ /**
3
+ * A helper hook that allows quick creation of theme-dependent styles.
4
+ * Results in more compact code than using useMemo and
5
+ * useDesignSystemTheme separately.
6
+ *
7
+ * @example
8
+ * const styles = useThemedStyles((theme) => ({
9
+ * overlay: {
10
+ * backgroundColor: theme.colors.backgroundPrimary,
11
+ * borderRadius: theme.borders.borderRadiusMd,
12
+ * },
13
+ * wrapper: {
14
+ * display: 'flex',
15
+ * gap: theme.spacing.md,
16
+ * },
17
+ * }));
18
+
19
+ * <div css={styles.overlay}>...</div>
20
+ *
21
+ * @param styleFactory Factory function that accepts theme object as a parameter and returns
22
+ * the style object. **Note**: factory function body is being memoized internally and is intended
23
+ * to be used only for simple style objects that depend solely on the theme. If you want to use
24
+ * styles that change depending on external values (state, props etc.) you should use
25
+ * `useDesignSystemTheme` directly with your own reaction mechanism.
26
+ * @returns The constructed style object
27
+ */
28
+ export declare const useThemedStyles: <T>(styleFactory: (theme: Theme) => T) => T;