1.0.2 • Published 6 years ago

rc-tipso v1.0.2

Weekly downloads
13
License
MIT
Repository
-
Last release
6 years ago

React Tipso

npm version js-standard-style rc-tipso GitHub license

NPM

A tooltip component for react.

Screenshot

rc-tipso

Live demo

Click here: https://ecmadao.github.io/rc-tipso

Install

$ npm i rc-tipso --save

Build config

  • Webpack 3.x config example
// webpack config file

// loaders
const postcssLoader = {
  loader: 'postcss-loader',
  options: {
    config: {
      path: path.join(__dirname, 'postcss.config.js')
    }
  }
};
const cssModulesLoader = ExtractTextPlugin.extract({
  fallback: 'style-loader',
  use: [
    {
      loader: 'css-loader',
      options: {
        modules: true,
        sourceMaps: true,
        importLoaders: 1,
        localIdentName: '[name]__[local]___[hash:base64:5]'
      }
    },
    postcssLoader
  ],
});

const webpackConfig = {
  module: {
    rules: [
      {
        test: /\.css$/,
        include: /rc-tipso/,
        loaders: cssModulesLoader
      }
    ]
  }
};
  • Webpack 1.x config example
// webpack config file

// css loaders
const cssLoaders = [
  'style-loader',
  'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
  'postcss-loader'
];

const webpackConfig = {
  module: {
    loaders: [
      {
        test: /\.css$/,
        include: /rc-tipso/,
        loaders: cssLoaders
      }
    ]
  },
  postcss: () => {
    return [
      require('postcss-cssnext')
    ]
  }
};

Usage

import Tipso from 'rc-tipso';

// ...

render() {
  return (
    <Tipso
      theme="dark"
      position="bottom"
      trigger="hover"
      tipsoContent={(
        <div style={{
          width: '95px',
          textAlign: 'center'
        }}>This is an example</div>
      )}>
      <div>hover to show</div>
    </Tipso>
  )
}

Example

Click here to see tipso usage examples.

Api

nametypedefaultdescription
tipsoContentreact element or nodenullThe DOM content you wanna show in tooltip.
themestringlightTooltip theme, support light or dark
triggerstringhoverThe way to active tooltip, you can use hover, click, focus and so on.
wrapperStyleobject{}A style object that change the UI of tooltip container.
wrapperClassstring''Custom className to change the UI of tooltip container.
classNamestring''Custom className to change the UI of tooltip
tipsoStyleobject{}A style object that change the UI of tooltip.
positionstringtopTooltip position. support top, bottom
showboolfalseUse outside prosp to deside whether show tooltip or not.

Dev

$ git clone git@github.com:ecmadao/rc-tipso.git
$ cd rc-tipso
$ npm i
$ npm run storybook

License

Released under MIT License

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.6

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago