Browse Source

fix: context issues for Space.Compact (#38887)

pull/38913/head
Yuki Zhang 2 years ago
committed by GitHub
parent
commit
3af410ab3f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 61
      components/drawer/index.tsx
  2. 2
      components/drawer/style/index.tsx
  3. 5
      components/dropdown/dropdown.tsx
  4. 18
      components/input-number/index.tsx
  5. 47
      components/modal/Modal.tsx
  6. 2
      components/modal/style/index.tsx
  7. 322
      components/space/__tests__/__snapshots__/demo-extend.test.ts.snap
  8. 186
      components/space/__tests__/__snapshots__/demo.test.ts.snap
  9. 68
      components/space/__tests__/space-compact.test.tsx
  10. 173
      components/space/demo/compact-debug.md

61
components/drawer/index.tsx

@ -9,6 +9,7 @@ import { NoFormStyle } from '../form/context';
import { getTransitionName } from '../_util/motion';
import { tuple } from '../_util/type';
import warning from '../_util/warning';
import { NoCompactStyle } from '../space/Compact';
const SizeTypes = tuple('default', 'large');
type sizeType = typeof SizeTypes[number];
@ -163,7 +164,7 @@ function Drawer(props: DrawerProps) {
motionDeadline: 500,
};
const panelMotion: RcDrawerProps['motion'] = motionPlacement => ({
const panelMotion: RcDrawerProps['motion'] = (motionPlacement) => ({
motionName: getTransitionName(prefixCls, `panel-motion-${motionPlacement}`),
motionAppear: true,
motionEnter: true,
@ -173,35 +174,37 @@ function Drawer(props: DrawerProps) {
// =========================== Render ===========================
return (
<NoFormStyle status override>
<RcDrawer
prefixCls={prefixCls}
onClose={onClose}
{...rest}
open={open || visible}
mask={mask}
push={push}
width={mergedWidth}
height={mergedHeight}
rootClassName={drawerClassName}
getContainer={getContainer}
afterOpenChange={isOpen => {
afterOpenChange?.(isOpen);
afterVisibleChange?.(isOpen);
}}
maskMotion={maskMotion}
motion={panelMotion}
rootStyle={style}
>
<div className={`${prefixCls}-wrapper-body`} style={{ ...drawerStyle }}>
{renderHeader()}
<div className={`${prefixCls}-body`} style={bodyStyle}>
{children}
<NoCompactStyle>
<NoFormStyle status override>
<RcDrawer
prefixCls={prefixCls}
onClose={onClose}
{...rest}
open={open || visible}
mask={mask}
push={push}
width={mergedWidth}
height={mergedHeight}
rootClassName={drawerClassName}
getContainer={getContainer}
afterOpenChange={(isOpen) => {
afterOpenChange?.(isOpen);
afterVisibleChange?.(isOpen);
}}
maskMotion={maskMotion}
motion={panelMotion}
rootStyle={style}
>
<div className={`${prefixCls}-wrapper-body`} style={{ ...drawerStyle }}>
{renderHeader()}
<div className={`${prefixCls}-body`} style={bodyStyle}>
{children}
</div>
{renderFooter()}
</div>
{renderFooter()}
</div>
</RcDrawer>
</NoFormStyle>
</RcDrawer>
</NoFormStyle>
</NoCompactStyle>
);
}

2
components/drawer/style/index.tsx

@ -1,3 +1,3 @@
// deps-lint-skip: empty, form
// deps-lint-skip: empty, form, space
import '../../style/index.less';
import './index.less';

5
components/dropdown/dropdown.tsx

@ -13,6 +13,7 @@ import { cloneElement } from '../_util/reactNode';
import { tuple } from '../_util/type';
import warning from '../_util/warning';
import DropdownButton from './dropdown-button';
import { NoCompactStyle } from '../space/Compact';
const Placements = tuple(
'topLeft',
@ -83,7 +84,7 @@ interface DropdownInterface extends React.FC<DropdownProps> {
Button: typeof DropdownButton;
}
const Dropdown: DropdownInterface = props => {
const Dropdown: DropdownInterface = (props) => {
const {
getPopupContainer: getContextPopupContainer,
getPrefixCls,
@ -244,7 +245,7 @@ const Dropdown: DropdownInterface = props => {
);
}}
>
{overlayNode}
<NoCompactStyle>{overlayNode}</NoCompactStyle>
</OverrideProvider>
);
};

18
components/input-number/index.tsx

@ -11,7 +11,7 @@ import DisabledContext from '../config-provider/DisabledContext';
import type { SizeType } from '../config-provider/SizeContext';
import SizeContext from '../config-provider/SizeContext';
import { FormItemInputContext, NoFormStyle } from '../form/context';
import { useCompactItemContext } from '../space/Compact';
import { NoCompactStyle, useCompactItemContext } from '../space/Compact';
import { cloneElement } from '../_util/reactNode';
import type { InputStatus } from '../_util/statusUtils';
import { getMergedStatus, getStatusClassNames } from '../_util/statusUtils';
@ -180,15 +180,19 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props,
<div className={mergedGroupClassName} style={props.style}>
<div className={mergedWrapperClassName}>
{addonBeforeNode && (
<NoFormStyle status override>
{addonBeforeNode}
</NoFormStyle>
<NoCompactStyle>
<NoFormStyle status override>
{addonBeforeNode}
</NoFormStyle>
</NoCompactStyle>
)}
{cloneElement(element, { style: null, disabled: mergedDisabled })}
{addonAfterNode && (
<NoFormStyle status override>
{addonAfterNode}
</NoFormStyle>
<NoCompactStyle>
<NoFormStyle status override>
{addonAfterNode}
</NoFormStyle>
</NoCompactStyle>
)}
</div>
</div>

47
components/modal/Modal.tsx

@ -10,6 +10,7 @@ import type { DirectionType } from '../config-provider';
import { ConfigContext } from '../config-provider';
import { NoFormStyle } from '../form/context';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import { NoCompactStyle } from '../space/Compact';
import { getTransitionName } from '../_util/motion';
import { canUseDocElement } from '../_util/styleChecker';
import warning from '../_util/warning';
@ -148,7 +149,7 @@ export interface ModalLocale {
justOkText: string;
}
const Modal: React.FC<ModalProps> = props => {
const Modal: React.FC<ModalProps> = (props) => {
const {
getPopupContainer: getContextPopupContainer,
getPrefixCls,
@ -190,7 +191,7 @@ const Modal: React.FC<ModalProps> = props => {
const defaultFooter = (
<LocaleReceiver componentName="Modal" defaultLocale={getConfirmLocale()}>
{contextLocale => {
{(contextLocale) => {
const { okText, okType = 'primary', cancelText, confirmLoading = false } = props;
return (
@ -223,25 +224,29 @@ const Modal: React.FC<ModalProps> = props => {
[`${prefixCls}-wrap-rtl`]: direction === 'rtl',
});
return (
<NoFormStyle status override>
<Dialog
width={width}
{...restProps}
getContainer={
getContainer === undefined ? (getContextPopupContainer as getContainerFunc) : getContainer
}
prefixCls={prefixCls}
wrapClassName={wrapClassNameExtended}
footer={footer === undefined ? defaultFooter : footer}
visible={open || visible}
mousePosition={restProps.mousePosition ?? mousePosition}
onClose={handleCancel}
closeIcon={closeIconToRender}
focusTriggerAfterClose={focusTriggerAfterClose}
transitionName={getTransitionName(rootPrefixCls, 'zoom', props.transitionName)}
maskTransitionName={getTransitionName(rootPrefixCls, 'fade', props.maskTransitionName)}
/>
</NoFormStyle>
<NoCompactStyle>
<NoFormStyle status override>
<Dialog
width={width}
{...restProps}
getContainer={
getContainer === undefined
? (getContextPopupContainer as getContainerFunc)
: getContainer
}
prefixCls={prefixCls}
wrapClassName={wrapClassNameExtended}
footer={footer === undefined ? defaultFooter : footer}
visible={open || visible}
mousePosition={restProps.mousePosition ?? mousePosition}
onClose={handleCancel}
closeIcon={closeIconToRender}
focusTriggerAfterClose={focusTriggerAfterClose}
transitionName={getTransitionName(rootPrefixCls, 'zoom', props.transitionName)}
maskTransitionName={getTransitionName(rootPrefixCls, 'fade', props.maskTransitionName)}
/>
</NoFormStyle>
</NoCompactStyle>
);
};

2
components/modal/style/index.tsx

@ -1,6 +1,6 @@
import '../../style/index.less';
import './index.less';
// deps-lint-skip: form
// deps-lint-skip: form, space
// style dependencies
import '../../button/style';

322
components/space/__tests__/__snapshots__/demo-extend.test.ts.snap

@ -10227,6 +10227,7 @@ exports[`renders ./components/space/demo/compact-debug.md extend context correct
</div>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<div
class="ant-space-compact"
@ -10399,6 +10400,327 @@ exports[`renders ./components/space/demo/compact-debug.md extend context correct
</button>
</div>
</div>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<br />
</div>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<div
class="ant-space-compact"
>
<button
class="ant-btn ant-btn-default ant-btn-compact-item ant-btn-compact-first-item ant-btn-compact-last-item"
type="button"
>
<span>
debug Modal context
</span>
</button>
</div>
</div>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<div
class="ant-space-compact"
>
<div
class="ant-space-compact ant-space-compact-block ant-dropdown-button ant-dropdown-button-compact-item ant-dropdown-button-compact-first-item ant-dropdown-button-compact-last-item"
>
<button
class="ant-btn ant-btn-default ant-btn-compact-item ant-btn-compact-first-item"
type="button"
>
<span>
debug Dropdown.Button context
</span>
</button>
<button
class="ant-btn ant-btn-default ant-btn-icon-only ant-btn-compact-item ant-btn-compact-last-item ant-dropdown-trigger"
type="button"
>
<span
aria-label="ellipsis"
class="anticon anticon-ellipsis"
role="img"
>
<svg
aria-hidden="true"
data-icon="ellipsis"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M176 511a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0z"
/>
</svg>
</span>
</button>
<div>
<div
class="ant-dropdown"
style="opacity:0"
>
<ul
class="ant-dropdown-menu ant-dropdown-menu-root ant-dropdown-menu-vertical ant-dropdown-menu-light"
data-menu-list="true"
role="menu"
tabindex="0"
>
<li
class="ant-dropdown-menu-item ant-dropdown-menu-item-only-child"
role="menuitem"
tabindex="-1"
>
<span
class="ant-dropdown-menu-title-content"
>
<button
class="ant-btn ant-btn-default"
type="button"
>
<span>
menu button
</span>
</button>
</span>
</li>
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0"
>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-arrow"
>
<span
class="ant-tooltip-arrow-content"
/>
</div>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
</div>
<li
class="ant-dropdown-menu-item ant-dropdown-menu-item-only-child"
role="menuitem"
tabindex="-1"
>
<span
class="ant-dropdown-menu-title-content"
>
normal menu item
</span>
</li>
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0"
>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-arrow"
>
<span
class="ant-tooltip-arrow-content"
/>
</div>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
</div>
</ul>
<div
aria-hidden="true"
style="display:none"
>
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0"
>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-arrow"
>
<span
class="ant-tooltip-arrow-content"
/>
</div>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
</div>
<div>
<div
class="ant-tooltip ant-dropdown-menu-inline-collapsed-tooltip"
style="opacity:0"
>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-arrow"
>
<span
class="ant-tooltip-arrow-content"
/>
</div>
<div
class="ant-tooltip-inner"
role="tooltip"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<div
class="ant-space-compact"
>
<button
class="ant-btn ant-btn-default ant-btn-compact-item ant-btn-compact-first-item ant-btn-compact-last-item"
type="button"
>
<span>
debug Drawer context
</span>
</button>
</div>
</div>
<div
class="ant-space-item"
>
<div
class="ant-space-compact"
>
<div
class="ant-input-number-group-wrapper"
>
<div
class="ant-input-number-wrapper ant-input-number-group"
>
<div
class="ant-input-number-group-addon"
>
+
</div>
<div
class="ant-input-number ant-input-number-compact-item ant-input-number-compact-first-item ant-input-number-compact-last-item"
>
<div
class="ant-input-number-handler-wrap"
>
<span
aria-disabled="false"
aria-label="Increase Value"
class="ant-input-number-handler ant-input-number-handler-up"
role="button"
unselectable="on"
>
<span
aria-label="up"
class="anticon anticon-up ant-input-number-handler-up-inner"
role="img"
>
<svg
aria-hidden="true"
data-icon="up"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M890.5 755.3L537.9 269.2c-12.8-17.6-39-17.6-51.7 0L133.5 755.3A8 8 0 00140 768h75c5.1 0 9.9-2.5 12.9-6.6L512 369.8l284.1 391.6c3 4.1 7.8 6.6 12.9 6.6h75c6.5 0 10.3-7.4 6.5-12.7z"
/>
</svg>
</span>
</span>
<span
aria-disabled="false"
aria-label="Decrease Value"
class="ant-input-number-handler ant-input-number-handler-down"
role="button"
unselectable="on"
>
<span
aria-label="down"
class="anticon anticon-down ant-input-number-handler-down-inner"
role="img"
>
<svg
aria-hidden="true"
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</span>
</div>
<div
class="ant-input-number-input-wrap"
>
<input
aria-valuenow="100"
autocomplete="off"
class="ant-input-number-input"
role="spinbutton"
step="1"
value="100"
/>
</div>
</div>
<div
class="ant-input-number-group-addon"
>
$
</div>
</div>
</div>
</div>
</div>
</div>
`;

186
components/space/__tests__/__snapshots__/demo.test.ts.snap

@ -2711,6 +2711,7 @@ exports[`renders ./components/space/demo/compact-debug.md correctly 1`] = `
</div>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<div
class="ant-space-compact"
@ -2808,6 +2809,191 @@ exports[`renders ./components/space/demo/compact-debug.md correctly 1`] = `
</button>
</div>
</div>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<br />
</div>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<div
class="ant-space-compact"
>
<button
class="ant-btn ant-btn-default ant-btn-compact-item ant-btn-compact-first-item ant-btn-compact-last-item"
type="button"
>
<span>
debug Modal context
</span>
</button>
</div>
</div>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<div
class="ant-space-compact"
>
<div
class="ant-space-compact ant-space-compact-block ant-dropdown-button ant-dropdown-button-compact-item ant-dropdown-button-compact-first-item ant-dropdown-button-compact-last-item"
>
<button
class="ant-btn ant-btn-default ant-btn-compact-item ant-btn-compact-first-item"
type="button"
>
<span>
debug Dropdown.Button context
</span>
</button>
<button
class="ant-btn ant-btn-default ant-btn-icon-only ant-btn-compact-item ant-btn-compact-last-item ant-dropdown-trigger"
type="button"
>
<span
aria-label="ellipsis"
class="anticon anticon-ellipsis"
role="img"
>
<svg
aria-hidden="true"
data-icon="ellipsis"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M176 511a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0z"
/>
</svg>
</span>
</button>
</div>
</div>
</div>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<div
class="ant-space-compact"
>
<button
class="ant-btn ant-btn-default ant-btn-compact-item ant-btn-compact-first-item ant-btn-compact-last-item"
type="button"
>
<span>
debug Drawer context
</span>
</button>
</div>
</div>
<div
class="ant-space-item"
>
<div
class="ant-space-compact"
>
<div
class="ant-input-number-group-wrapper"
>
<div
class="ant-input-number-wrapper ant-input-number-group"
>
<div
class="ant-input-number-group-addon"
>
+
</div>
<div
class="ant-input-number ant-input-number-compact-item ant-input-number-compact-first-item ant-input-number-compact-last-item"
>
<div
class="ant-input-number-handler-wrap"
>
<span
aria-disabled="false"
aria-label="Increase Value"
class="ant-input-number-handler ant-input-number-handler-up"
role="button"
unselectable="on"
>
<span
aria-label="up"
class="anticon anticon-up ant-input-number-handler-up-inner"
role="img"
>
<svg
aria-hidden="true"
data-icon="up"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M890.5 755.3L537.9 269.2c-12.8-17.6-39-17.6-51.7 0L133.5 755.3A8 8 0 00140 768h75c5.1 0 9.9-2.5 12.9-6.6L512 369.8l284.1 391.6c3 4.1 7.8 6.6 12.9 6.6h75c6.5 0 10.3-7.4 6.5-12.7z"
/>
</svg>
</span>
</span>
<span
aria-disabled="false"
aria-label="Decrease Value"
class="ant-input-number-handler ant-input-number-handler-down"
role="button"
unselectable="on"
>
<span
aria-label="down"
class="anticon anticon-down ant-input-number-handler-down-inner"
role="img"
>
<svg
aria-hidden="true"
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</span>
</div>
<div
class="ant-input-number-input-wrap"
>
<input
aria-valuenow="100"
autocomplete="off"
class="ant-input-number-input"
role="spinbutton"
step="1"
value="100"
/>
</div>
</div>
<div
class="ant-input-number-group-addon"
>
$
</div>
</div>
</div>
</div>
</div>
</div>
`;

68
components/space/__tests__/space-compact.test.tsx

@ -12,6 +12,9 @@ import DatePicker from '../../date-picker';
import Select from '../../select';
import TimePicker from '../../time-picker';
import TreeSelect from '../../tree-select';
import Modal from '../../modal';
import Dropdown from '../../dropdown';
import Drawer from '../../drawer';
describe('Space.Compact', () => {
mountTest(Space.Compact);
@ -131,7 +134,7 @@ describe('Space.Compact', () => {
<Space.Compact>{React.createElement(component as any)}</Space.Compact>,
);
expect(container.querySelectorAll(`.${targetCls}`).length).toBe(1);
['compact-item', 'compact-first-item', 'compact-last-item'].forEach(suffix => {
['compact-item', 'compact-first-item', 'compact-last-item'].forEach((suffix) => {
expect(
container
.querySelector(`.${targetCls}`)
@ -182,4 +185,67 @@ describe('Space.Compact', () => {
?.classList.contains('ant-btn-compact-vertical-last-item'),
).toBe(true);
});
it('context for Modal', () => {
render(
<Space.Compact size="small">
<Modal title="Basic Modal" open>
<Button>normal button A</Button>
<Input />
</Modal>
</Space.Compact>,
);
expect(
document.body
.querySelectorAll('.ant-modal')[0]
.querySelector('.ant-btn')
?.classList.contains('ant-btn-compact-item'),
).toBe(false);
expect(
document.body
.querySelectorAll('.ant-modal')[0]
.querySelector('.ant-input')
?.classList.contains('ant-input-compact-item'),
).toBe(false);
});
it('context for Dropdown', () => {
render(
<Space.Compact size="small">
<Dropdown.Button
visible
menu={{
items: [
{
key: '1',
label: <Button>menu button</Button>,
},
],
}}
>
debug Dropdown.Button context
</Dropdown.Button>
</Space.Compact>,
);
expect(
document.body
.querySelector('.ant-dropdown')
?.querySelector('.ant-btn')
?.classList.contains('ant-btn-compact-item'),
).toBe(false);
});
it('context for Drawer', () => {
render(
<Space.Compact size="small">
<Drawer title="Basic Drawer" open>
<Button>normal button A</Button>
</Drawer>
</Space.Compact>,
);
expect(
document.body
.querySelector('.ant-drawer')
?.querySelector('.ant-btn')
?.classList.contains('ant-btn-compact-item'),
).toBe(false);
});
});

173
components/space/demo/compact-debug.md

@ -17,8 +17,19 @@ Input addon debug.
```tsx
import { SettingOutlined, CopyOutlined, DownloadOutlined } from '@ant-design/icons';
import { Cascader, Input, Select, Space, Button, Tooltip } from 'antd';
import React from 'react';
import {
Cascader,
Input,
Select,
Space,
Button,
Tooltip,
Modal,
Dropdown,
Drawer,
InputNumber,
} from 'antd';
import React, { useState } from 'react';
const { Option } = Select;
@ -37,53 +48,117 @@ const selectAfter = (
</Select>
);
const App: React.FC = () => (
<Space direction="vertical">
<Space.Compact block>
<Button>default Button</Button>
<Button danger>danger Button</Button>
<Button type="dashed">dashed Button</Button>
<Button type="text">text Button</Button>
<Button type="link">Link Button</Button>
<Tooltip title="Tooltip">
<Button icon={<DownloadOutlined />} disabled />
</Tooltip>
</Space.Compact>
<br />
<Space.Compact>
<Button>Prefix</Button>
<Input addonBefore="http://" addonAfter=".com" defaultValue="mysite" />
<Button type="primary">Submit</Button>
</Space.Compact>
<Space.Compact>
<Input placeholder="prefix" />
<Input addonBefore={selectBefore} addonAfter={selectAfter} defaultValue="mysite" />
<Button icon={<CopyOutlined />} />
</Space.Compact>
<Space.Compact>
<Input.Search />
<Input.Search />
<Button icon={<CopyOutlined />} />
</Space.Compact>
<Space.Compact>
<Input addonAfter={<SettingOutlined />} defaultValue="mysite" />
<Button type="primary">Submit</Button>
<Input placeholder="suffix" addonAfter={<SettingOutlined />} />
</Space.Compact>
<Space.Compact>
<Input addonBefore="http://" suffix=".com" defaultValue="mysite" />
<Button type="primary">Submit</Button>
</Space.Compact>
<Space.Compact>
<Button>Prefix</Button>
<Input
addonBefore={<Cascader placeholder="cascader" style={{ width: 150 }} />}
defaultValue="mysite"
/>
<Button type="primary">Submit</Button>
</Space.Compact>
</Space>
);
const App: React.FC = () => {
const [showModal, setShowModal] = useState(false);
const [showDrawer, setShowDrawer] = useState(false);
return (
<Space direction="vertical">
<Space.Compact block>
<Button>default Button</Button>
<Button danger>danger Button</Button>
<Button type="dashed">dashed Button</Button>
<Button type="text">text Button</Button>
<Button type="link">Link Button</Button>
<Tooltip title="Tooltip">
<Button icon={<DownloadOutlined />} disabled />
</Tooltip>
</Space.Compact>
<br />
<Space.Compact>
<Button>Prefix</Button>
<Input addonBefore="http://" addonAfter=".com" defaultValue="mysite" />
<Button type="primary">Submit</Button>
</Space.Compact>
<Space.Compact>
<Input placeholder="prefix" />
<Input addonBefore={selectBefore} addonAfter={selectAfter} defaultValue="mysite" />
<Button icon={<CopyOutlined />} />
</Space.Compact>
<Space.Compact>
<Input.Search />
<Input.Search />
<Button icon={<CopyOutlined />} />
</Space.Compact>
<Space.Compact>
<Input addonAfter={<SettingOutlined />} defaultValue="mysite" />
<Button type="primary">Submit</Button>
<Input placeholder="suffix" addonAfter={<SettingOutlined />} />
</Space.Compact>
<Space.Compact>
<Input addonBefore="http://" suffix=".com" defaultValue="mysite" />
<Button type="primary">Submit</Button>
</Space.Compact>
<Space.Compact>
<Button>Prefix</Button>
<Input
addonBefore={<Cascader placeholder="cascader" style={{ width: 150 }} />}
defaultValue="mysite"
/>
<Button type="primary">Submit</Button>
</Space.Compact>
<br />
<Space.Compact>
<Button onClick={() => setShowModal(true)}>debug Modal context</Button>
{showModal && (
<Modal title="Basic Modal" open={showModal} onCancel={() => setShowModal(false)}>
<Button>normal button A</Button>
<Button>normal button B</Button>
<br />
<br />
<Input />
<br />
<br />
<Space.Compact>
<Button>compact button A</Button>
<Button>compact button B</Button>
</Space.Compact>
</Modal>
)}
</Space.Compact>
<Space.Compact>
<Dropdown.Button
menu={{
items: [
{
key: '1',
label: <Button>menu button</Button>,
},
{
key: '2',
label: 'normal menu item',
},
],
}}
>
debug Dropdown.Button context
</Dropdown.Button>
</Space.Compact>
<Space.Compact>
<Button onClick={() => setShowDrawer(true)}>debug Drawer context</Button>
{showDrawer && (
<Drawer
title="Basic Drawer"
placement="right"
onClose={() => setShowDrawer(false)}
open={showDrawer}
>
<Button>normal button A</Button>
<Button>normal button B</Button>
<br />
<br />
<Space.Compact>
<Button>compact button A</Button>
<Button>compact button B</Button>
</Space.Compact>
</Drawer>
)}
</Space.Compact>
<Space.Compact>
<InputNumber addonBefore="+" addonAfter="$" defaultValue={100} />
</Space.Compact>
</Space>
);
};
export default App;
```

Loading…
Cancel
Save