5.34.9 • Published 10 days ago

@puppet/react-components v5.34.9

Weekly downloads
726
License
Apache-2.0
Repository
-
Last release
10 days ago

Puppet React Components

Puppet React Components is a collection of general-purpose reusable React components and their associated styles.

Component documentation

Components are documented using React Styleguidist, which provides API docs alongside live editable (in-browser) React components. To view these, clone this repository, install dependencies, and run the Styleguidist server:

  • git clone git@github.com:puppetlabs/design-system.git && cd design-system/packages/react-components
  • npm install
  • npm start
  • Open http://localhost:6060.

Installation

npm install @puppet/react-components

Setup

Using with webpack (without Create React App)

React Components utilizes Calibre and Open Sans. In order for Calibre to load, you will need to process the react-components scss with Webpack. This has currently been tested with webpack 4 using css-loader, sass-loader, file-loader, resolve-url-loader, and mini-css-extract-plugin. The following is an example configuration for a consuming application:

const common = {
  mode: 'none',
  context: path.join(__dirname, '/source/react'),
  entry: ['./main.js'],
  output: {
    path: path.join(__dirname, '/build'),
    publicPath: '/',
    filename: 'application.js',
  },
  resolve: {
    symlinks: false,
    extensions: ['.js', '.jsx', '.json'],
  },
  module: {
    rules: [
      {
        test: /\.scss$/,
        exclude: /node_modules/,
        use: [
          { loader: MiniCssExtractPlugin.loader },
          { loader: 'css-loader' },
          { loader: 'resolve-url-loader' },
          { loader: 'sass-loader', options: { sourceMap: true } },
        ],
      },
      {
        test: /\.js$/,
        use: 'babel-loader',
      },
      {
        test: /\.(eot|svg|ttf|woff|woff2|png|jpg)$/,
        use: 'file-loader',
      },
    ],
  },
  node: {
    fs: 'empty',
  },
};

Troubleshooting missing fonts and SASS/SCSS compiling errors when using with webpack

If you encounter an error loading fonts, you are most likely not installing the resolve-url-loader package defined in the setup above. A possible error message for this failure could read:

Can't resolve './fonts/OpenSans-SemiboldItalic.woff2' in '/Users/me/Documents/Puppet/relay-website/src/pages'

Likewise, SASS/SCSS compilation errors will arise if css-loader and sass-loader are not declared.

An alternative to resolve-url-loader when using with webpack

Import react-components' ui.scss after defining the path to your local sass-variables/fonts file.

pds_styles.scss

// Allow webpack to resolve font URLs relative to this entrypoint
$puppet-common-font-path: './node_modules/@puppet/sass-variables/fonts';

@import '~@puppet/react-components/source/scss/library/ui';

pages/index.js

import '../pds_styles.scss'

...

Using With Gatsby

In addition to needing resolve-url-loader, a Gatsby app will need gatsby-plugin-sass in order to support the SASS/SCSS stylesheets in the design system. First install gatsby-plugin-sass, then configure useResolveUrlLoader. Given this configuration, a Gatsby app will not need css-loader or sass-loader.

Using with Create React App (CRA)

If you are using CRA with react-app-rewired (after following their instructions for switching from react-scripts to react-app-rewired in package.json), you can use this included rewire instead (after adding resolve-url-loader to devDependencies):

// config-overrides.js
const rewireResolveUrlLoader = require('@puppet/react-components/config/rewire-resolve-url-loader.js');
module.exports = function override(config, env) {
  config = rewireResolveUrlLoader(config, env);
  return config;
};

Contributing with CRA

If you want to npm link or yarn link react-components in a CRA app, you may need to disable CRA's ModuleScopePlugin because resolve-url-loader will output an absolute path to the react-components. This can be accomplished with an included rewire:

// config-overrides.js
const rewireRemoveModuleScopePlugin = require('@puppet/react-components/config/rewire-remove-module-scope-plugin.js');
module.exports = function override(config, env) {
  config = rewireRemoveModuleScopePlugin(config, env);
  return config;
};

Using components

The full set of react components are exported from the project root and can be imported as such:

import { Button } from '@puppet/react-components';
const MyComponent = () => <Button>My Button</Button>;

Contributing

Please see our CONTRIBUTING.md for details on setting up your development environment, opening a Pull Request, and requesting reviews.

Additional configuration examples

