-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Theme switching: Add TypeScript types #24178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
grgia
merged 43 commits into
Expensify:main
from
margelo:@chrispader/theme-switching-ts-types
Nov 6, 2023
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
2da64c9
add ts type for theme
899d38e
adapt light and dark theme to ts type
e089833
use light theme in ThemeProvider
b32f538
adapt colors to new ts type
21787ba
change usage of "default.js" to "dark.js"
0e02b13
fix: rename back dark.ts
1d2de3f
Merge branch 'main' into @chrispader/theme-switching-ts-types
2ba934c
add TODO comment about renaming default.ts
4b10b95
fix: update outdated comment
84c4731
fix: add TODO comment
429e2b6
fix: add types for the rest of theme switching logic
b7b1179
fix: type remaining file with TODO
b77e4d0
Merge branch 'main' into @chrispader/theme-switching-ts-types
f69116a
fix: remove theme spreading and abstraction
08f5b4f
fix: changed colors
fd4e5aa
fix: remove more diffs to main
c794fd1
fix: typo
10f4778
update todo comments
dba25a2
fix: naming
283467a
Merge branch 'ts/style/styles-refactor' into @chrispader/theme-switch…
0bbcd56
fix: update styles.ts
2b6f412
feat: update types int ThemeStylesProvider logic
b2d6054
Merge branch 'main' into @chrispader/theme-switching-ts-types
e4d4a10
fix: merge main
3f28300
enforce consistent themes
fb20af7
fix: move ThemeColors to types.ts
33d0bc8
fix: make colors non optional
0b7a872
fix: add remaining color in light theme
6a41699
Merge branch 'main' into @chrispader/theme-switching-ts-types
8fb99cc
Merge branch 'main' into @chrispader/theme-switching-ts-types
6f0eb4c
Merge branch 'main' into @chrispader/theme-switching-ts-types
58a59de
remove TODO
2caad03
replace comment
ef2771c
remove TODO
23bcb92
remove TODO block
5a3cbad
Merge branch 'main' into @chrispader/theme-switching-ts-types
e70f1a9
Merge branch 'main' into @chrispader/theme-switching-ts-types
0b54f57
Merge branch 'main' into @chrispader/theme-switching-ts-types
bbdb468
Merge branch 'main' into @chrispader/theme-switching-ts-types
chrispader bb89e03
Merge branch 'main' into @chrispader/theme-switching-ts-types
chrispader 0c74c17
fix: imports and remove TODO blocks
chrispader 0eb2fe6
Merge branch 'main' into @chrispader/theme-switching-ts-types
chrispader b46f0b2
fix: prettier
chrispader File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 +1,6 @@ | ||
| import React from 'react'; | ||
| import styles from './styles'; | ||
| import styles, {type Styles} from './styles'; | ||
|
|
||
| const ThemeStylesContext = React.createContext(styles); | ||
| const ThemeStylesContext = React.createContext<Styles>(styles); | ||
|
|
||
| export default ThemeStylesContext; |
This file contains hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,7 @@ | ||
| import React from 'react'; | ||
| import darkTheme from './default'; | ||
| import {ThemeColors} from './types'; | ||
|
|
||
| const ThemeContext = React.createContext<ThemeColors>(darkTheme); | ||
|
|
||
| export default ThemeContext; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,8 +1,89 @@ | ||
| import DeepRecord from '@src/types/utils/DeepRecord'; | ||
| import defaultTheme from './default'; | ||
| type Color = string; | ||
|
|
||
| type ThemeBase = DeepRecord<string, string>; | ||
| type ThemeColors = { | ||
| // Figma keys | ||
| appBG: Color; | ||
| splashBG: Color; | ||
| highlightBG: Color; | ||
| border: Color; | ||
| borderLighter: Color; | ||
| borderFocus: Color; | ||
| icon: Color; | ||
| iconMenu: Color; | ||
| iconHovered: Color; | ||
| iconSuccessFill: Color; | ||
| iconReversed: Color; | ||
| iconColorfulBackground: Color; | ||
| textSupporting: Color; | ||
| text: Color; | ||
| textColorfulBackground: Color; | ||
| link: Color; | ||
| linkHover: Color; | ||
| buttonDefaultBG: Color; | ||
| buttonHoveredBG: Color; | ||
| buttonPressedBG: Color; | ||
| danger: Color; | ||
| dangerHover: Color; | ||
| dangerPressed: Color; | ||
| warning: Color; | ||
| success: Color; | ||
| successHover: Color; | ||
| successPressed: Color; | ||
| transparent: Color; | ||
| signInPage: Color; | ||
| dangerSection: Color; | ||
|
|
||
| type ThemeDefault = typeof defaultTheme; | ||
| // Additional keys | ||
| overlay: Color; | ||
| inverse: Color; | ||
| shadow: Color; | ||
| componentBG: Color; | ||
| hoverComponentBG: Color; | ||
| activeComponentBG: Color; | ||
| signInSidebar: Color; | ||
| sidebar: Color; | ||
| sidebarHover: Color; | ||
| heading: Color; | ||
| textLight: Color; | ||
| textDark: Color; | ||
| textReversed: Color; | ||
| textBackground: Color; | ||
| textMutedReversed: Color; | ||
| textError: Color; | ||
| offline: Color; | ||
| modalBackground: Color; | ||
| cardBG: Color; | ||
| cardBorder: Color; | ||
| spinner: Color; | ||
| unreadIndicator: Color; | ||
| placeholderText: Color; | ||
| heroCard: Color; | ||
| uploadPreviewActivityIndicator: Color; | ||
| dropUIBG: Color; | ||
| receiptDropUIBG: Color; | ||
| checkBox: Color; | ||
| pickerOptionsTextColor: Color; | ||
| imageCropBackgroundColor: Color; | ||
| fallbackIconColor: Color; | ||
| reactionActiveBackground: Color; | ||
| reactionActiveText: Color; | ||
| badgeAdHoc: Color; | ||
| badgeAdHocHover: Color; | ||
| mentionText: Color; | ||
| mentionBG: Color; | ||
| ourMentionText: Color; | ||
| ourMentionBG: Color; | ||
| tooltipSupportingText: Color; | ||
| tooltipPrimaryText: Color; | ||
| skeletonLHNIn: Color; | ||
| skeletonLHNOut: Color; | ||
| QRLogo: Color; | ||
| starDefaultBG: Color; | ||
| loungeAccessOverlay: Color; | ||
| mapAttributionText: Color; | ||
| white: Color; | ||
|
|
||
| export type {ThemeBase, ThemeDefault}; | ||
| PAGE_BACKGROUND_COLORS: Record<string, Color>; | ||
| }; | ||
|
|
||
| export {type ThemeColors, type Color}; |
5 changes: 3 additions & 2 deletions
5
src/styles/themes/useTheme.js → src/styles/themes/useTheme.ts
This file contains hidden or 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
18 changes: 10 additions & 8 deletions
18
src/styles/themes/useThemePreference.js → src/styles/themes/useThemePreference.ts
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.