@helpwave/hightide-native 0.2.0 → 0.3.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.
- package/package.json +2 -2
- package/src/components/chat/ChatConversationRow.tsx +127 -27
- package/src/components/chat/ChatThreadHeader.tsx +88 -48
- package/src/components/user-interaction/MultiSelect.tsx +66 -38
- package/src/components/user-interaction/Select.tsx +4 -0
- package/src/global-contexts/HightideProvider.tsx +9 -17
- package/src/theme/adapters/index.ts +1 -4
- package/src/theme/adapters/style-adapter-utils.ts +433 -0
- package/src/theme/resolvers/avatar.ts +9 -10
- package/src/theme/resolvers/button.ts +6 -7
- package/src/theme/resolvers/card.ts +3 -2
- package/src/theme/resolvers/chat/attachment-message-bubble.ts +22 -38
- package/src/theme/resolvers/chat/conversation-list.ts +5 -4
- package/src/theme/resolvers/chat/conversation-row.ts +114 -14
- package/src/theme/resolvers/chat/date-divider.ts +4 -4
- package/src/theme/resolvers/chat/message-bubble.ts +9 -10
- package/src/theme/resolvers/chat/message-composer.ts +5 -6
- package/src/theme/resolvers/chat/message-list.ts +3 -2
- package/src/theme/resolvers/chat/quick-reply-chip.ts +9 -28
- package/src/theme/resolvers/chat/system-line.ts +5 -6
- package/src/theme/resolvers/chat/thread-header.ts +60 -12
- package/src/theme/resolvers/checkbox.ts +6 -6
- package/src/theme/resolvers/chip.ts +5 -6
- package/src/theme/resolvers/divider.ts +3 -3
- package/src/theme/resolvers/iconButton.ts +5 -5
- package/src/theme/resolvers/input.ts +12 -7
- package/src/theme/resolvers/listItem.ts +16 -17
- package/src/theme/resolvers/multiSelect.ts +23 -16
- package/src/theme/resolvers/searchBar.ts +14 -7
- package/src/theme/resolvers/select.ts +22 -15
- package/src/theme/resolvers/switch.ts +5 -4
- package/src/theme/resolvers/themedPressable.ts +6 -7
- package/src/theme/themes/createHightideTheme.ts +13 -4
- package/src/theme/types/components/chat.ts +54 -3
- package/src/theme/types/components/multiSelect.ts +1 -0
- package/src/theme/types/components/select.ts +1 -0
- package/src/theme/types/layout.ts +13 -7
- package/src/theme/types/semantics.ts +2 -1
- package/src/theme/types/theme.ts +40 -12
- package/src/theme/types/typography.ts +9 -4
- package/src/theme/adapters/container-adapter.ts +0 -323
- package/src/theme/adapters/defined.ts +0 -11
- package/src/theme/adapters/icon-style-adapter.ts +0 -10
- package/src/theme/adapters/text-style-adapter.ts +0 -16
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { toContainerStyle } from '../adapters/container-adapter'
|
|
2
|
-
import { toIconStyle } from '../adapters/icon-style-adapter'
|
|
3
|
-
import { toTextStyle } from '../adapters/text-style-adapter'
|
|
4
1
|
import type {
|
|
5
2
|
ThemedPressableIconStyle,
|
|
6
3
|
ThemedPressableState,
|
|
@@ -15,6 +12,8 @@ import {
|
|
|
15
12
|
type ComponentThemeResolver
|
|
16
13
|
} from '../types/resolver'
|
|
17
14
|
|
|
15
|
+
import { StyleAdapterUtils } from '../adapters'
|
|
16
|
+
|
|
18
17
|
export const toThemedPressableThemeResolvers: ComponentThemeResolver<ThemedPressableThemeResolvers> = ({
|
|
19
18
|
themeTokens,
|
|
20
19
|
semanticTokens,
|
|
@@ -35,14 +34,14 @@ export const toThemedPressableThemeResolvers: ComponentThemeResolver<ThemedPress
|
|
|
35
34
|
|
|
36
35
|
return {
|
|
37
36
|
container: createStyleResolver((state: ThemedPressableState): ThemedPressableStyle => ({
|
|
38
|
-
...
|
|
37
|
+
...StyleAdapterUtils.container(resolve(state).container),
|
|
39
38
|
alignSelf: 'flex-start',
|
|
40
39
|
})),
|
|
41
40
|
stateLayer: createStyleResolver((state: ThemedPressableState): ThemedPressableStyle => {
|
|
42
41
|
const tokens = resolve(state)
|
|
43
42
|
|
|
44
43
|
return {
|
|
45
|
-
...
|
|
44
|
+
...StyleAdapterUtils.container(tokens.stateLayer),
|
|
46
45
|
position: 'absolute',
|
|
47
46
|
top: 0,
|
|
48
47
|
right: 0,
|
|
@@ -51,10 +50,10 @@ export const toThemedPressableThemeResolvers: ComponentThemeResolver<ThemedPress
|
|
|
51
50
|
}
|
|
52
51
|
}),
|
|
53
52
|
icon: createValueResolver((state: ThemedPressableState): ThemedPressableIconStyle => (
|
|
54
|
-
|
|
53
|
+
StyleAdapterUtils.icon(resolve(state).icon)
|
|
55
54
|
)),
|
|
56
55
|
text: createStyleResolver((state: ThemedPressableState): ThemedPressableTextStyle => (
|
|
57
|
-
|
|
56
|
+
StyleAdapterUtils.text(resolve(state).text)
|
|
58
57
|
)),
|
|
59
58
|
}
|
|
60
59
|
}
|
|
@@ -58,6 +58,7 @@ const resolveElementLayouts = (themeTokens: ThemeTokens): ElementLayoutTokens =>
|
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
const bindSemantics = (themeTokens: ThemeTokens): HightideThemeSemantics => ({
|
|
61
|
+
...resolveElementLayouts(themeTokens),
|
|
61
62
|
coloringColorVariant: (parameter) => hightideSemanticTokenResolvers.coloringColorVariant({
|
|
62
63
|
themeTokens,
|
|
63
64
|
...parameter,
|
|
@@ -114,19 +115,27 @@ const bindSemantics = (themeTokens: ThemeTokens): HightideThemeSemantics => ({
|
|
|
114
115
|
|
|
115
116
|
export const createHightideTheme = (themeTokens: ThemeTokens): HightideTheme => ({
|
|
116
117
|
colors: themeTokens.color,
|
|
117
|
-
|
|
118
|
+
fontFamilies: themeTokens.fontFamilies,
|
|
119
|
+
fontWeights: themeTokens.fontWeights,
|
|
120
|
+
fontSizing: themeTokens.fontSizing,
|
|
118
121
|
typography: themeTokens.typography,
|
|
119
122
|
icongraphy: themeTokens.icongraphy,
|
|
123
|
+
size: themeTokens.size,
|
|
120
124
|
spacing: themeTokens.spacing,
|
|
121
|
-
|
|
122
|
-
borderRadius: themeTokens.
|
|
123
|
-
|
|
125
|
+
padding: themeTokens.padding,
|
|
126
|
+
borderRadius: themeTokens.borderRadius,
|
|
127
|
+
borderWidth: themeTokens.borderWidth,
|
|
128
|
+
elevation: themeTokens.elevation,
|
|
124
129
|
shadow: {
|
|
125
130
|
raised: themeTokens.elevation.level1,
|
|
126
131
|
container: themeTokens.elevation.level2,
|
|
127
132
|
popover: themeTokens.elevation.level3,
|
|
128
133
|
dialog: themeTokens.elevation.level4,
|
|
129
134
|
},
|
|
135
|
+
motion: themeTokens.motion,
|
|
136
|
+
focusOutline: themeTokens.focusOutline,
|
|
137
|
+
config: themeTokens.config,
|
|
138
|
+
semantics: bindSemantics(themeTokens),
|
|
130
139
|
components: {
|
|
131
140
|
button: toButtonThemeResolvers({
|
|
132
141
|
themeTokens,
|
|
@@ -24,12 +24,15 @@ export type ChatConversationRowState = InteractionState & {
|
|
|
24
24
|
isSelected?: boolean,
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export type
|
|
27
|
+
export type ChatConversationRowContentContainerStyle = ViewStyle
|
|
28
|
+
export type ChatConversationRowHeaderRowStyle = ViewStyle
|
|
29
|
+
export type ChatConversationRowMessageRowStyle = ViewStyle
|
|
28
30
|
export type ChatConversationRowTitleStyle = TextStyle
|
|
29
31
|
export type ChatConversationRowTimestampStyle = TextStyle
|
|
30
32
|
export type ChatConversationRowPreviewStyle = TextStyle
|
|
31
33
|
export type ChatConversationRowUnreadBadgeStyle = ViewStyle
|
|
32
34
|
export type ChatConversationRowUnreadBadgeTextStyle = TextStyle
|
|
35
|
+
export type ChatConversationRowSentIndicatorStyle = IconStyle
|
|
33
36
|
|
|
34
37
|
export type ChatConversationListStyle = ViewStyle
|
|
35
38
|
export type ChatConversationListHeaderStyle = ViewStyle
|
|
@@ -92,13 +95,40 @@ export type ChatMessageComposerStyle = ViewStyle
|
|
|
92
95
|
export type ChatMessageComposerInputStyle = ViewStyle & TextStyle
|
|
93
96
|
|
|
94
97
|
export type ChatConversationRowThemeResolvers = {
|
|
95
|
-
|
|
98
|
+
pressable: StyleResolverFunction<
|
|
99
|
+
ChatConversationRowState,
|
|
100
|
+
{
|
|
101
|
+
container: StyleResolverFunction<
|
|
102
|
+
PressableState,
|
|
103
|
+
PressableContainerStyle
|
|
104
|
+
>,
|
|
105
|
+
stateLayer: StyleResolverFunction<
|
|
106
|
+
PressableState,
|
|
107
|
+
PressableStateLayerStyle
|
|
108
|
+
>,
|
|
109
|
+
text: StyleResolverFunction<
|
|
110
|
+
PressableState,
|
|
111
|
+
PressableTextStyle
|
|
112
|
+
>,
|
|
113
|
+
icon: StyleResolverFunction<
|
|
114
|
+
PressableState,
|
|
115
|
+
PressableIconStyle
|
|
116
|
+
>,
|
|
117
|
+
}
|
|
118
|
+
>,
|
|
119
|
+
contentContainer: StyleResolverFunction<ChatConversationRowState, ChatConversationRowContentContainerStyle>,
|
|
120
|
+
headerRow: StyleResolverFunction<ChatConversationRowState, ChatConversationRowHeaderRowStyle>,
|
|
121
|
+
messageRow: StyleResolverFunction<ChatConversationRowState, ChatConversationRowMessageRowStyle>,
|
|
96
122
|
title: StyleResolverFunction<ChatConversationRowState, ChatConversationRowTitleStyle>,
|
|
97
123
|
timestamp: StyleResolverFunction<ChatConversationRowState, ChatConversationRowTimestampStyle>,
|
|
98
124
|
preview: StyleResolverFunction<ChatConversationRowState, ChatConversationRowPreviewStyle>,
|
|
99
125
|
unreadBadge: StyleResolverFunction<Record<string, never>, ChatConversationRowUnreadBadgeStyle>,
|
|
100
126
|
unreadBadgeText: StyleResolverFunction<Record<string, never>, ChatConversationRowUnreadBadgeTextStyle>,
|
|
101
|
-
sentIndicator: StyleResolverFunction<Record<string, never>,
|
|
127
|
+
sentIndicator: StyleResolverFunction<Record<string, never>, ChatConversationRowSentIndicatorStyle>,
|
|
128
|
+
avatar: StyleResolverFunction<
|
|
129
|
+
AvatarState,
|
|
130
|
+
AvatarThemeResolvers
|
|
131
|
+
>,
|
|
102
132
|
}
|
|
103
133
|
|
|
104
134
|
export type ChatConversationListThemeResolvers = {
|
|
@@ -116,6 +146,27 @@ export type ChatThreadHeaderThemeResolvers = {
|
|
|
116
146
|
AvatarState,
|
|
117
147
|
AvatarThemeResolvers
|
|
118
148
|
>,
|
|
149
|
+
pressable: StyleResolverFunction<
|
|
150
|
+
Record<string, never>,
|
|
151
|
+
{
|
|
152
|
+
container: StyleResolverFunction<
|
|
153
|
+
PressableState,
|
|
154
|
+
PressableContainerStyle
|
|
155
|
+
>,
|
|
156
|
+
stateLayer: StyleResolverFunction<
|
|
157
|
+
PressableState,
|
|
158
|
+
PressableStateLayerStyle
|
|
159
|
+
>,
|
|
160
|
+
text: StyleResolverFunction<
|
|
161
|
+
PressableState,
|
|
162
|
+
PressableTextStyle
|
|
163
|
+
>,
|
|
164
|
+
icon: StyleResolverFunction<
|
|
165
|
+
PressableState,
|
|
166
|
+
PressableIconStyle
|
|
167
|
+
>,
|
|
168
|
+
}
|
|
169
|
+
>,
|
|
119
170
|
}
|
|
120
171
|
|
|
121
172
|
export type ChatMessageListThemeResolvers = {
|
|
@@ -37,6 +37,7 @@ export type MultiSelectCheckboxIconStyle = IconStyle
|
|
|
37
37
|
|
|
38
38
|
export type MultiSelectThemeResolvers = {
|
|
39
39
|
trigger: StyleResolverFunction<MultiSelectState, MultiSelectTriggerStyle>,
|
|
40
|
+
stateLayer: StyleResolverFunction<MultiSelectState, MultiSelectTriggerStyle>,
|
|
40
41
|
triggerText: StyleResolverFunction<MultiSelectState, SelectTriggerTextStyle>,
|
|
41
42
|
overlay: SimpleStyleResolver<SelectOverlayStyle>,
|
|
42
43
|
menu: StyleResolverFunction<SelectMenuState, SelectMenuStyle>,
|
|
@@ -48,6 +48,7 @@ export type SelectEmptyTextStyle = TextStyle
|
|
|
48
48
|
|
|
49
49
|
export type SelectThemeResolvers = {
|
|
50
50
|
trigger: StyleResolverFunction<SelectState, SelectTriggerStyle>,
|
|
51
|
+
stateLayer: StyleResolverFunction<SelectState, SelectTriggerStyle>,
|
|
51
52
|
triggerText: StyleResolverFunction<SelectState, SelectTriggerTextStyle>,
|
|
52
53
|
icon: StyleResolverFunction<SelectState, SelectIconStyle>,
|
|
53
54
|
overlay: SimpleStyleResolver<SelectOverlayStyle>,
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
} from '@helpwave/hightide-design/semantic-token-resolvers'
|
|
4
|
-
import type {
|
|
2
|
+
ThemeBorderRadiusTokens,
|
|
5
3
|
ThemeBorderWidthTokens,
|
|
6
4
|
ThemeElevationTokens,
|
|
7
|
-
|
|
5
|
+
ThemeMotionTokens,
|
|
6
|
+
ThemePaddingTokens,
|
|
7
|
+
ThemeSizeTokens,
|
|
8
8
|
ThemeSpacingTokens
|
|
9
9
|
} from '@helpwave/hightide-design/theme-tokens'
|
|
10
10
|
|
|
11
|
+
export type HightideSize = ThemeSizeTokens
|
|
12
|
+
|
|
11
13
|
export type HightideSpacing = ThemeSpacingTokens
|
|
12
14
|
|
|
13
|
-
export type
|
|
15
|
+
export type HightidePadding = ThemePaddingTokens
|
|
16
|
+
|
|
17
|
+
export type HightideBorderRadius = ThemeBorderRadiusTokens
|
|
18
|
+
|
|
19
|
+
export type HightideBorderWidth = ThemeBorderWidthTokens
|
|
14
20
|
|
|
15
|
-
export type
|
|
21
|
+
export type HightideElevation = ThemeElevationTokens
|
|
16
22
|
|
|
17
|
-
export type
|
|
23
|
+
export type HightideMotion = ThemeMotionTokens
|
|
18
24
|
|
|
19
25
|
export type HightideShadowToken = ThemeElevationTokens[keyof ThemeElevationTokens]
|
|
20
26
|
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
ColoringToken,
|
|
8
8
|
ContainerLayoutToken,
|
|
9
9
|
ControlElementLayoutToken,
|
|
10
|
+
ElementLayoutTokens,
|
|
10
11
|
InputColoringTokens,
|
|
11
12
|
InsideControlElementLayoutToken,
|
|
12
13
|
PressableColoringTokens,
|
|
@@ -69,4 +70,4 @@ export type HightideThemeSemantics = {
|
|
|
69
70
|
asDescription: BoundSemanticResolver<{
|
|
70
71
|
color: HexColorToken,
|
|
71
72
|
}, HexColorToken>,
|
|
72
|
-
}
|
|
73
|
+
} & ElementLayoutTokens
|
package/src/theme/types/theme.ts
CHANGED
|
@@ -1,39 +1,67 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
OutlineToken,
|
|
3
|
+
ThemeColorTokens,
|
|
4
|
+
ThemeConfigTokens
|
|
5
|
+
} from '@helpwave/hightide-design/theme-tokens'
|
|
2
6
|
|
|
3
7
|
import type { HightideComponentThemes } from './components/hightide'
|
|
4
8
|
import type { HightideIcongraphy } from './icongraphy'
|
|
5
9
|
import type {
|
|
6
|
-
HightideBorder,
|
|
7
10
|
HightideBorderRadius,
|
|
8
|
-
|
|
11
|
+
HightideBorderWidth,
|
|
12
|
+
HightideElevation,
|
|
13
|
+
HightideMotion,
|
|
14
|
+
HightidePadding,
|
|
9
15
|
HightideShadow,
|
|
16
|
+
HightideSize,
|
|
10
17
|
HightideSpacing
|
|
11
18
|
} from './layout'
|
|
12
19
|
import type { HightideThemeSemantics } from './semantics'
|
|
13
|
-
import type {
|
|
20
|
+
import type {
|
|
21
|
+
HightideFontFamilies,
|
|
22
|
+
HightideFontSizing,
|
|
23
|
+
HightideFontWeights,
|
|
24
|
+
HightideTypography
|
|
25
|
+
} from './typography'
|
|
14
26
|
|
|
15
27
|
export type Theme = {
|
|
16
28
|
colors: Record<string, unknown>,
|
|
17
|
-
|
|
18
|
-
|
|
29
|
+
fontFamilies: Record<string, unknown>,
|
|
30
|
+
fontWeights: Record<string, unknown>,
|
|
31
|
+
fontSizing: Record<string, unknown>,
|
|
19
32
|
typography: Record<string, unknown>,
|
|
20
33
|
icongraphy: Record<string, unknown>,
|
|
34
|
+
size: Record<string, unknown>,
|
|
21
35
|
spacing: Record<string, unknown>,
|
|
22
|
-
|
|
36
|
+
padding: Record<string, unknown>,
|
|
23
37
|
borderRadius: Record<string, unknown>,
|
|
24
|
-
|
|
38
|
+
borderWidth: Record<string, unknown>,
|
|
39
|
+
elevation: Record<string, unknown>,
|
|
25
40
|
shadow: Record<string, unknown>,
|
|
41
|
+
motion: Record<string, unknown>,
|
|
42
|
+
focusOutline: Record<string, unknown>,
|
|
43
|
+
config: Record<string, unknown>,
|
|
44
|
+
semantics: Record<string, unknown>,
|
|
45
|
+
components: Record<string, unknown>,
|
|
26
46
|
}
|
|
27
47
|
|
|
28
48
|
export type HightideTheme = Theme & {
|
|
29
49
|
colors: ThemeColorTokens & Theme['colors'],
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
fontFamilies: HightideFontFamilies & Theme['fontFamilies'],
|
|
51
|
+
fontWeights: HightideFontWeights & Theme['fontWeights'],
|
|
52
|
+
fontSizing: HightideFontSizing & Theme['fontSizing'],
|
|
32
53
|
typography: HightideTypography & Theme['typography'],
|
|
33
54
|
icongraphy: HightideIcongraphy & Theme['icongraphy'],
|
|
55
|
+
size: HightideSize & Theme['size'],
|
|
34
56
|
spacing: HightideSpacing & Theme['spacing'],
|
|
35
|
-
|
|
57
|
+
padding: HightidePadding & Theme['padding'],
|
|
36
58
|
borderRadius: HightideBorderRadius & Theme['borderRadius'],
|
|
37
|
-
|
|
59
|
+
borderWidth: HightideBorderWidth & Theme['borderWidth'],
|
|
60
|
+
elevation: HightideElevation & Theme['elevation'],
|
|
38
61
|
shadow: HightideShadow & Theme['shadow'],
|
|
62
|
+
motion: HightideMotion & Theme['motion'],
|
|
63
|
+
focusOutline: OutlineToken & Theme['focusOutline'],
|
|
64
|
+
config: ThemeConfigTokens & Theme['config'],
|
|
65
|
+
semantics: HightideThemeSemantics & Theme['semantics'],
|
|
66
|
+
components: HightideComponentThemes & Theme['components'],
|
|
39
67
|
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
ThemeFontFamilyTokens,
|
|
3
|
+
ThemeFontSizingTokens,
|
|
4
|
+
ThemeFontWeightTokens,
|
|
3
5
|
ThemeTypographySize,
|
|
6
|
+
ThemeTypographyTokens,
|
|
4
7
|
TypographyStyleToken
|
|
5
8
|
} from '@helpwave/hightide-design/theme-tokens'
|
|
6
9
|
|
|
7
10
|
export type TextStyle = TypographyStyleToken
|
|
8
11
|
|
|
9
|
-
export type
|
|
12
|
+
export type HightideFontFamilies = ThemeFontFamilyTokens
|
|
10
13
|
|
|
11
|
-
export type
|
|
14
|
+
export type HightideFontWeights = ThemeFontWeightTokens
|
|
12
15
|
|
|
13
|
-
export type
|
|
16
|
+
export type HightideFontSizing = ThemeFontSizingTokens
|
|
17
|
+
|
|
18
|
+
export type HightideTypography = ThemeTypographyTokens
|
|
14
19
|
|
|
15
20
|
export type TypographySizes = ThemeTypographySize
|
|
16
21
|
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import type { ViewStyle } from 'react-native'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
AlignSelfToken,
|
|
5
|
-
AxisAligmentToken,
|
|
6
|
-
BorderRadiusToken,
|
|
7
|
-
BorderToken,
|
|
8
|
-
ContainerTokens,
|
|
9
|
-
DirectionalToken,
|
|
10
|
-
LayoutDirectionToken,
|
|
11
|
-
MarginToken,
|
|
12
|
-
PaddingToken
|
|
13
|
-
} from '@helpwave/hightide-design/component-token-resolvers'
|
|
14
|
-
import {
|
|
15
|
-
defaultWritingMode,
|
|
16
|
-
resolveDirectionalTokens
|
|
17
|
-
} from '@helpwave/hightide-design/component-token-resolvers'
|
|
18
|
-
import type { ColorToken, HexColorToken } from '@helpwave/hightide-design/primitive-tokens'
|
|
19
|
-
import type { ShadowToken } from '@helpwave/hightide-design/theme-tokens'
|
|
20
|
-
import { HexColorUtils } from '@helpwave/hightide-design/utils'
|
|
21
|
-
|
|
22
|
-
import { defined } from './defined'
|
|
23
|
-
|
|
24
|
-
export const toShadowStyle = (shadow: ShadowToken): ViewStyle => defined({
|
|
25
|
-
boxShadow: [{
|
|
26
|
-
color: shadow.color,
|
|
27
|
-
offsetX: shadow.x,
|
|
28
|
-
offsetY: shadow.y,
|
|
29
|
-
blurRadius: shadow.blur,
|
|
30
|
-
spreadDistance: shadow.spread,
|
|
31
|
-
}],
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
const toFlexDirection = (
|
|
35
|
-
direction?: LayoutDirectionToken
|
|
36
|
-
): ViewStyle['flexDirection'] => {
|
|
37
|
-
if (direction === undefined) {
|
|
38
|
-
return undefined
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return direction === 'horizontal' ? 'row' : 'column'
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const toJustifyContent = (
|
|
45
|
-
alignment?: AxisAligmentToken
|
|
46
|
-
): ViewStyle['justifyContent'] => {
|
|
47
|
-
if (alignment === undefined) {
|
|
48
|
-
return undefined
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (alignment === 'start') {
|
|
52
|
-
return 'flex-start'
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (alignment === 'end') {
|
|
56
|
-
return 'flex-end'
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return 'center'
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const toAlignItems = (
|
|
63
|
-
alignment?: AxisAligmentToken
|
|
64
|
-
): ViewStyle['alignItems'] => {
|
|
65
|
-
if (alignment === undefined) {
|
|
66
|
-
return undefined
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (alignment === 'start') {
|
|
70
|
-
return 'flex-start'
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (alignment === 'end') {
|
|
74
|
-
return 'flex-end'
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return 'center'
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const toAlignSelf = (
|
|
81
|
-
alignment?: AlignSelfToken
|
|
82
|
-
): ViewStyle['alignSelf'] => {
|
|
83
|
-
if (alignment === undefined) {
|
|
84
|
-
return undefined
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (alignment === 'start') {
|
|
88
|
-
return 'flex-start'
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (alignment === 'end') {
|
|
92
|
-
return 'flex-end'
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return alignment
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const toAlignContent = (
|
|
99
|
-
alignment?: AlignSelfToken
|
|
100
|
-
): ViewStyle['alignContent'] => {
|
|
101
|
-
if (alignment === undefined) {
|
|
102
|
-
return undefined
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (alignment === 'start') {
|
|
106
|
-
return 'flex-start'
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (alignment === 'end') {
|
|
110
|
-
return 'flex-end'
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return alignment
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const toBorderRadiusStyle = (
|
|
117
|
-
borderRadius?: BorderRadiusToken
|
|
118
|
-
): ViewStyle => {
|
|
119
|
-
if (borderRadius === undefined) {
|
|
120
|
-
return {}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (borderRadius.type === 'all') {
|
|
124
|
-
return defined({ borderRadius: borderRadius.value })
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return defined({
|
|
128
|
-
borderTopLeftRadius: borderRadius.topLeft,
|
|
129
|
-
borderTopRightRadius: borderRadius.topRight,
|
|
130
|
-
borderBottomLeftRadius: borderRadius.bottomLeft,
|
|
131
|
-
borderBottomRightRadius: borderRadius.bottomRight,
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const toDirectionalBorderWidths = (
|
|
136
|
-
width?: DirectionalToken<number>
|
|
137
|
-
): ViewStyle => {
|
|
138
|
-
if (width === undefined) {
|
|
139
|
-
return {}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
switch (width.type) {
|
|
143
|
-
case 'all':
|
|
144
|
-
return defined({
|
|
145
|
-
borderWidth: width.value,
|
|
146
|
-
})
|
|
147
|
-
case 'physicalAxis':
|
|
148
|
-
return defined({
|
|
149
|
-
borderTopWidth: width.vertical,
|
|
150
|
-
borderBottomWidth: width.vertical,
|
|
151
|
-
borderLeftWidth: width.horizontal,
|
|
152
|
-
borderRightWidth: width.horizontal,
|
|
153
|
-
})
|
|
154
|
-
case 'physicalSide':
|
|
155
|
-
return defined({
|
|
156
|
-
borderTopWidth: width.top,
|
|
157
|
-
borderRightWidth: width.right,
|
|
158
|
-
borderBottomWidth: width.bottom,
|
|
159
|
-
borderLeftWidth: width.left,
|
|
160
|
-
})
|
|
161
|
-
case 'logicalAxis':
|
|
162
|
-
return defined({
|
|
163
|
-
borderTopWidth: width.block,
|
|
164
|
-
borderBottomWidth: width.block,
|
|
165
|
-
borderStartWidth: width.inline,
|
|
166
|
-
borderEndWidth: width.inline,
|
|
167
|
-
})
|
|
168
|
-
case 'logicalSide':
|
|
169
|
-
return defined({
|
|
170
|
-
borderStartWidth: width.inlineStart,
|
|
171
|
-
borderEndWidth: width.inlineEnd,
|
|
172
|
-
borderTopWidth: width.blockStart,
|
|
173
|
-
borderBottomWidth: width.blockEnd,
|
|
174
|
-
})
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const toDirectionalBorderColors = (
|
|
179
|
-
color?: NonNullable<BorderToken['color']>
|
|
180
|
-
): ViewStyle => {
|
|
181
|
-
if (color === undefined) {
|
|
182
|
-
return {}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
switch (color.type) {
|
|
186
|
-
case 'all':
|
|
187
|
-
return defined({
|
|
188
|
-
borderColor: color.value,
|
|
189
|
-
})
|
|
190
|
-
case 'physicalAxis':
|
|
191
|
-
return defined({
|
|
192
|
-
borderTopColor: color.vertical,
|
|
193
|
-
borderBottomColor: color.vertical,
|
|
194
|
-
borderLeftColor: color.horizontal,
|
|
195
|
-
borderRightColor: color.horizontal,
|
|
196
|
-
})
|
|
197
|
-
case 'physicalSide':
|
|
198
|
-
return defined({
|
|
199
|
-
borderTopColor: color.top,
|
|
200
|
-
borderRightColor: color.right,
|
|
201
|
-
borderBottomColor: color.bottom,
|
|
202
|
-
borderLeftColor: color.left,
|
|
203
|
-
})
|
|
204
|
-
case 'logicalAxis':
|
|
205
|
-
return defined({
|
|
206
|
-
borderTopColor: color.block,
|
|
207
|
-
borderBottomColor: color.block,
|
|
208
|
-
borderStartColor: color.inline,
|
|
209
|
-
borderEndColor: color.inline,
|
|
210
|
-
})
|
|
211
|
-
case 'logicalSide':
|
|
212
|
-
return defined({
|
|
213
|
-
borderStartColor: color.inlineStart,
|
|
214
|
-
borderEndColor: color.inlineEnd,
|
|
215
|
-
borderTopColor: color.blockStart,
|
|
216
|
-
borderBottomColor: color.blockEnd,
|
|
217
|
-
})
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const toBorderStyle = (border?: BorderToken): ViewStyle => {
|
|
222
|
-
if (border === undefined) {
|
|
223
|
-
return {}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return defined({
|
|
227
|
-
...toDirectionalBorderWidths(border.width),
|
|
228
|
-
...toDirectionalBorderColors(border.color),
|
|
229
|
-
borderStyle: border.style,
|
|
230
|
-
})
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const toPaddingStyle = (padding?: PaddingToken): ViewStyle => {
|
|
234
|
-
if (padding === undefined) {
|
|
235
|
-
return {}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const sides = resolveDirectionalTokens([padding], defaultWritingMode)
|
|
239
|
-
|
|
240
|
-
return defined({
|
|
241
|
-
paddingTop: sides.top,
|
|
242
|
-
paddingRight: sides.right,
|
|
243
|
-
paddingBottom: sides.bottom,
|
|
244
|
-
paddingLeft: sides.left,
|
|
245
|
-
})
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const toMarginStyle = (margin?: MarginToken): ViewStyle => {
|
|
249
|
-
if (margin === undefined) {
|
|
250
|
-
return {}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const sides = resolveDirectionalTokens([margin], defaultWritingMode)
|
|
254
|
-
|
|
255
|
-
return defined({
|
|
256
|
-
marginTop: sides.top,
|
|
257
|
-
marginRight: sides.right,
|
|
258
|
-
marginBottom: sides.bottom,
|
|
259
|
-
marginLeft: sides.left,
|
|
260
|
-
})
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export const toContainerStyle = (tokens: ContainerTokens): ViewStyle => defined({
|
|
264
|
-
display: 'flex',
|
|
265
|
-
overflow: tokens.overflow,
|
|
266
|
-
flexWrap: tokens.layout?.flexWrap,
|
|
267
|
-
flexDirection: toFlexDirection(tokens.layout?.direction),
|
|
268
|
-
justifyContent: toJustifyContent(tokens.layout?.mainAxisAlignment),
|
|
269
|
-
alignItems: toAlignItems(tokens.layout?.crossAxisAligment),
|
|
270
|
-
alignContent: toAlignContent(tokens.layout?.alignContent),
|
|
271
|
-
alignSelf: toAlignSelf(tokens.layout?.alignSelf),
|
|
272
|
-
backgroundColor: tokens.backgroundColor,
|
|
273
|
-
opacity: tokens.opacity,
|
|
274
|
-
...toBorderStyle(tokens.border),
|
|
275
|
-
height: tokens.size?.height,
|
|
276
|
-
width: tokens.size?.width,
|
|
277
|
-
minHeight: tokens.size?.minHeight,
|
|
278
|
-
minWidth: tokens.size?.minWidth,
|
|
279
|
-
maxHeight: tokens.size?.maxHeight,
|
|
280
|
-
maxWidth: tokens.size?.maxWidth,
|
|
281
|
-
...toBorderRadiusStyle(tokens.shape?.borderRadius),
|
|
282
|
-
...toPaddingStyle(tokens.padding),
|
|
283
|
-
...toMarginStyle(tokens.margin),
|
|
284
|
-
gap: tokens.layout?.gap,
|
|
285
|
-
outlineColor: tokens.outline?.color,
|
|
286
|
-
outlineOffset: tokens.outline?.offset,
|
|
287
|
-
outlineWidth: tokens.outline?.width,
|
|
288
|
-
outlineStyle: tokens.outline?.style,
|
|
289
|
-
...(tokens.decoration?.shadow ? toShadowStyle(tokens.decoration.shadow) : {}),
|
|
290
|
-
})
|
|
291
|
-
|
|
292
|
-
const blendWithStateLayer = (
|
|
293
|
-
base: ColorToken | undefined,
|
|
294
|
-
tint: ColorToken
|
|
295
|
-
): ColorToken | undefined => {
|
|
296
|
-
if (base === undefined || tint === 'transparent' || base === 'transparent') {
|
|
297
|
-
return base
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return HexColorUtils.blend(base as HexColorToken, tint as HexColorToken)
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
export const toContainerStyleWithStateLayer = (
|
|
304
|
-
container: ContainerTokens,
|
|
305
|
-
stateLayer?: ContainerTokens
|
|
306
|
-
): ViewStyle => {
|
|
307
|
-
const tint = stateLayer?.backgroundColor ?? 'transparent'
|
|
308
|
-
const borderColor = container.border?.color
|
|
309
|
-
|
|
310
|
-
return toContainerStyle({
|
|
311
|
-
...container,
|
|
312
|
-
backgroundColor: blendWithStateLayer(container.backgroundColor, tint),
|
|
313
|
-
border: container.border === undefined ? undefined : {
|
|
314
|
-
...container.border,
|
|
315
|
-
color: borderColor?.type === 'all'
|
|
316
|
-
? {
|
|
317
|
-
type: 'all',
|
|
318
|
-
value: blendWithStateLayer(borderColor.value, tint) ?? borderColor.value,
|
|
319
|
-
}
|
|
320
|
-
: borderColor,
|
|
321
|
-
},
|
|
322
|
-
})
|
|
323
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IconTokens } from '@helpwave/hightide-design/component-token-resolvers'
|
|
2
|
-
|
|
3
|
-
import type { IconStyle } from '../../icons'
|
|
4
|
-
import { defined } from './defined'
|
|
5
|
-
|
|
6
|
-
export const toIconStyle = (tokens: IconTokens): IconStyle => defined({
|
|
7
|
-
color: tokens.color,
|
|
8
|
-
size: tokens.size,
|
|
9
|
-
strokeWidth: tokens.strokeWidth,
|
|
10
|
-
})
|