Continuous Delivery for PE

The following configuration allows CD4PE to rely on react-components to provide all its required fonts.

5.34.9

10 days ago

5.34.8

28 days ago

5.34.7

1 month ago

5.34.6

1 month ago

5.34.5

1 month ago

5.34.4

2 months ago

5.34.3

2 months ago

5.34.2

2 months ago

5.34.1

2 months ago

5.34.0

2 months ago

5.33.9

2 years ago

5.33.8

2 years ago

5.33.7

2 years ago

6.0.0-alpha.17

2 years ago

5.33.5

2 years ago

5.33.6

2 years ago

5.33.4

2 years ago

6.0.0-alpha.16

2 years ago

5.33.3

2 years ago

5.33.1

2 years ago

5.33.2

2 years ago

5.32.4

2 years ago

5.32.5

2 years ago

5.32.2

2 years ago

5.32.3

2 years ago

5.32.0

2 years ago

5.32.1

2 years ago

5.33.0

2 years ago

6.0.0-alpha.11

2 years ago

6.0.0-alpha.12

2 years ago

6.0.0-alpha.13

2 years ago

6.0.0-alpha.14

2 years ago

6.0.0-alpha.15

2 years ago

5.31.0

2 years ago

5.30.0

3 years ago

6.0.0-alpha.10

3 years ago

5.29.4

3 years ago

6.0.0-alpha.9

3 years ago

5.29.3

3 years ago

6.0.0-alpha.8

3 years ago

6.0.0-alpha.7

3 years ago

6.0.0-alpha.6

3 years ago

6.0.0-alpha.4

3 years ago

6.0.0-alpha.5

3 years ago

5.29.2

3 years ago

5.29.1

3 years ago

5.29.0

3 years ago

5.27.3

3 years ago

5.27.2

3 years ago

5.28.0

3 years ago

5.27.1

3 years ago

5.27.0

3 years ago

5.26.8

3 years ago

5.26.7

3 years ago

5.26.6

3 years ago

5.26.5

3 years ago

5.26.4

3 years ago

5.26.3

3 years ago

5.26.2

3 years ago

5.26.1

3 years ago

5.26.0

3 years ago

5.25.1

3 years ago

5.25.0

4 years ago

5.24.3

4 years ago

5.24.2

4 years ago

5.24.1

4 years ago

6.0.0-alpha.3

4 years ago

5.24.0

4 years ago

5.23.1

4 years ago

5.23.0

4 years ago

5.22.5

4 years ago

5.22.4

4 years ago

5.22.3

4 years ago

5.22.2

4 years ago

5.22.1

4 years ago

6.0.0-alpha.2

4 years ago

5.22.0

4 years ago

5.21.1

4 years ago

6.0.0-alpha.1

4 years ago

5.21.0

4 years ago

5.20.4

4 years ago

5.20.3

4 years ago

5.20.2

4 years ago

5.20.1

4 years ago

5.20.0

4 years ago

5.19.6

4 years ago

5.19.6-alpha.1

4 years ago

5.19.5

4 years ago

5.19.4

4 years ago

5.19.3

4 years ago

5.19.2

4 years ago

5.19.1

4 years ago

5.19.0

4 years ago

5.18.0

4 years ago

5.17.0

4 years ago

5.16.0

4 years ago

5.15.2

4 years ago

5.15.1

4 years ago

5.15.0

4 years ago

5.14.0

4 years ago

5.13.1

4 years ago

5.13.0

4 years ago

5.12.0

4 years ago

5.11.1

4 years ago

5.11.0

4 years ago

5.10.0

4 years ago

5.9.20

4 years ago

5.9.19

4 years ago

5.9.18

4 years ago

5.9.17

5 years ago

5.9.16

5 years ago

5.9.15

5 years ago

5.9.14

5 years ago

5.9.13

5 years ago

5.9.12

5 years ago

5.9.11

5 years ago

5.9.10

5 years ago

5.9.9

5 years ago

5.9.8

5 years ago

5.9.7

5 years ago

5.9.6

5 years ago

5.9.5

5 years ago

5.9.4

5 years ago

5.9.3

5 years ago

5.9.2

5 years ago

5.9.1

5 years ago

5.9.0

5 years ago

5.8.0

5 years ago

5.7.1

5 years ago

5.7.0

5 years ago

5.6.1

5 years ago

5.6.0

5 years ago