1.1.12 • Published 2 years ago

react-notion-avatar v1.1.12

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

简体中文

Assets

Installation

npm install react-notion-avatar

or

yarn add react-notion-avatar

Usage

  1. Import the component.
    import { NotionAvatar, getRandomConfig } from 'react-notion-avatar'
  2. Set the required 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,
    }

    or generate a random config

    const config = getRandomConfig()

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

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

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

    or

    <NotionAvatar
      className="className"
      bgColor="#debaba"
      shape="square"
      config={config}
    />

Attributes

The Attributes can be passed into config

keytypedefaultaccept
facenumber0~11
eyenumber0~14
eyebrownumber0~16
glassnumber0~13
hairnumber0~58
mouthnumber0~20
nosenumber0~14
accessorynumber00~13
beardnumber00~17
detailnumber00~14

or as React props

keytypedefaultoptionstips
classNamestringOnly for React Props
styleobjectOnly for React Props
shapestring'circle''circle' , 'rounded' , 'square'Only for React Props
bgColorstringHexadecimal , RGB , HSL , PredefinedOnly for React Props

Development

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

License

Released under MIT by @zonemeen.