Created
February 16, 2018 19:26
-
-
Save pshev/e1fd6d5e2be6fd29308252a8f24c74c4 to your computer and use it in GitHub Desktop.
preact-fela basic usage
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
import {h} from 'preact' | |
import {style} from 'preact-fela-simple' | |
const Header = ({title, styles}) => | |
<header className={styles.container}> | |
<h1 className={styles.title}>{title}</h1> | |
</header> | |
const styles = ({theme, size}) => ({ | |
container: { | |
textAlign: 'center', | |
padding: '20px', | |
height: '200px' | |
}, | |
title: { | |
lineHeight: 1.2, | |
fontSize: size, | |
color: theme.colors.primary | |
} | |
}) | |
export default style(styles)(Header) |
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
import Preact, {h} from 'preact' | |
import {createRenderer} from 'fela' | |
import {Provider} from 'preact-fela-simple' | |
import Header from './header' | |
const renderer = createRenderer() | |
const theme = { | |
colors: { | |
primary: 'red' | |
} | |
} | |
Preact.render(( | |
<Provider renderer={renderer} theme={theme}> | |
<Header title="Hello world" size="17px" /> | |
</Provider> | |
), document.getElementById('root')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment