From 9f4c6a5ece5646ea229ea8f6fc2367a6fda33260 Mon Sep 17 00:00:00 2001 From: eyunhua <876482803@qq.com> Date: Fri, 25 Nov 2022 16:42:06 +0800 Subject: [PATCH] feat(empty): add empty component,and update styles. #298 --- .github/workflows/ci.yml | 4 +- demo/cases/Empty.vue | 95 +++++++++++++++++++++++++++++ demo/cases/index.js | 6 ++ demo/router.js | 6 +- src/components/Empty.js | 14 +++++ src/components/empty.less | 79 ++++++++++++++++++++++++ src/variables/components/empty.less | 29 +++++++++ 7 files changed, 228 insertions(+), 5 deletions(-) create mode 100644 demo/cases/Empty.vue create mode 100644 src/components/Empty.js create mode 100644 src/components/empty.less create mode 100644 src/variables/components/empty.less diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8948c75e..5ee41e24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,8 +24,8 @@ jobs: # Runs a set of commands using the runners shell - name: Install and Build run: | - npm install - npm run build + pnpm install + pnpm run build echo test, and install your project. - name: Deploy to GitHub Pages diff --git a/demo/cases/Empty.vue b/demo/cases/Empty.vue new file mode 100644 index 00000000..e5d50ef2 --- /dev/null +++ b/demo/cases/Empty.vue @@ -0,0 +1,95 @@ + + + + + + diff --git a/demo/cases/index.js b/demo/cases/index.js index 70187880..17f75dea 100644 --- a/demo/cases/index.js +++ b/demo/cases/index.js @@ -62,6 +62,7 @@ import VDragSort from './VDragSort'; import Plugins from './Plugins'; import Message from './Message'; import Cascader from './Cascader'; +import Empty from './Empty'; export default [ { @@ -195,6 +196,11 @@ export default [ name: 'Embedded', component: Embedded }, + { + path: '/empty', + name: 'Empty', + component: Empty + }, { path: '/form', name: 'Form', diff --git a/demo/router.js b/demo/router.js index 04f6dec5..ed4396ca 100644 --- a/demo/router.js +++ b/demo/router.js @@ -9,9 +9,9 @@ const router = new Router({ routes: [ { path: '/', - name: 'Empty', + name: 'Home', component: { - name: 'empty', + name: 'Home', render(h) { return h('article', [ h('h1', 'Welcome to VEUI!'), @@ -25,7 +25,7 @@ const router = new Router({ }); router.beforeEach((to, from, next) => { - let name = to.name === 'Empty' ? '' : to.name; + let name = to.name === 'home' ? '' : to.name; document.title = `Veui${name} - demo`; next(); }); diff --git a/src/components/Empty.js b/src/components/Empty.js new file mode 100644 index 00000000..9c725391 --- /dev/null +++ b/src/components/Empty.js @@ -0,0 +1,14 @@ +import ui from 'veui/managers/ui'; + +ui.defaults( + { + ui: { + size: { + values: ['s', 'm'], + inherit: true, + default: 's' + } + } + }, + 'empty' +); diff --git a/src/components/empty.less b/src/components/empty.less new file mode 100644 index 00000000..e38ca6ec --- /dev/null +++ b/src/components/empty.less @@ -0,0 +1,79 @@ +@import "../lib.less"; +@import "../variables/components/empty.less"; + +.@{veui-prefix}-empty { + text-align: center; + display: flex; + flex-direction: column; + align-items: center; + + &-title { + line-height: @veui-empty-title-line-height; + color: @veui-empty-title-font-color; + font-weight: @veui-empty-title-font-weight; + } + + &-image, + &-title, + &-desc { + &:not(:first-child) { + margin-top: @veui-empty-content-spacing; + } + } + + &-desc { + line-height: @veui-empty-desc-line-height; + color: @veui-empty-desc-font-color; + font-weight: @veui-empty-desc-font-weight; + } + + &-actions:not(:first-child) { + margin-top: @veui-empty-actions-spacing-before; + } + + &-actions { + .@{veui-prefix}-button + .@{veui-prefix}-button { + margin-left: @veui-empty-actions-content-spacing; + } + } + + &[ui~="m"] { + max-width: @veui-empty-max-width-m; + + .@{veui-prefix}-empty { + &-image, + &-image > * { + width: @veui-empty-image-width-m; + height: @veui-empty-image-height-m; + } + + &-title { + font-size: @veui-empty-title-font-size-m; + } + + &-desc { + font-size: @veui-empty-desc-font-size-m; + } + } + } + + &[ui~="s"] { + max-width: @veui-empty-max-width-s; + + .@{veui-prefix}-empty { + &-image, + &-image > * { + width: @veui-empty-image-width-s; + height: @veui-empty-image-height-s; + } + + &-title { + font-size: @veui-empty-title-font-size-s; + } + + &-desc { + font-size: @veui-empty-desc-font-size-s; + } + } + } +} diff --git a/src/variables/components/empty.less b/src/variables/components/empty.less new file mode 100644 index 00000000..50a03400 --- /dev/null +++ b/src/variables/components/empty.less @@ -0,0 +1,29 @@ +@import "../global.less"; + +/* Sizes */ +@veui-empty-max-width-s: @veui-padding-unit * 60; +@veui-empty-max-width-m: @veui-padding-unit * 80; +@veui-empty-image-width-s: @veui-padding-unit * 19; +@veui-empty-image-height-s: @veui-padding-unit * 18 - 2; +@veui-empty-image-width-m: @veui-padding-unit * 23; +@veui-empty-image-height-m: @veui-padding-unit * 22 - 2; + + +/* Title */ +@veui-empty-title-font-size-s: @veui-font-size-s; +@veui-empty-title-font-size-m: @veui-font-size-m; +@veui-empty-title-line-height: @veui-line-height-m; +@veui-empty-title-font-color: @veui-font-color-normal; +@veui-empty-title-font-weight: @veui-font-weight-2; + +/* Desc */ +@veui-empty-desc-font-size-s: @veui-font-size-s; +@veui-empty-desc-font-size-m: @veui-font-size-m; +@veui-empty-desc-line-height: @veui-line-height-m; +@veui-empty-desc-font-color: @veui-font-color-weak; +@veui-empty-desc-font-weight: @veui-font-weight-1; + +/* Spacing */ +@veui-empty-content-spacing: @veui-padding-unit * 2 - 2; +@veui-empty-actions-spacing-before: @veui-padding-unit * 4; +@veui-empty-actions-content-spacing: @veui-padding-unit * 2;