-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
252 additions
and
18,692 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import React from 'react' | ||
import { UnistylesTheme } from 'react-native-unistyles' | ||
import { ExampleScreen } from './ExampleScreen' | ||
import * as Examples from './examples' | ||
import { theme } from './styles' | ||
|
||
export const App: React.FunctionComponent = () => ( | ||
<UnistylesTheme theme={theme}> | ||
<ExampleScreen /> | ||
<Examples.Extreme /> | ||
</UnistylesTheme> | ||
) |
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,33 @@ | ||
import React from 'react' | ||
import { Text, View } from 'react-native' | ||
import { createStyles, useStyles } from '../styles' | ||
|
||
// Use breakpoints for some values | ||
export const Breakpoints: React.FunctionComponent = () => { | ||
const { styles } = useStyles(stylesheet) | ||
|
||
return ( | ||
<View style={styles.dynamicContainer}> | ||
<Text> | ||
Breakpoint demo, resize me :) | ||
</Text> | ||
<Text> | ||
Row or column? | ||
</Text> | ||
</View> | ||
) | ||
} | ||
|
||
const stylesheet = createStyles(theme => ({ | ||
dynamicContainer: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
flexDirection: { | ||
// hints for breakpoints are available here | ||
xs: 'row', | ||
md: 'column' | ||
}, | ||
backgroundColor: theme.colors.sky | ||
} | ||
})) |
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,46 @@ | ||
import React from 'react' | ||
import { Text, View } from 'react-native' | ||
import { createStyles, useStyles } from '../styles' | ||
|
||
// Edge cases | ||
export const Extreme: React.FunctionComponent = () => { | ||
const { styles } = useStyles(stylesheet) | ||
|
||
return ( | ||
<View style={styles.dynamicContainer(1)}> | ||
<Text style={styles.text}> | ||
Edge cases | ||
</Text> | ||
</View> | ||
) | ||
} | ||
|
||
const stylesheet = createStyles(theme => ({ | ||
// dynamic function with hints | ||
dynamicContainer: (flex: number) => ({ | ||
flex, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: { | ||
xs: theme.colors.oak, | ||
md: theme.colors.sky | ||
}, | ||
shadowOpacity: 20 | ||
}), | ||
text: { | ||
height: 100, | ||
shadowOpacity: { | ||
xs: 20 | ||
}, | ||
transform: [ | ||
{ | ||
scale: 2 | ||
}, | ||
{ | ||
translateX: { | ||
sm: 10 | ||
} | ||
} | ||
] | ||
} | ||
})) |
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,36 @@ | ||
import React from 'react' | ||
import { Text, View } from 'react-native' | ||
import { createStyles, useStyles } from '../styles' | ||
|
||
// Media queries | ||
export const MediaQueries: React.FunctionComponent = () => { | ||
const { styles } = useStyles(stylesheet) | ||
|
||
return ( | ||
<View style={styles.dynamicContainer}> | ||
<Text> | ||
Media queries, resize me :) | ||
</Text> | ||
<Text> | ||
Row of column | ||
</Text> | ||
</View> | ||
) | ||
} | ||
|
||
const stylesheet = createStyles(theme => ({ | ||
dynamicContainer: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
flexDirection: { | ||
xs: 'row', | ||
// mixed queries | ||
':w[400]': 'column' | ||
}, | ||
backgroundColor: { | ||
':w[, 300]:h[100]': theme.colors.oak, | ||
':w[301]': theme.colors.barbie | ||
} | ||
} | ||
})) |
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,25 @@ | ||
import React from 'react' | ||
import { Text, View, StyleSheet } from 'react-native' | ||
import { useStyles } from '../styles' | ||
|
||
// Compatibility between StyleSheet.create and useStyles | ||
// access theme from useStyles | ||
export const Minimal: React.FunctionComponent = () => { | ||
const { styles, theme } = useStyles(stylesheet) | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Text> | ||
I'm just a minimal example with {theme.colors.barbie} color | ||
</Text> | ||
</View> | ||
) | ||
} | ||
|
||
const stylesheet = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center' | ||
} | ||
}) |
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 React from 'react' | ||
import { Text, View } from 'react-native' | ||
import { createStyles, useStyles } from '../styles' | ||
|
||
// createStyles with StyleSheet.create compatible Object | ||
export const MinimalWithCreateStyles: React.FunctionComponent = () => { | ||
const { styles } = useStyles(stylesheet) | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Text style={styles.text}> | ||
I'm just a minimal example with createStyles | ||
</Text> | ||
</View> | ||
) | ||
} | ||
|
||
const stylesheet = createStyles({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
alignContent: 'space-between', | ||
resizeMode: 'contain' | ||
}, | ||
text: { | ||
borderWidth: 1, | ||
borderColor: 'purple', | ||
padding: 20 | ||
} | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export { Minimal } from './Minimal' | ||
export { MinimalWithCreateStyles } from './MinimalWithCreateStyles' | ||
export { Theme } from './Theme' | ||
export { Breakpoints } from './Breakpoints' | ||
export { MediaQueries } from './MediaQueries' | ||
export { Extreme } from './Extreme' |
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
Oops, something went wrong.