Skip to content

Instantly share code, notes, and snippets.

@lukebrandonfarrell
Last active June 6, 2019 15:53
Show Gist options
  • Save lukebrandonfarrell/cecac4c416099cb4422153372bce59fd to your computer and use it in GitHub Desktop.
Save lukebrandonfarrell/cecac4c416099cb4422153372bce59fd to your computer and use it in GitHub Desktop.
<Alert /> component styled at project / organisation level.
import React from "react";
import { View, Text } from "react-native";
import palx from "palx" // props to palx!
const ThemeContext = React.createContext(palx("#ff0066"));
const Alert = ({ title, text }) => {
return (
<ThemeContext.Consumer>
{theme => (
<View style={[
...,
{
backgroundColor: theme.red[1],
borderColor: theme.red[3]
}
]}>
<Text style={[..., { color: theme.red[8] }]}> {title} </Text>
<Text style={[..., { color: theme.red[8] }]}> {text} </Text>
</View>
</ThemeContext.Consumer>
);
};
export default Alert;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment