diff --git a/packages/devui-vue/devui/result/__tests__/result.spec.ts b/packages/devui-vue/devui/result/__tests__/result.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..59d954360834c3bf2b1dd3e90684a97df3983951 --- /dev/null +++ b/packages/devui-vue/devui/result/__tests__/result.spec.ts @@ -0,0 +1,8 @@ +import { mount } from '@vue/test-utils'; +import { Result } from '../index'; + +describe('result test', () => { + it('result init render', async () => { + // todo + }) +}) diff --git a/packages/devui-vue/devui/result/index.ts b/packages/devui-vue/devui/result/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..750a3b8dda6ec21a4b5fb53391de800e70dded7e --- /dev/null +++ b/packages/devui-vue/devui/result/index.ts @@ -0,0 +1,17 @@ +import type { App } from 'vue' +import Result from './src/result' + +Result.install = function(app: App): void { + app.component(Result.name, Result) +} + +export { Result } + +export default { + title: 'Result 结果', + category: '反馈', + status: '10%', // TODO: 组件若开发完成则填入"已完成",并删除该注释 + install(app: App): void { + app.use(Result as any) + } +} diff --git a/packages/devui-vue/devui/result/src/result-types.ts b/packages/devui-vue/devui/result/src/result-types.ts new file mode 100644 index 0000000000000000000000000000000000000000..b2588a2847aebf08512cf7660b3b50d777a1172d --- /dev/null +++ b/packages/devui-vue/devui/result/src/result-types.ts @@ -0,0 +1,20 @@ +import type { ExtractPropTypes } from 'vue' + +export type ResultIcon = 'success' | 'danger' | 'warning' | 'info' + +export const resultProps = { + icon: { + type: String as () => ResultIcon, + default: 'info' + }, + title: { + type: String, + default: '' + }, + desc: { + type: String, + default: '' + } +} as const + +export type ResultProps = ExtractPropTypes diff --git a/packages/devui-vue/devui/result/src/result.scss b/packages/devui-vue/devui/result/src/result.scss new file mode 100644 index 0000000000000000000000000000000000000000..9a0cec2b661c98e16c3c29e78ef1868ecf79360e --- /dev/null +++ b/packages/devui-vue/devui/result/src/result.scss @@ -0,0 +1,43 @@ +@import '../../style/theme/color'; +@import '../../style/theme/font'; + +.devui-result { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + text-align: center; + box-sizing: border-box; + padding: 30px; + + &__icon{ + &-success::before{ + color: $devui-success + } + &-danger::before{ + color: $devui-danger + } + &-warning::before{ + color: $devui-warning + } + &-info::before{ + color: $devui-info + } + } + + &__title { + margin-top: 20px; + color: $devui-text; + font-size: $devui-font-size-lg; + } + + &__desc { + margin-top: 10px; + color: $devui-text-weak; + font-size: $devui-font-size-md; + } + + &__extra{ + margin-top: 30px; + } +} \ No newline at end of file diff --git a/packages/devui-vue/devui/result/src/result.tsx b/packages/devui-vue/devui/result/src/result.tsx new file mode 100644 index 0000000000000000000000000000000000000000..04a91a1947147e99cfdf21aa404c4a44a55a0ba1 --- /dev/null +++ b/packages/devui-vue/devui/result/src/result.tsx @@ -0,0 +1,28 @@ +import { defineComponent } from 'vue' +import { resultProps, ResultProps } from './result-types' +import Icon from '../../icon/src/icon' +import './result.scss' + +export default defineComponent({ + name: 'DResult', + props: resultProps, + emits: [], + setup(props: ResultProps, ctx) { + enum IconEnum {success = 'right-o', danger='error-o', warning='warning-o', info='info-o'} + + return () => { + return ( +
+ { + ctx.slots.icon ? ctx.slots.icon() : + } +
+ {ctx.slots.title ? ctx.slots?.title() : props.title} +
+
{ctx.slots.title ? ctx.slots?.title() : props.desc}
+
{ctx.slots.extra ? ctx.slots?.extra() : ''}
+
+ ) + } + } +}) diff --git a/packages/devui-vue/docs/components/result/index.md b/packages/devui-vue/docs/components/result/index.md new file mode 100644 index 0000000000000000000000000000000000000000..b30efe6a3ab261eb586f03c6636e4fdb4206063d --- /dev/null +++ b/packages/devui-vue/docs/components/result/index.md @@ -0,0 +1,79 @@ +# Result 结果 + +操作结果反馈。 + +### 何时使用 + +用于对用户的操作结果或者异常状态做反馈。 + +### 基本用法 + +:::demo + +```vue + +``` + +::: + +### 自定义 + +:::demo + +```vue + +``` + +::: + +### d-result +d-result 参数 + +| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | +| ----- | --------------------------- | ---- | -------------- | --------------------- | +| icon | [`ResultIcon`](#ResultIcon) | info | 指定 icon 类型 | [基本用法](#基本用法) | +| title | string | - | 结果标题 | [基本用法](#基本用法) | +| desc | string | - | 结果描述 | [基本用法](#基本用法) | + +### ResultIcon + +默认值为'info' + +```ts +export type ResultIcon = 'success' | 'danger' | 'warning' | 'info' +``` + +### 插槽 +两种方式使用:`v-slot:icon` 或者具名插槽`#icon` + +| 参数 | 说明 | +| ----- | -------------- | +| icon | 自定义图标 | +| title | 自定义标题 | +| desc | 自定义描述内容 | +| extra | 底部额外区域 |