Skip to content

Refactor test #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const base = require('@umijs/fabric/dist/eslint');

module.exports = {
...base,
extends: [require.resolve('@umijs/fabric/dist/eslint')],
rules: {
...base.rules,
'no-template-curly-in-string': 0,
'prefer-promise-reject-errors': 0,
'react/no-array-index-key': 0,
Expand All @@ -13,5 +10,6 @@ module.exports = {
'no-param-reassign': 0,
'no-restricted-globals': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-shadow': 'off',
},
};
};
3 changes: 3 additions & 0 deletions docs/demo/base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## base

<code src="../examples/base.tsx">
39 changes: 39 additions & 0 deletions docs/examples/base.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import React, { useState } from 'react';
import Drawer from 'rc-drawer';

const Demo = () => {
const [open, setOpen] = useState(false);
const onChange = (bool: boolean) => {
// console.log('change: ', bool);
};
const onTouchEnd = () => {
setOpen(false);
};
const onSwitch = () => {
setOpen(c => !c);
};
return (
<div>
<Drawer
onChange={onChange}
open={open}
// defaultOpen
onClose={onTouchEnd}
handler={false}
level={null}
afterVisibleChange={(c: boolean) => {
// console.log('transitionEnd: ', c);
}}
placement="right"
width={400}
>
content
</Drawer>
<div>
<button onClick={onSwitch}>打开</button>
</div>
</div>
);
};
export default Demo;
118 changes: 66 additions & 52 deletions docs/examples/change-remove.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/* eslint-disable no-console,react/no-multi-comp */
import { Icon, Menu } from 'antd';
import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons';
import { Menu } from 'antd';
import * as React from 'react';

import Drawer from 'rc-drawer';

import 'antd/lib/menu/style';
import 'antd/lib/style';


import '../../assets/index.less';
import './assets/index.less';

