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

Commit 45ee71f

Browse files
committed
feat(alert): alert description and icons for alert statuses
1 parent 72b86ee commit 45ee71f

File tree

5 files changed

+107
-11
lines changed

5 files changed

+107
-11
lines changed

src/App.vue

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,50 @@
22
<theme-provider :theme="theme" :icons="$kiwi.icons">
33
<div class="root">
44
<div class="wrapper">
5-
<Alert mb="1">
5+
6+
<Alert mb="3" status="error">
7+
<AlertIcon />
8+
There was an error processing your request
9+
</Alert>
10+
11+
<Alert mb="3" status="success">
12+
<AlertIcon />
13+
Data uploaded to the server. Fire on!
14+
</Alert>
15+
16+
<Alert mb="3" status="warning">
17+
<AlertIcon />
18+
Seems your account is about expire, upgrade now
19+
</Alert>
20+
21+
<Alert mb="3" status="info">
622
<AlertIcon />
723
Chakra is going live on August 30th. Get ready!
824
</Alert>
25+
26+
<Alert
27+
status="success"
28+
variant="subtle"
29+
flexDirection="column"
30+
justifyContent="center"
31+
textAlign="center"
32+
height="200px"
33+
>
34+
<AlertIcon size="40px" mr="0" />
35+
<AlertTitle mt="4" mb="1" fontSize="lg">
36+
Application submitted!
37+
</AlertTitle>
38+
<AlertDescription maxWidth="sm">
39+
Thanks for submitting your application. Our team will get back to you soon.
40+
</AlertDescription>
41+
</Alert>
942
</div>
1043
</div>
1144
</theme-provider>
1245
</template>
1346

