-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- refactor(foundation): refactor theme hierarchy
- feat(core): added group channel labels
- Loading branch information
Showing
17 changed files
with
472 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
...foundation/src/styles/appearanceHelper.ts → ...tion/src/styles/createAppearanceHelper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import type { AppearanceHelper, UIKitAppearance } from '../types'; | ||
import type { UIKitAppearance, UIKitTheme } from '../types'; | ||
|
||
/** | ||
* Appearance helper factory function | ||
* Return a function that returns a value matching with the current appearance among the input values. | ||
* @param appearance | ||
* @returns AppearanceHelper | ||
* @returns Function | ||
* */ | ||
const createAppearanceHelper = (appearance: UIKitAppearance): AppearanceHelper => ({ | ||
select(options) { | ||
const createAppearanceHelper = | ||
(appearance: UIKitAppearance): UIKitTheme['select'] => | ||
(options) => { | ||
const value = options[appearance ?? 'default'] ?? options['light'] ?? options['dark'] ?? options['default']; | ||
if (!value) throw Error('Not provided any selectable appearance values'); | ||
return value; | ||
}, | ||
}); | ||
}; | ||
|
||
export default createAppearanceHelper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/uikit-react-native-foundation/src/styles/themeFactory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Palette from '../theme/Palette'; | ||
import { createTypography } from '../theme/Typography'; | ||
import type { UIKitColors, UIKitTheme } from '../types'; | ||
import createAppearanceHelper from './createAppearanceHelper'; | ||
import createScaleFactor from './createScaleFactor'; | ||
import createStyleSheet from './createStyleSheet'; | ||
|
||
type Options = { | ||
appearance: UIKitTheme['appearance']; | ||
palette?: UIKitTheme['palette']; | ||
colors: (palette: UIKitTheme['palette']) => UIKitColors; | ||
scaleFactorOption?: { | ||
scaleFactor: UIKitTheme['scaleFactor']; | ||
applyToCreateStyleSheet: boolean; | ||
}; | ||
}; | ||
|
||
const defaultScaleFactor = createScaleFactor(); | ||
|
||
export const themeFactory = ({ appearance, scaleFactorOption, palette = Palette, colors }: Options): UIKitTheme => { | ||
if (scaleFactorOption?.applyToCreateStyleSheet) createStyleSheet.updateScaleFactor(scaleFactorOption.scaleFactor); | ||
const _scaleFactor = scaleFactorOption?.scaleFactor ?? defaultScaleFactor; | ||
|
||
return { | ||
appearance, | ||
palette, | ||
select: createAppearanceHelper(appearance), | ||
colors: colors(palette), | ||
scaleFactor: _scaleFactor, | ||
typography: createTypography({ shared: { fontFamily: 'System' } }, _scaleFactor), | ||
}; | ||
}; |
Oops, something went wrong.