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

Commit de9624a

Browse files
committed
feat(components): spinner and icon components
1 parent a789119 commit de9624a

File tree

11 files changed

+153
-19
lines changed

11 files changed

+153
-19
lines changed

Diff for: .npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@fortawesome:registry=https://npm.fontawesome.com/
2+
//npm.fontawesome.com/:_authToken=9EEF60B7-9FFF-4698-88EC-EE6087D439F8

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ yarn serve
2828
- [x] Setup Vue.js plugin system
2929
- [x] Provide Theme
3030
- [x] Observe theme and set it dynamically in javascript with ease.
31-
- [ ] Provide icons API for icons component
32-
- [ ] Accessibility (Focus) Styling
31+
- [x] Provide icons API for icons component
32+
- [x] Accessibility (Focus) Styling
3333
- [ ] Setup NPM distribution
3434
- [ ] Set up type system for components with Typescript
3535

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dependencies": {
1818
"@babel/preset-env": "^7.6.3",
1919
"@fortawesome/free-solid-svg-icons": "^5.11.2",
20+
"@fortawesome/pro-light-svg-icons": "^5.11.2",
2021
"@styled-system/should-forward-prop": "^5.1.2",
2122
"@vue/composition-api": "^0.3.2",
2223
"color": "^3.1.2",

Diff for: src/App.vue

+23-14
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,43 @@
44
<Icon
55
name="star"
66
color="yellow.500"
7-
size="5"
7+
size="6"
8+
mx="3"
89
/>
910
<Icon
1011
name="email"
11-
color="teal.600"
12-
size="8"
12+
color="orange.400"
13+
size="12"
14+
mx="3"
1315
/>
1416
<Icon
15-
name="phone"
16-
color="indigo.400"
17-
size="10"
17+
name="not-allowed"
18+
color="red.400"
19+
size="12"
20+
mx="3"
1821
/>
1922
<Icon
20-
name="ambulance"
21-
color="indigo.400"
22-
size="10"
23+
name="chevron-circle-up"
24+
color="blue.500"
25+
size="12"
26+
mx="3"
2327
/>
2428
<Icon
25-
name="not-allowed"
26-
color="teal.600"
27-
size="12"
29+
name="times-circle"
30+
color="indigo.300"
31+
size="24"
32+
mx="3"
2833
/>
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>
2937
</div>
3038
</theme-provider>
3139
</template>
3240

