-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for open and closed ranges
- Loading branch information
Showing
7 changed files
with
156 additions
and
8 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
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,59 @@ | ||
import React from 'react' | ||
import { Text, View } from 'react-native' | ||
import { createStyleSheet, useStyles, UnistylesRegistry, UnistylesRuntime } from 'react-native-unistyles' | ||
import { DemoScreen } from '../components' | ||
import { darkTheme, lightTheme, premiumTheme } from '../styles' | ||
import { useLazyRegistryForDemo } from '../hooks' | ||
|
||
export const MediaQueriesOpenRanges: React.FunctionComponent = () => { | ||
useLazyRegistryForDemo(() => { | ||
UnistylesRegistry | ||
.addThemes({ | ||
light: lightTheme, | ||
dark: darkTheme, | ||
premium: premiumTheme | ||
}) | ||
.addConfig({ | ||
adaptiveThemes: true | ||
}) | ||
}) | ||
|
||
const { styles } = useStyles(stylesheet) | ||
|
||
return ( | ||
<DemoScreen> | ||
<View style={styles.container}> | ||
<Text style={styles.text}> | ||
This demo has media queries for width and height with open ranges | ||
</Text> | ||
<Text style={styles.text}> | ||
Open range uses `(` or `)` instead of `[` or `]` | ||
</Text> | ||
<Text style={styles.text}> | ||
Your window dimensions are: {UnistylesRuntime.screen.width}x{UnistylesRuntime.screen.height} | ||
</Text> | ||
<Text> | ||
Rotate or resize the window to see the changes | ||
</Text> | ||
</View> | ||
</DemoScreen> | ||
) | ||
} | ||
|
||
const stylesheet = createStyleSheet(theme => ({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
paddingHorizontal: 20, | ||
backgroundColor: { | ||
':w[, 430):h[, 932)': theme.colors.backgroundColor, | ||
':w[430]:h[, 932]': theme.colors.aloes | ||
}, | ||
rowGap: 20 | ||
}, | ||
text: { | ||
textAlign: 'center', | ||
color: theme.colors.typography | ||
} | ||
})) |
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,61 @@ | ||
import React from 'react' | ||
import { Text, View } from 'react-native' | ||
import { createStyleSheet, useStyles, UnistylesRegistry, UnistylesRuntime } from 'react-native-unistyles' | ||
import { DemoScreen } from '../components' | ||
import { breakpoints, darkTheme, lightTheme, premiumTheme } from '../styles' | ||
import { useLazyRegistryForDemo } from '../hooks' | ||
|
||
export const MixedMediaQueries: React.FunctionComponent = () => { | ||
useLazyRegistryForDemo(() => { | ||
UnistylesRegistry | ||
.addThemes({ | ||
light: lightTheme, | ||
dark: darkTheme, | ||
premium: premiumTheme | ||
}) | ||
.addBreakpoints(breakpoints) | ||
.addConfig({ | ||
adaptiveThemes: true | ||
}) | ||
}) | ||
|
||
const { styles } = useStyles(stylesheet) | ||
|
||
return ( | ||
<DemoScreen> | ||
<View style={styles.container}> | ||
<Text style={styles.text}> | ||
This demo has media queries for width and height and user defined breakpoints | ||
</Text> | ||
<Text style={styles.text}> | ||
Media queries have bigger priority than user defined breakpoints! | ||
</Text> | ||
<Text style={styles.text}> | ||
Your window dimensions are: {UnistylesRuntime.screen.width}x{UnistylesRuntime.screen.height} | ||
</Text> | ||
<Text> | ||
Rotate or resize the window to see the changes | ||
</Text> | ||
</View> | ||
</DemoScreen> | ||
) | ||
} | ||
|
||
const stylesheet = createStyleSheet(theme => ({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
paddingHorizontal: 20, | ||
backgroundColor: { | ||
':w[, 430]:h[, 1000]': theme.colors.barbie, | ||
// xs will could also be applied here, but it has lower priority than media queries | ||
xs: theme.colors.aloes | ||
}, | ||
rowGap: 20 | ||
}, | ||
text: { | ||
textAlign: 'center', | ||
color: theme.colors.typography | ||
} | ||
})) |
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