1447
<script>
15-
import { ThemeProvider, Alert, AlertIcon } from './lib/core/'
48+
import { ThemeProvider, Alert, AlertIcon, AlertTitle, AlertDescription } from './lib/core/'
1649
import theme from './lib/theme'
1750
1851
export default {
@@ -27,7 +60,9 @@ export default {
2760
components: {
2861
ThemeProvider,
2962
Alert,
30-
AlertIcon
63+
AlertIcon,
64+
AlertTitle,
65+
AlertDescription
3166
},
3267
methods: {
3368
toggle () {

src/components/Alert/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ export const Alert: Vue.Component<{
1212
* Icon component for composing alerts
1313
*/
1414
export const AlertIcon: Vue.Component<{}>;
15+
16+
/**
17+
* Alert title component for composing alert title.
18+
*/
19+
export const AlertTitle: Vue.Component<{}>;

src/components/Alert/index.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { forwardProps } from '../../lib/utils'
44
import useAlertStyle, { useAlertIconStyle } from './alert.styles'
55

66
export const statuses = {
7-
info: { icon: 'info', color: 'blue' },
8-
warning: { icon: 'warning-2', color: 'orange' },
9-
success: { icon: 'check-circle', color: 'green' },
10-
error: { icon: 'warning', color: 'red' }
7+
info: { icon: '_info', color: 'blue' },
8+
warning: { icon: '_warning-2', color: 'orange' },
9+
success: { icon: '_check-circle', color: 'green' },
10+
error: { icon: '_warning', color: 'red' }
1111
}
1212

1313
const Alert = {
@@ -38,6 +38,8 @@ const Alert = {
3838
theme: this.$theme()
3939
})
4040

41+
console.log({ alertStyles })
42+
4143
return h(Box, {
4244
props: {
4345
...alertStyles,
@@ -53,6 +55,12 @@ const Alert = {
5355
const AlertIcon = {
5456
name: 'AlertIcon',
5557
inject: ['_status', '_variant', '$colorMode', '$theme'],
58+
props: {
59+
size: {
60+
default: 5
61+
},
62+
...baseProps
63+
},
5664

5765
render (h) {
5866
const alertIconStyles = useAlertIconStyle({
@@ -63,8 +71,8 @@ const AlertIcon = {
6371

6472
return h(Icon, {
6573
props: {
66-
mr: 3,
67-
size: 5,
74+
mr: this.$props.mr || 3,
75+
size: this.size,
6876
name: statuses[this._status] && statuses[this._status]['icon'],
6977
...alertIconStyles,
7078
...forwardProps(this.$props)
@@ -76,4 +84,30 @@ const AlertIcon = {
7684
}
7785
}
7886

79-
export { Alert, AlertIcon }
87+
const AlertTitle = {
88+
name: 'AlertTitle',
89+
props: {
90+
...baseProps
91+
},
92+
render (h) {
93+
return h(Box, {
94+
props: {
95+
fontWeight: 'bold',
96+
lineHeight: 'normal',
97+
...forwardProps(this.$props)
98+
}
99+
}, this.$slots.default)
100+
}
101+
}
102+
103+
const AlertDescription = {
104+
name: 'AlertDescription',
105+
props: {
106+
...baseProps
107+
},
108+
render (h) {
109+
return h(Box, { props: forwardProps(this.$props) }, this.$slots.default)
110+
}
111+
}
112+
113+
export { Alert, AlertIcon, AlertTitle, AlertDescription }

src/lib/config/props/props.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const baseProps = {
1414
maxH: [String, Array],
1515
maxHeight: [Number, String, Array],
1616
d: [String, Array],
17+
display: [String, Array],
1718
lineClamp: [String, Number, Array],
1819
truncate: [Boolean, Number],
1920
pt: [Number, String, Array],

src/lib/plugin/iconsPaths.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,35 @@ const icons = {
2727
/>
2828
`
2929
},
30-
info: {
30+
_info: {
3131
path: `
3232
<path
3333
fill="currentColor"
3434
d="M12,0A12,12,0,1,0,24,12,12.013,12.013,0,0,0,12,0Zm.25,5a1.5,1.5,0,1,1-1.5,1.5A1.5,1.5,0,0,1,12.25,5ZM14.5,18.5h-4a1,1,0,0,1,0-2h.75a.25.25,0,0,0,.25-.25v-4.5a.25.25,0,0,0-.25-.25H10.5a1,1,0,0,1,0-2h1a2,2,0,0,1,2,2v4.75a.25.25,0,0,0,.25.25h.75a1,1,0,1,1,0,2Z"
3535
/>
3636
`
3737
},
38+
'_warning-2': {
39+
path: `
40+
<path
41+
fill="currentColor"
42+
d="M23.119,20,13.772,2.15h0a2,2,0,0,0-3.543,0L.881,20a2,2,0,0,0,1.772,2.928H21.347A2,2,0,0,0,23.119,20ZM11,8.423a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Zm1.05,11.51h-.028a1.528,1.528,0,0,1-1.522-1.47,1.476,1.476,0,0,1,1.448-1.53h.028A1.527,1.527,0,0,1,13.5,18.4,1.475,1.475,0,0,1,12.05,19.933Z"
43+
/>`
44+
},
45+
'_check-circle': {
46+
path: `
47+
<path
48+
fill="currentColor"
49+
d="M12,0A12,12,0,1,0,24,12,12.014,12.014,0,0,0,12,0Zm6.927,8.2-6.845,9.289a1.011,1.011,0,0,1-1.43.188L5.764,13.769a1,1,0,1,1,1.25-1.562l4.076,3.261,6.227-8.451A1,1,0,1,1,18.927,8.2Z"
50+
/>`
51+
},
52+
_warning: {
53+
path: `
54+
<path
55+
fill="currentColor"
56+
d="M11.983,0a12.206,12.206,0,0,0-8.51,3.653A11.8,11.8,0,0,0,0,12.207,11.779,11.779,0,0,0,11.8,24h.214A12.111,12.111,0,0,0,24,11.791h0A11.766,11.766,0,0,0,11.983,0ZM10.5,16.542a1.476,1.476,0,0,1,1.449-1.53h.027a1.527,1.527,0,0,1,1.523,1.47,1.475,1.475,0,0,1-1.449,1.53h-.027A1.529,1.529,0,0,1,10.5,16.542ZM11,12.5v-6a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Z"
57+
/>`
58+
},
3859
'question-outline': {
3960
viewBox: '0 0 24 24',
4061
path: `

0 commit comments

Comments
 (0)