Comparing version 1.0.17 to 1.0.18
{ | ||
"name": "toast-me", | ||
"version": "1.0.17", | ||
"version": "1.0.18", | ||
"description": "Creates toast messages", | ||
@@ -5,0 +5,0 @@ "main": "lib/toast-me.min.js", |
122
README.md
@@ -9,2 +9,29 @@ # toast-me | ||
## Table of Contents | ||
* [Features](#features) | ||
* [How to use](#how-to-use) | ||
* [Install](#install) | ||
* [Import module to your script](#import-module-to-your-script) | ||
* [Using](#using) | ||
* [Using with own customization](#using-with-own-customization) | ||
* [Toast function arguments](#toast-function-arguments) | ||
* [Message argument](#message-argument) | ||
* [Options argument](#options-argument) | ||
* [Accepted options](#accepted-options) | ||
* [Options presets](#options-presets) | ||
* [Action argument](#action-argument) | ||
* [Contributing](#contributing) | ||
* [Getting started](#getting-started) | ||
* [Scripts](#scripts) | ||
* [Structure](#structure) | ||
* [Files structure](#files-structure) | ||
* [Path alias](#path-alias) | ||
* [Git repository architecture](#git-repository-architecture) | ||
* [Redux state](#redux-state) | ||
* [Dependencies](#dependencies) | ||
* [API](#api) | ||
* [Guidelines](#guidelines) | ||
* [Useful links](#useful-links) | ||
## Features | ||
@@ -18,3 +45,3 @@ | ||
## How to use | ||
#### Import | ||
#### Install | ||
Install package from npm | ||
@@ -27,3 +54,3 @@ ``` | ||
#### Add module to your script | ||
#### Import module to your script | ||
```javascript | ||
@@ -33,3 +60,3 @@ import toast from 'toast-me'; | ||
#### Use it | ||
#### Using | ||
```javascript | ||
@@ -39,3 +66,3 @@ toast('My message'); | ||
#### Use it with own customization | ||
#### Using with own customization | ||
```javascript | ||
@@ -46,3 +73,5 @@ toast('My message', { duration: 3000, toastClass: 'my-toast-class' /* ... */ }); | ||
## Toast function arguments | ||
```javascript | ||
toast(message, [options, [action]]); | ||
``` | ||
Function accepts three arguments: | ||
@@ -55,9 +84,11 @@ * `message` - message to show in toast, | ||
Accepts string, any message to put in toast. | ||
Accepts `string`, any message to put in toast. | ||
Text shown in one line, no wraps allowed. | ||
Overflowed text will be hidden with ellipsis. | ||
Complete text shown on hover with the `title` attribute on toast node. | ||
#### Options argument | ||
Accepts object with any allowed fields, or string as a name of options preset. | ||
**Optional** - Accepts `object` with any allowed fields, or `string` as a name of options preset, or `null`. | ||
If you don't need to set options, but need to pass an action - pass `null` instead options. | ||
@@ -80,4 +111,10 @@ ##### Accepted options | ||
#### Action argument | ||
**Optional** - Accepts object with three fields: | ||
* `label` - *string*, text to put in button. | ||
* `action` - callback *function* - to be called on button click. | ||
* `class` - *string*, CSS class for button node. | ||
#Contributing | ||
@@ -87,46 +124,45 @@ | ||
SECTION IN WORK | ||
SECTION BELOW IS IN WORK | ||
%%%%%%%%%%%%%%%%%%%%%%%% | ||
%%%%%%%%%%%%%%%%%%%%%%%%% | ||
## Getting started | ||
You will need [node.js](https://nodejs.org/en/) and preferred to have | ||
[yarn](https://yarnpkg.com/lang/en/) to run the project. | ||
Copy project to your local folder and then run in project's root | ||
folder next command to load dependencies: | ||
``` | ||
yarn | ||
``` | ||
## Scripts | ||
When you load all dependencies, you able to run several commands: | ||
* `yarn build` or `npm run build` - produces production version of your library under the `lib` folder | ||
* `yarn dev` or `npm run dev` - produces development version of your library and runs a watcher | ||
* `yarn test` or `npm run test` - well ... it runs the tests :) | ||
* `yarn build` - produces production pack of library under the `lib` folder | ||
* `yarn run-dev` - produces development version of your library, runs file watcher | ||
and http server on [http://localhost:3005](http://localhost:3005) | ||
* `yarn watch` - produces development version of your library, runs a file watcher | ||
* `yarn test` - runs the tests | ||
## Structure | ||
* `Root folder` | ||
* `dev/` - Folder, containing development environment files. This folder is | ||
published with `yarn run-dev` command. `toast-me.js` and `taos-me.js.map` | ||
files inside are generated by webpack watcher from `/src` folder. You are | ||
able to change files in both folders and they are to be reloaded in browser. | ||
* `lib/` - The place production pack will be located after build. Usually you won't | ||
need it, until you wan't to compile library by yourself and insert in your | ||
project manually | ||
* `scripts/` - Node.js executable scripts' folder, such as `dev-server.js` or `test.js`. | ||
* `config/` - Configuration files' folder. | ||
* `src/` - Here is the code of library itself. | ||
## Readings | ||
## Misc | ||
### An example of using dependencies that shouldn’t be resolved by webpack, but should become dependencies of the resulting bundle | ||
In the following example we are excluding React and Lodash: | ||
```js | ||
{ | ||
devtool: 'source-map', | ||
output: { | ||
path: '...', | ||
libraryTarget: 'umd', | ||
library: '...' | ||
}, | ||
entry: '...', | ||
... | ||
externals: { | ||
react: 'react' | ||
// Use more complicated mapping for lodash. | ||
// We need to access it differently depending | ||
// on the environment. | ||
lodash: { | ||
commonjs: 'lodash', | ||
commonjs2: 'lodash', | ||
amd: '_', | ||
root: '_' | ||
} | ||
} | ||
} | ||
``` | ||
1. [Git-flow workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) | ||
1. [AirBnB Style Guide](https://airbnb.io/javascript/) | ||
1. [Webpack](https://webpack.js.org/) | ||
1. [Node.js](https://nodejs.org/en/) | ||
1. [Yarn](https://yarnpkg.com/lang/en/) | ||
1. [SASS](http://sass-lang.com/) | ||
1. [Jest - main documentation](https://jestjs.io/docs/en/getting-started) |
@@ -69,3 +69,3 @@ // @flow | ||
} | ||
actionNode.textContent = action.name; | ||
actionNode.textContent = action.label; | ||
actionNode.addEventListener('click', () => { | ||
@@ -75,3 +75,3 @@ action.action(); | ||
}); | ||
actionNode.title = action.name; | ||
actionNode.title = action.label; | ||
node.appendChild(actionNode); | ||
@@ -78,0 +78,0 @@ } |
@@ -14,5 +14,5 @@ // @flow | ||
export type ToastActionType = { | ||
name: string, | ||
label: string, | ||
action: () => void, | ||
class?: string, | ||
}; |
345289
160