Skip to content
Component library for building Lightspeed products
TypeScript JavaScript Other
Branch: master
Clone or download

Latest commit

dependabot-preview [Security] Bump acorn from 5.7.3 to 5.7.4 (#79)
Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4. **This update includes a security fix.**
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](acornjs/acorn@5.7.3...5.7.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Latest commit 529145d Mar 16, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update publish-mainline.yml Dec 10, 2019
.storybook Update Storybook & Percy, (partially) remove Sass from stories (#7) Sep 26, 2019
.vscode Enable Circle CI for test, lint and typecheck (#6) Sep 18, 2019
packages Publish Feb 17, 2020
scripts Improve contributing guide (#53) Nov 26, 2019
stories
tests Initial commit Sep 11, 2019
typings Update Storybook & Percy, (partially) remove Sass from stories (#7) Sep 26, 2019
.editorconfig Initial commit Sep 11, 2019
.eslintignore Initial commit Sep 11, 2019
.eslintrc.js Update to latest @lightspeed/eslint-config (#61) Dec 9, 2019
.gitignore Initial commit Sep 11, 2019
.npmrc Initial commit Sep 11, 2019
.nvmrc Initial commit Sep 11, 2019
.prettierignore Initial commit Sep 11, 2019
LICENSE Initial commit Sep 11, 2019
README.md Remove FlameFonts from install docs, mark as deprecated (#50) Nov 22, 2019
RELEASE.md Improve contributing guide (#53) Nov 26, 2019
babel.config.js Initial commit Sep 11, 2019
codecov.yml Removed excessive console.warn from Group and Input (#47) Nov 22, 2019
jest.config.js Rework Group and Inputs (#2) Oct 25, 2019
jest.setup.js Initial commit Sep 11, 2019
lerna.json Initial commit Sep 11, 2019
netlify.toml Initial commit Sep 11, 2019
package.json Revert @types/react package update, use locked version (#64) Dec 10, 2019
plopfile.js Improve contributing guide (#53) Nov 26, 2019
prettier.config.js Initial commit Sep 11, 2019
tsconfig.json Initial commit Sep 11, 2019
yarn.lock [Security] Bump acorn from 5.7.3 to 5.7.4 (#79) Mar 16, 2020

README.md

Lightspeed Flame

Component library for building Lightspeed products.


npm version GitHub Actions workflow status badge codecov

Storybook

For the deployed version of our development environment visit https://lightspeed-flame.netlify.com.

Playground

Fork this CodeSandbox and start playing around with components:

Edit Flame Sandbox

Installing

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

Getting Started

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

Link fonts

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"
/>

Hook the theme provider, load global styles, and import components

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.

Testing your app with Flame components

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>,
    );
  });
});

Getting started with server-side rendering (SSR)

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.

Styled System props

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:

Contributing

See the contributing guidelines.

Licenses

The source code is licensed with a custom license.

You can’t perform that action at this time.