@helpwave/hightide-native 0.0.2 → 0.0.6

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 (71) hide show
  1. package/package.json +4 -3
  2. package/src/components/chat/ChatAttachmentCard.tsx +26 -13
  3. package/src/components/chat/ChatConversationList.tsx +12 -8
  4. package/src/components/chat/ChatConversationRow.tsx +21 -13
  5. package/src/components/chat/ChatDateDivider.tsx +18 -8
  6. package/src/components/chat/ChatMessageBubble.tsx +23 -13
  7. package/src/components/chat/ChatMessageCard.tsx +25 -14
  8. package/src/components/chat/ChatMessageComposer.tsx +14 -9
  9. package/src/components/chat/ChatMessageList.tsx +12 -5
  10. package/src/components/chat/ChatQuickReplyChip.tsx +7 -6
  11. package/src/components/chat/ChatSystemLine.tsx +21 -10
  12. package/src/components/chat/ChatThreadHeader.tsx +19 -9
  13. package/src/components/menu/Menu.tsx +16 -6
  14. package/src/components/menu/MenuActionItem.tsx +10 -5
  15. package/src/components/menu/MenuItem.tsx +16 -6
  16. package/src/components/menu/MenuNavigationItem.tsx +11 -6
  17. package/src/components/user-interaction/Button.tsx +18 -11
  18. package/src/components/user-interaction/Checkbox.tsx +26 -7
  19. package/src/components/user-interaction/IconButton.tsx +23 -9
  20. package/src/components/user-interaction/Input.tsx +22 -5
  21. package/src/components/user-interaction/MultiSelect.tsx +14 -7
  22. package/src/components/user-interaction/Select.tsx +11 -4
  23. package/src/components/visualization-and-display/Chip.tsx +21 -9
  24. package/src/components/visualization-and-display/Icon.tsx +27 -0
  25. package/src/components/visualization-and-display/index.ts +1 -0
  26. package/src/global-contexts/HightideContext.ts +4 -1
  27. package/src/global-contexts/HightideProvider.tsx +21 -9
  28. package/src/global-contexts/hightide-config/HightideConfigUtils.ts +15 -12
  29. package/src/global-contexts/localization/LocalizationProvider.tsx +3 -1
  30. package/src/global-contexts/localization/forward-exports.ts +1 -0
  31. package/src/global-contexts/theme/ThemeContext.ts +11 -6
  32. package/src/global-contexts/theme/ThemeProvider.tsx +34 -37
  33. package/src/hooks/useMultiSelect.ts +1 -0
  34. package/src/hooks/useNativeKeyValueStore.ts +7 -1
  35. package/src/hooks/useSelect.ts +1 -0
  36. package/src/theme/resolvers/button.ts +33 -20
  37. package/src/theme/resolvers/chat.ts +370 -336
  38. package/src/theme/resolvers/checkbox.ts +22 -18
  39. package/src/theme/resolvers/chip.ts +27 -19
  40. package/src/theme/resolvers/coloring.ts +21 -17
  41. package/src/theme/resolvers/iconButton.ts +25 -17
  42. package/src/theme/resolvers/input.ts +25 -18
  43. package/src/theme/resolvers/menu.ts +37 -29
  44. package/src/theme/resolvers/multiSelect.ts +20 -16
  45. package/src/theme/resolvers/select.ts +20 -16
  46. package/src/theme/themes/createTheme.ts +42 -17
  47. package/src/theme/themes/nativeThemes.ts +7 -6
  48. package/src/theme/types/color.ts +60 -0
  49. package/src/theme/types/components/button.ts +30 -0
  50. package/src/theme/types/components/chat.ts +198 -0
  51. package/src/theme/types/{checkbox.ts → components/checkbox.ts} +11 -5
  52. package/src/theme/types/components/chip.ts +30 -0
  53. package/src/theme/types/{components.ts → components/hightide.ts} +22 -1
  54. package/src/theme/types/components/iconButton.ts +30 -0
  55. package/src/theme/types/components/index.ts +10 -0
  56. package/src/theme/types/components/input.ts +19 -0
  57. package/src/theme/types/{menu.ts → components/menu.ts} +21 -14
  58. package/src/theme/types/{multiSelect.ts → components/multiSelect.ts} +13 -9
  59. package/src/theme/types/{select.ts → components/select.ts} +18 -11
  60. package/src/theme/types/decoration.ts +11 -0
  61. package/src/theme/types/index.ts +4 -9
  62. package/src/theme/types/layout.ts +46 -0
  63. package/src/theme/types/theme.ts +14 -10
  64. package/src/theme/types/typography.ts +18 -0
  65. package/src/icons/Icon.tsx +0 -35
  66. package/src/icons/index.ts +0 -1
  67. package/src/theme/types/button.ts +0 -18
  68. package/src/theme/types/chat.ts +0 -141
  69. package/src/theme/types/chip.ts +0 -18
  70. package/src/theme/types/iconButton.ts +0 -20
  71. package/src/theme/types/input.ts +0 -15
