@helpwave/hightide-native 0.0.8 → 0.1.1
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 +4 -4
- package/package.json +8 -19
- package/src/components/card/Card.tsx +41 -0
- package/src/components/card/index.ts +1 -0
- package/src/components/chat/ChatAttachmentMessageBubble.tsx +246 -0
- package/src/components/chat/ChatConversationRow.tsx +21 -16
- package/src/components/chat/ChatDateDivider.tsx +2 -2
- package/src/components/chat/ChatMessageBubble.tsx +62 -52
- package/src/components/chat/ChatMessageComposer.tsx +16 -14
- package/src/components/chat/ChatQuickReplyChip.tsx +41 -43
- package/src/components/chat/ChatSystemLine.tsx +14 -7
- package/src/components/chat/ChatThreadHeader.tsx +60 -6
- package/src/components/chat/index.ts +1 -2
- package/src/components/index.ts +3 -1
- package/src/components/layout/Divider.tsx +60 -0
- package/src/components/layout/index.ts +1 -0
- package/src/components/list/ListActionItem.tsx +99 -0
- package/src/components/list/ListItem.tsx +96 -0
- package/src/components/list/ListNavigationItem.tsx +102 -0
- package/src/components/list/index.ts +3 -0
- package/src/components/user-interaction/Button.tsx +80 -31
- package/src/components/user-interaction/Checkbox.tsx +72 -32
- package/src/components/user-interaction/IconButton.tsx +68 -30
- package/src/components/user-interaction/Input.tsx +61 -14
- package/src/components/user-interaction/MultiSelect.tsx +142 -75
- package/src/components/user-interaction/SearchBar.tsx +222 -0
- package/src/components/user-interaction/Select.tsx +129 -58
- package/src/components/user-interaction/Switch.tsx +110 -80
- package/src/components/user-interaction/ThemedPressable.tsx +136 -0
- package/src/components/user-interaction/index.ts +2 -0
- package/src/components/visualization-and-display/Avatar.tsx +112 -93
- package/src/components/visualization-and-display/Chip.tsx +22 -22
- package/src/components/visualization-and-display/ThemedIcon.tsx +72 -0
- package/src/components/visualization-and-display/ThemedText.tsx +38 -0
- package/src/components/visualization-and-display/index.ts +2 -1
- package/src/global-contexts/HightideProvider.tsx +19 -10
- package/src/global-contexts/content-theme/ContentThemeContext.ts +22 -0
- package/src/global-contexts/content-theme/ContentThemeProvider.tsx +32 -0
- package/src/global-contexts/content-theme/index.ts +2 -0
- package/src/global-contexts/debug/forward-exports.ts +10 -0
- package/src/global-contexts/debug/index.ts +1 -0
- package/src/global-contexts/index.ts +2 -0
- package/src/global-contexts/theme/ThemeProvider.tsx +7 -1
- package/src/icons/HightideIconRegistry.ts +33 -0
- package/src/icons/index.ts +2 -0
- package/src/icons/types.ts +11 -0
- package/src/theme/adapters/container-adapter.ts +323 -0
- package/src/theme/adapters/defined.ts +11 -0
- package/src/theme/adapters/icon-style-adapter.ts +10 -0
- package/src/theme/adapters/index.ts +4 -0
- package/src/theme/adapters/text-style-adapter.ts +16 -0
- package/src/theme/index.ts +1 -0
- package/src/theme/resolvers/avatar.ts +385 -186
- package/src/theme/resolvers/button.ts +50 -82
- package/src/theme/resolvers/card.ts +27 -0
- package/src/theme/resolvers/chat/attachment-message-bubble.ts +163 -0
- package/src/theme/resolvers/chat/chat-theme.ts +69 -0
- package/src/theme/resolvers/chat/conversation-list.ts +35 -0
- package/src/theme/resolvers/chat/conversation-row.ts +64 -0
- package/src/theme/resolvers/chat/date-divider.ts +31 -0
- package/src/theme/resolvers/chat/index.ts +11 -0
- package/src/theme/resolvers/chat/message-bubble.ts +57 -0
- package/src/theme/resolvers/chat/message-composer.ts +38 -0
- package/src/theme/resolvers/chat/message-list.ts +27 -0
- package/src/theme/resolvers/chat/quick-reply-chip.ts +80 -0
- package/src/theme/resolvers/chat/system-line.ts +41 -0
- package/src/theme/resolvers/chat/thread-header.ts +85 -0
- package/src/theme/resolvers/checkbox.ts +87 -74
- package/src/theme/resolvers/chip.ts +30 -67
- package/src/theme/resolvers/colorScheme.ts +136 -0
- package/src/theme/resolvers/divider.ts +34 -0
- package/src/theme/resolvers/icon.ts +21 -0
- package/src/theme/resolvers/iconButton.ts +45 -61
- package/src/theme/resolvers/index.ts +7 -2
- package/src/theme/resolvers/input.ts +64 -42
- package/src/theme/resolvers/listItem.ts +115 -0
- package/src/theme/resolvers/multiSelect.ts +159 -84
- package/src/theme/resolvers/searchBar.ts +121 -0
- package/src/theme/resolvers/select.ts +141 -66
- package/src/theme/resolvers/switch.ts +59 -53
- package/src/theme/resolvers/themedPressable.ts +54 -0
- package/src/theme/themes/createHightideTheme.ts +214 -51
- package/src/theme/themes/hightideThemes.ts +10 -6
- package/src/theme/types/color.ts +2 -59
- package/src/theme/types/components/avatar.ts +37 -36
- package/src/theme/types/components/button.ts +13 -14
- package/src/theme/types/components/card.ts +9 -0
- package/src/theme/types/components/chat.ts +124 -103
- package/src/theme/types/components/checkbox.ts +11 -12
- package/src/theme/types/components/chip.ts +8 -14
- package/src/theme/types/components/divider.ts +18 -0
- package/src/theme/types/components/hightide.ts +41 -42
- package/src/theme/types/components/iconButton.ts +19 -14
- package/src/theme/types/components/index.ts +5 -1
- package/src/theme/types/components/input.ts +17 -8
- package/src/theme/types/components/listItem.ts +86 -0
- package/src/theme/types/components/multiSelect.ts +14 -12
- package/src/theme/types/components/searchBar.ts +28 -0
- package/src/theme/types/components/select.ts +21 -9
- package/src/theme/types/components/switch.ts +12 -5
- package/src/theme/types/components/themedPressable.ts +31 -0
- package/src/theme/types/decoration.ts +1 -11
- package/src/theme/types/icongraphy.ts +8 -0
- package/src/theme/types/index.ts +2 -0
- package/src/theme/types/layout.ts +25 -57
- package/src/theme/types/resolver.ts +54 -1
- package/src/theme/types/semantics.ts +72 -0
- package/src/theme/types/theme.ts +26 -13
- package/src/theme/types/typography.ts +16 -17
- package/src/utils/hitBoxOverlay.ts +44 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/minimumTouchTargetHitSlop.ts +68 -0
- package/src/components/chat/ChatAttachmentCard.tsx +0 -110
- package/src/components/chat/ChatMessageCard.tsx +0 -118
- package/src/components/menu/Menu.tsx +0 -61
- package/src/components/menu/MenuActionItem.tsx +0 -90
- package/src/components/menu/MenuItem.tsx +0 -73
- package/src/components/menu/MenuNavigationItem.tsx +0 -90
- package/src/components/menu/index.ts +0 -4
- package/src/components/visualization-and-display/Icon.tsx +0 -27
- package/src/storybook/helper.tsx +0 -36
- package/src/theme/resolvers/chat.ts +0 -418
- package/src/theme/resolvers/coloring.ts +0 -94
- package/src/theme/resolvers/menu.ts +0 -120
- package/src/theme/types/components/menu.ts +0 -57
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InputState as DesignInputState,
|
|
3
|
+
InputStateValue
|
|
4
|
+
} from '@helpwave/hightide-design/component-token-resolvers'
|
|
5
|
+
import type { ColorPairToken } from '@helpwave/hightide-design/theme-tokens'
|
|
6
|
+
import { toContainerStyle, toContainerStyleWithStateLayer } from '../adapters/container-adapter'
|
|
7
|
+
import { toTextStyle } from '../adapters/text-style-adapter'
|
|
8
|
+
import type {
|
|
9
|
+
SearchBarContainerStyle,
|
|
10
|
+
SearchBarIconButtonStyle,
|
|
11
|
+
SearchBarInputStyle,
|
|
12
|
+
SearchBarPlaceholderStyle,
|
|
13
|
+
SearchBarState,
|
|
14
|
+
SearchBarThemeResolvers
|
|
15
|
+
} from '../types/components/searchBar'
|
|
16
|
+
import {
|
|
17
|
+
createStyleResolver,
|
|
18
|
+
createValueResolver,
|
|
19
|
+
type ComponentThemeResolver
|
|
20
|
+
} from '../types/resolver'
|
|
21
|
+
|
|
22
|
+
const toDesignSearchBarState = (state: SearchBarState = {}): DesignInputState => {
|
|
23
|
+
const active = new Set<InputStateValue>()
|
|
24
|
+
|
|
25
|
+
if (state.isDisabled) {
|
|
26
|
+
active.add('disabled')
|
|
27
|
+
}
|
|
28
|
+
if (state.isFocused) {
|
|
29
|
+
active.add('focused')
|
|
30
|
+
}
|
|
31
|
+
if (state.isFocusVisible) {
|
|
32
|
+
active.add('focusVisible')
|
|
33
|
+
}
|
|
34
|
+
if (state.isHovered) {
|
|
35
|
+
active.add('hovered')
|
|
36
|
+
}
|
|
37
|
+
if (state.isPressed) {
|
|
38
|
+
active.add('pressed')
|
|
39
|
+
}
|
|
40
|
+
if (state.isReadonly) {
|
|
41
|
+
active.add('readonly')
|
|
42
|
+
}
|
|
43
|
+
if (state.isInvalid) {
|
|
44
|
+
active.add('invalid')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return active
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const toSearchBarThemeResolvers: ComponentThemeResolver<SearchBarThemeResolvers> = ({
|
|
51
|
+
themeTokens,
|
|
52
|
+
semanticTokens,
|
|
53
|
+
componentTokens,
|
|
54
|
+
}) => {
|
|
55
|
+
const resolve = (state: SearchBarState = {}) => componentTokens.searchBar({
|
|
56
|
+
themeTokens,
|
|
57
|
+
semanticResolvers: semanticTokens,
|
|
58
|
+
overrides: {
|
|
59
|
+
color: state.color,
|
|
60
|
+
},
|
|
61
|
+
state: toDesignSearchBarState(state),
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
container: createStyleResolver((state: SearchBarState): SearchBarContainerStyle => ({
|
|
66
|
+
...toContainerStyle(resolve(state).container),
|
|
67
|
+
position: 'relative',
|
|
68
|
+
justifyContent: 'center',
|
|
69
|
+
})),
|
|
70
|
+
input: createStyleResolver((state: SearchBarState): SearchBarInputStyle => {
|
|
71
|
+
const tokens = resolve(state)
|
|
72
|
+
const { container, stateLayer, text } = tokens.input
|
|
73
|
+
// TODO remove this computation with a better solution
|
|
74
|
+
const base = toContainerStyleWithStateLayer(container, stateLayer)
|
|
75
|
+
const horizontalPadding = typeof base.paddingLeft === 'number'
|
|
76
|
+
? base.paddingLeft
|
|
77
|
+
: typeof base.paddingRight === 'number'
|
|
78
|
+
? base.paddingRight
|
|
79
|
+
: 0
|
|
80
|
+
const iconButtonWidth = typeof tokens.iconButton.size?.width === 'number'
|
|
81
|
+
? tokens.iconButton.size.width
|
|
82
|
+
: 0
|
|
83
|
+
const iconButtonMargin = tokens.iconButton.margin?.type === 'physicalAxis'
|
|
84
|
+
? tokens.iconButton.margin.horizontal ?? 0
|
|
85
|
+
: 0
|
|
86
|
+
const trailingInset = iconButtonWidth + iconButtonMargin
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
...base,
|
|
90
|
+
...toTextStyle(text),
|
|
91
|
+
paddingLeft: horizontalPadding,
|
|
92
|
+
paddingRight: horizontalPadding + trailingInset,
|
|
93
|
+
}
|
|
94
|
+
}),
|
|
95
|
+
placeholder: createStyleResolver((state: SearchBarState): SearchBarPlaceholderStyle => (
|
|
96
|
+
toTextStyle(resolve(state).input.placeholder)
|
|
97
|
+
)),
|
|
98
|
+
iconButton: createStyleResolver((state: SearchBarState): SearchBarIconButtonStyle => {
|
|
99
|
+
const { iconButton } = resolve(state)
|
|
100
|
+
const style = toContainerStyle(iconButton)
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
...style,
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
right: 0,
|
|
106
|
+
top: '50%',
|
|
107
|
+
transform: [{ translateY: '-50%' }],
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
iconButtonColor: createValueResolver((state: SearchBarState): ColorPairToken => {
|
|
111
|
+
const iconColor = resolve(state).icon.color
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
color: (iconColor === undefined || iconColor === 'transparent'
|
|
115
|
+
? themeTokens.color.surface.onColor
|
|
116
|
+
: iconColor),
|
|
117
|
+
onColor: themeTokens.color.surface.color,
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -1,82 +1,157 @@
|
|
|
1
|
-
import { fontWeights } from '@helpwave/hightide-design/tokens'
|
|
2
1
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from '@helpwave/hightide-design/
|
|
6
|
-
|
|
7
|
-
import
|
|
2
|
+
SelectState as DesignSelectState,
|
|
3
|
+
SelectStateValue
|
|
4
|
+
} from '@helpwave/hightide-design/component-token-resolvers'
|
|
5
|
+
import { toContainerStyle, toContainerStyleWithStateLayer } from '../adapters/container-adapter'
|
|
6
|
+
import { toIconStyle } from '../adapters/icon-style-adapter'
|
|
7
|
+
import { toTextStyle } from '../adapters/text-style-adapter'
|
|
8
8
|
import type {
|
|
9
|
+
SelectIconStyle,
|
|
10
|
+
SelectMenuStyle,
|
|
11
|
+
SelectMenuState,
|
|
12
|
+
SelectHeaderStyle,
|
|
13
|
+
SelectEmptyTextStyle,
|
|
9
14
|
SelectOptionState,
|
|
15
|
+
SelectOptionStyle,
|
|
16
|
+
SelectOptionTextStyle,
|
|
17
|
+
SelectOverlayStyle,
|
|
10
18
|
SelectState,
|
|
11
|
-
|
|
19
|
+
SelectThemeResolvers,
|
|
20
|
+
SelectTriggerStyle,
|
|
21
|
+
SelectTriggerTextStyle
|
|
12
22
|
} from '../types/components/select'
|
|
13
23
|
import {
|
|
24
|
+
createSimpleStyleResolver,
|
|
14
25
|
createStyleResolver,
|
|
15
|
-
createValueResolver
|
|
26
|
+
createValueResolver,
|
|
27
|
+
type ComponentThemeResolver
|
|
16
28
|
} from '../types/resolver'
|
|
17
29
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
type SelectResolveState = {
|
|
31
|
+
color?: SelectState['color'],
|
|
32
|
+
isDisabled?: boolean,
|
|
33
|
+
isInvalid?: boolean,
|
|
34
|
+
isHovered?: boolean,
|
|
35
|
+
isFocused?: boolean,
|
|
36
|
+
isFocusVisible?: boolean,
|
|
37
|
+
isPressed?: boolean,
|
|
38
|
+
isReadonly?: boolean,
|
|
39
|
+
isOpen?: boolean,
|
|
40
|
+
hasValue?: boolean,
|
|
41
|
+
isSelected?: boolean,
|
|
42
|
+
isHighlighted?: boolean,
|
|
43
|
+
hasSearch?: boolean,
|
|
21
44
|
}
|
|
22
45
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
color: state.hasValue ? component.input.text : semantic.placeholder,
|
|
41
|
-
})),
|
|
42
|
-
overlay: createStyleResolver(() => ({
|
|
43
|
-
flex: 1,
|
|
44
|
-
backgroundColor: '#00000059',
|
|
45
|
-
justifyContent: 'center',
|
|
46
|
-
padding: 24,
|
|
47
|
-
})),
|
|
48
|
-
menu: createStyleResolver(() => ({
|
|
49
|
-
maxHeight: 360,
|
|
50
|
-
borderRadius: 12,
|
|
51
|
-
backgroundColor: component.menu.background,
|
|
52
|
-
borderWidth: 1,
|
|
53
|
-
borderColor: component.menu.border,
|
|
54
|
-
overflow: 'hidden',
|
|
55
|
-
})),
|
|
56
|
-
search: createStyleResolver(() => ({
|
|
57
|
-
paddingHorizontal: 16,
|
|
58
|
-
paddingVertical: 12,
|
|
59
|
-
borderBottomWidth: 1,
|
|
60
|
-
borderBottomColor: component.menu.border,
|
|
61
|
-
color: component.menu.text,
|
|
62
|
-
})),
|
|
63
|
-
searchPlaceholderColor: createValueResolver(() => semantic.placeholder),
|
|
64
|
-
option: createStyleResolver((state: SelectOptionState) => ({
|
|
65
|
-
paddingHorizontal: 16,
|
|
66
|
-
paddingVertical: 12,
|
|
67
|
-
backgroundColor: state.isHighlighted ? component.table.rowHoverBackground : 'transparent',
|
|
68
|
-
opacity: state.isDisabled ? 0.5 : 1,
|
|
69
|
-
})),
|
|
70
|
-
optionText: createStyleResolver((state: SelectOptionState) => ({
|
|
71
|
-
color: state.isSelected ? semantic.primary : component.menu.text,
|
|
72
|
-
fontWeight: state.isSelected ? fontWeights.semibold : fontWeights.base,
|
|
73
|
-
})),
|
|
46
|
+
const toDesignSelectState = (state: SelectResolveState = {}): DesignSelectState => {
|
|
47
|
+
const active = new Set<SelectStateValue>()
|
|
48
|
+
|
|
49
|
+
if (state.isDisabled) {
|
|
50
|
+
active.add('disabled')
|
|
51
|
+
}
|
|
52
|
+
if (state.isFocused) {
|
|
53
|
+
active.add('focused')
|
|
54
|
+
}
|
|
55
|
+
if (state.isFocusVisible) {
|
|
56
|
+
active.add('focusVisible')
|
|
57
|
+
}
|
|
58
|
+
if (state.isHovered) {
|
|
59
|
+
active.add('hovered')
|
|
60
|
+
}
|
|
61
|
+
if (state.isPressed) {
|
|
62
|
+
active.add('pressed')
|
|
74
63
|
}
|
|
64
|
+
if (state.isReadonly) {
|
|
65
|
+
active.add('readonly')
|
|
66
|
+
}
|
|
67
|
+
if (state.isInvalid) {
|
|
68
|
+
active.add('invalid')
|
|
69
|
+
}
|
|
70
|
+
if (state.isOpen) {
|
|
71
|
+
active.add('open')
|
|
72
|
+
}
|
|
73
|
+
if (state.hasValue) {
|
|
74
|
+
active.add('hasValue')
|
|
75
|
+
}
|
|
76
|
+
if (state.isSelected) {
|
|
77
|
+
active.add('selected')
|
|
78
|
+
}
|
|
79
|
+
if (state.isHighlighted) {
|
|
80
|
+
active.add('highlighted')
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return active
|
|
75
84
|
}
|
|
76
85
|
|
|
77
|
-
export const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
export const toSelectThemeResolvers: ComponentThemeResolver<SelectThemeResolvers> = ({
|
|
87
|
+
themeTokens,
|
|
88
|
+
semanticTokens,
|
|
89
|
+
componentTokens,
|
|
90
|
+
}) => {
|
|
91
|
+
const resolve = (state: SelectResolveState = {}) => componentTokens.select({
|
|
92
|
+
themeTokens,
|
|
93
|
+
semanticResolvers: semanticTokens,
|
|
94
|
+
config: {
|
|
95
|
+
hasSearch: state.hasSearch,
|
|
96
|
+
},
|
|
97
|
+
overrides: {
|
|
98
|
+
color: state.color,
|
|
99
|
+
},
|
|
100
|
+
state: toDesignSelectState(state),
|
|
81
101
|
})
|
|
102
|
+
|
|
103
|
+
const toTriggerState = (state: SelectState): SelectResolveState => ({
|
|
104
|
+
color: state.color,
|
|
105
|
+
isDisabled: state.isDisabled,
|
|
106
|
+
isInvalid: state.isInvalid,
|
|
107
|
+
isHovered: state.isHovered,
|
|
108
|
+
isFocused: state.isFocused,
|
|
109
|
+
isFocusVisible: state.isFocusVisible,
|
|
110
|
+
isPressed: state.isPressed,
|
|
111
|
+
isReadonly: state.isReadonly,
|
|
112
|
+
isOpen: state.isOpen,
|
|
113
|
+
hasValue: state.hasValue,
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
trigger: createStyleResolver((state: SelectState): SelectTriggerStyle => {
|
|
118
|
+
const { trigger, stateLayer } = resolve(toTriggerState(state))
|
|
119
|
+
return toContainerStyleWithStateLayer(trigger, stateLayer)
|
|
120
|
+
}),
|
|
121
|
+
triggerText: createStyleResolver((state: SelectState): SelectTriggerTextStyle => (
|
|
122
|
+
toTextStyle(resolve(toTriggerState(state)).triggerText)
|
|
123
|
+
)),
|
|
124
|
+
icon: createValueResolver((state: SelectState): SelectIconStyle => (
|
|
125
|
+
toIconStyle(resolve(toTriggerState(state)).icon)
|
|
126
|
+
)),
|
|
127
|
+
overlay: createSimpleStyleResolver((): SelectOverlayStyle => ({
|
|
128
|
+
...toContainerStyle(resolve().overlay),
|
|
129
|
+
flex: 1,
|
|
130
|
+
})),
|
|
131
|
+
menu: createStyleResolver((state: SelectMenuState): SelectMenuStyle => (
|
|
132
|
+
toContainerStyle(resolve({ hasSearch: state.hasSearch }).menu)
|
|
133
|
+
)),
|
|
134
|
+
header: createSimpleStyleResolver((): SelectHeaderStyle => (
|
|
135
|
+
toContainerStyle(resolve().header)
|
|
136
|
+
)),
|
|
137
|
+
option: createStyleResolver((state: SelectOptionState): SelectOptionStyle => (
|
|
138
|
+
toContainerStyle(resolve({
|
|
139
|
+
color: state.color,
|
|
140
|
+
isDisabled: state.isDisabled,
|
|
141
|
+
isSelected: state.isSelected,
|
|
142
|
+
isHighlighted: state.isHighlighted,
|
|
143
|
+
}).option)
|
|
144
|
+
)),
|
|
145
|
+
optionText: createStyleResolver((state: SelectOptionState): SelectOptionTextStyle => (
|
|
146
|
+
toTextStyle(resolve({
|
|
147
|
+
color: state.color,
|
|
148
|
+
isDisabled: state.isDisabled,
|
|
149
|
+
isSelected: state.isSelected,
|
|
150
|
+
isHighlighted: state.isHighlighted,
|
|
151
|
+
}).optionText)
|
|
152
|
+
)),
|
|
153
|
+
emptyText: createSimpleStyleResolver((): SelectEmptyTextStyle => (
|
|
154
|
+
toTextStyle(resolve().emptyText)
|
|
155
|
+
)),
|
|
156
|
+
}
|
|
82
157
|
}
|
|
@@ -1,65 +1,71 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from '@helpwave/hightide-design/
|
|
5
|
-
|
|
6
|
-
import type { HightideSemanticColors } from '../types/color'
|
|
2
|
+
SwitchState as DesignSwitchState,
|
|
3
|
+
SwitchStateValue
|
|
4
|
+
} from '@helpwave/hightide-design/component-token-resolvers'
|
|
5
|
+
import { toContainerStyle } from '../adapters/container-adapter'
|
|
7
6
|
import type {
|
|
7
|
+
SwitchContainerStyle,
|
|
8
8
|
SwitchState,
|
|
9
|
-
|
|
9
|
+
SwitchThemeResolvers,
|
|
10
|
+
SwitchThumbStyle,
|
|
11
|
+
SwitchTrackStyle
|
|
10
12
|
} from '../types/components/switch'
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
component: ComponentColorTokens,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const createSwitchTheme = ({
|
|
19
|
-
semantic,
|
|
20
|
-
component,
|
|
21
|
-
}: CreateSwitchThemeOptions): SwitchTheme => {
|
|
22
|
-
const resolveState = (state: SwitchState) => {
|
|
23
|
-
const trackInactive = state.isDisabled
|
|
24
|
-
? semantic.disabled
|
|
25
|
-
: component.switch.track.inactive
|
|
26
|
-
const trackActive = state.isDisabled
|
|
27
|
-
? semantic.disabled
|
|
28
|
-
: component.switch.track.active
|
|
29
|
-
|
|
30
|
-
const trackColor = state.isActive ? trackActive : trackInactive
|
|
13
|
+
import {
|
|
14
|
+
createStyleResolver,
|
|
15
|
+
type ComponentThemeResolver
|
|
16
|
+
} from '../types/resolver'
|
|
31
17
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
: state.isInvalid
|
|
35
|
-
? semantic.negative
|
|
36
|
-
: state.isActive
|
|
37
|
-
? trackActive
|
|
38
|
-
: component.switch.borderColor
|
|
18
|
+
const toDesignSwitchState = (state: SwitchState = {}): DesignSwitchState => {
|
|
19
|
+
const active = new Set<SwitchStateValue>()
|
|
39
20
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
: state.isActive
|
|
43
|
-
? component.switch.thumb.active
|
|
44
|
-
: component.switch.thumb.inactive
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
trackColor,
|
|
48
|
-
borderColor,
|
|
49
|
-
thumbColor,
|
|
50
|
-
}
|
|
21
|
+
if (state.isDisabled) {
|
|
22
|
+
active.add('disabled')
|
|
51
23
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
24
|
+
if (state.isFocused) {
|
|
25
|
+
active.add('focused')
|
|
26
|
+
}
|
|
27
|
+
if (state.isFocusVisible) {
|
|
28
|
+
active.add('focusVisible')
|
|
57
29
|
}
|
|
30
|
+
if (state.isHovered) {
|
|
31
|
+
active.add('hovered')
|
|
32
|
+
}
|
|
33
|
+
if (state.isPressed) {
|
|
34
|
+
active.add('pressed')
|
|
35
|
+
}
|
|
36
|
+
if (state.isReadonly) {
|
|
37
|
+
active.add('readonly')
|
|
38
|
+
}
|
|
39
|
+
if (state.isInvalid) {
|
|
40
|
+
active.add('invalid')
|
|
41
|
+
}
|
|
42
|
+
if (state.isActive) {
|
|
43
|
+
active.add('active')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return active
|
|
58
47
|
}
|
|
59
48
|
|
|
60
|
-
export const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
export const toSwitchThemeResolvers: ComponentThemeResolver<SwitchThemeResolvers> = ({
|
|
50
|
+
themeTokens,
|
|
51
|
+
semanticTokens,
|
|
52
|
+
componentTokens,
|
|
53
|
+
}) => {
|
|
54
|
+
const resolve = (state: SwitchState = {}) => componentTokens.switch({
|
|
55
|
+
themeTokens,
|
|
56
|
+
semanticResolvers: semanticTokens,
|
|
57
|
+
state: toDesignSwitchState(state),
|
|
64
58
|
})
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
container: createStyleResolver((state: SwitchState): SwitchContainerStyle => (
|
|
62
|
+
toContainerStyle(resolve(state).container)
|
|
63
|
+
)),
|
|
64
|
+
track: createStyleResolver((state: SwitchState): SwitchTrackStyle => (
|
|
65
|
+
toContainerStyle(resolve(state).track)
|
|
66
|
+
)),
|
|
67
|
+
thumb: createStyleResolver((state: SwitchState): SwitchThumbStyle => (
|
|
68
|
+
toContainerStyle(resolve(state).thumb)
|
|
69
|
+
)),
|
|
70
|
+
}
|
|
65
71
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { toContainerStyle } from '../adapters/container-adapter'
|
|
2
|
+
import { toTextStyle } from '../adapters/text-style-adapter'
|
|
3
|
+
import type {
|
|
4
|
+
ThemedPressableState,
|
|
5
|
+
ThemedPressableStyle,
|
|
6
|
+
ThemedPressableTextStyle,
|
|
7
|
+
ThemedPressableThemeResolvers
|
|
8
|
+
} from '../types/components/themedPressable'
|
|
9
|
+
import {
|
|
10
|
+
createStyleResolver,
|
|
11
|
+
toPressableInteractionState,
|
|
12
|
+
type ComponentThemeResolver
|
|
13
|
+
} from '../types/resolver'
|
|
14
|
+
|
|
15
|
+
export const toThemedPressableThemeResolvers: ComponentThemeResolver<ThemedPressableThemeResolvers> = ({
|
|
16
|
+
themeTokens,
|
|
17
|
+
semanticTokens,
|
|
18
|
+
componentTokens,
|
|
19
|
+
}) => {
|
|
20
|
+
const resolve = (state: ThemedPressableState) => componentTokens.pressable({
|
|
21
|
+
themeTokens,
|
|
22
|
+
semanticResolvers: semanticTokens,
|
|
23
|
+
overrides: {
|
|
24
|
+
size: state.size,
|
|
25
|
+
color: state.color,
|
|
26
|
+
coloringStyle: state.coloringStyle,
|
|
27
|
+
coloringColorVariant: state.coloringColorVariant,
|
|
28
|
+
hasAdditionalHorizontalPadding: state.hasAdditionalHorizontalPadding,
|
|
29
|
+
},
|
|
30
|
+
state: toPressableInteractionState(state),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
container: createStyleResolver((state: ThemedPressableState): ThemedPressableStyle => ({
|
|
35
|
+
...toContainerStyle(resolve(state).container),
|
|
36
|
+
alignSelf: 'flex-start',
|
|
37
|
+
})),
|
|
38
|
+
stateLayer: createStyleResolver((state: ThemedPressableState): ThemedPressableStyle => {
|
|
39
|
+
const tokens = resolve(state)
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
...toContainerStyle(tokens.stateLayer),
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
top: 0,
|
|
45
|
+
right: 0,
|
|
46
|
+
bottom: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
text: createStyleResolver((state: ThemedPressableState): ThemedPressableTextStyle => (
|
|
51
|
+
toTextStyle(resolve(state).text)
|
|
52
|
+
)),
|
|
53
|
+
}
|
|
54
|
+
}
|