JSPM

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

Package Exports

  • react-kindness

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-kindness) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-kindness Build Status

A lightweight, fully-customizable kind screen guide for React

mini demo

Demo

To install

$ npm install --save react-kindness

Put this somewhere in your component tree,

import {KindnessPanel, Kindness} from 'react-kindness';
import 'react-kindness/dist/index.css';

// ...
    <KindnessPanel enabled={this.state.show}
                   onExit={() => this.setState({show: false})} />

then point out some elements that you want your guests to focus on

<Kindness>
    <input type="text" {...} />
</Kindness>

<Kindness>
    <button type="submit">
        Submit
    </button>
</Kindness>

When the <KindnessPanel>'s enabled becomes true, the tutorial starts.

Props of <KindnessPanel>

type KindnessPanelProps = {|
  enabled: boolean,
  onExit: Function,
  spotType?: 'circle' | 'rect', // 'circle' by default
  initialIndex?: number,        // 0 by default
  children?: mixed,
  seriesId?: SeriesId,          // 'default' by default
|};

Props of <Kindness>

export type KindnessProps = {|
  children: mixed,
  title?: mixed,                // null by default
  message?: mixed,              // null by default
  order?: number | 'auto',      // 'auto' by default
  seriesId?: SeriesId,          // 'default' by default
|}

Customizing a panel content

By default <KindnessPanel /> uses <KindnessPanelContent/> internally. By passing a function as a child, you can customize the content.

<KindnessPanel enabled={true}>
    {
        ({total, currentIndex, goNext, goPrevious, goIndex, finish}) => (
            <div>
                <h3>This is {stage} item</h3>
                <button onClick={goPrev}>Go previous</button>
                <button onClick={goNext}>Go next</button>
            </div>
        )
    }
</KindnessPanel>

(wip) Get additional variables from <Kindness />

When you pass a function to <Kindness /> as a child, you can use additional variables.

<Kindness>
    { (focused) => <div style={focused && {fontWeight: 'bold'}}>yeah</div> }
</Kindness>

Todo

  • When scrolling a spot is something wrong
  • How can I put all into a single root dom
  • Jump to a target with animated-scroll-to
  • Why my popper doesn't flip on viewport boundary
  • 0.3.0 Fancy API for customising
  • 0.4.0 More tests
  • Scroll X
  • Accept a function as a child to <Kindness />

License

MIT