Files
flipper/desktop/app/src/sandy-chrome/DesignComponentDemos.tsx
dependabot[bot] 91b501d0ed Bump antd from 4.6.6 to 4.9.1 in /desktop (#1734)
Summary:
allow-large-files

Bumps [antd](https://github.com/ant-design/ant-design) from 4.6.6 to 4.9.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/ant-design/ant-design/releases">antd's releases</a>.</em></p>
<blockquote>
<h2>4.9.1</h2>
<ul>
<li>TypeScript
<ul>
<li>� Fix Collapse.Panel <code>collapsible</code> property to optional. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28092">#28092</a> <a href="https://github.com/sammarks">sammarks</a></li>
</ul>
</li>
</ul>
<hr />
<ul>
<li>TypeScript
<ul>
<li>� 修复 Collapse.Panel 可折叠属性 <code>collapsible</code> 为可选。<a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28092">#28092</a> <a href="https://github.com/sammarks">sammarks</a></li>
</ul>
</li>
</ul>
<h2>4.9.0</h2>
<ul>
<li>Modal
<ul>
<li>{emoji:1f195} Modal support <code>focusTriggerAfterClose</code> to disable auto focus back. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27985">#27985</a> <a href="https://github.com/molokovev">molokovev</a></li>
<li>{emoji:1f41e} Fix Modal hooks not trigger <code>onCancel</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28063">#28063</a> <a href="https://github.com/JuniorTour">JuniorTour</a></li>
<li>{emoji:1f41e} Fix Modal sometime not popup from the click position. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28037">#28037</a></li>
<li>{emoji:1f195} Support <code>closable</code> and <code>closeIcon</code> api for Modal.method. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27909">#27909</a> <a href="https://github.com/MrHeer">MrHeer</a></li>
</ul>
</li>
<li>{emoji:1f484} Reduce Table selection column width to <code>32px</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28073">#28073</a></li>
<li>Image
<ul>
<li>{emoji:1f525} Image add PreviewGroup component to support multiple images preview. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28069">#28069</a></li>
<li>{emoji:1f41e} Fix Image style prop not acting on img element. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27446">#27446</a></li>
</ul>
</li>
<li>Collapse
<ul>
<li>{emoji:1f525} Collapse support <code>collapsible</code> to customize trigger region and deprecated Panel <code>disabled</code> prop. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27790">#27790</a></li>
<li>{emoji:1f41e} Fix Collapse cannot contains <code>&lt;Table sticky /&gt;</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28039">#28039</a></li>
</ul>
</li>
<li>{emoji:1f41e} Fix Cascader bug that empty data can be selected. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28062">#28062</a> <a href="https://github.com/n0ruSh">n0ruSh</a></li>
<li>{emoji:1f195} Alert support <code>action</code> prop. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/25892">#25892</a> <a href="https://github.com/jesse3mh9a">jesse3mh9a</a></li>
<li>{emoji:1f525} Tree refactor drag behavior. Add <code>dropIndicatorRender</code> and <code>allowDrop</code> prop. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/26462">#26462</a> <a href="https://github.com/07akioni">07akioni</a></li>
<li>{emoji:1f195} Space support <code>wrap</code> for auto break line. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27910">#27910</a></li>
<li>{emoji:1f195} Descriptions.Item support <code>labelStyle</code> &amp; <code>contentStyle</code> props. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27897">#27897</a></li>
<li>{emoji:1f195} Form.List support <code>initialValue</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27872">#27872</a></li>
<li>{emoji:1f195} Menu supports <code>expandIcon</code>, and optimize default expand icon style. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27565">#27565</a></li>
<li>{emoji:1f195} Input and TextArea add <code>setSelectionRange</code> of <code>ref</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27584">#27584</a> <a href="https://github.com/appleshell">appleshell</a></li>
<li>{emoji:1f195} Select support <code>filterSort</code> to order the filtered options. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27523">#27523</a> <a href="https://github.com/n0ruSh">n0ruSh</a></li>
<li>{emoji:1f1f0_1f1ff} Add Kazakh locale. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27589">#27589</a> <a href="https://github.com/nodkz">nodkz</a></li>
</ul>
<hr />
<ul>
<li>Modal
<ul>
<li>{emoji:1f195} Modal 支持 <code>focusTriggerAfterClose</code> 以关闭自动恢复焦点的功能。<a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27985">#27985</a> <a href="https://github.com/molokovev">molokovev</a></li>
<li>{emoji:1f41e} 修复 Modal hooks 没有触发 <code>onCancel</code> 的问题。<a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28063">#28063</a> <a href="https://github.com/JuniorTour">JuniorTour</a></li>
<li>{emoji:1f41e} 修复 Modal 有时不在点击位置弹出的问题。<a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28037">#28037</a></li>
<li>{emoji:1f195} Modal.method 支持 <code>closable</code> 和 <code>closeIcon</code>。<a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27909">#27909</a> <a href="https://github.com/MrHeer">MrHeer</a></li>
</ul>
</li>
<li>{emoji:1f484} 减少 Table 选中列宽度至 <code>32px</code>。<a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28073">#28073</a></li>
<li>Image
<ul>
<li>{emoji:1f525} Image 增加 PreviewGroup 组件支持多张图片预览。<a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28069">#28069</a></li>
<li>{emoji:1f41e} 修复 Image style 属性未作用于 img 元素的问题。<a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27446">#27446</a></li>
</ul>
</li>
<li>Collapse
<ul>
<li>{emoji:1f525} Collapse 添加 <code>collapsible</code> 以支持指定可折叠触发区域并废弃 Panel 的 <code>disabled</code> 属性。<a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27790">#27790</a></li>
<li>{emoji:1f41e} 修复 Collapse 内使用 <code>&lt;Table sticky /&gt;</code> 时不生效的问题。<a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28039">#28039</a></li>
</ul>
</li>
</ul>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/ant-design/ant-design/blob/master/CHANGELOG.en-US.md">antd's changelog</a>.</em></p>
<blockquote>
<h2>4.9.1</h2>
<p><code>2020-12-01</code></p>
<ul>
<li>TypeScript
<ul>
<li>� Fix Collapse.Panel <code>collapsible</code> property to optional. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28092">#28092</a> <a href="https://github.com/sammarks">sammarks</a></li>
</ul>
</li>
</ul>
<h2>4.9.0</h2>
<p><code>2020-11-30</code></p>
<ul>
<li>Modal
<ul>
<li>{emoji:1f195} Modal support <code>focusTriggerAfterClose</code> to disable auto focus back. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27985">#27985</a> <a href="https://github.com/molokovev">molokovev</a></li>
<li>{emoji:1f41e} Fix Modal hooks not trigger <code>onCancel</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28063">#28063</a> <a href="https://github.com/JuniorTour">JuniorTour</a></li>
<li>{emoji:1f41e} Fix Modal sometime not popup from the click position. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28037">#28037</a></li>
<li>{emoji:1f195} Support <code>closable</code> and <code>closeIcon</code> api for Modal.method. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27909">#27909</a> <a href="https://github.com/MrHeer">MrHeer</a></li>
</ul>
</li>
<li>{emoji:1f484} Reduce Table selection column width to <code>32px</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28073">#28073</a></li>
<li>Image
<ul>
<li>{emoji:1f525} Image add PreviewGroup component to support multiple images preview. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28069">#28069</a></li>
<li>{emoji:1f41e} Fix Image style prop not acting on img element. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27446">#27446</a></li>
</ul>
</li>
<li>Collapse
<ul>
<li>{emoji:1f525} Collapse support <code>collapsible</code> to customize trigger region and deprecated Panel <code>disabled</code> prop. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27790">#27790</a></li>
<li>{emoji:1f41e} Fix Collapse cannot contains <code>&lt;Table sticky /&gt;</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28039">#28039</a></li>
</ul>
</li>
<li>{emoji:1f41e} Fix Cascader bug that empty data can be selected. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28062">#28062</a> <a href="https://github.com/n0ruSh">n0ruSh</a></li>
<li>{emoji:1f195} Alert support <code>action</code> prop. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/25892">#25892</a> <a href="https://github.com/jesse3mh9a">jesse3mh9a</a></li>
<li>{emoji:1f525} Tree refactor drag behavior. Add <code>dropIndicatorRender</code> and <code>allowDrop</code> prop. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/26462">#26462</a> <a href="https://github.com/07akioni">07akioni</a></li>
<li>{emoji:1f195} Space support <code>wrap</code> for auto break line. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27910">#27910</a></li>
<li>{emoji:1f195} Descriptions.Item support <code>labelStyle</code> &amp; <code>contentStyle</code> props. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27897">#27897</a></li>
<li>{emoji:1f195} Form.List support <code>initialValue</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27872">#27872</a></li>
<li>{emoji:1f195} Menu supports <code>expandIcon</code>, and optimize default expand icon style. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27565">#27565</a></li>
<li>{emoji:1f195} Input and TextArea add <code>setSelectionRange</code> of <code>ref</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27584">#27584</a> <a href="https://github.com/appleshell">appleshell</a></li>
<li>{emoji:1f195} Select support <code>filterSort</code> to order the filtered options. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27523">#27523</a> <a href="https://github.com/n0ruSh">n0ruSh</a></li>
<li>{emoji:1f1f0_1f1ff} Add Kazakh locale. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27589">#27589</a> <a href="https://github.com/nodkz">nodkz</a></li>
</ul>
<h2>4.8.6</h2>
<p><code>2020-11-27</code></p>
<ul>
<li>{emoji:1f41e} Fix Badge style blink when mounted. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28003">#28003</a></li>
<li>{emoji:1f484} Reduce Modal style size. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27998">#27998</a></li>
<li>{emoji:1f41e} Fix Layout.Sider can not collapse when <code>width='0'</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28000">#28000</a></li>
<li>{emoji:1f41e} Fix Menu style when using none Ant Design icons. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27983">#27983</a></li>
<li>Input
<ul>
<li>{emoji:1f41e} Fix Input.Search button height when customize less variables. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27986">#27986</a></li>
<li>{emoji:1f41e} Fix Input.Search <code>addonBefore</code> abnormal style. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27960">#27960</a></li>
</ul>
</li>
<li>{emoji:1f41e} Fix Typography.Link clicking copy button will redirect. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27982">#27982</a></li>
<li>{emoji:1f41e} Fix Carousel throws error <code>Unable to preventDefault inside passive event listener</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/27957">#27957</a></li>
<li>{emoji:1f310} Improve data picker locale for <code>en_GB</code> and <code>zh_TW</code>. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28016">#28016</a> <a href="https://github.com/abz53378">abz53378</a></li>
<li>RTL
<ul>
<li>{emoji:1f484} Optimize the border style of Descriptions in RTL model. <a href="https://github-redirect.dependabot.com/ant-design/ant-design/pull/28010">#28010</a></li>
</ul>
</li>
</ul>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="dda1f2b09c"><code>dda1f2b</code></a> refactor: &lt;Timeline/&gt; move defaultProps into single destructuring (<a href="https://github-redirect.dependabot.com/ant-design/ant-design/issues/28094">#28094</a>)</li>
<li><a href="511c8510fb"><code>511c851</code></a> chore: allow run compressed size from outside PR</li>
<li><a href="2cc6b0ca05"><code>2cc6b0c</code></a> refactor: optimize &lt;Timeline/&gt; bundle size (<a href="https://github-redirect.dependabot.com/ant-design/ant-design/issues/28095">#28095</a>)</li>
<li><a href="6e040bbd98"><code>6e040bb</code></a> docs: 4.9.1 changelog (<a href="https://github-redirect.dependabot.com/ant-design/ant-design/issues/28102">#28102</a>)</li>
<li><a href="30cc31af7e"><code>30cc31a</code></a> chore: Fix site deploy script</li>
<li><a href="16bc4bcdab"><code>16bc4bc</code></a> fix: Collapse.Panel collapsible should be optional (<a href="https://github-redirect.dependabot.com/ant-design/ant-design/issues/28092">#28092</a>)</li>
<li><a href="682b55d6b6"><code>682b55d</code></a> docs: 4.9.0 changelog (<a href="https://github-redirect.dependabot.com/ant-design/ant-design/issues/28088">#28088</a>)</li>
<li><a href="98ddb8d8da"><code>98ddb8d</code></a> chore: RM circle ci (<a href="https://github-redirect.dependabot.com/ant-design/ant-design/issues/28080">#28080</a>)</li>
<li><a href="6bb9701e23"><code>6bb9701</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/ant-design/ant-design/issues/28081">#28081</a> from ant-design/feature</li>
<li><a href="ac3142acf6"><code>ac3142a</code></a> docs: fix site warning message</li>
<li>Additional commits viewable in <a href="https://github.com/ant-design/ant-design/compare/4.6.6...4.9.1">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=antd&package-manager=npm_and_yarn&previous-version=4.6.6&new-version=4.9.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/configuring-github-dependabot-security-updates)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

Pull Request resolved: https://github.com/facebook/flipper/pull/1734

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

Did some exploratory testing and styling simplifications

{F350178586}

Reviewed By: nikoant

Differential Revision: D25461255

Pulled By: mweststrate

fbshipit-source-id: 2f2948664f302829d8fc4bc954b910ff4d033b4c
2020-12-11 06:48:08 -08:00

429 lines
13 KiB
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import React from 'react';
import {Typography, Card, Table, Collapse, Button, Tabs} from 'antd';
import {Layout, Link} from '../ui';
import {NUX, theme, Tracked, TrackingScope} from 'flipper-plugin';
import reactElementToJSXString from 'react-element-to-jsx-string';
import {CodeOutlined} from '@ant-design/icons';
const {Text} = Typography;
const demoStyle: Record<string, React.CSSProperties> = {
square: {
background: theme.successColor,
width: 50,
height: 50,
lineHeight: '50px',
textAlign: 'center',
},
border: {border: `1px dotted ${theme.primaryColor}`},
} as const;
type PreviewProps = {
title: string;
description?: React.ReactNode;
props: [string, React.ReactNode, React.ReactNode][];
demos: Record<string, React.ReactNode>;
};
const largeChild = (
<div style={{background: theme.warningColor}}>
<img src="https://fbflipper.com/img/mascot.png" height={500} />
</div>
);
const aButton = <Button>A button</Button>;
const aBox = <div style={{...demoStyle.square, width: 100}}>A fixed child</div>;
const aFixedWidthBox = (
<div style={{background: theme.primaryColor, width: 150, color: 'white'}}>
Fixed width box
</div>
);
const aFixedHeightBox = (
<div
style={{
background: theme.primaryColor,
height: 40,
lineHeight: '40px',
color: 'white',
}}>
Fixed height box
</div>
);
const aDynamicBox = (
<div style={{background: theme.warningColor, flex: 1}}>
A dynamic child (flex: 1)
</div>
);
const someText = <Text>Some text</Text>;
const demos: PreviewProps[] = [
{
title: 'Layout.Container',
description: `Layout.Container can be used to organize the UI in regions. It takes care of paddings and borders. Children will be arranged vertically. Use Layout.Horizontal instead for arranging children horizontally. If you need a margin on this component, try to wrap it in other Layout component instead.`,
props: [
['rounded', 'boolean (false)', 'Make the corners rounded'],
[
'padv / padh / pad',
Object.keys(theme.space).join(' | ') + ' | number | true',
'Short-hand to set the horizontal, vertical or both paddings. The keys correspond to the theme space settings. Using `true` picks the default horizontal / vertical padding for inline elements.',
],
[
'width / height',
'number',
'Set the width / height of this container in pixels. Use sparingly.',
],
[
'bordered',
'boolean (false)',
'This container will use a default border on all sides',
],
[
'borderTop / borderRight / borderBottom / borderLeft',
'boolean (false)',
'Use a standard padding on the top side',
],
[
'gap',
'true / number (0)',
'Set the spacing between children. If just set, theme.space.small will be used.',
],
[
'center',
'boolean (false)',
'If set, all children will use their own naturally width, and they will be centered horizontally in the Container. If not set, all children will be stretched to the width of the Container.',
],
],
demos: {
'Basic container with fixed dimensions': (
<Layout.Container style={demoStyle.square}></Layout.Container>
),
'Basic container with fixed height': (
<Layout.Container
style={{
height: 50,
background: theme.successColor,
}}></Layout.Container>
),
'bordered pad rounded': (
<Layout.Container
bordered
pad
rounded
style={{background: theme.backgroundDefault, width: 200}}>
<div style={demoStyle.square}>child</div>
</Layout.Container>
),
'Multiple children, gap={24}': (
<Layout.Container gap={24}>
{aButton}
{someText}
{aBox}
{aDynamicBox}
</Layout.Container>
),
'Multiple children icmw. pad center gap': (
<Layout.Container pad center gap>
{aButton}
{someText}
{aBox}
{aDynamicBox}
</Layout.Container>
),
},
},
{
title: 'Layout.Horizontal',
description:
'Use this component to arrange multiple items horizontally. All vanilla Container props can be used as well.',
props: [
[
'center',
'boolean (false)',
'If set, all children will use their own height, and they will be centered vertically in the layout. If not set, all children will be stretched to the height of the layout.',
],
],
demos: {
'Basic usage, gap="large"': (
<Layout.Horizontal gap="large">
{aButton}
{someText}
{aBox}
{aDynamicBox}
</Layout.Horizontal>
),
'Using flags: pad center gap={8} (great for toolbars and such)': (
<Layout.Horizontal pad center gap={8}>
{aButton}
{someText}
{aBox}
{aDynamicBox}
</Layout.Horizontal>
),
},
},
{
title: 'Layout.ScrollContainer',
description:
'Use this component to create an area that can be scrolled. The scrollable area will automatically consume all available space. ScrollContainer accepts all properties that Container accepts as well. Padding will be applied to the child rather than the parent.',
props: [
[
'horizontal / vertical',
'boolean',
'specifies in which directions the container should scroll. If none is specified the container will scroll in both directions',
],
[
'padv / padh / pad',
'see Container',
'Padding will be applied to the child',
],
],
demos: {
'Basic usage': (
<Layout.ScrollContainer style={{height: 100}}>
{largeChild}
</Layout.ScrollContainer>
),
'ScrollContainer + Vertical for vertical scroll only': (
<Layout.ScrollContainer
vertical
style={{
height: 100,
width: 100,
border: `2px solid ${theme.primaryColor}`,
}}>
<Layout.Container>
<Text ellipsis>
This text is truncated because it is too long and scroll is
vertical only...
</Text>
{largeChild}
</Layout.Container>
</Layout.ScrollContainer>
),
},
},
{
title: 'Layout.Top|Left|Right|Bottom',
description:
"Divides all available space over two children. The (top|left|right|bottom)-most first child will keep it's own dimensions, and positioned (top|left|right|bottom) of the other child. All remaining space will be assigned to the remaining child.",
props: [
[
'scrollable',
'boolean (false)',
'If set, the area of the second child will automatically be made scrollable.',
],
[
'center',
'boolean (false)',
'If set, all children will use their own height, and they will be centered vertically in the layout. If not set, all children will be stretched to the height of the layout.',
],
],
demos: {
'Layout.Top': (
<Layout.Top>
{aFixedHeightBox}
{aDynamicBox}
</Layout.Top>
),
'Layout.Left': (
<Layout.Left>
{aFixedWidthBox}
{aDynamicBox}
</Layout.Left>
),
'Layout.Right': (
<Layout.Right>
{aDynamicBox}
{aFixedWidthBox}
</Layout.Right>
),
'Layout.Bottom': (
<Layout.Bottom>
{aDynamicBox}
{aFixedHeightBox}
</Layout.Bottom>
),
'Layout.Top + Layout.ScrollContainer': (
<Layout.Container style={{height: 150}}>
<Layout.Top>
{aFixedHeightBox}
<Layout.ScrollContainer>{largeChild}</Layout.ScrollContainer>
</Layout.Top>
</Layout.Container>
),
'Layout.Left + Layout.ScrollContainer': (
<Layout.Container style={{height: 150}}>
<Layout.Left>
{aFixedWidthBox}
<Layout.ScrollContainer>{largeChild}</Layout.ScrollContainer>
</Layout.Left>
</Layout.Container>
),
'Layout.Right + Layout.ScrollContainer': (
<Layout.Container style={{height: 150}}>
<Layout.Right>
<Layout.ScrollContainer>{largeChild}</Layout.ScrollContainer>
{aFixedWidthBox}
</Layout.Right>
</Layout.Container>
),
'Layout.Bottom + Layout.ScrollContainer': (
<Layout.Container style={{height: 150}}>
<Layout.Bottom>
<Layout.ScrollContainer>{largeChild}</Layout.ScrollContainer>
{aFixedHeightBox}
</Layout.Bottom>
</Layout.Container>
),
},
},
{
title: 'NUX',
description:
'A component to provide a New-User-eXperience: Highlight new features to first time users. For tooltips that should stay available, use ToolTip from ANT design',
props: [
['title', 'string / React element', 'The tooltip contents'],
[
'placement',
<>
See{' '}
<Link href="https://ant.design/components/tooltip/#components-tooltip-demo-placement">
docs
</Link>
</>,
'(optional) on which side to place the tooltip',
],
],
demos: {
'NUX example': (
<NUX title="This button does something cool" placement="right">
<Button>Hello world</Button>
</NUX>
),
},
},
{
title: 'Tracked',
description:
'A component that tracks component interactions. For Facebook internal builds, global stats for these interactions will be tracked. Wrap this component around another element to track its events',
props: [
[
'events',
'string | string[] (default: "onClick")',
'The event(s) of the child component that should be tracked',
],
[
'action',
'string (optional)',
'Describes the element the user interacted with. Will by default be derived from the title, key or contents of the element',
],
],
demos: {
'Basic example': (
<Tracked>
<Button onClick={() => {}}>Test</Button>
</Tracked>
),
},
},
{
title: 'TrackingScope',
description:
'Describes more precisely the place in the UI for all underlying Tracked elements. Multiple Tracking scopes are automatically nested. Use the `withTrackingScope` HoC to automatically wrap a component definition in a tracking scope',
props: [
['scope', 'string', 'The name of the scope. For example "Login Dialog"'],
],
demos: {
'Basic example': (
<TrackingScope scope="tracking scope demo">
<Tracked>
<Button onClick={() => {}}>Test</Button>
</Tracked>
</TrackingScope>
),
},
},
];
function ComponentPreview({title, demos, description, props}: PreviewProps) {
return (
<Card title={title} size="small" type="inner">
<TrackingScope scope={title}>
<Layout.Container gap="small">
<Text type="secondary">{description}</Text>
<Collapse ghost>
<Collapse.Panel header="Examples" key="demos">
<Layout.Container gap="large">
{Object.entries(demos).map(([name, children]) => (
<Tabs type="line" key={name}>
<Tabs.TabPane tab={name} key="1">
<div
style={{
background: theme.backgroundWash,
width: '100%',
}}>
{children}
</div>
</Tabs.TabPane>
<Tabs.TabPane tab={<CodeOutlined />} key="2">
<div
style={{
background: theme.backgroundWash,
width: '100%',
padding: theme.space.medium,
}}>
<pre>{reactElementToJSXString(children)}</pre>
</div>
</Tabs.TabPane>
</Tabs>
))}
</Layout.Container>
</Collapse.Panel>
<Collapse.Panel header="Props" key="props">
<Table
size="small"
pagination={false}
dataSource={props.map((prop) =>
Object.assign(prop, {key: prop[0]}),
)}
columns={[
{
title: 'Property',
dataIndex: 0,
width: 100,
},
{
title: 'Type and default',
dataIndex: 1,
width: 200,
},
{
title: 'Description',
dataIndex: 2,
},
]}
/>
</Collapse.Panel>
</Collapse>
</Layout.Container>
</TrackingScope>
</Card>
);
}
export const DesignComponentDemos = () => (
<Layout.Container gap={theme.space.large}>
{demos.map((demo) => (
<ComponentPreview key={demo.title} {...demo} />
))}
</Layout.Container>
);