@@ -1,23 +1,27 @@
1
- import {
2
- remToPx,
3
- spacing,
4
- type ComponentColors,
5
- type DesignTheme as DesignTokensTheme,
6
- type ElementSize,
7
- type SemanticColors
8
- } from '@helpwave/hightide-design'
9
1
  import type { ViewStyle } from 'react-native'
2
+
3
+ import { componentLayouts } from '@helpwave/hightide-design/tokens'
4
+ import type {
5
+ ComponentColorTokens,
6
+ HightideDesignTokens as DesignTokensTheme,
7
+ ElementSize
8
+ } from '@helpwave/hightide-design/types'
9
+
10
+ import type { HightideSemanticColors } from '../types/color'
10
11
  import type {
11
12
  CheckboxSize,
12
13
  CheckboxState,
13
14
  CheckboxTheme
14
- } from '../types'
15
- import { createStyleResolver, createValueResolver } from '../types/resolver'
15
+ } from '../types/components/checkbox'
16
+ import {
17
+ createStyleResolver,
18
+ createValueResolver
19
+ } from '../types/resolver'
16
20
 
17
21
  const checkboxSizes: Record<CheckboxSize, number> = {
18
- sm: remToPx('1.25rem'),
19
- md: remToPx('1.5rem'),
20
- lg: remToPx('2rem'),
22
+ sm: 20,
23
+ md: 24,
24
+ lg: 32,
21
25
  }
22
26
 
