2.9.0 • Published 7 years ago

fyndiq-component-button v2.9.0

Weekly downloads
21
License
MIT
Repository
github
Last release
7 years ago

fyndiq-component-button npm

Preview

A button component for Fyndiq

Installation

The component can be installed through NPM:

npm i -S fyndiq-component-button

Usage

import React from 'react'
import Button from 'fyndiq-component-button'

// Normal usage
<Button onClick={() => console.log('clicked')}>
  My Button
</Button>

// Red button
<Button type="cancel">Cancel my task</Button>

// Bigger button
<Button size="l">My big button</Button>

// Custom className
<Button className="additional-styles">Button</Button>

// Disabled usage
<Button disabled>My disabled Button</Button>

// Render a link as a button
<Button link="#hello">My link</Button>

// Use a custom Link element
import { Link } from 'react-router-dom'

<Button link={<Link to="my/path" />}>
  My link
</Button>

// Render anything as a button
<Button type="primary" size="l">
  {({ className }) => (
    <header className={className}>
      My header
    </header>
  )}
</Button>

// Next.JS Link rendered as a button
import Link from 'next/link'
<Button type="primary" size="l" pill>
  {({ className }) => (
    <Link href="/link/">
      <a className={className}>
        My link
      </a>
    </Link>
  )}
</Button>

// Manipulate buttons as a group
import Button, { Wrapper } from 'fyndiq-component-button'

<Wrapper>
  <Button>Button 1</Button>
  <Button>Button 2</Button>
  <Button>Button 3</Button>
</Wrapper>

// vertical layout
<Wrapper orientation="vertical">
  <Button>Button 1</Button>
  <Button>Button 2</Button>
  <Button>Button 3</Button>
</Wrapper>

API

The component Button has the following customizable props:

NameTypeDescriptionDefault value
typeStringOne of primary, cancel, blue, inverted. Changes the color style of the button normal
 htmlType String Set the original html type for button. See: MDN button
 className String Classname of the wrapping button ''
sizeStringOne of xs, s, l, xl. Changes the size of the button m
disabledBooleanIf true, will disable the button. false
pressedBooleanShow the button as pressed false
 pill BooleanRounds border-radius mode false
 link String or ElementUses an <a> tag or a custom element to render the button  undefined
 onClickFunctionCallback when the button is pressednoop => noop

The component Wrapper has the following customizable props:

NameTypeDescriptionDefault value
orientationStringOne of horizontal or vertical. Changes the flex-direction of the wrapper horizontal
 children ElementContent of the Wrapper null
 classNameString Additionnal className for the wrapper ''
 noOuterBorderBooleanRemoves the outer border of the button group false
2.9.0

7 years ago

2.8.0

7 years ago

2.7.0

7 years ago

2.6.2

7 years ago

2.6.1

7 years ago

2.6.0

8 years ago

2.5.0

8 years ago

2.4.0

8 years ago

2.3.0

8 years ago

2.2.0

8 years ago

2.1.3

8 years ago

2.1.2

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.1

8 years ago

2.0.1-0

8 years ago

2.0.0

8 years ago

2.0.0-pre.0

8 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago