Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 37c92de

Browse files
committed
feat(iconbutton): icon button storybook
1 parent 93aa1cc commit 37c92de

File tree

6 files changed

+62
-18
lines changed

6 files changed

+62
-18
lines changed

src/App.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<theme-provider :theme="theme" :icons="$kiwi.icons">
33
<div class="root">
4-
<Button size="md" variant-color="indigo" mr="3" left-icon="search" @click="setLoading" :is-loading="loading"> Search </Button>
5-
<IconButton _aria-label="Search" size="sm" variant-color="blue" :is-round="true" icon="search" />
6-
<IconButton _aria-label="Search" variant-color="blue" :is-round="true" size="md" icon="search" />
7-
<IconButton _aria-label="Search" size="lg" variant-color="blue" :is-round="true" icon="search" />
4+
<Button size="md" variant-color="indigo" mx="3" left-icon="search" @click="setLoading" loading-text="Submitting" :is-loading="loading"> Search </Button>
5+
<IconButton _aria-label="Search" size="sm" variant-color="blue" mx="3" icon="search" />
6+
<IconButton _aria-label="Search" variant-color="blue" mx="3" size="md" icon="star" />
7+
<IconButton _aria-label="Search" size="lg" variant-color="blue" mx="3" :is-round="true" icon="phone" />
88
</div>
99
</theme-provider>
1010
</template>

src/components/Button/button.props.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ export const buttonProps = {
4242
},
4343
loadingText: {
4444
type: String,
45-
default: 'Loading',
46-
validator: (value) => typeof value === 'string'
45+
default: null
4746
},
4847
iconSpacing: {
4948
type: [String, Number],

src/components/Button/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default {
9393
this.leftIcon && !this.isLoading && h(ButtonIcon, {
9494
props: {
9595
mr: this.iconSpacing,
96+
mb: 'px',
9697
icon: this.leftIcon,
9798
size: '1em'
9899
}
@@ -110,6 +111,7 @@ export default {
110111
this.rightIcon && !this.isLoading && h(ButtonIcon, {
111112
props: {
112113
ml: this.iconSpacing,
114+
mb: 'px',
113115
icon: this.rightIcon,
114116
size: '1em'
115117
}

src/components/Icon/index.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import styled from 'vue-styled-components'
22
import { Box } from '../../lib/core/'
33
import iconPaths from '../../lib/plugin/iconsPaths'
44
import { forwardProps } from '../../lib/utils'
5-
import { iconStyles } from './icon.utils'
65
import { baseProps } from '../../lib/config/props'
76

87
const fallbackIcon = iconPaths['question-outline']
@@ -59,19 +58,14 @@ export default {
5958

6059
viewBox = icon.viewBox || '0 0 24 24'
6160

62-
// Evaluate icon size
63-
const iconSize = iconStyles({
64-
size: this.size,
65-
theme: this.$theme
66-
})
67-
6861
return h(Svg, {
6962
props: {
7063
as: 'svg',
64+
w: this.size,
65+
h: this.size,
7166
color: this.color,
7267
d: 'inline-block',
7368
verticalAlign: 'middle',
74-
...iconSize,
7569
...forwardProps(this.$props)
7670
},
7771
attrs: {

src/components/IconButton/index.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Button, Icon, Box } from '../../lib/core'
22
import styleProps from '../../lib/config/props'
33
import { forwardProps } from '../../lib/utils'
4-
import { setIconSizes } from '../Button/button.styles'
54
import { buttonProps } from '../Button/button.props'
65

76
const baseStyles = {
@@ -40,7 +39,7 @@ export default {
4039
return h(Button, {
4140
props: {
4241
p: 0,
43-
borderRadius: this.isRound ? 'full' : 'md',
42+
rounded: this.isRound ? 'full' : 'md',
4443
size: this.size,
4544
...forwardProps(props)
4645
},
@@ -55,8 +54,8 @@ export default {
5554
focusable: false,
5655
name: this.icon,
5756
color: 'currentColor',
58-
mb: '-2px',
59-
...setIconSizes(props)
57+
mb: '2px',
58+
size: '1em'
6059
},
6160
attrs: {
6261
focusable: false,

stories/5-IconButton.stories.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { storiesOf } from '@storybook/vue'
2+
import centered from '@storybook/addon-centered/vue'
3+
import IconButton from '../src/components/IconButton'
4+
5+
storiesOf('UI | IconButton', module)
6+
.addDecorator(centered)
7+
.add('Default IconButton', () => ({
8+
components: { IconButton },
9+
template: `
10+
<div>
11+
<IconButton _aria-label="Phone" variant-color="blue" icon="phone" />
12+
</div>
13+
`
14+
}))
15+
.add('With sizes', () => ({
16+
components: { IconButton },
17+
template: `
18+
<div>
19+
<IconButton _aria-label="Phone" size="sm" mx="3" variant-color="blue" icon="phone" />
20+
<IconButton _aria-label="Phone" size="md" mx="3" variant-color="blue" icon="phone" />
21+
<IconButton _aria-label="Phone" size="lg" mx="3" variant-color="blue" icon="phone" />
22+
</div>
23+
`
24+
}))
25+
.add('With colors', () => ({
26+
components: { IconButton },
27+
template: `
28+
<div>
29+
<IconButton _aria-label="Phone" size="sm" mx="3" variant-color="green" icon="phone" />
30+
<IconButton _aria-label="Phone" size="md" mx="3" variant-color="orange" icon="star" />
31+
<IconButton _aria-label="Phone" size="lg" mx="3" variant-color="red" icon="email" />
32+
</div>
33+
`
34+
}))
35+
.add('With Loading', () => ({
36+
components: { IconButton },
37+
template: `
38+
<div>
39+
<IconButton _aria-label="Phone" is-loading size="lg" mx="3" variant-color="indigo" icon="phone" />
40+
</div>
41+
`
42+
}))
43+
.add('With Rounding', () => ({
44+
components: { IconButton },
45+
template: `
46+
<div>
47+
<IconButton _aria-label="Phone" is-round size="lg" mx="3" variant-color="indigo" icon="star" />
48+
</div>
49+
`
50+
}))

0 commit comments

Comments
 (0)