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