-
Notifications
You must be signed in to change notification settings - Fork 957
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(theme): style provider cache service * refactor(theme) adopt to eva exports * refactor(theme): move app container -> style provider * refactor(theme): split style specs * refactor(theme): split theme specs * refactor(theme): move types to common type file * refactor(theme): expect style values to match snapshot * test(theme): fix radio snapshot * test(theme): add style consumer uncovered cases tests * build(package): update eva dependency * refactor(framework): adopt to eva package * refactor(playground): adopt to eva package * refactor(framework): adopt to eva package * refactor(theme): style creation to style consumer service * refactor(package): adopt to eva exports * refactor(framework): code re-arrange * fix(package): update eva dependency path
- Loading branch information
1 parent
2c86a03
commit 4872a85
Showing
54 changed files
with
3,176 additions
and
3,759 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
Large diffs are not rendered by default.
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
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,4 +1,3 @@ | ||
export * from './type'; | ||
export * from './mappingContext'; | ||
export { | ||
MappingProvider, | ||
|
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,67 @@ | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
import { render } from 'react-native-testing-library'; | ||
import { | ||
ThemeMappingType, | ||
ThemeMapType, | ||
} from 'eva/packages/common'; | ||
import { | ||
MappingContext, | ||
MappingContextValueType, | ||
} from './mappingContext'; | ||
import { | ||
MappingProvider, | ||
Props as MappingProviderProps, | ||
} from './mappingProvider.component'; | ||
|
||
describe('@mapping: ui component checks', () => { | ||
|
||
const json = (object: any) => JSON.stringify(object); | ||
|
||
const Provider = (props: MappingProviderProps): React.ReactElement<MappingProviderProps> => ( | ||
<MappingProvider {...props}/> | ||
); | ||
|
||
const withMapping = (Component: React.ComponentClass<any>): React.ReactElement<any> => ( | ||
<MappingContext.Consumer>{(receivedValue: MappingContextValueType) => ( | ||
<Component | ||
testID='@mapping/consumer' | ||
mapping={receivedValue.mapping} | ||
styles={receivedValue.styles}/> | ||
)}</MappingContext.Consumer> | ||
); | ||
|
||
interface Props { | ||
mapping: ThemeMappingType; | ||
styles: any; | ||
} | ||
|
||
const Tree = (props: Props) => ( | ||
<Provider mapping={props.mapping} styles={props.styles}> | ||
{withMapping(View)} | ||
</Provider> | ||
); | ||
|
||
describe('* consumer', () => { | ||
const mapping: ThemeMappingType = {}; | ||
const styles: ThemeMapType = {}; | ||
|
||
it('receives mapping prop', () => { | ||
|
||
const component = render(<Tree mapping={mapping} styles={styles}/>); | ||
const consumerComponent = component.getByTestId('@mapping/consumer'); | ||
|
||
expect(json(consumerComponent.props.mapping)).toEqual(json(mapping)); | ||
}); | ||
|
||
it('receives styles prop', () => { | ||
|
||
const component = render(<Tree mapping={mapping} styles={styles}/>); | ||
const consumerComponent = component.getByTestId('@mapping/consumer'); | ||
|
||
expect(json(consumerComponent.props.styles)).toEqual(json(styles)); | ||
}); | ||
|
||
}); | ||
|
||
}); |
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,6 +1,17 @@ | ||
import React from 'react'; | ||
import { ThemeMappingType } from './type'; | ||
import { | ||
ThemeMappingType, | ||
ThemeMapType, | ||
} from 'eva/packages/common'; | ||
|
||
const defaultValue: ThemeMappingType = {}; | ||
export interface MappingContextValueType { | ||
mapping: ThemeMappingType; | ||
styles: ThemeMapType; | ||
} | ||
|
||
const defaultValue: MappingContextValueType = { | ||
mapping: {}, | ||
styles: {}, | ||
}; | ||
|
||
export const MappingContext = React.createContext(defaultValue); |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './type'; | ||
export { | ||
StyleProvider, | ||
Props as StyleProviderProps, | ||
|
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
Oops, something went wrong.