mirror of
https://github.com/dzeiocom/components.git
synced 2025-04-22 10:52:16 +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 = {
|
module.exports = {
|
||||||
"stories": [
|
"stories": [
|
||||||
"../src/dzeio/**/*.stories.@(ts|tsx)",
|
"../src/dzeio/**/*.stories.tsx",
|
||||||
],
|
],
|
||||||
"addons": [
|
"addons": [
|
||||||
"@storybook/addon-essentials"
|
"@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-radius 4px
|
||||||
border none
|
border none
|
||||||
justify-content center
|
justify-content center
|
||||||
|
align-items center
|
||||||
color $textOnMain
|
color $textOnMain
|
||||||
background-color $main
|
background-color $main
|
||||||
|
|
||||||
@ -24,9 +25,6 @@
|
|||||||
// Link specific
|
// Link specific
|
||||||
text-decoration none
|
text-decoration none
|
||||||
|
|
||||||
&.nomargintop
|
|
||||||
margin-top 0
|
|
||||||
|
|
||||||
&.outline
|
&.outline
|
||||||
border 2px solid @background-color
|
border 2px solid @background-color
|
||||||
padding 8px 18px // @padding - @border
|
padding 8px 18px // @padding - @border
|
||||||
@ -36,7 +34,7 @@
|
|||||||
&:hover
|
&:hover
|
||||||
&:active
|
&:active
|
||||||
&:focus
|
&:focus
|
||||||
color @color
|
color $textOnMain
|
||||||
|
|
||||||
&:hover
|
&:hover
|
||||||
background-color @background-color
|
background-color @background-color
|
||||||
@ -47,6 +45,12 @@
|
|||||||
&:focus
|
&:focus
|
||||||
background-color darken(@background-color, 30%)
|
background-color darken(@background-color, 30%)
|
||||||
|
|
||||||
|
&.block
|
||||||
|
display flex
|
||||||
|
width 100%
|
||||||
|
margin 0
|
||||||
|
margin-top 8px
|
||||||
|
|
||||||
&.large
|
&.large
|
||||||
padding 15px 30px
|
padding 15px 30px
|
||||||
font-size rem(20)
|
font-size rem(20)
|
||||||
@ -61,11 +65,8 @@
|
|||||||
&.outline
|
&.outline
|
||||||
padding 3px 8px // @padding - @border
|
padding 3px 8px // @padding - @border
|
||||||
|
|
||||||
&.block
|
&.nomargintop
|
||||||
display flex
|
margin-top 0
|
||||||
width 100%
|
|
||||||
margin 0
|
|
||||||
margin-top 8px
|
|
||||||
|
|
||||||
&:disabled
|
&:disabled
|
||||||
background $grayLight
|
background $grayLight
|
||||||
@ -124,11 +125,17 @@ btn($color, $theme)
|
|||||||
&.outline
|
&.outline
|
||||||
color @background-color
|
color @background-color
|
||||||
border-color @background-color
|
border-color @background-color
|
||||||
|
// background none
|
||||||
|
|
||||||
&:hover
|
&:hover
|
||||||
&:active
|
&:active
|
||||||
&:focus
|
&:focus
|
||||||
color @color
|
color $textColor
|
||||||
|
|
||||||
|
if $theme is 'darken'
|
||||||
|
&:active
|
||||||
|
&:focus
|
||||||
|
background-color darken(@color, 30%)
|
||||||
|
|
||||||
&:hover
|
&:hover
|
||||||
background-color @background-color
|
background-color @background-color
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Meta } from '@storybook/react/types-6-0'
|
import { Meta } from '@storybook/react/types-6-0'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import { Zap } from 'react-feather'
|
||||||
import Component from '.'
|
import Component from '.'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -8,3 +9,19 @@ export default {
|
|||||||
} as Meta
|
} as Meta
|
||||||
|
|
||||||
export const Basic = (args: any) => <Component {...args}>Button</Component>
|
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
|
color?: ColorType
|
||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
icon?: FC<IconProps> | string
|
icon?: FC<IconProps> | string
|
||||||
size?: 'large' | 'small' | 'block'
|
size?: 'large' | 'small'
|
||||||
|
block?: boolean
|
||||||
href?: string
|
href?: string
|
||||||
as?: string
|
as?: string
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
@ -33,9 +34,9 @@ export default class Button extends React.Component<Props> {
|
|||||||
inner = (
|
inner = (
|
||||||
<>
|
<>
|
||||||
{typeof Icon === 'string' ? (
|
{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 && (
|
{this.props.children && (
|
||||||
<span className={css.textInner}>{this.props.children}</span>
|
<span className={css.textInner}>{this.props.children}</span>
|
||||||
@ -48,6 +49,7 @@ export default class Button extends React.Component<Props> {
|
|||||||
[css.button],
|
[css.button],
|
||||||
[css[this.props.color as string], this.props.color],
|
[css[this.props.color as string], this.props.color],
|
||||||
[css.outline, this.props.outline],
|
[css.outline, this.props.outline],
|
||||||
|
[css.block, this.props.block],
|
||||||
[css[this.props.size as string], this.props.size],
|
[css[this.props.size as string], this.props.size],
|
||||||
[css.nomargintop, this.props.nomargintop],
|
[css.nomargintop, this.props.nomargintop],
|
||||||
[css.loading, this.props.loading]
|
[css.loading, this.props.loading]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
.parent
|
.parent
|
||||||
position relative
|
position relative
|
||||||
|
display inline-flex
|
||||||
|
|
||||||
.image
|
.image
|
||||||
transition .3s
|
transition .3s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user