@noths/elements

Component library for the NOTHS design system

Usage no npm install needed!

<script type="module">
  import nothsElements from 'https://cdn.skypack.dev/@noths/elements';
</script>

README

Elements

About

The component library & design system for notonthehighstreet.com

Usage

Using a Component

import { Heading } from '@noths/elements';

<Heading />;

Next JS App SSR Setup + Importing via CDN

  1. Create custom _document file which uses the NothsElementsScript before any app code.
// _document.js

import { NothsElementsScript } from '@noths/elements';

class MyDocument extends Document {
  render() {
    return (
      <html>
        <Head />
        <body>
          <NothsElementsScript />
          <Main />
          <NextScript />
        </body>
      </html>
    );
  }
}
  1. Extend next webpack config like so with the ElementsWebpackPlugin. This sets @noths/elements as a webpack external when used in the browser, causing the app to use the library from a CDN.
// next.config.js

const { ElementsWebpackPlugin } = require('@noths/elements');

module.exports = {
  webpack: (webpackConfig, { isServer }) => {
    return isServer
      ? webpackConfig
      : {
          ...webpackConfig,

          externals: {
            react: 'React',
            'react-dom': 'ReactDOM',
            'styled-components': 'styled',
          },

          plugins: [].concat(webpackConfig.plugins, new ElementsWebpackPlugin()).filter(Boolean),
        };
  },
};

Contributing

To contribute and create new components please see CONTRIBUTING.md.