generated from thzxcx/vue3
feat: 反馈组件/Alert
This commit is contained in:
53
packages/alert/index.vue
Normal file
53
packages/alert/index.vue
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<template>
|
||||||
|
<View v-show="modelValue" h-100vh w-full w-750rpx relative bg="#818181" overflow-hidden z-1000>
|
||||||
|
<View class="th-prompt" w-400rpx text-center rounded-16rpx absolute top="1/3" left="1/2" ml="-200rpx" right-0 bg-white z-1001>
|
||||||
|
<View color="#3a3a3a" fs-32 font-400 my-48rpx>
|
||||||
|
{{ content }}
|
||||||
|
</View>
|
||||||
|
<View fs-32>
|
||||||
|
<View bg="#f2f7ff" h-1rpx mx-32rpx />
|
||||||
|
<View
|
||||||
|
active="bg-#f2f7ff"
|
||||||
|
flex-grow
|
||||||
|
color="#3b82f6"
|
||||||
|
py-16rpx
|
||||||
|
cursor-pointer
|
||||||
|
select-none
|
||||||
|
rounded-b-16rpx
|
||||||
|
@click="confirm"
|
||||||
|
>
|
||||||
|
{{ confirmText }}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup name="Alert">
|
||||||
|
withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
/** 是否显示 */
|
||||||
|
modelValue?: boolean
|
||||||
|
/** 内容 */
|
||||||
|
content?: string
|
||||||
|
/** 确认按钮的默认值 */
|
||||||
|
confirmText?: string
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
modelValue: false,
|
||||||
|
confirmText: '确定',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
/** 更新modelValue */
|
||||||
|
(event: 'update:modelValue', modelValue: boolean): void
|
||||||
|
/** 确认事件 */
|
||||||
|
(event: 'confirm'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
function confirm() {
|
||||||
|
emit('update:modelValue', false)
|
||||||
|
emit('confirm')
|
||||||
|
}
|
||||||
|
</script>
|
37
stories/Alert.stories.ts
Normal file
37
stories/Alert.stories.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* @Author: peerless_hero peerless_hero@outlook.com
|
||||||
|
* @Date: 2023-07-11 01:57:00
|
||||||
|
* @LastEditors: peerless_hero peerless_hero@outlook.com
|
||||||
|
* @LastEditTime: 2023-07-11 03:03:30
|
||||||
|
* @FilePath: \uni\stories\Alert.stories.ts
|
||||||
|
* @Description:
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
||||||
|
import ThAlert from '../packages/alert/index.vue'
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
title: '反馈组件/Alert',
|
||||||
|
component: ThAlert,
|
||||||
|
tags: ['autodocs'],
|
||||||
|
args: {
|
||||||
|
modelValue: true,
|
||||||
|
content: '操作执行成功',
|
||||||
|
confirmText: '确定',
|
||||||
|
},
|
||||||
|
argTypes: {
|
||||||
|
onConfirm: { action: 'clicked' },
|
||||||
|
},
|
||||||
|
} satisfies Meta<typeof ThAlert>
|
||||||
|
export default meta
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof meta>
|
||||||
|
|
||||||
|
export const Base: Story = {
|
||||||
|
name: '仅提示操作信息',
|
||||||
|
args: {
|
||||||
|
modelValue: true,
|
||||||
|
content: '信息填写有误',
|
||||||
|
confirmText: '确定',
|
||||||
|
},
|
||||||
|
}
|
Reference in New Issue
Block a user