From ad14a3f40b93b49320be925423d48ad74b316fe3 Mon Sep 17 00:00:00 2001 From: Javey Date: Mon, 6 Jul 2020 18:35:20 +0800 Subject: [PATCH] feat(Form): support size to control margin between FormItems, close #499 --- components/form/demos/layout.md | 12 ++++++++++-- components/form/form.js | 6 ++++-- components/form/form.vdt | 3 ++- components/form/index.md | 1 + components/form/index.styl | 9 ++++++++- components/form/variables.styl | 8 +++++++- components/input/demos/textarea.md | 1 + components/input/index.styl | 1 + components/tooltip/index.spec.js | 14 +++++++------- styles/themes/ksyun/index.styl | 10 ++++++++++ 10 files changed, 51 insertions(+), 14 deletions(-) diff --git a/components/form/demos/layout.md b/components/form/demos/layout.md index af4719847..4ef6d887e 100644 --- a/components/form/demos/layout.md +++ b/components/form/demos/layout.md @@ -3,7 +3,7 @@ title: 表单布局 order: 5 --- -通过`layout`指定表单布局:`horizontal`, `vertical`, `inline` +通过`layout`指定表单布局:`horizontal`, `vertical`, `inline`,还可以通过`size`控制`FormItem`的间距 ```vdt import {Form, FormItem} from 'kpc/components/form'; @@ -11,7 +11,7 @@ import {Input} from 'kpc/components/input'; import {Select, Option} from 'kpc/components/select'; import {ButtonGroup, Button} from 'kpc/components/button'; -
+ @@ -19,6 +19,13 @@ import {ButtonGroup, Button} from 'kpc/components/button'; + + + + + + + @@ -48,6 +55,7 @@ export default class extends Intact { checkbox: [], }, layout: 'horizontal', + size: 'default', }; } } diff --git a/components/form/form.js b/components/form/form.js index ac54fc909..617059542 100644 --- a/components/form/form.js +++ b/components/form/form.js @@ -5,9 +5,9 @@ import '../../styles/kpc.styl'; import './index.styl'; export default class Form extends Intact { - static methods = methods; + static methods = methods; - static messages = messages; + static messages = messages; static classNames = classNames; @@ -22,6 +22,7 @@ export default class Form extends Intact { labelWidth: [String, Number], layout: ['horizontal', 'vertical', 'inline'], starOnRequired: Boolean, + size: ['default', 'small', 'mini'], }; static events = { @@ -35,6 +36,7 @@ export default class Form extends Intact { labelWidth: undefined, layout: 'horizontal', starOnRequired: false, + size: 'default', } } diff --git a/components/form/form.vdt b/components/form/form.vdt index f1fa63e4c..66e21b154 100644 --- a/components/form/form.vdt +++ b/components/form/form.vdt @@ -1,11 +1,12 @@ import {getRestProps} from '../utils'; -const {children, className, layout} = self.get(); +const {children, className, layout, size} = self.get(); const classNameObj = { 'k-form': true, [className]: className, [`k-${layout}`]: layout, + [`k-${size}`]: size !== 'default', };
+
``` diff --git a/components/input/index.styl b/components/input/index.styl index aab37b793..289f5f67b 100644 --- a/components/input/index.styl +++ b/components/input/index.styl @@ -146,6 +146,7 @@ padding $input-textarea-padding height auto line-height 1.5 + vertical-align top // fake dom for get value's width .k-fake diff --git a/components/tooltip/index.spec.js b/components/tooltip/index.spec.js index bb5126f32..abc62eef3 100644 --- a/components/tooltip/index.spec.js +++ b/components/tooltip/index.spec.js @@ -13,13 +13,13 @@ import {mount, unmount, dispatchEvent, getElement, wait} from 'test/utils'; describe('Tooltip', () => { let instance; - // afterEach((done) => { - // if (instance) { - // unmount(instance); - // instance = null; - // } - // setTimeout(done, 500); - // }); + afterEach((done) => { + if (instance) { + unmount(instance); + instance = null; + } + setTimeout(done, 500); + }); it('should show and hide content correctly', async () => { instance = mount(BasicDemo); diff --git a/styles/themes/ksyun/index.styl b/styles/themes/ksyun/index.styl index ef57a3403..22d7a5b78 100644 --- a/styles/themes/ksyun/index.styl +++ b/styles/themes/ksyun/index.styl @@ -338,4 +338,14 @@ $colorpicker-small-padding := 2px $colorpicker-mini-width := 40px $colorpicker-mini-padding = 1px +/** + * form + */ +$form-item-margin := 0 0 24px 0 +$form-item-inline-margin-right := 16px +$form-small-item-margin := 0 0 16px 0 +$form-small-item-inline-margin-right := 12px +$form-mini-item-margin := 0 0 8px 0 +$form-mini-item-inline-margin-right := 8px + @require('../default.styl')