Skip to content

Commit

Permalink
feat(dark): form basic
Browse files Browse the repository at this point in the history
  • Loading branch information
Erindcl committed Aug 12, 2020
1 parent b503266 commit 60f54bf
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 2 deletions.
101 changes: 101 additions & 0 deletions components/form/demo/basic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
order: 0
title:
zh-CN: 基本使用
en-US: Basic usage
---

## zh-CN

基本使用。

## en-US

Basic usage example.

```jsx
import { Form, Icon, Input, Button, Checkbox, InputNumber, Radio, Switch } from 'antd';
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 3 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 10 },
},
};
class NormalLoginForm extends React.Component {
handleSubmit = e => {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
}
});
};

render() {
const { getFieldDecorator } = this.props.form;
return (
<Form {...formItemLayout} onSubmit={this.handleSubmit}>
<Form.Item label={'用户名'}>
{getFieldDecorator('username', {
rules: [{ required: true, message: 'It is required!' }],
})(
<Input placeholder="Username"/>
)}
</Form.Item>
<Form.Item label={'密码'}>
{getFieldDecorator('password', {
rules: [{ required: true, message: 'It is required!' }],
})(
<Input type="password" placeholder="Password"/>
)}
</Form.Item>
<Form.Item label={'次数限制'}>
{getFieldDecorator('count', {
rules: [{ required: false, message: 'It is required!' }],
})(
<InputNumber min={1} style={{ width: '100%' }} max={10} />
)}
</Form.Item>
<Form.Item label={'告警方式'}>
{getFieldDecorator('way', {
rules: [{ required: false, message: 'It is required!' }],
})(
<Checkbox.Group options={[{ label: '邮件', value: '1' }, { label: '短信', value: '2' }]} />
)}
</Form.Item>
<Form.Item label={'存储类型'}>
{getFieldDecorator('type', {
rules: [{ required: false, message: 'It is required!' }],
})(
<Radio.Group>
<Radio value={1}>orc</Radio>
<Radio value={2}>text</Radio>
<Radio value={3}>md</Radio>
</Radio.Group>
)}
</Form.Item>
<Form.Item label={'开关'}>
{getFieldDecorator('switch', {
rules: [{ required: false, message: 'It is required!' }],
})(
<Switch />
)}
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
提交表单
</Button>
</Form.Item>
</Form>
);
}
}

const WrappedNormalLoginForm = Form.create({ name: 'normal_login' })(NormalLoginForm);

ReactDOM.render(<WrappedNormalLoginForm />, mountNode);
```
20 changes: 20 additions & 0 deletions components/form/index.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
category: Components
subtitle: 表单
type: 数据录入
title: Form
cols: 1
---

具有数据收集、校验和提交功能的表单,包含复选框、单选框、输入框、下拉选择框等元素。

## 设计规则

纵向相邻表单之间的间隔为 20 px

## API

|类名 |说明 |使用示例 |
|---------|---------|---------|
|.dt-form-shadow-bg | 灰色背景,表单样式设置 | 灰色背景(仅默认主题下使用) |
|.dt-form-light-bg | 浅色背景上,显示深色控件 | 浅色背景(仅暗黑主题下使用) |
2 changes: 1 addition & 1 deletion components/select/demo/light.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const { Option } = Select;

ReactDOM.render(
<div className="demo-select-light">
<Select defaultValue="lucy" dropdownClassName="dt-form-light-bg" className="dt-form-light-bg" style={{ width: 200 }}>
<Select defaultValue="lucy" dropdownClassName="dt-form-light-bg" className="dt-form-light-bg" style={{ width: 200, marginRight: 20 }}>
<Option value="jack">Jack</Option>
<Option value="lucy">Lucy</Option>
<Option value="Yiminghe">yiminghe</Option>
Expand Down
11 changes: 11 additions & 0 deletions docs/react/change-log.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ toc: false
timeline: true
---

## [1.1.0](http://gitlab.prod.dtstack.cn/dt-insight-front/infrastructure/ant-design-dtinsight-theme/tree/v1.1.0) (020-07-31)

### Features

* (待补充)

### Fix

* 更新 readme 线上地址
* 修复 layout 侧边栏导航图标不对齐问题

## [1.0.9](http://gitlab.prod.dtstack.cn/dt-insight-front/infrastructure/ant-design-dtinsight-theme/tree/v1.0.9) (020-07-31)

### Fix
Expand Down
21 changes: 21 additions & 0 deletions theme/dt-theme/dark/form.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@import '../const.less';

// form
.ant-form-item-label > label {
color: @whiteBF;
}
// input
.ant-input {
border-radius: 4px;
Expand Down Expand Up @@ -31,6 +35,23 @@
.ant-select-dropdown {
box-shadow:0px 2px 8px 0px rgba(6,7,10,1);
}
// checkbox
.ant-checkbox-inner {
background-color: #11121C;
border-color: #363B59;
}
.ant-checkbox + span {
color: @whiteBF;
}
// radio
.ant-radio-inner {
background-color: #11121C;
border-color: #363B59;
}
// switch
.ant-switch-loading-icon, .ant-switch::after {
background-color: #ffffff;
}

// 浅色背景中 显示深色控件
.dt-form-light-bg {
Expand Down
2 changes: 1 addition & 1 deletion theme/dt-theme/dark/resetDark.less
Original file line number Diff line number Diff line change
Expand Up @@ -493,4 +493,4 @@
// select
@select-background: #1D1F2E;
@select-item-selected-bg: #292D42;
@select-item-selected-font-weight: normal;
@select-item-selected-font-weight: normal;
1 change: 1 addition & 0 deletions theme/static/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ a {
.demo-select-size {
.ant-select {
margin-bottom: 20px;
margin-right: 20px;
width: 200px;
}
}
Expand Down

0 comments on commit 60f54bf

Please sign in to comment.