Skip to content

Commit b973495

Browse files
committed
feat: Alert基础使用
1 parent 1196a74 commit b973495

File tree

3 files changed

+97
-10
lines changed

3 files changed

+97
-10
lines changed

src/lib/alert/index.vue

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,91 @@
11
<template>
2-
<div class="jw-alert">alert</div>
2+
<div class="jw-alert" :class="classes">
3+
<div class="jw-alert-body">
4+
<div class="jw-alert-body-title">{{ title }}</div>
5+
<div class="jw-alert-body-content"></div>
6+
</div>
7+
</div>
38
</template>
49

5-
<script setup lang="ts"></script>
10+
<script setup lang="ts">
11+
import { computed } from "vue";
12+
const props = defineProps({
13+
title: {
14+
type: String,
15+
default: "",
16+
},
17+
description: {
18+
type: String,
19+
default: "",
20+
},
21+
type: {
22+
type: String,
23+
default: "default",
24+
},
25+
closable: {
26+
type: Boolean,
27+
default: true,
28+
},
29+
showIcon: Boolean,
30+
center: Boolean,
31+
});
32+
33+
const classes = computed(() => ({
34+
[`jw-alert-${props.type}`]: props.type,
35+
}));
36+
</script>
637
<script lang="ts">
738
export default {
839
name: "JwAlert",
940
};
1041
</script>
1142

12-
<style scoped></style>
43+
<style lang="scss">
44+
.jw-alert {
45+
width: 100%;
46+
line-height: 1.6;
47+
padding: 8px 16px;
48+
border-radius: 4px;
49+
position: relative;
50+
overflow: hidden;
51+
opacity: 1;
52+
display: flex;
53+
align-items: center;
54+
transition: opacity 0.2s;
55+
56+
.jw-alert-body {
57+
.jw-alert-body-title {
58+
transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
59+
font-size: 16px;
60+
line-height: 19px;
61+
font-weight: 500;
62+
color: rgb(31, 34, 37);
63+
}
64+
}
65+
66+
&.jw-alert-default {
67+
background-color: #fafafc;
68+
border: 1px solid #efeff4;
69+
}
70+
71+
&.jw-alert-info {
72+
background-color: #eef5fd;
73+
border: 1px solid #ccdef8;
74+
}
75+
76+
&.jw-alert-success {
77+
background-color: #eff7f2;
78+
border: 1px solid #cce6d6;
79+
}
80+
81+
&.jw-alert-warning {
82+
background-color: #fdf7ee;
83+
border: 1px solid #f6e1ba;
84+
}
85+
86+
&.jw-alert-error {
87+
background-color: #f9eef1;
88+
border: 1px solid #edccd3;
89+
}
90+
}
91+
</style>
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<preview>基础用法</preview>
22
<template>
3-
<jw-alert />
3+
<jw-alert title="Default 类型" />
4+
<jw-alert title="Info 类型" type="info" />
5+
<jw-alert title="Success 类型" type="success" />
6+
<jw-alert title="Warning 类型" type="warning" />
7+
<jw-alert title="Error 类型" type="error" />
48
</template>

src/views/doc/alert/index.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
<h1>提示 Alert</h1>
44
<p>用于页面中展示重要的提示信息。</p>
55
<div class="preview-wrapper">
6-
<Preview :component="AlertPreview1"/>
6+
<Preview :component="AlertPreview1" />
77
</div>
88
</div>
99
</template>
1010

1111
<script setup lang="ts">
12-
import Preview from '@/components/Preview.vue'
13-
import AlertPreview1 from './AlertPreview1.preview.vue'
12+
import Preview from "@/components/Preview.vue";
13+
import AlertPreview1 from "./AlertPreview1.preview.vue";
1414
</script>
1515

16-
<style scoped>
17-
18-
</style>
16+
<style lang="scss">
17+
.alert-doc-wrapper {
18+
.jw-alert {
19+
margin-bottom: 12px;
20+
}
21+
}
22+
</style>

0 commit comments

Comments
 (0)