@helpwave/hightide-native 0.0.1 → 0.0.5
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 +56 -0
- package/package.json +3 -3
- package/src/components/chat/ChatAttachmentCard.tsx +110 -0
- package/src/components/chat/ChatConversationList.tsx +72 -0
- package/src/components/chat/ChatConversationRow.tsx +153 -0
- package/src/components/chat/ChatDateDivider.tsx +55 -0
- package/src/components/chat/ChatMessageBubble.tsx +112 -0
- package/src/components/chat/ChatMessageCard.tsx +118 -0
- package/src/components/chat/ChatMessageComposer.tsx +115 -0
- package/src/components/chat/ChatMessageList.tsx +66 -0
- package/src/components/chat/ChatQuickReplyChip.tsx +72 -0
- package/src/components/chat/ChatSystemLine.tsx +68 -0
- package/src/components/chat/ChatThreadHeader.tsx +90 -0
- package/src/components/chat/index.ts +11 -0
- package/src/components/index.ts +4 -7
- package/src/components/menu/Menu.tsx +61 -0
- package/src/components/menu/MenuActionItem.tsx +90 -0
- package/src/components/menu/MenuItem.tsx +73 -0
- package/src/components/menu/MenuNavigationItem.tsx +90 -0
- package/src/components/menu/index.ts +4 -0
- package/src/components/user-interaction/Button.tsx +101 -0
- package/src/components/{Checkbox → user-interaction}/Checkbox.tsx +38 -16
- package/src/components/user-interaction/IconButton.tsx +95 -0
- package/src/components/{Input → user-interaction}/Input.tsx +35 -14
- package/src/components/{MultiSelect → user-interaction}/MultiSelect.tsx +47 -15
- package/src/components/{Select → user-interaction}/Select.tsx +44 -12
- package/src/components/user-interaction/index.ts +6 -0
- package/src/components/{Chip → visualization-and-display}/Chip.tsx +36 -20
- package/src/components/visualization-and-display/Icon.tsx +27 -0
- package/src/components/{Chip → visualization-and-display}/index.ts +1 -0
- package/src/global-contexts/HightideContext.ts +4 -1
- package/src/global-contexts/HightideProvider.tsx +22 -10
- package/src/global-contexts/hightide-config/HightideConfigUtils.ts +15 -12
- package/src/global-contexts/localization/LocalizationProvider.tsx +4 -2
- package/src/global-contexts/localization/forward-exports.ts +1 -0
- package/src/global-contexts/theme/ThemeContext.ts +11 -6
- package/src/global-contexts/theme/ThemeProvider.tsx +35 -38
- package/src/hooks/useMultiSelect.ts +1 -0
- package/src/hooks/useNativeKeyValueStore.ts +7 -1
- package/src/hooks/useSelect.ts +1 -0
- package/src/theme/resolvers/button.ts +38 -23
- package/src/theme/resolvers/chat.ts +418 -0
- package/src/theme/resolvers/checkbox.ts +26 -21
- package/src/theme/resolvers/chip.ts +32 -22
- package/src/theme/resolvers/coloring.ts +21 -17
- package/src/theme/resolvers/iconButton.ts +28 -18
- package/src/theme/resolvers/index.ts +2 -0
- package/src/theme/resolvers/input.ts +28 -19
- package/src/theme/resolvers/menu.ts +120 -0
- package/src/theme/resolvers/multiSelect.ts +39 -34
- package/src/theme/resolvers/select.ts +35 -30
- package/src/theme/themes/createTheme.ts +44 -15
- package/src/theme/themes/nativeThemes.ts +7 -6
- package/src/theme/types/color.ts +60 -0
- package/src/theme/types/components/button.ts +30 -0
- package/src/theme/types/components/chat.ts +198 -0
- package/src/theme/types/components/checkbox.ts +33 -0
- package/src/theme/types/components/chip.ts +30 -0
- package/src/theme/types/components/hightide.ts +42 -0
- package/src/theme/types/components/iconButton.ts +30 -0
- package/src/theme/types/components/index.ts +10 -0
- package/src/theme/types/components/input.ts +19 -0
- package/src/theme/types/components/menu.ts +57 -0
- package/src/theme/types/components/multiSelect.ts +47 -0
- package/src/theme/types/components/select.ts +47 -0
- package/src/theme/types/decoration.ts +11 -0
- package/src/theme/types/index.ts +4 -7
- package/src/theme/types/layout.ts +46 -0
- package/src/theme/types/resolver.ts +43 -1
- package/src/theme/types/theme.ts +14 -10
- package/src/theme/types/typography.ts +18 -0
- package/src/components/Button/Button.tsx +0 -101
- package/src/components/Button/index.ts +0 -1
- package/src/components/Checkbox/index.ts +0 -1
- package/src/components/IconButton/IconButton.tsx +0 -89
- package/src/components/IconButton/index.ts +0 -1
- package/src/components/Input/index.ts +0 -1
- package/src/components/MultiSelect/index.ts +0 -1
- package/src/components/Select/index.ts +0 -1
- package/src/icons/Icon.tsx +0 -35
- package/src/icons/index.ts +0 -1
- package/src/theme/types/button.ts +0 -41
- package/src/theme/types/checkbox.ts +0 -36
- package/src/theme/types/chip.ts +0 -41
- package/src/theme/types/components.ts +0 -17
- package/src/theme/types/iconButton.ts +0 -34
- package/src/theme/types/input.ts +0 -25
- package/src/theme/types/multiSelect.ts +0 -65
- package/src/theme/types/select.ts +0 -77
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
type ElementSize
|
|
6
|
-
} from '@helpwave/hightide-design'
|
|
7
|
-
import type { ReactNode } from 'react'
|
|
2
|
+
useMemo,
|
|
3
|
+
type ReactNode
|
|
4
|
+
} from 'react'
|
|
8
5
|
import {
|
|
9
6
|
Text,
|
|
10
7
|
View,
|
|
11
8
|
type StyleProp,
|
|
12
|
-
type TextStyle,
|
|
13
9
|
type ViewProps,
|
|
14
10
|
type ViewStyle
|
|
15
11
|
} from 'react-native'
|
|
16
|
-
|
|
17
|
-
import
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
coloringTypes,
|
|
15
|
+
type ColoringType
|
|
16
|
+
} from '@helpwave/hightide-design/helpers'
|
|
17
|
+
import type {
|
|
18
|
+
ChipColoringStyle,
|
|
19
|
+
ElementSize
|
|
20
|
+
} from '@helpwave/hightide-design/types'
|
|
21
|
+
|
|
22
|
+
import { useTheme } from '@/src/global-contexts/theme/ThemeContext'
|
|
23
|
+
import type {
|
|
24
|
+
ChipState,
|
|
25
|
+
ChipStyle,
|
|
26
|
+
ChipTextStyle
|
|
27
|
+
} from '@/src/theme/types/components/chip'
|
|
28
|
+
import type { StyleOverwrite } from '@/src/theme/types/resolver'
|
|
18
29
|
|
|
19
30
|
export type ChipSize = ElementSize
|
|
20
31
|
|
|
21
32
|
export type ChipColor = ColoringType
|
|
22
33
|
|
|
23
34
|
export const ChipUtil = {
|
|
24
|
-
colors:
|
|
35
|
+
colors: coloringTypes,
|
|
25
36
|
sizes: ['xs', 'sm', 'md', 'lg'] as const satisfies readonly ElementSize[],
|
|
26
37
|
coloringStyles: ['solid', 'tonal', 'outline', 'tonal-outline'] as const satisfies readonly ChipColoringStyle[],
|
|
27
38
|
}
|
|
@@ -32,8 +43,8 @@ export type ChipProps = Omit<ViewProps, 'children' | 'style'> & {
|
|
|
32
43
|
size?: ChipSize,
|
|
33
44
|
children?: ReactNode,
|
|
34
45
|
style?: StyleProp<ViewStyle>,
|
|
35
|
-
chipStyle?:
|
|
36
|
-
textStyle?:
|
|
46
|
+
chipStyle?: StyleOverwrite<ChipState, ChipStyle>,
|
|
47
|
+
textStyle?: StyleOverwrite<ChipState, ChipTextStyle>,
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
export const Chip = ({
|
|
@@ -47,24 +58,29 @@ export const Chip = ({
|
|
|
47
58
|
...props
|
|
48
59
|
}: ChipProps) => {
|
|
49
60
|
const { theme } = useTheme()
|
|
50
|
-
|
|
61
|
+
|
|
62
|
+
const state = useMemo((): ChipState => ({
|
|
51
63
|
size,
|
|
52
64
|
color,
|
|
53
65
|
coloringStyle,
|
|
54
|
-
}
|
|
66
|
+
}), [size, color, coloringStyle])
|
|
55
67
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
const resolvedChipStyle = useMemo(
|
|
69
|
+
() => theme.components.chip.chip(state, chipStyle),
|
|
70
|
+
[theme, state, chipStyle]
|
|
71
|
+
)
|
|
72
|
+
const resolvedTextStyle = useMemo(
|
|
73
|
+
() => theme.components.chip.text(state, textStyle),
|
|
74
|
+
[theme, state, textStyle]
|
|
75
|
+
)
|
|
60
76
|
|
|
61
77
|
return (
|
|
62
78
|
<View
|
|
63
79
|
{...props}
|
|
64
|
-
style={[
|
|
80
|
+
style={[resolvedChipStyle, style]}
|
|
65
81
|
>
|
|
66
82
|
{typeof children === 'string' || typeof children === 'number'
|
|
67
|
-
? <Text style={
|
|
83
|
+
? <Text style={resolvedTextStyle}>{children}</Text>
|
|
68
84
|
: children}
|
|
69
85
|
</View>
|
|
70
86
|
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react-native'
|
|
2
|
+
|
|
3
|
+
import type { ElementSize } from '@helpwave/hightide-design/types'
|
|
4
|
+
|
|
5
|
+
import { useTheme } from '@/src/global-contexts/theme/ThemeContext'
|
|
6
|
+
|
|
7
|
+
export type IconProps = {
|
|
8
|
+
icon: LucideIcon,
|
|
9
|
+
size?: ElementSize,
|
|
10
|
+
color?: string,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Icon = ({
|
|
14
|
+
icon: IconComponent,
|
|
15
|
+
size = 'md',
|
|
16
|
+
color,
|
|
17
|
+
}: IconProps) => {
|
|
18
|
+
const { theme } = useTheme()
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<IconComponent
|
|
22
|
+
size={theme.layout.icon[size].size}
|
|
23
|
+
strokeWidth={theme.layout.icon[size].strokeWidth}
|
|
24
|
+
color={color}
|
|
25
|
+
/>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
useMemo,
|
|
3
|
+
type PropsWithChildren
|
|
4
|
+
} from 'react'
|
|
5
|
+
|
|
4
6
|
import { useLocalization } from '@helpwave/hightide-utils/context/localization'
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import { hightideTranslation } from '@helpwave/hightide-utils/i18n'
|
|
8
|
+
import { ArrayUtil } from '@helpwave/hightide-utils/utils'
|
|
9
|
+
|
|
10
|
+
import { HightideContext } from '@/src/global-contexts/HightideContext'
|
|
11
|
+
import {
|
|
12
|
+
LocalizationProvider,
|
|
13
|
+
type LocalizationProviderProps
|
|
14
|
+
} from '@/src/global-contexts/localization/LocalizationProvider'
|
|
15
|
+
import { useTheme } from '@/src/global-contexts/theme/ThemeContext'
|
|
16
|
+
import {
|
|
17
|
+
ThemeProvider,
|
|
18
|
+
type ThemeProviderProps
|
|
19
|
+
} from '@/src/global-contexts/theme/ThemeProvider'
|
|
20
|
+
import {
|
|
21
|
+
TranslationProvider,
|
|
22
|
+
type TranslationProviderProps
|
|
23
|
+
} from '@/src/global-contexts/translation/forward-exports'
|
|
12
24
|
|
|
13
25
|
export type HightideProviderProps = PropsWithChildren & {
|
|
14
26
|
theme?: Omit<ThemeProviderProps, 'children'>,
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { SupportedThemesConfig } from '@helpwave/hightide-utils/context'
|
|
2
|
+
|
|
3
|
+
import type { SupportedLocalesConfig } from '@/src/global-contexts/localization/forward-exports'
|
|
4
|
+
import { themes } from '@/src/theme/themes/nativeThemes'
|
|
5
|
+
import type { Theme } from '@/src/theme/types/theme'
|
|
3
6
|
|
|
4
7
|
export const HightideConfigUtils = {
|
|
5
|
-
defaultSupportedLocales:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
defaultSupportedThemes:
|
|
10
|
-
{
|
|
11
|
-
theme: 'light',
|
|
8
|
+
defaultSupportedLocales: {
|
|
9
|
+
'de-DE': { localName: 'Deutsch' },
|
|
10
|
+
'en-US': { localName: 'English (US)' },
|
|
11
|
+
} as const satisfies SupportedLocalesConfig,
|
|
12
|
+
defaultSupportedThemes: {
|
|
13
|
+
light: {
|
|
12
14
|
nameTranslations: {
|
|
13
15
|
'de-DE': 'Hell',
|
|
14
16
|
'en-US': 'Light',
|
|
15
17
|
},
|
|
18
|
+
theme: themes.light
|
|
16
19
|
},
|
|
17
|
-
{
|
|
18
|
-
theme: 'dark',
|
|
20
|
+
dark: {
|
|
19
21
|
nameTranslations: {
|
|
20
22
|
'de-DE': 'Dunkel',
|
|
21
23
|
'en-US': 'Dark',
|
|
22
24
|
},
|
|
25
|
+
theme: themes.dark,
|
|
23
26
|
},
|
|
24
|
-
|
|
27
|
+
} as const satisfies SupportedThemesConfig<Theme>,
|
|
25
28
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react'
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
4
|
LocalizationProvider as LocalizationProviderBase,
|
|
4
5
|
type LocalizationProviderProps as LocalizationProviderPropsBase
|
|
5
6
|
} from '@helpwave/hightide-utils/context/localization'
|
|
6
|
-
|
|
7
|
-
import { HightideConfigUtils } from '
|
|
7
|
+
|
|
8
|
+
import { HightideConfigUtils } from '@/src/global-contexts/hightide-config/HightideConfigUtils'
|
|
9
|
+
import { useNativeKeyValueStore } from '@/src/hooks/useNativeKeyValueStore'
|
|
8
10
|
|
|
9
11
|
export type LocalizationProviderProps = PropsWithChildren
|
|
10
12
|
& Omit<LocalizationProviderPropsBase, 'store' | 'fallbackLocale' | 'supportedLocales'>
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext
|
|
4
|
+
} from 'react'
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
ThemeConfigValue,
|
|
8
|
+
ThemeInformation
|
|
9
|
+
} from '@/src/global-contexts/theme/forward-exports'
|
|
10
|
+
import type { Theme } from '@/src/theme/types/theme'
|
|
4
11
|
|
|
5
12
|
export type { ThemeInformation }
|
|
6
13
|
|
|
7
|
-
export type ThemeContextValue =
|
|
8
|
-
themeMode: ThemeMode,
|
|
9
|
-
theme: DesignTheme,
|
|
14
|
+
export type ThemeContextValue = ThemeConfigValue<Theme> & {
|
|
10
15
|
isInitialized: boolean,
|
|
11
16
|
}
|
|
12
17
|
|
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useMemo,
|
|
4
|
+
useState,
|
|
5
|
+
type PropsWithChildren
|
|
6
|
+
} from 'react'
|
|
2
7
|
import { Appearance } from 'react-native'
|
|
3
|
-
import { useNativeKeyValueStore } from '../../hooks/useNativeKeyValueStore'
|
|
4
|
-
import { getTheme, themes, type ThemeMode } from '../../theme'
|
|
5
|
-
import { HightideConfigUtils } from '../hightide-config/HightideConfigUtils'
|
|
6
|
-
import type { SystemTheme, ThemeInformation } from './forward-exports'
|
|
7
|
-
import { useCreateThemeConfig } from './forward-exports'
|
|
8
|
-
import { ThemeContext, useTheme, type ThemeContextValue } from './ThemeContext'
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
theme?: string | null,
|
|
12
|
-
systemTheme?: SystemTheme,
|
|
13
|
-
fallbackTheme?: ThemeMode,
|
|
14
|
-
supportedThemes?: readonly ThemeInformation[],
|
|
15
|
-
onChangedTheme?: (theme: string) => void,
|
|
16
|
-
}
|
|
9
|
+
import type { SupportedThemesConfig } from '@helpwave/hightide-utils/context'
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
import { HightideConfigUtils } from '@/src/global-contexts/hightide-config/HightideConfigUtils'
|
|
12
|
+
import {
|
|
13
|
+
ThemeContext,
|
|
14
|
+
useTheme,
|
|
15
|
+
type ThemeContextValue
|
|
16
|
+
} from '@/src/global-contexts/theme/ThemeContext'
|
|
17
|
+
import {
|
|
18
|
+
useCreateThemeConfig,
|
|
19
|
+
type SystemTheme
|
|
20
|
+
} from '@/src/global-contexts/theme/forward-exports'
|
|
21
|
+
import { useNativeKeyValueStore } from '@/src/hooks/useNativeKeyValueStore'
|
|
22
|
+
import type { ThemeMode } from '@/src/theme/themes/nativeThemes'
|
|
23
|
+
import type { Theme } from '@/src/theme/types/theme'
|
|
24
|
+
|
|
25
|
+
export type ThemeProviderProps<T> = PropsWithChildren & {
|
|
26
|
+
theme?: ThemeMode | null,
|
|
27
|
+
fallbackTheme?: ThemeMode,
|
|
28
|
+
supportedThemes?: SupportedThemesConfig<T>,
|
|
29
|
+
onChangedTheme?: (themeMode: string) => void,
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
export const useThemeMode = (): ThemeMode => {
|
|
@@ -34,7 +41,7 @@ const detectNativeSystemTheme = (): SystemTheme | undefined => {
|
|
|
34
41
|
return undefined
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
const useNativeSystemTheme = (enabled: boolean) => {
|
|
44
|
+
const useNativeSystemTheme = (enabled: boolean = true) => {
|
|
38
45
|
const [systemTheme, setSystemTheme] = useState<SystemTheme | undefined>(() =>
|
|
39
46
|
(enabled ? detectNativeSystemTheme() : undefined))
|
|
40
47
|
|
|
@@ -57,13 +64,11 @@ export const ThemeProvider = ({
|
|
|
57
64
|
children,
|
|
58
65
|
theme,
|
|
59
66
|
fallbackTheme = 'light',
|
|
60
|
-
systemTheme: systemThemeOverride,
|
|
61
67
|
supportedThemes = HightideConfigUtils.defaultSupportedThemes,
|
|
62
68
|
onChangedTheme,
|
|
63
|
-
}: ThemeProviderProps) => {
|
|
69
|
+
}: ThemeProviderProps<Theme>) => {
|
|
64
70
|
const store = useNativeKeyValueStore()
|
|
65
|
-
const
|
|
66
|
-
const systemTheme = systemThemeOverride ?? detectedSystemTheme
|
|
71
|
+
const systemTheme = useNativeSystemTheme()
|
|
67
72
|
|
|
68
73
|
const themeConfig = useCreateThemeConfig({
|
|
69
74
|
store,
|
|
@@ -74,27 +79,19 @@ export const ThemeProvider = ({
|
|
|
74
79
|
onChangedTheme,
|
|
75
80
|
})
|
|
76
81
|
|
|
77
|
-
const
|
|
78
|
-
const themeMode = resolveThemeMode(themeConfig.theme)
|
|
79
|
-
|
|
82
|
+
const contextValue = useMemo((): ThemeContextValue => {
|
|
80
83
|
return {
|
|
81
|
-
|
|
84
|
+
preferredThemeMode: themeConfig.preferredThemeMode,
|
|
82
85
|
setTheme: themeConfig.setTheme,
|
|
83
86
|
supportedThemes: themeConfig.supportedThemes,
|
|
84
|
-
themeMode,
|
|
85
|
-
theme:
|
|
87
|
+
themeMode: themeConfig.themeMode,
|
|
88
|
+
theme: themeConfig.theme,
|
|
86
89
|
isInitialized: store.isInitialized,
|
|
87
90
|
}
|
|
88
|
-
}, [
|
|
89
|
-
store.isInitialized,
|
|
90
|
-
themeConfig.preferredTheme,
|
|
91
|
-
themeConfig.setTheme,
|
|
92
|
-
themeConfig.supportedThemes,
|
|
93
|
-
themeConfig.theme,
|
|
94
|
-
])
|
|
91
|
+
}, [store.isInitialized, themeConfig.preferredThemeMode, themeConfig.setTheme, themeConfig.supportedThemes, themeConfig.theme, themeConfig.themeMode])
|
|
95
92
|
|
|
96
93
|
return (
|
|
97
|
-
<ThemeContext.Provider value={
|
|
94
|
+
<ThemeContext.Provider value={contextValue}>
|
|
98
95
|
{children}
|
|
99
96
|
</ThemeContext.Provider>
|
|
100
97
|
)
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useMemo,
|
|
4
|
+
useRef,
|
|
5
|
+
useState
|
|
6
|
+
} from 'react'
|
|
2
7
|
import AsyncStorage from '@react-native-async-storage/async-storage'
|
|
8
|
+
|
|
3
9
|
import type { SimpleValueStore } from '@helpwave/hightide-utils/hooks'
|
|
4
10
|
|
|
5
11
|
const storagePrefix = '@helpwave/hightide/'
|
package/src/hooks/useSelect.ts
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TextStyle,
|
|
3
|
+
ViewStyle
|
|
4
|
+
} from 'react-native'
|
|
5
|
+
|
|
1
6
|
import {
|
|
2
7
|
componentLayouts,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from '@helpwave/hightide-design'
|
|
9
|
-
|
|
10
|
-
import {
|
|
8
|
+
fontWeights
|
|
9
|
+
} from '@helpwave/hightide-design/tokens'
|
|
10
|
+
import type {
|
|
11
|
+
HightideDesignTokens as DesignTokensTheme,
|
|
12
|
+
ElementSize
|
|
13
|
+
} from '@helpwave/hightide-design/types'
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
isOutlineColoringStyle,
|
|
17
|
+
resolveColoringStyles
|
|
18
|
+
} from '@/src/theme/resolvers/coloring'
|
|
19
|
+
import type { HightideSemanticColors } from '@/src/theme/types/color'
|
|
20
|
+
import type {
|
|
21
|
+
ButtonState,
|
|
22
|
+
ButtonTheme
|
|
23
|
+
} from '@/src/theme/types/components/button'
|
|
24
|
+
import type { HightideComponentThemes } from '@/src/theme/types/components/hightide'
|
|
25
|
+
import { createStyleResolver } from '@/src/theme/types/resolver'
|
|
11
26
|
|
|
12
27
|
const buttonFontSizes: Record<ElementSize, number> = {
|
|
13
28
|
xs: 12,
|
|
@@ -17,8 +32,8 @@ const buttonFontSizes: Record<ElementSize, number> = {
|
|
|
17
32
|
}
|
|
18
33
|
|
|
19
34
|
export type CreateButtonThemeOptions = {
|
|
20
|
-
semantic:
|
|
21
|
-
coloring:
|
|
35
|
+
semantic: HightideSemanticColors,
|
|
36
|
+
coloring: HightideComponentThemes['coloring'],
|
|
22
37
|
}
|
|
23
38
|
|
|
24
39
|
export const createButtonTheme = ({
|
|
@@ -35,40 +50,40 @@ export const createButtonTheme = ({
|
|
|
35
50
|
const sizing = componentLayouts.element[size]
|
|
36
51
|
const outlinePadding = isOutlineColoringStyle(coloringStyle)
|
|
37
52
|
|
|
38
|
-
const button:
|
|
53
|
+
const button: ViewStyle = {
|
|
39
54
|
flexDirection: 'row',
|
|
40
55
|
alignItems: 'center',
|
|
41
56
|
justifyContent: 'center',
|
|
42
57
|
backgroundColor: resolved.backgroundColor,
|
|
43
58
|
borderColor: resolved.borderColor,
|
|
44
59
|
borderWidth: resolved.borderWidth,
|
|
45
|
-
paddingVertical:
|
|
46
|
-
paddingHorizontal:
|
|
47
|
-
gap:
|
|
48
|
-
minWidth:
|
|
49
|
-
minHeight:
|
|
50
|
-
borderRadius:
|
|
60
|
+
paddingVertical: outlinePadding ? padding.paddingYOutline : padding.paddingY,
|
|
61
|
+
paddingHorizontal: outlinePadding ? padding.paddingXOutline : padding.paddingX,
|
|
62
|
+
gap: padding.gap,
|
|
63
|
+
minWidth: padding.minWidth,
|
|
64
|
+
minHeight: sizing.height,
|
|
65
|
+
borderRadius: padding.borderRadius,
|
|
51
66
|
opacity: state.isDisabled ? 0.6 : 1,
|
|
52
67
|
}
|
|
53
68
|
|
|
54
|
-
const text:
|
|
69
|
+
const text: TextStyle = {
|
|
55
70
|
color: resolved.color,
|
|
56
71
|
fontSize: buttonFontSizes[size],
|
|
57
|
-
fontWeight:
|
|
72
|
+
fontWeight: fontWeights.semibold,
|
|
58
73
|
}
|
|
59
74
|
|
|
60
75
|
return { button, text }
|
|
61
76
|
}
|
|
62
77
|
|
|
63
78
|
return {
|
|
64
|
-
button: (state) => resolveState(state).button,
|
|
65
|
-
text: (state) => resolveState(state).text,
|
|
79
|
+
button: createStyleResolver((state) => resolveState(state).button),
|
|
80
|
+
text: createStyleResolver((state) => resolveState(state).text),
|
|
66
81
|
}
|
|
67
82
|
}
|
|
68
83
|
|
|
69
84
|
export const createButtonThemeFromDesign = (theme: DesignTokensTheme): ButtonTheme => {
|
|
70
85
|
return createButtonTheme({
|
|
71
|
-
semantic: theme.
|
|
72
|
-
coloring: theme.coloring,
|
|
86
|
+
semantic: theme.semanticColors,
|
|
87
|
+
coloring: theme.coloring as HightideComponentThemes['coloring'],
|
|
73
88
|
})
|
|
74
89
|
}
|