UNPKG

the-toast

Version:
184 lines (120 loc) 4.13 kB
the-toast ========== <!--- This file is generated by the-tmpl. Do not update manually. ---> <!-- Badge Start --> <a name="badges"></a> [![Build Status][bd_travis_shield_url]][bd_travis_url] [![npm Version][bd_npm_shield_url]][bd_npm_url] [![JS Standard][bd_standard_shield_url]][bd_standard_url] [bd_repo_url]: https://github.com/the-labo/the-toast [bd_travis_url]: http://travis-ci.org/the-labo/the-toast [bd_travis_shield_url]: http://img.shields.io/travis/the-labo/the-toast.svg?style=flat [bd_travis_com_url]: http://travis-ci.com/the-labo/the-toast [bd_travis_com_shield_url]: https://api.travis-ci.com/the-labo/the-toast.svg?token= [bd_license_url]: https://github.com/the-labo/the-toast/blob/master/LICENSE [bd_npm_url]: http://www.npmjs.org/package/the-toast [bd_npm_shield_url]: http://img.shields.io/npm/v/the-toast.svg?style=flat [bd_standard_url]: http://standardjs.com/ [bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg <!-- Badge End --> <!-- Description Start --> <a name="description"></a> Toast of the-components <!-- Description End --> <!-- Overview Start --> <a name="overview"></a> <!-- Overview End --> <!-- Sections Start --> <a name="sections"></a> <!-- Section from "doc/guides/01.Installation.md.hbs" Start --> <a name="section-doc-guides-01-installation-md"></a> Installation ----- ```bash $ npm install the-toast --save ``` <!-- Section from "doc/guides/01.Installation.md.hbs" End --> <!-- Section from "doc/guides/02.Usage.md.hbs" Start --> <a name="section-doc-guides-02-usage-md"></a> Usage --------- [Live Demo](https://the-labo.github.io/the-toast/doc/demo/index.html#/) is hosted on GitHub Page ```javascript 'use strict' import React from 'react' import { TheToast, TheToastGroup, TheToastStyle } from 'the-toast' class ExampleComponent extends React.PureComponent { constructor(props) { super(props) this.state = { messages: { normal: ['This is normal', 'This is normal 2'], info: ['This is info', 'This is info 2'], warn: ['This is warn', 'This is warn 2'], error: ['This is error', 'This is error 2'] } } } render() { const { messages } = this.state const onUpdate = (values) => this.setState({ messages: Object.assign({}, this.state.messages, values) }) return ( <React.StrictMode> <div> <TheToastStyle /> <TheToastGroup> <TheToast.Normal onUpdate={onUpdate} messages={messages.normal} /> <TheToast.Info onUpdate={onUpdate} messages={messages.info} clearAfter={1200} /> <TheToast.Warn onUpdate={onUpdate} messages={messages.warn} /> <TheToast.Error onUpdate={onUpdate} messages={messages.error} /> </TheToastGroup> </div> </React.StrictMode> ) } } export default ExampleComponent ``` <!-- Section from "doc/guides/02.Usage.md.hbs" End --> <!-- Section from "doc/guides/03.Components.md.hbs" Start --> <a name="section-doc-guides-03-components-md"></a> Components ----------- ### TheToast Toast of the-components **Props** | Name | Type | Description | Default | | --- | --- | ---- | ---- | | `clearAfter` | number | Clear message after seconds | `-1` | | `level` | enum | Level of toast | `'normal'` | | `messages` | arrayOf node | Messages to show | `` | | `onUpdate` | func | Handle update | `` | | `role` | | | `'alert'` | | `transitionTimeout` | | | `100` | ### TheToastGroup ToastGroup ### TheToastStyle Style for TheToast **Props** | Name | Type | Description | Default | | --- | --- | ---- | ---- | | `options` | object | Style options | `{}` | <!-- Section from "doc/guides/03.Components.md.hbs" End --> <!-- Sections Start --> <!-- LICENSE Start --> <a name="license"></a> License ------- This software is released under the [MIT License](https://github.com/the-labo/the-toast/blob/master/LICENSE). <!-- LICENSE End --> <!-- Links Start --> <a name="links"></a> Links ------ + [THE Labo][t_h_e_labo_url] [t_h_e_labo_url]: https://github.com/the-labo <!-- Links End -->