-
Notifications
You must be signed in to change notification settings - Fork 33
feat: scoped theme #393
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
Merged
feat: scoped theme #393
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
97acf37
feat: scoped theme
Brentlok d61a527
chore: move variant variables to the scope
Brentlok 5733bfe
feat: move variant selectors to scope
Brentlok f1e8751
feat: web visitors to support scoped themes
Brentlok b3b47e5
feat: web scoped themes for hooks and hoc
Brentlok c62b005
feat: native scoped theme
Brentlok 6708125
test: ScopedTheme tests
Brentlok e3b762c
feat: scoped theme tests after changing the theme
Brentlok ac13056
chore: revert expo-example/App.tsx
Brentlok f5e4a9d
chore: fix tests on ci
Brentlok 465350c
chore: multiple minor improvements
Brentlok f5ef46c
chore: exclude example folders from language stats
Brentlok e2d6da9
feat: support useUniwind hook in scoped theme
Brentlok 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
Some comments aren't visible on the classic Files Changed page.
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Exclude HTML | ||
| *.html linguist-detectable=false | ||
| *.htm linguist-detectable=false | ||
|
|
||
| # Exclude Kotlin | ||
| *.kt linguist-detectable=false | ||
| *.kts linguist-detectable=false | ||
|
|
||
| # Exclude JavaScript | ||
| *.js linguist-detectable=false | ||
| *.jsx linguist-detectable=false | ||
| *.mjs linguist-detectable=false | ||
| *.cjs linguist-detectable=false | ||
|
|
||
| # Exclude Ruby | ||
| *.rb linguist-detectable=false | ||
|
|
||
| # Exclude Swift | ||
| *.swift linguist-detectable=false |
Large diffs are not rendered by default.
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
17 changes: 17 additions & 0 deletions
17
packages/uniwind/src/components/ScopedTheme/ScopedTheme.native.tsx
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,17 @@ | ||
| import React, { useMemo } from 'react' | ||
| import { UniwindContext } from '../../core/context' | ||
| import { ThemeName, UniwindContextType } from '../../core/types' | ||
|
|
||
| type ScopedThemeProps = { | ||
| theme: ThemeName | ||
| } | ||
|
|
||
| export const ScopedTheme: React.FC<React.PropsWithChildren<ScopedThemeProps>> = ({ theme, children }) => { | ||
| const value = useMemo<UniwindContextType>(() => ({ scopedTheme: theme }), [theme]) | ||
|
|
||
| return ( | ||
| <UniwindContext.Provider value={value}> | ||
| {children} | ||
| </UniwindContext.Provider> | ||
| ) | ||
| } |
19 changes: 19 additions & 0 deletions
19
packages/uniwind/src/components/ScopedTheme/ScopedTheme.tsx
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,19 @@ | ||
| import React, { useMemo } from 'react' | ||
| import { UniwindContext } from '../../core/context' | ||
| import type { ThemeName, UniwindContextType } from '../../core/types' | ||
|
|
||
| type ScopedThemeProps = { | ||
| theme: ThemeName | ||
| } | ||
|
|
||
| export const ScopedTheme: React.FC<React.PropsWithChildren<ScopedThemeProps>> = ({ theme, children }) => { | ||
| const value = useMemo<UniwindContextType>(() => ({ scopedTheme: theme }), [theme]) | ||
|
|
||
| return ( | ||
| <UniwindContext.Provider value={value}> | ||
| <div className={theme} style={{ display: 'contents' }}> | ||
| {children} | ||
| </div> | ||
| </UniwindContext.Provider> | ||
| ) | ||
| } |
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 @@ | ||
| export * from './ScopedTheme' |
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { createContext, useContext } from 'react' | ||
| import type { ThemeName } from './types' | ||
|
|
||
| export const UniwindContext = createContext({ | ||
| scopedTheme: null as ThemeName | null, | ||
| }) | ||
|
|
||
| export const useUniwindContext = () => useContext(UniwindContext) | ||
|
|
||
| UniwindContext.displayName = 'UniwindContext' |
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
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.