3.0.1 • Published 8 months ago

yapui v3.0.1

Weekly downloads
118
License
MIT
Repository
gitlab
Last release
8 months ago

YAPUI

Yet Another Primitive UI.

Development Requirements

  • node
  • npm | yarn

See package.json for dependencies

Motivation

Can read the full reasoning in the blog post, however the main motivation are:

  • to learn,
  • control the API,
  • opinionated way of styling via objects
  • most important have set of UI components that I have full control over when building my side projects.

Installation

npm install yapui

Setup

Single page application (SPA)

This is how is used in a React SPA

// index.js
import React from 'react';
import { render } from 'react-dom';
import { UiProvider, createStylesRenderer } from 'yapui';
import { App } from './App';

const renderer = createStylesRenderer();
render(
  <UiProvider renderer={renderer}>
    <App />
  </UiProvider>,
  document.getElementById('app')
);

Next.js

Usage in next.js is based on this (now-example)https://github.com/zeit/next.js/tree/master/examples/with-fela

// pages/_document.js
import React from 'react';
import Document, { Html, Head, Main, NextScript } from 'next/document';
import { createStylesRenderer, renderToNodeList } from 'yapui';

export default class MyDocument extends Document {
  static async getInitialProps(ctx) {
    const renderer = createStylesRenderer();
    const originalRenderPage = ctx.renderPage;

    ctx.renderPage = () =>
      originalRenderPage({
        enhanceApp: (App) => (props) => <App {...props} renderer={renderer} />,
      });

    const initialProps = await Document.getInitialProps(ctx);
    const styles = renderToNodeList(renderer);
    return {
      ...initialProps,
      // styles prop is then used in the render method automatically
      // by the custom document. No need to add it manually
      styles: [...initialProps.styles, ...styles],
    };
  }

  render() {
    return (
      <Html>
        <Head />
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}
// pages/_app.js

import React from 'react';
import { UiProvider } from 'yapui';
// before 2.6.1 you need a fallback renderer, now this is included in
// UiProvider
export default function MyApp({ Component, pageProps, renderer }) {
  return (
    <UiProvider renderer={renderer}>
      <Component {...pageProps} />
    </UiProvider>
  );
}

Usage

For the api of each component available See for Storybook and documentation

Scripts

  • install install project dependencies
  • storybook start the storybook dev server
  • build runs build:cjs and build:esm
  • build:storybook builds the storybook site for this project
  • build:cjs builds primitive ui as commonjs compatible module
  • build:esm builds primitive ui as ES modules compatible module
  • clean:dist deletes distribution directory
  • clean:node_modules deletes dependencies directory
  • lint runs eslint script

TODO

  • document usage
  • finalize api
  • revise components and check if more are needed
  • document api
  • finish typescript declaration files
3.0.1

8 months ago

3.0.0

1 year ago

2.9.1

2 years ago

2.8.1

2 years ago

2.8.0

2 years ago

2.8.2

2 years ago

2.7.6

3 years ago

2.7.4

3 years ago

2.7.5

3 years ago

2.7.3

3 years ago

2.7.0

3 years ago

2.7.2

3 years ago

2.7.1

3 years ago

2.7.0-0

3 years ago

2.6.2

3 years ago

2.6.2-beta.0

3 years ago

2.6.2-beta.1

3 years ago

2.6.1

3 years ago

2.6.1-0

3 years ago

2.6.0

3 years ago

2.5.1

3 years ago

2.5.0

3 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.5

4 years ago

2.2.3

4 years ago

2.2.4

4 years ago

2.2.1

4 years ago

2.2.2

4 years ago

2.2.0

4 years ago

2.1.8

4 years ago

2.1.7

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago