Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@_nu/react-switch

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@_nu/react-switch

No UI dependency switch of react

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
23
-11.54%
Maintainers
2
Weekly downloads
 
Created
Source

Switch

npm package npm downloads github

无 UI 依赖的 Swith 组件。

功能

  • When got href tagName will replace by a;
  • When tagName is button will got type="button" as default;
  • When children is <string> and title will be children as default;
  • When tagName is not button will got role="button"

Install

yarn add @_nu/react-button @_nu/css-button

Custom

/* @components/Button/index.js */
import "@_nu/css-button";                         // core style
import "@_nu/css-button/css/skins/bootstrap.css"; // skin of bootstrap
import './style.css';                             // custome style
import NuButton from "@_nu/react-button";         // import

// Add default class
NuButton.defaultProps.onBeforeReturn = ({className='', props})=> ({
  className:`nu_btn ${className}`
  ...props
});

export default NuButton;

Use

<Button className="_fill _primay">Button</Button>
<Button className="_fill _primay" href="/nu-button">Link Button</Button>
<Button component="strong" className="_fill _primay">Button</Button>

Api

ProptypeDefaultFunction
hrefstring' 'href for a
Componentstring | func | object'button'tagName
<Button className="_fill">hello</Button>
<Button className="_fill" component="strong">hello</Button>
<Button className="_fill"><strong>hello</strong></Button>
<Button className="_fill" disabled>hello</Button>
<Button className="_fill _primary">hello</Button>
<Button className="_fill _primary" href="." title="hello">hello</Button>

=>

<button class="nu_btn _fill" type="button" title="hello">hello</button>
<strong class="nu_btn _fill" role="button" title="hello">hello</strong>
<button class="nu_btn _fill" type="button"><strong>hello</strong></button>
<button class="nu_btn _fill" type="button" disabled title="hello">hello</button>
<button class="nu_btn _fill _primary" type="button" title="hello">hello</button>
<a class="nu_btn _fill _primary" role="button" href="." title="hello">hello</a>
defaultPropstypeDefaultFunction
onBeforeReturnfunction(props)=> propscustom props on before return

Custom style?

Go to @_nu/css-button

test

// How to start
npm test
// generate coverage report
npm run test:coverage

Keywords

react-component

FAQs

Package last updated on 12 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts