mirror of
https://github.com/dzeiocom/components.git
synced 2025-04-22 02:42:12 +00:00
Updated Button Component
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
d06386119b
commit
506fa8c01b
@ -3,7 +3,7 @@ const webpack = require('webpack')
|
||||
|
||||
module.exports = {
|
||||
"stories": [
|
||||
"../src/dzeio/**/*.stories.@(ts|tsx)",
|
||||
"../src/dzeio/**/*.stories.tsx",
|
||||
],
|
||||
"addons": [
|
||||
"@storybook/addon-essentials"
|
||||
|
3
.storybook/public/16-16.svg
Normal file
3
.storybook/public/16-16.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="16" height="16" fill="#C4C4C4"/>
|
||||
</svg>
|
After Width: | Height: | Size: 150 B |
@ -15,6 +15,7 @@
|
||||
border-radius 4px
|
||||
border none
|
||||
justify-content center
|
||||
align-items center
|
||||
color $textOnMain
|
||||
background-color $main
|
||||
|
||||
@ -24,9 +25,6 @@
|
||||
// Link specific
|
||||
text-decoration none
|
||||
|
||||
&.nomargintop
|
||||
margin-top 0
|
||||
|
||||
&.outline
|
||||
border 2px solid @background-color
|
||||
padding 8px 18px // @padding - @border
|
||||
@ -36,7 +34,7 @@
|
||||
&:hover
|
||||
&:active
|
||||
&:focus
|
||||
color @color
|
||||
color $textOnMain
|
||||
|
||||
&:hover
|
||||
background-color @background-color
|
||||
@ -46,6 +44,12 @@
|
||||
&:active
|
||||
&:focus
|
||||
background-color darken(@background-color, 30%)
|
||||
|
||||
&.block
|
||||
display flex
|
||||
width 100%
|
||||
margin 0
|
||||
margin-top 8px
|
||||
|
||||
&.large
|
||||
padding 15px 30px
|
||||
@ -61,11 +65,8 @@
|
||||
&.outline
|
||||
padding 3px 8px // @padding - @border
|
||||
|
||||
&.block
|
||||
display flex
|
||||
width 100%
|
||||
margin 0
|
||||
margin-top 8px
|
||||
&.nomargintop
|
||||
margin-top 0
|
||||
|
||||
&:disabled
|
||||
background $grayLight
|
||||
@ -124,11 +125,17 @@ btn($color, $theme)
|
||||
&.outline
|
||||
color @background-color
|
||||
border-color @background-color
|
||||
// background none
|
||||
|
||||
&:hover
|
||||
&:active
|
||||
&:focus
|
||||
color @color
|
||||
color $textColor
|
||||
|
||||
if $theme is 'darken'
|
||||
&:active
|
||||
&:focus
|
||||
background-color darken(@color, 30%)
|
||||
|
||||
&:hover
|
||||
background-color @background-color
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Meta } from '@storybook/react/types-6-0'
|
||||
import React from 'react'
|
||||
import { Zap } from 'react-feather'
|
||||
import Component from '.'
|
||||
|
||||
export default {
|
||||
@ -8,3 +9,19 @@ export default {
|
||||
} as Meta
|
||||
|
||||
export const Basic = (args: any) => <Component {...args}>Button</Component>
|
||||
Basic.args = {
|
||||
nomargintop: true,
|
||||
icon: Zap,
|
||||
size: 'small',
|
||||
href: '/pouet',
|
||||
block: true
|
||||
}
|
||||
|
||||
export const WithImg = (args: any) => <Component {...args}>Button</Component>
|
||||
WithImg.args = {
|
||||
nomargintop: true,
|
||||
icon: '/16-16.svg',
|
||||
size: 'small',
|
||||
href: '/pouet',
|
||||
block: true
|
||||
}
|
||||
|
@ -14,7 +14,8 @@ interface Props {
|
||||
color?: ColorType
|
||||
children?: React.ReactNode
|
||||
icon?: FC<IconProps> | string
|
||||
size?: 'large' | 'small' | 'block'
|
||||
size?: 'large' | 'small'
|
||||
block?: boolean
|
||||
href?: string
|
||||
as?: string
|
||||
disabled?: boolean
|
||||
@ -33,9 +34,9 @@ export default class Button extends React.Component<Props> {
|
||||
inner = (
|
||||
<>
|
||||
{typeof Icon === 'string' ? (
|
||||
<Image className={css.img} src={Icon} width={16} height={16} />
|
||||
<Image parentClassName={css.img} src={Icon} width={16} height={16} />
|
||||
) : (
|
||||
<Icon size={16} />
|
||||
<Icon size={this.props.size === 'large' ? 20 : this.props.size === 'small' ? 14 : 16} />
|
||||
)}
|
||||
{this.props.children && (
|
||||
<span className={css.textInner}>{this.props.children}</span>
|
||||
@ -48,6 +49,7 @@ export default class Button extends React.Component<Props> {
|
||||
[css.button],
|
||||
[css[this.props.color as string], this.props.color],
|
||||
[css.outline, this.props.outline],
|
||||
[css.block, this.props.block],
|
||||
[css[this.props.size as string], this.props.size],
|
||||
[css.nomargintop, this.props.nomargintop],
|
||||
[css.loading, this.props.loading]
|
||||
|
@ -1,5 +1,6 @@
|
||||
.parent
|
||||
position relative
|
||||
display inline-flex
|
||||
|
||||
.image
|
||||
transition .3s
|
||||
|
Loading…
x
Reference in New Issue
Block a user