JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 18
  • Score
    100M100P100Q48371F
  • License MIT

react library for generating notion-style avatar

Package Exports

  • react-notion-avatar
  • react-notion-avatar/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-notion-avatar) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React Notion Avatar

imagewall

简体中文

Assets

Installation

npm install react-notion-avatar

or

yarn add react-notion-avatar

Usage

  1. Import the component.

    import NotionAvatar from 'react-notion-avatar'
  2. Set the config attribute, so that you can always rendering a same avatar with the configuration.

    const config = {
        eye: 3,
        eyebrow: 3,
        face: 4,
        glass: 1,
        hair: 1,
        mouth: 2,
        nose: 3,
        accessory: 0,
        beard: 0,
        detail: 0,
    }

    tip: config is an Object, please check the Attributes below for what attributes can be passed in.

    Note: If you don't set the config attribute, component will generate a random avatar.

  3. Render the component with specific width / height and configuration.

    <NotionAvatar style={{ width: '6rem', height: '6rem' }} config={config} />

    or

    <NotionAvatar className="className" config={config} />

    or

     <NotionAvatar />

Attributes

The Attributes can be passed into config

key type default accept
face number 0~10
eye number 0~10
eyebrow number 0~10
glass number 0~10
hair number 0~30
mouth number 0~10
nose number 0~10
accessory number 0 0~10
beard number 0 0~10
detail number 0 0~10

or as React props

key type tips
id string Only for React Props
className string Only for React Props
style object Only for React Props

Development

  1. Clone the repo:
    $ git clone git@github.com:miqilin21/react-notion-avatar.git
    $ cd react-notion-avatar
  2. Install dependencies:
    $ yarn
    Or
    $ npm install
  3. Start the server for the example:
    $ yarn dev
    Or
    $ npm run dev
  4. Open the browser to reivew the example:
    $ open http://localhost:8080
  5. Edit the files inside src.

License

Released under MIT by @miqilin21.