3341
<script>
3442
import ThemeProvider from './components/ThemeProvider'
35-
import { Icon } from './lib/core/'
43+
import { Icon, Button } from './lib/core/'
3644
import Badge from './components/Badge'
3745
import theme from './lib/theme'
3846
@@ -47,7 +55,8 @@ export default {
4755
name: 'App',
4856
components: {
4957
ThemeProvider,
50-
Icon
58+
Icon,
59+
Button
5160
},
5261
methods: {
5362
toggle () {

Diff for: src/components/Button/index.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import * as Vue from 'vue';
22

3+
/**
4+
* Kiwi Button component for UI interactions
5+
*/
36
declare const Button: Vue.Component<{
47
as?: String,
58
type?: String,

Diff for: src/components/Spinner/index.js

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { keyframes } from 'vue-styled-components'
2+
import { baseProps } from '../../lib/config/props'
3+
import { Box, VisuallyHidden } from '../../lib/core'
4+
import { forwardProps } from '../../lib/utils'
5+
6+
const spin = keyframes`
7+
0% {
8+
transform: rotate(0deg);
9+
}
10+
100% {
11+
transform: rotate(360deg);
12+
}
13+
`
14+
15+
const sizes = {
16+
xs: {
17+
w: '0.75rem',
18+
h: '0.75rem'
19+
},
20+
sm: {
21+
w: '1rem',
22+
h: '1rem'
23+
},
24+
md: {
25+
w: '1.5rem',
26+
h: '1.5rem'
27+
},
28+
lg: {
29+
w: '2rem',
30+
h: '2rem'
31+
},
32+
xl: {
33+
w: '3rem',
34+
h: '3rem'
35+
}
36+
}
37+
38+
const setSizes = (props) => {
39+
return sizes[props.size] || sizes['md']
40+
}
41+
42+
export default {
43+
name: 'Spinner',
44+
props: {
45+
size: {
46+
type: [String, Array],
47+
default: 'md'
48+
},
49+
label: {
50+
type: String,
51+
default: 'Loading...'
52+
},
53+
thickness: {
54+
type: [String, Array],
55+
default: '2px'
56+
},
57+
speed: {
58+
type: [String, Array],
59+
default: '0.45s'
60+
},
61+
color: {
62+
type: [String, Array],
63+
default: 'gray.200'
64+
},
65+
emptyColor: {
66+
type: [String, Array],
67+
default: 'transparent'
68+
},
69+
_ref: Object,
70+
...baseProps
71+
},
72+
render (h) {
73+
return h(Box, {
74+
ref: this._ref,
75+
props: {
76+
d: 'inline-block',
77+
borderWidth: this.thickness,
78+
borderBottomColor: this.emptyColor,
79+
borderLeftColor: this.emptyColor,
80+
borderStyle: 'solid',
81+
rounded: 'full',
82+
color: this.color,
83+
animation: `${spin} ${this.speed} linear infinite`,
84+
...setSizes(this.$props),
85+
...forwardProps(this.$props)
86+
}
87+
}, this.label && h(VisuallyHidden, {}, this.label))
88+
}
89+
}

Diff for: src/lib/config/props/props.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ const baseProps = {
7575
order: [String, Array],
7676
outline: [String, Array],
7777
cursor: [String, Array],
78-
transition: [String, Array]
78+
transition: [String, Array],
79+
borderBottomColor: [String, Array],
80+
borderTopColor: [String, Array],
81+
borderLeftColor: [String, Array],
82+
borderRightColor: [String, Array],
83+
borderColor: [String, Array],
84+
borderStyle: [String, Array]
7985
// appearance: [String, Array],
8086
// transform: [String, Array],
8187
// transformOrigin: [String, Array],

Diff for: src/lib/core/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ export { default as Box } from '../../components/Box'
22
export { default as PseudoBox } from '../../components/PseudoBox'
33
export { default as Button } from '../../components/Button'
44
export { default as Icon } from '../../components/Icon'
5+
export { default as Spinner } from '../../components/Spinner'
6+
export { default as VisuallyHidden } from '../../components/VisuallyHidden'
7+
export { default as TransitionExpand } from '../../components/TransitionExpand'
8+
export { default as ThemeProvider } from '../../components/ThemeProvider'

Diff for: src/main.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,22 @@ import { faCoffee,
1010
faCalendar,
1111
faCar,
1212
faBraille,
13-
faCaretLeft } from '@fortawesome/free-solid-svg-icons'
13+
faCaretLeft,
14+
faAnchor } from '@fortawesome/free-solid-svg-icons'
15+
import { faChevronCircleUp, faTimesCircle } from '@fortawesome/pro-light-svg-icons'
1416

1517
Vue.config.productionTip = false
1618
Vue.use(VueCompositionApi)
1719

1820
// Install Kiwi plugin
1921
Vue.use(Kiwi, {
22+
// include theme property that can be extended by user.
23+
/**
24+
* theme: {
25+
* ...someImportedThemeObject
26+
* icons: Object
27+
* }
28+
*/
2029
icons: {
2130
iconPack: 'fa',
2231
iconSet: {
@@ -25,7 +34,10 @@ Vue.use(Kiwi, {
2534
faCoffee,
2635
faBraille,
2736
faAmbulance,
28-
faCaretLeft
37+
faCaretLeft,
38+
faAnchor,
39+
faChevronCircleUp,
40+
faTimesCircle
2941
},
3042
extend: {
3143
'not-allowed': {

Diff for: stories/4-Icon.stories.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ storiesOf('UI | Icon', module)
1111
<Icon name="star" mx="2" color="yellow.400" size="4" />
1212
<Icon name="email" mx="2" color="indigo.400" size="5" />
1313
<Icon name="phone" mx="2" color="green.400" size="6" />
14+
<Icon name="anchor" mx="2" color="red.400" size="10" />
1415
</div>
1516
`
1617
}))

Diff for: yarn.lock

+7
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,13 @@
11541154
dependencies:
11551155
"@fortawesome/fontawesome-common-types" "^0.2.25"
11561156

1157+
"@fortawesome/pro-light-svg-icons@^5.11.2":
1158+
version "5.11.2"
1159+
resolved "https://npm.fontawesome.com/@fortawesome/pro-light-svg-icons/-/pro-light-svg-icons-5.11.2.tgz#61543170feb34e04f4d4bd1843b08bbde6682833"
1160+
integrity sha512-NzN0K+hnKQ8fw4PLsr7WjLgtlnH1QjD4/N26YVUEMzLZiTgYBiqE7NDlRL6q/xJ9ittCj6PDPNY/IQ0T8XPLiA==
1161+
dependencies:
1162+
"@fortawesome/fontawesome-common-types" "^0.2.25"
1163+
11571164
11581165
version "2.1.1"
11591166
resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.1.tgz#61395b5ed94c4cb19c2dc4c85969cff3d40d583f"

0 commit comments

Comments
 (0)