This repository was archived by the owner on Sep 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +58
-661
lines changed
Expand file tree Collapse file tree 8 files changed +58
-661
lines changed Original file line number Diff line number Diff line change 11<template >
22 <theme-provider :theme =" theme" :icons =" $kiwi.icons" >
33 <div class =" root" >
4- <Icon
5- name =" star"
6- color =" yellow.500"
7- size =" 6"
8- mx =" 3"
9- />
10- <Icon
11- name =" email"
12- color =" orange.400"
13- size =" 12"
14- mx =" 3"
15- />
16- <Icon
17- name =" not-allowed"
18- color =" red.400"
19- size =" 12"
20- mx =" 3"
21- />
22- <Icon
23- name =" chevron-circle-up"
24- color =" blue.500"
25- size =" 12"
26- mx =" 3"
27- />
28- <Icon
29- name =" times-circle"
30- color =" indigo.300"
31- size =" 24"
32- mx =" 3"
33- />
34- <Button variant-color =" blue" size =" lg" >Large</Button >
35- <Button variant-color =" red" size =" md" >Medium</Button >
36- <Button variant-color =" blue" size =" sm" >Small</Button >
4+ <Button size =" lg" variant-color =" blue" @click =" setLoading" :is-loading =" loading" > Button </Button >
375 </div >
386 </theme-provider >
397</template >
408
419<script >
4210import ThemeProvider from ' ./components/ThemeProvider'
43- import { Icon , Button } from ' ./lib/core/'
11+ import { Button } from ' ./lib/core/'
4412import Badge from ' ./components/Badge'
4513import theme from ' ./lib/theme'
14+ import { setTimeout } from ' timers'
4615
4716export default {
4817 data () {
4918 return {
5019 theme,
5120 element: true ,
52- Badge
21+ Badge,
22+ loading: false
5323 }
5424 },
5525 name: ' App' ,
5626 components: {
5727 ThemeProvider,
58- Icon,
5928 Button
6029 },
6130 methods: {
6231 toggle () {
6332 this .element = ! this .element
6433 },
65- alert () {
66- console .log (' button clicked' )
34+ setLoading () {
35+ this .loading = true
36+ setTimeout (() => {
37+ this .loading = false
38+ }, 1000 )
6739 }
6840 },
6941 computed: {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import PseudoBox from '../PseudoBox'
22import styleProps from '../../lib/config/props'
33import { forwardProps } from '../../lib/utils'
44import createButtonStyles from './button.styles'
5+ import { Spinner } from '../../lib/core'
56
67/**
78 * @description The Button component is an accessible rich component that does what a button does :)
@@ -61,8 +62,17 @@ export default {
6162 } ,
6263 iconSpacing : {
6364 type : String ,
65+ default : 2 ,
6466 validator : ( value ) => value >= 0
6567 } ,
68+ leftIcon : {
69+ type : String ,
70+ default : null
71+ } ,
72+ rightIcon : {
73+ type : String ,
74+ default : null
75+ } ,
6676 rounded : {
6777 type : Boolean ,
6878 default : false
@@ -105,6 +115,19 @@ export default {
105115 on : {
106116 click : ( $event ) => this . $emit ( 'click' , $event )
107117 }
108- } , this . $slots . default )
118+ } , [
119+ this . leftIcon && ! this . isLoading && h ( Spinner ) ,
120+ this . isLoading && h ( Spinner , {
121+ props : {
122+ position : this . loadingText ? 'relative' : 'absolute' ,
123+ color : 'currentColor' ,
124+ mb : '-4px' ,
125+ mr : this . loadingText ? this . iconSpacing : 0 ,
126+ size : '1em'
127+ }
128+ } ) ,
129+ this . isLoading ? this . loadingText : this . $slots . default ,
130+ this . rightIcon && ! this . isLoading && h ( Spinner )
131+ ] )
109132 }
110133}
Original file line number Diff line number Diff line change 1+ import * as Vue from 'vue' ;
2+
3+ /**
4+ * The Spinner component is a loading component for users
5+ */
6+ declare const Spinner : Vue . Component < {
7+ size ?:String ,
8+ label ?: String ,
9+ thickness ?: String ,
10+ speed ?: String ,
11+ color ?: String ,
12+ emptyColor ?: String ,
13+ _ref ?: Object
14+ } > ;
15+ export default Spinner ;
16+
Original file line number Diff line number Diff line change @@ -35,8 +35,15 @@ const sizes = {
3535 }
3636}
3737
38+ const createCustomSize = ( size ) => {
39+ return {
40+ w : size ,
41+ h : size
42+ }
43+ }
44+
3845const setSizes = ( props ) => {
39- return sizes [ props . size ] || sizes [ 'md' ]
46+ return sizes [ props . size ] || createCustomSize ( props . size )
4047}
4148
4249export default {
You can’t perform that action at this time.
0 commit comments