-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
a9bae99
commit 2c71673
Showing
22 changed files
with
591 additions
and
39 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
9 changes: 0 additions & 9 deletions
9
packages/mobile/src/harmony-native/components/Text/Text.test.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
packages/mobile/src/harmony-native/foundations/color/color.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,19 @@ | ||
import { primitiveTheme } from './primitive' | ||
import { semanticTheme } from './semantic' | ||
|
||
export const colorTheme = { | ||
day: { | ||
...primitiveTheme.day, | ||
...semanticTheme.day | ||
}, | ||
dark: { | ||
...primitiveTheme.dark, | ||
...semanticTheme.dark | ||
}, | ||
matrix: { | ||
...primitiveTheme.matrix, | ||
...semanticTheme.matrix | ||
} | ||
} | ||
|
||
export type ColorTheme = typeof colorTheme |
2 changes: 2 additions & 0 deletions
2
packages/mobile/src/harmony-native/foundations/color/index.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,2 @@ | ||
export * from './primitive' | ||
export * from './color' |
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
104 changes: 104 additions & 0 deletions
104
packages/mobile/src/harmony-native/foundations/color/semantic.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,104 @@ | ||
import type { Theme } from '../types' | ||
|
||
import type { GradientColor } from './primitive' | ||
import { primitiveTheme } from './primitive' | ||
|
||
export type SemanticColors = { | ||
textIcon: { | ||
heading: GradientColor | ||
default: string | ||
subdued: string | ||
disabled: string | ||
} | ||
background: { | ||
default: string | ||
white: string | ||
surface1: string | ||
surface2: string | ||
} | ||
border: { | ||
default: string | ||
strong: string | ||
} | ||
focus: string | ||
status: { | ||
error: string | ||
warning: string | ||
success: string | ||
} | ||
} | ||
|
||
export const semanticTheme: Record<Theme, SemanticColors> = { | ||
day: { | ||
textIcon: { | ||
heading: primitiveTheme.day.special.gradient, | ||
default: primitiveTheme.day.neutral.neutral, | ||
subdued: primitiveTheme.day.neutral['n-400'], | ||
disabled: primitiveTheme.day.neutral['n-150'] | ||
}, | ||
background: { | ||
default: primitiveTheme.day.special.background, | ||
white: primitiveTheme.day.special.white, | ||
surface1: primitiveTheme.day.neutral['n-25'], | ||
surface2: primitiveTheme.day.neutral['n-100'] | ||
}, | ||
border: { | ||
default: primitiveTheme.day.neutral['n-100'], | ||
strong: primitiveTheme.day.neutral['n-150'] | ||
}, | ||
focus: primitiveTheme.day.secondary.secondary, | ||
status: { | ||
error: primitiveTheme.day.special.red, | ||
warning: primitiveTheme.day.special.orange, | ||
success: primitiveTheme.day.special.green | ||
} | ||
}, | ||
dark: { | ||
textIcon: { | ||
heading: primitiveTheme.dark.special.gradient, | ||
default: primitiveTheme.dark.neutral.neutral, | ||
subdued: primitiveTheme.dark.neutral['n-400'], | ||
disabled: primitiveTheme.dark.neutral['n-150'] | ||
}, | ||
background: { | ||
default: primitiveTheme.dark.special.background, | ||
white: primitiveTheme.dark.special.white, | ||
surface1: primitiveTheme.dark.neutral['n-25'], | ||
surface2: primitiveTheme.dark.neutral['n-100'] | ||
}, | ||
border: { | ||
default: primitiveTheme.dark.neutral['n-100'], | ||
strong: primitiveTheme.dark.neutral['n-150'] | ||
}, | ||
focus: primitiveTheme.dark.secondary.secondary, | ||
status: { | ||
error: primitiveTheme.dark.special.red, | ||
warning: primitiveTheme.dark.special.orange, | ||
success: primitiveTheme.dark.special.green | ||
} | ||
}, | ||
matrix: { | ||
textIcon: { | ||
heading: primitiveTheme.matrix.special.gradient, | ||
default: primitiveTheme.matrix.neutral.neutral, | ||
subdued: primitiveTheme.matrix.neutral['n-400'], | ||
disabled: primitiveTheme.matrix.neutral['n-150'] | ||
}, | ||
background: { | ||
default: primitiveTheme.matrix.special.background, | ||
white: primitiveTheme.matrix.special.white, | ||
surface1: primitiveTheme.matrix.neutral['n-25'], | ||
surface2: primitiveTheme.matrix.neutral['n-100'] | ||
}, | ||
border: { | ||
default: primitiveTheme.matrix.neutral['n-100'], | ||
strong: primitiveTheme.matrix.neutral['n-150'] | ||
}, | ||
focus: primitiveTheme.matrix.secondary.secondary, | ||
status: { | ||
error: primitiveTheme.matrix.special.red, | ||
warning: primitiveTheme.matrix.special.orange, | ||
success: primitiveTheme.matrix.special.green | ||
} | ||
} | ||
} |
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 +1,3 @@ | ||
export * from './color/primitives' | ||
export * from './color' | ||
export * from './typography' | ||
export * from './theme' |
24 changes: 24 additions & 0 deletions
24
packages/mobile/src/harmony-native/foundations/theme/ThemeProvider.tsx
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,24 @@ | ||
import type { ReactNode } from 'react' | ||
import { createContext } from 'react' | ||
|
||
import type { Theme } from '../types' | ||
|
||
type ThemeContextType = { | ||
theme: Theme | ||
} | ||
|
||
export const ThemeContext = createContext<ThemeContextType>({ | ||
theme: 'day' | ||
}) | ||
|
||
type ThemeProviderProps = { | ||
theme: Theme | ||
children: ReactNode | ||
} | ||
|
||
export const ThemeProvider = (props: ThemeProviderProps) => { | ||
const { children, theme } = props | ||
return ( | ||
<ThemeContext.Provider value={{ theme }}>{children}</ThemeContext.Provider> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/mobile/src/harmony-native/foundations/theme/index.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,3 @@ | ||
export * from './makeStyles' | ||
export * from './ThemeProvider' | ||
export * from './useTheme' |
31 changes: 31 additions & 0 deletions
31
packages/mobile/src/harmony-native/foundations/theme/makeStyles.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,31 @@ | ||
import { useContext } from 'react' | ||
|
||
import { StyleSheet } from 'react-native' | ||
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native' | ||
|
||
import { ThemeContext } from './ThemeProvider' | ||
import type { HarmonyTheme } from './theme' | ||
import { darkTheme, dayTheme, matrixTheme } from './theme' | ||
|
||
export type NamedStyles<T> = { | ||
[P in keyof T]: | ||
| ViewStyle | ||
| TextStyle | ||
| ImageStyle | ||
| (ViewStyle & { fill: string }) // For SVGs | ||
} | ||
|
||
export const makeStyles = <T extends NamedStyles<T> | NamedStyles<any>>( | ||
styles: (theme: HarmonyTheme) => T | NamedStyles<T> | ||
) => { | ||
const harmonyStylesheets = { | ||
day: StyleSheet.create(styles(dayTheme)), | ||
dark: StyleSheet.create(styles(darkTheme)), | ||
matrix: StyleSheet.create(styles(matrixTheme)) | ||
} | ||
|
||
return function useStyles() { | ||
const { theme } = useContext(ThemeContext) | ||
return harmonyStylesheets[theme] | ||
} | ||
} |
Oops, something went wrong.