Expand All @@ -16,7 +12,7 @@ const MenuItemGroup = Menu.ItemGroup;
class Demo extends React.Component<any, { show: boolean }> {
public state = {
show: true,
}
};
public componentDidMount() {
setTimeout(() => {
this.setState({
Expand All @@ -26,55 +22,73 @@ class Demo extends React.Component<any, { show: boolean }> {
}
public render() {
return (
<div >
{this.state.show && <Drawer
wrapperClassName="drawer-wrapper"
width="20vw"
>
<Menu
defaultSelectedKeys={['1']}
defaultOpenKeys={['sub1']}
mode="inline"
>
<SubMenu
key="sub1"
title={<span><Icon type="mail" /><span>Navigation One</span></span>}
<div>
{this.state.show && (
<Drawer wrapperClassName="drawer-wrapper" width="20vw">
<Menu
defaultSelectedKeys={['1']}
defaultOpenKeys={['sub1']}
mode="inline"
>
<MenuItemGroup key="g1" title="Item 1">
<Menu.Item key="1">Option 1</Menu.Item>
<Menu.Item key="2">Option 2</Menu.Item>
</MenuItemGroup>
<MenuItemGroup key="g2" title="Item 2">
<Menu.Item key="3">Option 3</Menu.Item>
<Menu.Item key="4">Option 4</Menu.Item>
</MenuItemGroup>
</SubMenu>
<SubMenu
key="sub2"
title={<span><Icon type="appstore" /><span>Navigation Two</span></span>}
>
<Menu.Item key="5">Option 5</Menu.Item>
<Menu.Item key="6">Option 6</Menu.Item>
<SubMenu key="sub3" title="Submenu">
<Menu.Item key="7">Option 7</Menu.Item>
<Menu.Item key="8">Option 8</Menu.Item>
<SubMenu
key="sub1"
title={
<span>
<MailOutlined />
<span>Navigation One</span>
</span>
}
>
<MenuItemGroup key="g1" title="Item 1">
<Menu.Item key="1">Option 1</Menu.Item>
<Menu.Item key="2">Option 2</Menu.Item>
</MenuItemGroup>
<MenuItemGroup key="g2" title="Item 2">
<Menu.Item key="3">Option 3</Menu.Item>
<Menu.Item key="4">Option 4</Menu.Item>
</MenuItemGroup>
</SubMenu>
</SubMenu>
<SubMenu
key="sub4"
title={<span><Icon type="setting" /><span>Navigation Three</span></span>}
>
<Menu.Item key="9">Option 9</Menu.Item>
<Menu.Item key="10">Option 10</Menu.Item>
<Menu.Item key="11">Option 11</Menu.Item>
<Menu.Item key="12">Option 12</Menu.Item>
</SubMenu>
</Menu>
</Drawer>}
<SubMenu
key="sub2"
title={
<span>
<AppstoreOutlined />
<span>Navigation Two</span>
</span>
}
>
<Menu.Item key="5">Option 5</Menu.Item>
<Menu.Item key="6">Option 6</Menu.Item>
<SubMenu key="sub3" title="Submenu">
<Menu.Item key="7">Option 7</Menu.Item>
<Menu.Item key="8">Option 8</Menu.Item>
</SubMenu>
</SubMenu>
<SubMenu
key="sub4"
title={
<span>
<SettingOutlined />
<span>Navigation Three</span>
</span>
}
>
<Menu.Item key="9">Option 9</Menu.Item>
<Menu.Item key="10">Option 10</Menu.Item>
<Menu.Item key="11">Option 11</Menu.Item>
<Menu.Item key="12">Option 12</Menu.Item>
</SubMenu>
</Menu>
</Drawer>
)}
<div
style={{
width: '100%', height: 667, background: '#fff000',
color: '#fff', textAlign: 'center', lineHeight: '667px',
width: '100%',
height: 667,
background: '#fff000',
color: '#fff',
textAlign: 'center',
lineHeight: '667px',
}}
>
内容区块
Expand Down
51 changes: 38 additions & 13 deletions docs/examples/change.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console,react/no-multi-comp */
import { Icon, Menu } from 'antd';
import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons';
import { Menu } from 'antd';
import * as React from 'react';

import Drawer from 'rc-drawer';
Expand All @@ -15,7 +15,7 @@ const MenuItemGroup = Menu.ItemGroup;
class Demo extends React.Component {
public state = {
open: true,
}
};
public componentDidMount() {
setTimeout(() => {
this.setState({
Expand All @@ -25,20 +25,20 @@ class Demo extends React.Component {
}
public onChange = (bool: boolean) => {
console.log('change: ', bool);
}
};
public onTouchEnd = () => {
this.setState({
open: false,
});
}
};
public onSwitch = () => {
this.setState({
open: !this.state.open,
});
}
};
public render() {
return (
<div >
<div>
<Drawer
onChange={this.onChange}
open={this.state.open}
Expand All @@ -57,7 +57,12 @@ class Demo extends React.Component {
>
<SubMenu
key="sub1"
title={<span><Icon type="mail" /><span>Navigation One</span></span>}
title={
<span>
<MailOutlined />
<span>Navigation One</span>
</span>
}
>
<MenuItemGroup key="g1" title="Item 1">
<Menu.Item key="1">Option 1</Menu.Item>
Expand All @@ -70,7 +75,12 @@ class Demo extends React.Component {
</SubMenu>
<SubMenu
key="sub2"
title={<span><Icon type="appstore" /><span>Navigation Two</span></span>}
title={
<span>
<AppstoreOutlined />
<span>Navigation Two</span>
</span>
}
>
<Menu.Item key="5">Option 5</Menu.Item>
<Menu.Item key="6">Option 6</Menu.Item>
Expand All @@ -81,7 +91,12 @@ class Demo extends React.Component {
</SubMenu>
<SubMenu
key="sub4"
title={<span><Icon type="setting" /><span>Navigation Three</span></span>}
title={
<span>
<SettingOutlined />
<span>Navigation Three</span>
</span>
}
>
<Menu.Item key="9">Option 9</Menu.Item>
<Menu.Item key="10">Option 10</Menu.Item>
Expand All @@ -92,14 +107,24 @@ class Demo extends React.Component {
</Drawer>
<div
style={{
width: '100%', height: 667, background: '#fff000',
color: '#fff', textAlign: 'center', lineHeight: '667px',
width: '100%',
height: 667,
background: '#fff000',
color: '#fff',
textAlign: 'center',
lineHeight: '667px',
}}
>
内容区块
<button
onClick={this.onSwitch}
style={{ height: 24, width: 100, marginLeft: 20, color: '#000', lineHeight: '24px' }}
style={{
height: 24,
width: 100,
marginLeft: 20,
color: '#000',
lineHeight: '24px',
}}
>
{!this.state.open ? '打开' : '关闭'}
</button>
Expand Down
Loading