23
27
  const checkboxIconSizes: Record<CheckboxSize, Exclude<ElementSize, 'xs'>> = {
@@ -27,8 +31,8 @@ const checkboxIconSizes: Record<CheckboxSize, Exclude<ElementSize, 'xs'>> = {
27
31
  }
28
32
 
29
33
  export type CreateCheckboxThemeOptions = {
30
- semantic: SemanticColors,
31
- component: ComponentColors,
34
+ semantic: HightideSemanticColors,
35
+ component: ComponentColorTokens,
32
36
  }
33
37
 
34
38
  export const createCheckboxTheme = ({
@@ -56,7 +60,7 @@ export const createCheckboxTheme = ({
56
60
  height: dimension,
57
61
  alignItems: 'center',
58
62
  justifyContent: 'center',
59
- borderWidth: remToPx(spacing.coloringOutlineWidth),
63
+ borderWidth: componentLayouts.shared.coloringOutlineWidth,
60
64
  borderColor,
61
65
  borderRadius: state.isRounded ? dimension / 2 : 6,
62
66
  backgroundColor,
@@ -81,7 +85,7 @@ export const createCheckboxTheme = ({
81
85
 
82
86
  export const createCheckboxThemeFromDesign = (theme: DesignTokensTheme): CheckboxTheme => {
83
87
  return createCheckboxTheme({
84
- semantic: theme.semantic,
85
- component: theme.component,
88
+ semantic: theme.semanticColors,
89
+ component: theme.componentColors,
86
90
  })
87
91
  }
@@ -1,18 +1,26 @@
1
+ import type {
2
+ TextStyle,
3
+ ViewStyle
4
+ } from 'react-native'
5
+
1
6
  import {
2
7
  componentLayouts,
3
- toPx,
4
- type ColoringTokensDefinitions,
5
- type DesignTheme as DesignTokensTheme,
6
- type SemanticColors
7
- } from '@helpwave/hightide-design'
8
- import type { TextStyle, ViewStyle } from 'react-native'
9
- import type { ChipState, ChipTheme } from '../types'
10
- import { createStyleResolver } from '../types/resolver'
8
+ fontWeights
9
+ } from '@helpwave/hightide-design/tokens'
10
+ import type { HightideDesignTokens as DesignTokensTheme } from '@helpwave/hightide-design/types'
11
+
11
12
  import { resolveColoringStyles } from './coloring'
13
+ import type { HightideSemanticColors } from '../types/color'
14
+ import type {
15
+ ChipState,
16
+ ChipTheme
17
+ } from '../types/components/chip'
18
+ import type { HightideComponentThemes } from '../types/components/hightide'
19
+ import { createStyleResolver } from '../types/resolver'
12
20
 
13
21
  export type CreateChipThemeOptions = {
14
- semantic: SemanticColors,
15
- coloring: ColoringTokensDefinitions,
22
+ semantic: HightideSemanticColors,
23
+ coloring: HightideComponentThemes['coloring'],
16
24
  }
17
25
 
18
26
  export const createChipTheme = ({
@@ -35,18 +43,18 @@ export const createChipTheme = ({
35
43
  backgroundColor: resolved.backgroundColor,
36
44
  borderColor: resolved.borderColor,
37
45
  borderWidth: resolved.borderWidth,
38
- paddingVertical: toPx(layout.paddingVertical),
39
- paddingHorizontal: toPx(layout.paddingHorizontal),
40
- gap: toPx(layout.gap),
41
- minHeight: toPx(layout.minHeight),
42
- borderRadius: toPx(layout.borderRadius),
46
+ paddingVertical: layout.paddingVertical,
47
+ paddingHorizontal: layout.paddingHorizontal,
48
+ gap: layout.gap,
49
+ minHeight: layout.minHeight,
50
+ borderRadius: layout.borderRadius,
43
51
  opacity: state.isDisabled ? 0.6 : 1,
44
52
  }
45
53
 
46
54
  const text: TextStyle = {
47
55
  color: resolved.color,
48
- fontSize: toPx(layout.fontSize),
49
- fontWeight: '600',
56
+ fontSize: layout.fontSize,
57
+ fontWeight: fontWeights.semibold,
50
58
  }
51
59
 
52
60
  return { chip, text }
@@ -60,7 +68,7 @@ export const createChipTheme = ({
60
68
 
61
69
  export const createChipThemeFromDesign = (theme: DesignTokensTheme): ChipTheme => {
62
70
  return createChipTheme({
63
- semantic: theme.semantic,
64
- coloring: theme.coloring,
71
+ semantic: theme.semanticColors,
72
+ coloring: theme.coloring as HightideComponentThemes['coloring'],
65
73
  })
66
74
  }
@@ -1,20 +1,24 @@
1
1
  import {
2
- componentLayouts,
3
- hexWithAlpha,
4
- toPx,
5
- type ButtonColoringStyle,
6
- type ChipColoringStyle,
7
- type ColorValue,
8
- type ColoringToken,
9
- type ColoringStyle,
10
- type SemanticColors
11
- } from '@helpwave/hightide-design'
12
- import type { InteractionState } from '../types'
2
+ hexWithAlpha
3
+ } from '@helpwave/hightide-design/helpers'
4
+ import { componentLayouts } from '@helpwave/hightide-design/tokens'
5
+ import type {
6
+ ButtonColoringStyle,
7
+ ChipColoringStyle,
8
+ ColoringStyle
9
+ } from '@helpwave/hightide-design/types'
10
+
11
+ import type {
12
+ Color,
13
+ HightideSemanticColors
14
+ } from '../types/color'
15
+ import type { ColoringDefinition } from '../types/components/hightide'
16
+ import type { InteractionState } from '../types/resolver'
13
17
 
14
18
  export type ResolvedColoringStyles = {
15
- backgroundColor: ColorValue | 'transparent',
16
- color: ColorValue,
17
- borderColor?: ColorValue,
19
+ backgroundColor: Color | 'transparent',
20
+ color: Color,
21
+ borderColor?: Color,
18
22
  borderWidth: number,
19
23
  }
20
24
 
@@ -23,12 +27,12 @@ const usesHover = (state: InteractionState): boolean => {
23
27
  }
24
28
 
25
29
  export const resolveColoringStyles = (
26
- tokens: ColoringToken,
30
+ tokens: ColoringDefinition,
27
31
  coloringStyle: ColoringStyle,
28
- semantic: SemanticColors,
32
+ semantic: HightideSemanticColors,
29
33
  state: InteractionState = {}
30
34
  ): ResolvedColoringStyles => {
31
- const outlineWidth = toPx(componentLayouts.shared.coloringOutlineWidth)
35
+ const outlineWidth = componentLayouts.shared.coloringOutlineWidth
32
36
  const hovered = usesHover(state)
33
37
 
34
38
  if (state.isDisabled) {
@@ -1,18 +1,26 @@
1
- import {
2
- componentLayouts,
3
- toPx,
4
- type ColoringTokensDefinitions,
5
- type DesignTheme as DesignTokensTheme,
6
- type SemanticColors
7
- } from '@helpwave/hightide-design'
8
1
  import type { ViewStyle } from 'react-native'
9
- import type { IconButtonState, IconButtonTheme } from '../types'
10
- import { createStyleResolver, createValueResolver } from '../types/resolver'
11
- import { isOutlineColoringStyle, resolveColoringStyles } from './coloring'
2
+
3
+ import { componentLayouts } from '@helpwave/hightide-design/tokens'
4
+ import type { HightideDesignTokens as DesignTokensTheme } from '@helpwave/hightide-design/types'
5
+
6
+ import {
7
+ isOutlineColoringStyle,
8
+ resolveColoringStyles
9
+ } from './coloring'
10
+ import type { HightideSemanticColors } from '../types/color'
11
+ import type { HightideComponentThemes } from '../types/components/hightide'
12
+ import type {
13
+ IconButtonState,
14
+ IconButtonTheme
15
+ } from '../types/components/iconButton'
16
+ import {
17
+ createStyleResolver,
18
+ createValueResolver
19
+ } from '../types/resolver'
12
20
 
13
21
  export type CreateIconButtonThemeOptions = {
14
- semantic: SemanticColors,
15
- coloring: ColoringTokensDefinitions,
22
+ semantic: HightideSemanticColors,
23
+ coloring: HightideComponentThemes['coloring'],
16
24
  }
17
25
 
18
26
  export const createIconButtonTheme = ({
@@ -26,8 +34,8 @@ export const createIconButtonTheme = ({
26
34
  const tokens = coloring[color]
27
35
  const resolved = resolveColoringStyles(tokens, coloringStyle, semantic, state)
28
36
  const sizing = componentLayouts.element[size]
29
- const outlineWidth = toPx(componentLayouts.shared.coloringOutlineWidth)
30
- const dimension = toPx(sizing.height)
37
+ const outlineWidth = componentLayouts.shared.coloringOutlineWidth
38
+ const dimension = sizing.height
31
39
  const borderWidth = resolved.borderWidth > 0
32
40
  ? resolved.borderWidth
33
41
  : (isOutlineColoringStyle(coloringStyle) ? outlineWidth : 0)
@@ -40,7 +48,7 @@ export const createIconButtonTheme = ({
40
48
  borderWidth,
41
49
  width: dimension,
42
50
  height: dimension,
43
- borderRadius: toPx(componentLayouts.button[size].borderRadius),
51
+ borderRadius: componentLayouts.button[size].borderRadius,
44
52
  opacity: state.isDisabled ? 0.6 : 1,
45
53
  }
46
54
 
@@ -58,7 +66,7 @@ export const createIconButtonTheme = ({
58
66
 
59
67
  export const createIconButtonThemeFromDesign = (theme: DesignTokensTheme): IconButtonTheme => {
60
68
  return createIconButtonTheme({
61
- semantic: theme.semantic,
62
- coloring: theme.coloring,
69
+ semantic: theme.semanticColors,
70
+ coloring: theme.coloring as HightideComponentThemes['coloring'],
63
71
  })
64
72
  }
@@ -1,17 +1,24 @@
1
- import {
2
- inputElementSizes,
3
- remToPx,
4
- type ComponentColors,
5
- type DesignTheme as DesignTokensTheme,
6
- type SemanticColors
7
- } from '@helpwave/hightide-design'
8
1
  import type { TextStyle } from 'react-native'
9
- import type { InputState, InputTheme } from '../types'
10
- import { createStyleResolver, createValueResolver } from '../types/resolver'
2
+
3
+ import { componentLayouts } from '@helpwave/hightide-design/tokens'
4
+ import type {
5
+ ComponentColorTokens,
6
+ HightideDesignTokens as DesignTokensTheme
7
+ } from '@helpwave/hightide-design/types'
8
+
9
+ import type { HightideSemanticColors } from '../types/color'
10
+ import type {
11
+ InputState,
12
+ InputTheme
13
+ } from '../types/components/input'
14
+ import {
15
+ createStyleResolver,
16
+ createValueResolver
17
+ } from '../types/resolver'
11
18
 
12
19
  export type CreateInputThemeOptions = {
13
- semantic: SemanticColors,
14
- component: ComponentColors,
20
+ semantic: HightideSemanticColors,
21
+ component: ComponentColorTokens,
15
22
  }
16
23
 
17
24
  export const createInputTheme = ({
@@ -19,14 +26,14 @@ export const createInputTheme = ({
19
26
  component,
20
27
  }: CreateInputThemeOptions): InputTheme => {
21
28
  const resolveInput = (state: InputState): TextStyle => {
22
- const sizing = inputElementSizes.md
29
+ const sizing = componentLayouts.input.md
23
30
  const borderColor = state.isInvalid ? semantic.negative : component.border
24
31
 
25
32
  return {
26
- minHeight: remToPx(sizing.height),
27
- paddingHorizontal: remToPx(sizing.paddingX),
28
- paddingVertical: remToPx(sizing.paddingY),
29
- borderRadius: remToPx(sizing.borderRadius),
33
+ minHeight: sizing.height,
34
+ paddingHorizontal: sizing.paddingX,
35
+ paddingVertical: sizing.paddingY,
36
+ borderRadius: sizing.borderRadius,
30
37
  borderWidth: 1,
31
38
  borderColor,
32
39
  backgroundColor: state.isDisabled ? semantic.disabled : component.input.background,
@@ -44,7 +51,7 @@ export const createInputTheme = ({
44
51
 
45
52
  export const createInputThemeFromDesign = (theme: DesignTokensTheme): InputTheme => {
46
53
  return createInputTheme({
47
- semantic: theme.semantic,
48
- component: theme.component,
54
+ semantic: theme.semanticColors,
55
+ component: theme.componentColors,
49
56
  })
50
57
  }
@@ -1,16 +1,24 @@
1
1
  import { StyleSheet } from 'react-native'
2
+
3
+ import { fontWeights } from '@helpwave/hightide-design/tokens'
4
+ import type {
5
+ ComponentColorTokens,
6
+ HightideDesignTokens as DesignTokensTheme
7
+ } from '@helpwave/hightide-design/types'
8
+
9
+ import type { HightideSemanticColors } from '../types/color'
10
+ import type {
11
+ MenuActionItemState,
12
+ MenuTheme
13
+ } from '../types/components/menu'
2
14
  import {
3
- remToPx,
4
- type ComponentColors,
5
- type DesignTheme as DesignTokensTheme,
6
- type SemanticColors
7
- } from '@helpwave/hightide-design'
8
- import type { MenuActionItemState, MenuTheme } from '../types'
9
- import { createStyleResolver, createValueResolver } from '../types/resolver'
15
+ createStyleResolver,
16
+ createValueResolver
17
+ } from '../types/resolver'
10
18
 
11
19
  export type CreateMenuThemeOptions = {
12
- semantic: SemanticColors,
13
- component: ComponentColors,
20
+ semantic: HightideSemanticColors,
21
+ component: ComponentColorTokens,
14
22
  }
15
23
 
16
24
  export const createMenuTheme = ({
@@ -24,9 +32,9 @@ export const createMenuTheme = ({
24
32
  flexDirection: 'row' as const,
25
33
  alignItems: 'center' as const,
26
34
  minHeight: 64,
27
- gap: remToPx('0.75rem'),
28
- paddingHorizontal: remToPx('1rem'),
29
- paddingVertical: remToPx('0.5rem'),
35
+ gap: 12,
36
+ paddingHorizontal: 16,
37
+ paddingVertical: 8,
30
38
  borderBottomWidth: StyleSheet.hairlineWidth,
31
39
  borderBottomColor: component.divider,
32
40
  backgroundColor: pressed ? semantic.surfaceHover : ('transparent' as const),
@@ -36,14 +44,14 @@ export const createMenuTheme = ({
36
44
 
37
45
  const resolveItemContent = () => ({
38
46
  flex: 1,
39
- gap: remToPx('0.25rem'),
47
+ gap: 4,
40
48
  justifyContent: 'center' as const,
41
49
  })
42
50
 
43
51
  const resolveActionLabel = (state: MenuActionItemState) => ({
44
52
  color: state.isDanger ? semantic.negative : semantic.onSurface,
45
- fontSize: remToPx('0.9375rem'),
46
- fontWeight: '500' as const,
53
+ fontSize: 15,
54
+ fontWeight: fontWeights.medium,
47
55
  })
48
56
 
49
57
  const resolveActionIcon = (state: MenuActionItemState) => ({
@@ -52,20 +60,20 @@ export const createMenuTheme = ({
52
60
 
53
61
  return {
54
62
  section: createStyleResolver(() => ({
55
- marginBottom: remToPx('1.25rem'),
56
- gap: remToPx('0.5rem'),
63
+ marginBottom: 20,
64
+ gap: 8,
57
65
  })),
58
66
  sectionTitle: createStyleResolver(() => ({
59
67
  color: semantic.description,
60
- fontSize: remToPx('0.75rem'),
61
- fontWeight: '700',
68
+ fontSize: 12,
69
+ fontWeight: fontWeights.bold,
62
70
  letterSpacing: 0.4,
63
71
  textTransform: 'uppercase',
64
- paddingHorizontal: remToPx('0.25rem'),
72
+ paddingHorizontal: 4,
65
73
  })),
66
74
  card: createStyleResolver(() => ({
67
75
  backgroundColor: semantic.surface,
68
- borderRadius: remToPx('0.75rem'),
76
+ borderRadius: 12,
69
77
  borderWidth: 1,
70
78
  borderColor: component.border,
71
79
  overflow: 'hidden',
@@ -74,21 +82,21 @@ export const createMenuTheme = ({
74
82
  flexDirection: 'row' as const,
75
83
  alignItems: 'center' as const,
76
84
  minHeight: 64,
77
- paddingHorizontal: remToPx('1rem'),
78
- paddingVertical: remToPx('0.5rem'),
85
+ paddingHorizontal: 16,
86
+ paddingVertical: 8,
79
87
  borderBottomWidth: StyleSheet.hairlineWidth,
80
88
  borderBottomColor: component.divider,
81
- gap: remToPx('0.75rem'),
89
+ gap: 12,
82
90
  })),
83
91
  itemContent: createStyleResolver(resolveItemContent),
84
92
  itemLabel: createStyleResolver(() => ({
85
93
  color: semantic.description,
86
- fontSize: remToPx('0.75rem'),
94
+ fontSize: 12,
87
95
  })),
88
96
  itemValue: createStyleResolver(() => ({
89
97
  color: semantic.onSurface,
90
- fontSize: remToPx('0.9375rem'),
91
- fontWeight: '500',
98
+ fontSize: 15,
99
+ fontWeight: fontWeights.medium,
92
100
  })),
93
101
  actionItem: createStyleResolver(resolveActionItem),
94
102
  actionItemContent: createStyleResolver(resolveItemContent),
@@ -106,7 +114,7 @@ export const createMenuTheme = ({
106
114
 
107
115
  export const createMenuThemeFromDesign = (theme: DesignTokensTheme): MenuTheme => {
108
116
  return createMenuTheme({
109
- semantic: theme.semantic,
110
- component: theme.component,
117
+ semantic: theme.semanticColors,
118
+ component: theme.componentColors,
111
119
  })
112
120
  }
@@ -1,19 +1,23 @@
1
- import {
2
- remToPx,
3
- type ComponentColors,
4
- type DesignTheme as DesignTokensTheme,
5
- type SemanticColors
6
- } from '@helpwave/hightide-design'
1
+ import { fontWeights } from '@helpwave/hightide-design/tokens'
2
+ import type {
3
+ ComponentColorTokens,
4
+ HightideDesignTokens as DesignTokensTheme
5
+ } from '@helpwave/hightide-design/types'
6
+
7
+ import type { HightideSemanticColors } from '../types/color'
7
8
  import type {
8
9
  MultiSelectOptionState,
9
10
  MultiSelectState,
10
11
  MultiSelectTheme
11
- } from '../types'
12
- import { createStyleResolver, createValueResolver } from '../types/resolver'
12
+ } from '../types/components/multiSelect'
13
+ import {
14
+ createStyleResolver,
15
+ createValueResolver
16
+ } from '../types/resolver'
13
17
 
14
18
  export type CreateMultiSelectThemeOptions = {
15
- semantic: SemanticColors,
16
- component: ComponentColors,
19
+ semantic: HightideSemanticColors,
20
+ component: ComponentColorTokens,
17
21
  }
18
22
 
19
23
  export const createMultiSelectTheme = ({
@@ -23,9 +27,9 @@ export const createMultiSelectTheme = ({
23
27
  return {
24
28
  trigger: createStyleResolver((state: MultiSelectState) => ({
25
29
  minHeight: 44,
26
- paddingHorizontal: remToPx('0.75rem'),
27
- paddingVertical: remToPx('0.5rem'),
28
- borderRadius: remToPx('0.375rem'),
30
+ paddingHorizontal: 12,
31
+ paddingVertical: 8,
32
+ borderRadius: 6,
29
33
  borderWidth: 1,
30
34
  borderColor: state.isInvalid ? semantic.negative : component.border,
31
35
  backgroundColor: state.isDisabled ? semantic.disabled : component.input.background,
@@ -69,7 +73,7 @@ export const createMultiSelectTheme = ({
69
73
  })),
70
74
  optionText: createStyleResolver((state: MultiSelectOptionState) => ({
71
75
  color: state.isSelected ? semantic.primary : component.menu.text,
72
- fontWeight: state.isSelected ? '600' : '400',
76
+ fontWeight: state.isSelected ? fontWeights.semibold : fontWeights.base,
73
77
  })),
74
78
  checkbox: createStyleResolver((state: MultiSelectOptionState) => ({
75
79
  width: 18,
@@ -90,7 +94,7 @@ export const createMultiSelectTheme = ({
90
94
 
91
95
  export const createMultiSelectThemeFromDesign = (theme: DesignTokensTheme): MultiSelectTheme => {
92
96
  return createMultiSelectTheme({
93
- semantic: theme.semantic,
94
- component: theme.component,
97
+ semantic: theme.semanticColors,
98
+ component: theme.componentColors,
95
99
  })
96
100
  }
@@ -1,19 +1,23 @@
1
- import {
2
- remToPx,
3
- type ComponentColors,
4
- type DesignTheme as DesignTokensTheme,
5
- type SemanticColors
6
- } from '@helpwave/hightide-design'
1
+ import { fontWeights } from '@helpwave/hightide-design/tokens'
2
+ import type {
3
+ ComponentColorTokens,
4
+ HightideDesignTokens as DesignTokensTheme
5
+ } from '@helpwave/hightide-design/types'
6
+
7
+ import type { HightideSemanticColors } from '../types/color'
7
8
  import type {
8
9
  SelectOptionState,
9
10
  SelectState,
10
11
  SelectTheme
11
- } from '../types'
12
- import { createStyleResolver, createValueResolver } from '../types/resolver'
12
+ } from '../types/components/select'
13
+ import {
14
+ createStyleResolver,
15
+ createValueResolver
16
+ } from '../types/resolver'
13
17
 
14
18
  export type CreateSelectThemeOptions = {
15
- semantic: SemanticColors,
16
- component: ComponentColors,
19
+ semantic: HightideSemanticColors,
20
+ component: ComponentColorTokens,
17
21
  }
18
22
 
19
23
  export const createSelectTheme = ({
@@ -23,9 +27,9 @@ export const createSelectTheme = ({
23
27
  return {
24
28
  trigger: createStyleResolver((state: SelectState) => ({
25
29
  minHeight: 44,
26
- paddingHorizontal: remToPx('0.75rem'),
27
- paddingVertical: remToPx('0.5rem'),
28
- borderRadius: remToPx('0.375rem'),
30
+ paddingHorizontal: 12,
31
+ paddingVertical: 8,
32
+ borderRadius: 6,
29
33
  borderWidth: 1,
30
34
  borderColor: state.isInvalid ? semantic.negative : component.border,
31
35
  backgroundColor: state.isDisabled ? semantic.disabled : component.input.background,
@@ -65,14 +69,14 @@ export const createSelectTheme = ({
65
69
  })),
66
70
  optionText: createStyleResolver((state: SelectOptionState) => ({
67
71
  color: state.isSelected ? semantic.primary : component.menu.text,
68
- fontWeight: state.isSelected ? '600' : '400',
72
+ fontWeight: state.isSelected ? fontWeights.semibold : fontWeights.base,
69
73
  })),
70
74
  }
71
75
  }
72
76
 
73
77
  export const createSelectThemeFromDesign = (theme: DesignTokensTheme): SelectTheme => {
74
78
  return createSelectTheme({
75
- semantic: theme.semantic,
76
- component: theme.component,
79
+ semantic: theme.semanticColors,
80
+ component: theme.componentColors,
77
81
  })
78
82
  }
@@ -1,22 +1,47 @@
1
- import type { DesignTheme as DesignTokensTheme } from '@helpwave/hightide-design'
2
- import {
3
- createButtonThemeFromDesign,
4
- createChatThemeFromDesign,
5
- createCheckboxThemeFromDesign,
6
- createChipThemeFromDesign,
7
- createIconButtonThemeFromDesign,
8
- createInputThemeFromDesign,
9
- createMenuThemeFromDesign,
10
- createMultiSelectThemeFromDesign,
11
- createSelectThemeFromDesign
12
- } from '../resolvers'
13
- import type { DesignTheme } from '../types'
1
+ import type {
2
+ ColorPaletteToken,
3
+ HightideDesignTokens
4
+ } from '@helpwave/hightide-design/types'
14
5
 
15
- export const createDesignTheme = (tokens: DesignTokensTheme): DesignTheme => ({
16
- palettes: tokens.palettes,
17
- semantic: tokens.semantic,
18
- coloring: tokens.coloring,
6
+ import { createButtonThemeFromDesign } from '../resolvers/button'
7
+ import { createChatThemeFromDesign } from '../resolvers/chat'
8
+ import { createCheckboxThemeFromDesign } from '../resolvers/checkbox'
9
+ import { createChipThemeFromDesign } from '../resolvers/chip'
10
+ import { createIconButtonThemeFromDesign } from '../resolvers/iconButton'
11
+ import { createInputThemeFromDesign } from '../resolvers/input'
12
+ import { createMenuThemeFromDesign } from '../resolvers/menu'
13
+ import { createMultiSelectThemeFromDesign } from '../resolvers/multiSelect'
14
+ import { createSelectThemeFromDesign } from '../resolvers/select'
15
+ import type {
16
+ Color,
17
+ ColorPalette,
18
+ HightideColors
19
+ } from '../types/color'
20
+ import type { Theme } from '../types/theme'
21
+
22
+ const unwrapColorPaletteToken = (token: ColorPaletteToken): Color | ColorPalette => {
23
+ if (token.type === 'singleValue') {
24
+ return token.value
25
+ }
26
+ return token.value
27
+ }
28
+
29
+ const unwrapColors = (colors: HightideDesignTokens['colors']): HightideColors & Record<string, Color | ColorPalette> => {
30
+ const result: Record<string, Color | ColorPalette> = {}
31
+ for (const [key, token] of Object.entries(colors)) {
32
+ result[key] = unwrapColorPaletteToken(token)
33
+ }
34
+ return result as HightideColors & Record<string, Color | ColorPalette>
35
+ }
36
+
37
+ export const createTheme = (tokens: HightideDesignTokens): Theme => ({
38
+ colors: unwrapColors(tokens.colors),
39
+ semantic: tokens.semanticColors,
40
+ typography: tokens.typography,
41
+ layout: tokens.layout,
42
+ decoration: tokens.decorcation,
19
43
  components: {
44
+ coloring: tokens.coloring,
20
45
  button: createButtonThemeFromDesign(tokens),
21
46
  iconButton: createIconButtonThemeFromDesign(tokens),
22
47
  chip: createChipThemeFromDesign(tokens),