-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
184 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
title: Alert | Sharp-UI | ||
description: Alert 组件的文档 | ||
--- | ||
|
||
# Alert 警告 | ||
用于页面中展示重要的提示信息。 | ||
|
||
## 基础用法 | ||
页面中的非浮层元素,不会自动消失。 | ||
Alert 组件提供四种主题,由`type`属性指定,默认值为`info`。 | ||
|
||
<preview path="../demo/Alert/Basic.vue" title="基础用法" description="Alert组件的基础用法" /> | ||
|
||
## 主题 | ||
Alert 组件提供了两个不同的主题:`light`和`dark`。通过设置`effect`属性来改变主题,默认为`light`。 | ||
|
||
<preview path="../demo/Alert/Theme.vue" title="主题" description="Alert 组件提供了两个不同的主题:`light`和`dark`。" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template> | ||
<Alert content="成功提示的文案" type="success"> </Alert> | ||
<Alert content="消息提示的文案"> </Alert> | ||
<Alert content="警告提示的文案" type="warning"> </Alert> | ||
<Alert content="错误提示的文案" type="danger"> </Alert> | ||
</template> | ||
|
||
<script setup> | ||
import Alert from '@/components/Alert/Alert.vue' | ||
</script> | ||
|
||
<style scoped> | ||
.s-alert { | ||
margin: 20px 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template> | ||
<Alert content="成功提示的文案" type="success" effect="dark"> </Alert> | ||
<Alert content="消息提示的文案" effect="dark"> </Alert> | ||
<Alert content="警告提示的文案" type="warning" effect="dark"> </Alert> | ||
<Alert content="错误提示的文案" type="danger" effect="dark"> </Alert> | ||
</template> | ||
|
||
<script setup> | ||
import Alert from '@/components/Alert/Alert.vue' | ||
</script> | ||
|
||
<style scoped> | ||
.s-alert { | ||
margin: 20px 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,52 @@ | ||
<template> | ||
<div> | ||
|
||
<div | ||
v-show="visible" | ||
ref="alertRef" | ||
role="alert" | ||
class="s-alert" | ||
:class="{ [`s-alert--${type}`]: type, 'is-close': closeable, 'is-dark': effect === 'dark' }" | ||
> | ||
<div class="s-alert__content"> | ||
<span class="s-alert__title"> | ||
<slot>{{ content }}</slot> | ||
</span> | ||
</div> | ||
<div v-if="closeable" class="s-alert__close"> | ||
<Icon icon="xmark" @click.stop="onClose" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import Icon from '@/components/Icon/Icon.vue' | ||
import type { AlertEvents, AlertInstance, AlertProps } from './types' | ||
import { ref } from 'vue' | ||
defineOptions({ | ||
name: 'S-Alert' | ||
}) | ||
const props = withDefaults(defineProps<AlertProps>(), { | ||
type: 'info', | ||
closeable: true | ||
}) | ||
const emits = defineEmits<AlertEvents>() | ||
</script> | ||
const alertRef = ref<HTMLElement>() | ||
const visible = ref(true) | ||
<style scoped> | ||
const onClose = () => { | ||
visible.value = false | ||
emits('close') | ||
} | ||
const show = () => { | ||
visible.value = true | ||
} | ||
defineExpose<AlertInstance>({ | ||
show, | ||
hide: onClose | ||
}) | ||
</script> | ||
|
||
</style> | ||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.s-alert { | ||
--s-alert-bg-color: var(--s-color-info-light-9); | ||
--s-alert-border-color: var(--s-border-color-lighter); | ||
--s-alert-padding: 8px 16px; | ||
--s-alert-close-size: 12px; | ||
--s-alert-close-icon-color: var(--s-text-color-placeholder); | ||
--s-alert-close-hover-color: var(--s-text-color-secondary); | ||
} | ||
.s-alert { | ||
position: relative; | ||
width: 100%; | ||
box-sizing: border-box; | ||
border-radius: var(--s-border-radius-base); | ||
border-width: var(--s-border-width); | ||
border-style: var(--s-border-style); | ||
border-color: var(--s-alert-border-color); | ||
background-color: var(--s-alert-bg-color); | ||
padding: var(--s-alert-padding); | ||
display: flex; | ||
align-items: center; | ||
transition: top var(--s-transition-duration), opacity var(--s-transition-duration), transform var(--s-transition-duration); | ||
.s-alert__content { | ||
color: var(--s-alert-text-color); | ||
overflow-wrap: anywhere; | ||
font-size: 13px; | ||
line-height: 18px; | ||
display: table-cell; | ||
padding: 0 8px; | ||
} | ||
&.is-close .s-alert__content { | ||
padding-right: 30px; | ||
} | ||
.s-alert__close { | ||
position: absolute; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
right: 15px; | ||
cursor: pointer; | ||
font-size: 12px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
.s-alert__close svg { | ||
cursor: pointer; | ||
} | ||
} | ||
@each $val in primary,info,success,warning,danger { | ||
.s-alert--$(val) { | ||
--s-alert-bg-color: var(--s-color-$(val)-light-9); | ||
--s-alert-border-color: var(--s-color-$(val)-light-8); | ||
--s-alert-text-color: var(--s-color-$(val)); | ||
.s-alert__close { | ||
--s-icon-color: var(--s-color-$(val)); | ||
} | ||
} | ||
.s-alert--$(val).is-dark { | ||
--s-alert-text-color: var(--s-color-white); | ||
--s-alert-bg-color: var(--s-color-$(val)); | ||
--s-alert-border-color: var(--s-color-$(val)-light-5); | ||
.s-alert__close { | ||
--s-icon-color: var(--s-color-white); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters