Skip to content
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

Feat/box update #4685

Merged
merged 2 commits into from
Jan 25, 2024
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
2 changes: 1 addition & 1 deletion components/box/__docs__/demo/wrap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BoxDemo extends React.Component {
state = {
wrap: true,
};
onSwitchChange = checked => {
onSwitchChange = (checked: boolean) => {
this.setState({
wrap: checked,
});
Expand Down
76 changes: 0 additions & 76 deletions components/box/__docs__/theme/index.jsx

This file was deleted.

93 changes: 93 additions & 0 deletions components/box/__docs__/theme/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React from 'react';
import ReactDOM from 'react-dom';
import '../../../demo-helper/style';
import { Demo, DemoGroup, initDemo, DemoFunctionDefineForObject } from '../../../demo-helper';
import ConfigProvider from '../../../config-provider';
import zhCN from '../../../locale/zh-cn';
import enUS from '../../../locale/en-us';
import '../../style';
import Box from '../../index';

const i18nMap = {
'zh-cn': {
box: '弹性布局',
normal: '正常',
},
'en-us': {
box: 'Box',
normal: 'Normal',
},
};
interface RenderBoxState {
demoFunction: Record<string, DemoFunctionDefineForObject>;
}

interface RenderBoxProps {
i18nMap: { [index: string]: string };
}
class RenderBox extends React.Component<RenderBoxProps, RenderBoxState> {
constructor(props: RenderBoxProps) {
super(props);
this.state = {
demoFunction: {
hasChildren: {
label: 'Box使用',
value: 'false',
enum: [
{
label: '不独立使用',
value: false,
},
{
label: '独立使用',
value: true,
},
],
},
},
};
}

onFunctionChange = (demoFunction: RenderBoxState['demoFunction']) => {
this.setState({ demoFunction });
};

render() {
const { i18nMap } = this.props;
const { demoFunction } = this.state;
const hasChildren = demoFunction ? demoFunction.hasChildren.value === 'true' : null;

return (
<Demo
title={i18nMap.box}
demoFunction={demoFunction}
onFunctionChange={this.onFunctionChange}
>
<Demo title={i18nMap.box}>
<DemoGroup label={i18nMap.normal}>
<Box children={hasChildren} />
</DemoGroup>
</Demo>
</Demo>
);
}
}

function render(i18nMap: { [index: string]: string }, lang: string) {
ReactDOM.render(
<ConfigProvider locale={lang === 'en-us' ? enUS : zhCN}>
<div className="demo-container">
<RenderBox i18nMap={i18nMap} />
</div>
</ConfigProvider>,
document.getElementById('container')
);
}

window.renderDemo = function (lang = 'en-us') {
render(i18nMap[lang], lang);
};

renderDemo();

initDemo('box');
26 changes: 0 additions & 26 deletions components/box/__tests__/a11y-spec.js

This file was deleted.

12 changes: 12 additions & 0 deletions components/box/__tests__/a11y-spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import Box from '../index';
import '../style';
import { testReact } from '../../util/__tests__/a11y/validate';

describe('Box A11y', () => {
describe('Box A11y', () => {
it('should render', async () => {
await testReact(<Box />);
});
});
});
95 changes: 0 additions & 95 deletions components/box/__tests__/index-spec.js

This file was deleted.

51 changes: 51 additions & 0 deletions components/box/__tests__/index-spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';
import Box from '../index';
import '../style';

describe('Box', () => {
it('should render', () => {
cy.mount(
<Box direction="row" wrap className="border-box" spacing={30}>
<Box
className="border-box height-100 width-150"
direction="row"
wrap
spacing={8}
padding={10}
>
<Box className="border-box height-30 width-30 dashed" />
<Box className="border-box height-30 width-30" />
<Box className="border-box height-30 width-30" />
<Box className="border-box height-30 width-30" />
<Box
className="border-box height-30 width-30 dashed"
margin={[3, 6]}
style={{ marginRight: 10 }}
/>
<Box className="border-box height-30 width-30" />
</Box>

<Box className="border-box height-100 width-150" />
<Box className="border-box height-100 width-150" />
<Box className="border-box height-100 width-150" />
<Box className="border-box height-100 width-150" />
<Box className="border-box height-100 width-150" />
<Box className="border-box height-100 width-150" />
<Box className="border-box height-100 width-150" />
</Box>
);
cy.get('.next-box');
});

it('justify should work when wrap and spacing setted', () => {
cy.mount(
<Box className="test" wrap spacing={20} direction="row" justify="center">
<Box className="box-180-50" />
<Box className="box-180-50" />
<Box className="box-180-50" />
<Box className="box-180-50" />
</Box>
);
cy.get('.test').should('have.css', 'justify-content', 'center');
});
});
19 changes: 0 additions & 19 deletions components/box/index.d.ts

This file was deleted.

Loading
Loading