For the deployed version of our development environment visit https://lightspeed-flame.netlify.com.
Fork this CodeSandbox and start playing around with components:
Install the package:
yarn add @lightspeed/flame
And its required peer dependencies:
yarn add react@^16 react-dom@^16 @emotion/core@^10 @emotion/styled@^10 emotion-theming@^10
Before being able to implement Flame in your application, there are a few steps to bootstrap the components properly. We also assume that your React application is using a bundler such as webpack.
Steps required:
- Link fonts
- Hook the theme provider
- Load global styles
- Import components via their namespace
There are two ways to load the proper fonts:
Add this <link>
tag to your <head>
to load the required fonts:
<link
href="https://fonts.googleapis.com/css?family=Lato:400,700&subset=latin-ext"
rel="stylesheet"
/>
In order to have the proper styling, it is necessary to load the theme object into the application.
To do so, wrap the <FlameTheme>
provider on your app and add FlameGlobalStyles
:
import React from 'react';
import { FlameTheme, FlameGlobalStyles } from '@lightspeed/flame/Core';
// Access components via their namespace
import { Button } from '@lightspeed/flame/Button';
import { Heading1, Text } from '@lightspeed/flame/Text';
// Within your root app component
class App extends React.Component {
render() {
return (
<FlameTheme>
{/* Wrapping `<div>` is necessary since `<FlameTheme>` is a Provider */}
<div>
{/* We set some global styles, like fonts and minimal resets */}
<FlameGlobalStyles />
{/* A Flame styled h1, paragraph, and button π */}
<Heading1>My heading</Heading1>
<Text as="p">Welcome to Flame</Text>
<Button variant="primary" fill={true}>
It's happening!
</Button>
</div>
</FlameTheme>
);
}
}
Please note
If you have Emotion already installed and you would like to use the theme values provided from Flame, you will still need to wrap your application with an Emotion <ThemeProvider />
and pass in the theme object.
import React from 'react';
import { FlameTheme, lightTheme } from '@lightspeed/flame/Core';
import { ThemeProvider } from 'emotion-theming';
class App extends React.Component {
render() {
return (
<ThemeProvider theme={lightTheme}>
<FlameTheme>
<div>{/* ... */}</div>
</FlameTheme>
</ThemeProvider>
);
}
}
This is intentional since we do not want changes on FlameTheme
to potentially affect your underlying components, as you might already have custom theme values being added.
It's important to wrap your tests with the appropriate theme provider. This is because some flame components requires theme values to be passed in order to compute new color values.
Before rendering your component inside of your tests, ensure you wrap it up with FlameTheme
.
For example:
describe('Some component', () => {
it('renders', () => {
const component = someTestRenderFunction(
<FlameTheme>
<Button />
</FlameTheme>,
);
});
});
Flame supports SSR out of the box without any additional configuration needed.
Since Flame uses the latest @emotion
package, when loading components on the server, components will automatically have their styles extracted without any required setup.
Many of flame components have been augmented with Styled System props.
<Alert mb={3}>
This Alert will now have a margin bottom (mb) of 1.125rem. That value corresponds to the 3rd
spacing value of the design system.
</Alert>
These props are essentially a way to quickly customize various css properties of a component without the need of writing a custom css class or component. These props are automatically attached to the values of the design system, so long as the application was properly wrapped with the <FlameTheme>
component.
Please consult the packages READMEs for a list of all activated props:
See the contributing guidelines.
The source code is licensed with a custom license.