mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-17 06:42:28 +08:00
Compare commits
91 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a91bd69cda | ||
|
|
0f46173410 | ||
|
|
ae49280ca0 | ||
|
|
544f407dd1 | ||
|
|
64b7b551e2 | ||
|
|
02021836e1 | ||
|
|
8a2ccae477 | ||
|
|
f7934f5df2 | ||
|
|
6fb38c342f | ||
|
|
31a9fffeac | ||
|
|
f6c8f81484 | ||
|
|
905ddfc2c7 | ||
|
|
ec87ea408b | ||
|
|
e129b0aae9 | ||
|
|
3d51c801e6 | ||
|
|
ada59b9d37 | ||
|
|
83b028c7fe | ||
|
|
2331ed0b39 | ||
|
|
718f362aea | ||
|
|
6cc16fb7f5 | ||
|
|
7a5939fa37 | ||
|
|
86e4cd1c0f | ||
|
|
cb544f7feb | ||
|
|
c7c6e9fe4f | ||
|
|
bb947709f9 | ||
|
|
7519fd14df | ||
|
|
d8181f84b1 | ||
|
|
1f04f78707 | ||
|
|
8af5e65467 | ||
|
|
18dc8bf961 | ||
|
|
57190f197b | ||
|
|
b2c359cb34 | ||
|
|
9a6c2f667a | ||
|
|
d380a8d3e4 | ||
|
|
6619c14579 | ||
|
|
8e6667880f | ||
|
|
c72c773e67 | ||
|
|
a9a651ffd5 | ||
|
|
84381e3e6c | ||
|
|
4e2118cad0 | ||
|
|
7f48f7336c | ||
|
|
d6d3de8a1b | ||
|
|
af5ff52a27 | ||
|
|
b2f3596f7d | ||
|
|
862488b41e | ||
|
|
637aa09bc5 | ||
|
|
1eb702b166 | ||
|
|
7071ac7f6e | ||
|
|
ece5c03526 | ||
|
|
2cd5167685 | ||
|
|
98860c64d1 | ||
|
|
69db6faebe | ||
|
|
965fce5d0b | ||
|
|
30217ade3f | ||
|
|
6129d3a1eb | ||
|
|
4dbb81b88e | ||
|
|
00bcdae2ae | ||
|
|
f61b32a0f9 | ||
|
|
ce0505561a | ||
|
|
5e1be364c4 | ||
|
|
e3a7635a2a | ||
|
|
e508ee778d | ||
|
|
4b239d65c0 | ||
|
|
019eeec3ce | ||
|
|
584f9fd907 | ||
|
|
e09ce6284e | ||
|
|
955fa520f1 | ||
|
|
e361b30ded | ||
|
|
dda650cc7b | ||
|
|
6f36f4a877 | ||
|
|
46f8399f99 | ||
|
|
f22c5d999b | ||
|
|
6493db80d4 | ||
|
|
6cea99be9d | ||
|
|
3d62c44325 | ||
|
|
f36576f12d | ||
|
|
902141f554 | ||
|
|
0d90c585fa | ||
|
|
b8fb4c411d | ||
|
|
3ca11e94ce | ||
|
|
076ed1bf9e | ||
|
|
33159218cd | ||
|
|
738ed22871 | ||
|
|
745c2182a5 | ||
|
|
cfff7967b3 | ||
|
|
2d7a950167 | ||
|
|
f263102500 | ||
|
|
d4aca5f343 | ||
|
|
46955f9f59 | ||
|
|
f4ee809e66 | ||
|
|
d0d75a6e54 |
40
.eslintrc.js
40
.eslintrc.js
@@ -50,19 +50,29 @@ module.exports = {
|
||||
'react/no-multi-comp': 0,
|
||||
'jsx-a11y/href-no-hash': 0,
|
||||
'import/no-extraneous-dependencies': 0,
|
||||
'import/no-unresolved': 0,
|
||||
'jsx-a11y/control-has-associated-label': 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
rules: {
|
||||
camelcase: 0,
|
||||
'react/jsx-one-expression-per-line': 0,
|
||||
'react/prop-types': 0,
|
||||
'react/forbid-prop-types': 0,
|
||||
'react/jsx-indent': 0,
|
||||
'react/jsx-wrap-multilines': ['error', { declaration: false, assignment: false }],
|
||||
'react/jsx-filename-extension': 0,
|
||||
'react/state-in-constructor': 0,
|
||||
'react/jsx-props-no-spreading': 0,
|
||||
'react/destructuring-assignment': 0, // TODO: remove later
|
||||
'react/require-default-props': 0,
|
||||
'react/sort-comp': 0,
|
||||
'react/display-name': 0,
|
||||
'react/static-property-placement': 0,
|
||||
'react/no-find-dom-node': 0,
|
||||
'react-hooks/rules-of-hooks': 2, // Checks rules of Hooks
|
||||
|
||||
'import/extensions': 0,
|
||||
'import/no-cycle': 0,
|
||||
'import/no-extraneous-dependencies': [
|
||||
'error',
|
||||
{
|
||||
@@ -82,38 +92,26 @@ module.exports = {
|
||||
'jsx-a11y/click-events-have-key-events': 0,
|
||||
'jsx-a11y/anchor-is-valid': 0,
|
||||
'jsx-a11y/no-noninteractive-element-interactions': 0,
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'react/jsx-filename-extension': 0,
|
||||
'react/state-in-constructor': 0,
|
||||
'react/jsx-props-no-spreading': 0,
|
||||
'prefer-destructuring': 0, // TODO: remove later
|
||||
'consistent-return': 0, // TODO: remove later
|
||||
'no-return-assign': 0, // TODO: remove later
|
||||
'no-param-reassign': 0, // TODO: remove later
|
||||
'react/destructuring-assignment': 0, // TODO: remove later
|
||||
'react/no-did-update-set-state': 0, // TODO: remove later
|
||||
'react/require-default-props': 0,
|
||||
'react/default-props-match-prop-types': 0,
|
||||
'import/no-cycle': 0,
|
||||
'react/no-find-dom-node': 0,
|
||||
'no-underscore-dangle': 0,
|
||||
'react/sort-comp': 0,
|
||||
// label-has-for has been deprecated
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
|
||||
'jsx-a11y/label-has-for': 0,
|
||||
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'consistent-return': 0, // TODO: remove later
|
||||
'no-param-reassign': 0, // TODO: remove later
|
||||
'no-underscore-dangle': 0,
|
||||
// for (let i = 0; i < len; i++)
|
||||
'no-plusplus': 0,
|
||||
// https://eslint.org/docs/rules/no-continue
|
||||
// labeledLoop is conflicted with `eslint . --fix`
|
||||
'no-continue': 0,
|
||||
'react/display-name': 0,
|
||||
// ban this for Number.isNaN needs polyfill
|
||||
'no-restricted-globals': 0,
|
||||
'max-classes-per-file': 0,
|
||||
'react/static-property-placement': 0,
|
||||
|
||||
'jest/no-test-callback': 0,
|
||||
'jest/expect-expect': 0,
|
||||
'react-hooks/rules-of-hooks': 2, // Checks rules of Hooks
|
||||
|
||||
'unicorn/better-regex': 2,
|
||||
'unicorn/prefer-trim-start-end': 2,
|
||||
'unicorn/expiring-todo-comments': 2,
|
||||
|
||||
1
.jest.js
1
.jest.js
@@ -25,6 +25,7 @@ module.exports = {
|
||||
'^react-dnd-touch-backend$': 'react-dnd-touch-backend/dist/cjs',
|
||||
'^react-dnd-test-backend$': 'react-dnd-test-backend/dist/cjs',
|
||||
'^react-dnd-test-utils$': 'react-dnd-test-utils/dist/cjs',
|
||||
'\\.(css|less)$': 'identity-obj-proxy',
|
||||
},
|
||||
testPathIgnorePatterns: ['/node_modules/', 'dekko', 'node', 'image.test.js'],
|
||||
transform: {
|
||||
|
||||
@@ -15,6 +15,68 @@ timeline: true
|
||||
|
||||
---
|
||||
|
||||
## 4.3.4
|
||||
|
||||
`2020-06-14`
|
||||
|
||||
- Form
|
||||
- 🐞 Fix `validateTrigger` not works on Form. [#24979](https://github.com/ant-design/ant-design/pull/24979)
|
||||
- 🐞 Fix Form.Item still replace component `id` when `id` configured. [#24929](https://github.com/ant-design/ant-design/pull/24929)
|
||||
- 🐞 Fix Form.List error message display not correct when nested with `noStyle`. [#24867](https://github.com/ant-design/ant-design/pull/24867)
|
||||
- Table
|
||||
- 🐞 Fix Table `shouldCellUpdate` missing `prevRecord` param. [#24963](https://github.com/ant-design/ant-design/pull/24963)
|
||||
- 🐞 Fix Table's filter dropdown's display value doesn't sync with controlled `filteredValue`. [#24952](https://github.com/ant-design/ant-design/pull/24952)
|
||||
- 🐞 Fix Table `onChange` get wrong state with multiple sorter operation. [#24852](https://github.com/ant-design/ant-design/pull/24852)
|
||||
- 🐞 Fix Modal `confirm()` has no default icon. [#24956](https://github.com/ant-design/ant-design/pull/24956)
|
||||
- 🐞 Fix List `grid` not working in React.Fragment or wrapped List.Item. [#24955](https://github.com/ant-design/ant-design/pull/24955)
|
||||
- 🐞 Fix Avatar fallback to children when loading image with error. [#24944](https://github.com/ant-design/ant-design/pull/24944) [@sosohime](https://github.com/sosohime)
|
||||
- 🐞 Fix Drawer doesn't omit prop `getTargetContainer`. [#24938](https://github.com/ant-design/ant-design/pull/24938)
|
||||
- 🐞 Fix Tabs dropdown clip text when tab title too long. [#24928](https://github.com/ant-design/ant-design/pull/24928)
|
||||
- 🐞 Fix Carousel under Tabs shaking when tab switch. [#24873](https://github.com/ant-design/ant-design/pull/24873)
|
||||
- 🐞 Fix Transfer package size will increase if tree shaking is disabled. [#24847](https://github.com/ant-design/ant-design/pull/24847) [@DavidSichau](https://github.com/DavidSichau)
|
||||
- 💄 Add `@rate-star-hover-scale` to control Rate scale when cursor hover. [#24917](https://github.com/ant-design/ant-design/pull/24917)
|
||||
- 💄 Add `@divider-orientation-margin` less variable to control Divider's left margin when `orientation` is set. [#24877](https://github.com/ant-design/ant-design/pull/24877)
|
||||
- 🌐 Localization
|
||||
- 🇫🇷 Improve fr_FR i18n. [#24962](https://github.com/ant-design/ant-design/pull/24962) [@sharkyze](https://github.com/sharkyze)
|
||||
- TypeScript
|
||||
- 🛠 Export Select `OptionProps` interface. [#24870](https://github.com/ant-design/ant-design/pull/24870) [@nitinknolder](https://github.com/nitinknolder)
|
||||
- 🛠 Export Card `CardInterface` interface. [#24866](https://github.com/ant-design/ant-design/pull/24866) [@THPubs](https://github.com/THPubs)
|
||||
- 🛠 Remove `emptyText` from Table `TableProps`. [#24948](https://github.com/ant-design/ant-design/pull/24948) [@hehex9](https://github.com/hehex9)
|
||||
- 🛠 Add `patch` type on Upload `method` prop. [#24936](https://github.com/ant-design/ant-design/pull/24936) [@miclle](https://github.com/miclle)
|
||||
|
||||
## 4.3.3
|
||||
|
||||
`2020-06-07`
|
||||
|
||||
- 🐞 Fix Drawer cannot open. [#24802](https://github.com/ant-design/ant-design/pull/24802)
|
||||
- 🐞 Fix Menu.SubMenu cannot scroll. [#24806](https://github.com/ant-design/ant-design/pull/24806)
|
||||
|
||||
## 4.3.2
|
||||
|
||||
`2020-06-06`
|
||||
|
||||
- 🐞 Fix Tag.CheckableTag don't support `onClick`. [#24743](https://github.com/ant-design/ant-design/pull/24743)
|
||||
- 🐞 Fix Drawer support set `getPopupContainer` and `getPrefixCls` by ConfigProvider. [#24727](https://github.com/ant-design/ant-design/pull/24727)
|
||||
- 🐞 Fix Button `loading.delay` repeat trigger when parent compoent re-render. [#24713](https://github.com/ant-design/ant-design/pull/24713)
|
||||
- 🐞 Fix Dropdown menu link color when has `icon`. [#24707](https://github.com/ant-design/ant-design/pull/24707) [#24702](https://github.com/ant-design/ant-design/pull/24702)
|
||||
- Select
|
||||
- 🐞 Fix Select virtual scroll display abnormally in compact mode. [#24706](https://github.com/ant-design/ant-design/pull/24706)
|
||||
- ⚡️ Optimize Select multiple mode performance. [#24785](https://github.com/ant-design/ant-design/pull/24785) [@Kermit-Xuan](https://github.com/Kermit-Xuan)
|
||||
- 🐞 Fix Calendar trigger `onPanelChange` even when in the same panel. [#24695](https://github.com/ant-design/ant-design/pull/24695)
|
||||
- 🐞 Fix Input component height issue in IE11. [#24673](https://github.com/ant-design/ant-design/pull/24673) [@xiaosongxiaosong](https://github.com/xiaosongxiaosong)
|
||||
- 🐞 Fix Radio typescript error typo. [#24693](https://github.com/ant-design/ant-design/pull/24693) [@hengkx](https://github.com/hengkx)
|
||||
- 🐞 Fix Statistic don't work with Tooltip. [#24782](https://github.com/ant-design/ant-design/pull/24782)
|
||||
- 🐞 Fix TimePicker.RangePicker `bordered={false}` not working when has `className`. [#24781](https://github.com/ant-design/ant-design/pull/24781)
|
||||
- 🐞 Fix List cannot trigger `onChange` in pagination. [#24514](https://github.com/ant-design/ant-design/pull/24514)
|
||||
- 🌐 Localization
|
||||
- 🇮🇱 Add Hebrew localisations for Form. [#24716](https://github.com/ant-design/ant-design/pull/24716) [@israelKusayev](https://github.com/israelKusayev)
|
||||
- 🇰🇷 Add ko_KR localizations for Form. [#24783](https://github.com/ant-design/ant-design/pull/24783) [@Jaewoook](https://github.com/Jaewoook)
|
||||
- 💄 Add less variable `@table-font-size`, `@table-font-size-md` and `@table-font-size-sm` to customize the size of Table text. [#24714](https://github.com/ant-design/ant-design/pull/24714) [@morenyang](https://github.com/morenyang)
|
||||
- RTL
|
||||
- 💄 Optimize Tabs dropdown style in RTL. [#24715](https://github.com/ant-design/ant-design/pull/24715)
|
||||
- 💄 Add `Modal.method()` RTL supports only use hooks. [#24682](https://github.com/ant-design/ant-design/pull/24682)
|
||||
- 💄 Fix Badge offset in RTL. [#24724](https://github.com/ant-design/ant-design/pull/24724)
|
||||
|
||||
## 4.3.1
|
||||
|
||||
`2020-06-02`
|
||||
|
||||
@@ -15,6 +15,68 @@ timeline: true
|
||||
|
||||
---
|
||||
|
||||
## 4.3.4
|
||||
|
||||
`2020-06-14`
|
||||
|
||||
- Form
|
||||
- 🐞 修复 Form 中配置 `validateTrigger` 无效的问题。[#24979](https://github.com/ant-design/ant-design/pull/24979)
|
||||
- 🐞 修复 Form.Item 在组件设置 `id` 时仍然会替换它的问题。[#24929](https://github.com/ant-design/ant-design/pull/24929)
|
||||
- 🐞 修复 Form.List 嵌套使用 `noStyle` 时,错误信息展示混乱的问题。[#24867](https://github.com/ant-design/ant-design/pull/24867)
|
||||
- Table
|
||||
- 🐞 修复 Table 的 `shouldCellUpdate` 缺少 `prevRecord` 参数的问题。[#24963](https://github.com/ant-design/ant-design/pull/24963)
|
||||
- 🐞 修复 Table 受控状态下列的过滤菜单显示的值和 `filteredValue` 不同步的问题。[#24952](https://github.com/ant-design/ant-design/pull/24952)
|
||||
- 🐞 修复 Table 在多列排序时 `onChange` 获得错误排序状态的问题。[#24852](https://github.com/ant-design/ant-design/pull/24852)
|
||||
- 🐞 修复 Modal 缺少 `confirm()` 默认图标。[#24956](https://github.com/ant-design/ant-design/pull/24956)
|
||||
- 🐞 修复 List `grid` 属性在 React.Framgment 或者封装了的 List.Item 上失效的问题。[#24955](https://github.com/ant-design/ant-design/pull/24955)
|
||||
- 🐞 修复 Avatar 图片加载错误的显示问题。[#24944](https://github.com/ant-design/ant-design/pull/24944) [@sosohime](https://github.com/sosohime)
|
||||
- 🐞 修复 Drawer `getTargetContainer` 属性没有被忽略的问题。[#24938](https://github.com/ant-design/ant-design/pull/24938)
|
||||
- 🐞 修复 Tabs 下拉框标题过长时被截断的问题。[#24928](https://github.com/ant-design/ant-design/pull/24928)
|
||||
- 🐞 修复 Carousel 在 Tabs 下切换时会跳跃的问题。[#24873](https://github.com/ant-design/ant-design/pull/24873)
|
||||
- 🐞 修复 Transfer 在关闭 tree shaking 后打包尺寸增加的问题。[#24847](https://github.com/ant-design/ant-design/pull/24847) [@DavidSichau](https://github.com/DavidSichau)
|
||||
- 💄 新增 `@rate-star-hover-scale` 控制 Rate 鼠标悬浮放大比例。[#24917](https://github.com/ant-design/ant-design/pull/24917)
|
||||
- 💄 新增 `@divider-orientation-margin` less 变量,以控制 Divider 设置了 `orientation` 时的左侧距离。[#24877](https://github.com/ant-design/ant-design/pull/24877)
|
||||
- 🌐 Localization
|
||||
- 🇫🇷 改进 fr_FR 语言包。[#24962](https://github.com/ant-design/ant-design/pull/24962) [@sharkyze](https://github.com/sharkyze)
|
||||
- TypeScript
|
||||
- 🛠 导出 Select 的 `OptionProps` 接口。[#24870](https://github.com/ant-design/ant-design/pull/24870) [@nitinknolder](https://github.com/nitinknolder)
|
||||
- 🛠 导出 Card 的 `CardInterface` 接口。[#24866](https://github.com/ant-design/ant-design/pull/24866) [@THPubs](https://github.com/THPubs)
|
||||
- 🛠 从 Table `TableProps` 中去除 `emptyText` 定义。[#24948](https://github.com/ant-design/ant-design/pull/24948) [@hehex9](https://github.com/hehex9)
|
||||
- 🛠 为 Upload `method` 属性添加 `patch` 类型。[#24936](https://github.com/ant-design/ant-design/pull/24936) [@miclle](https://github.com/miclle)
|
||||
|
||||
## 4.3.3
|
||||
|
||||
`2020-06-07`
|
||||
|
||||
- 🐞 修复 Drawer 无法显示的问题。[#24802](https://github.com/ant-design/ant-design/pull/24802)
|
||||
- 🐞 修复 Menu.SubMenu 滚动区域无法交互的问题。[#24806](https://github.com/ant-design/ant-design/pull/24806)
|
||||
|
||||
## 4.3.2
|
||||
|
||||
`2020-06-06`
|
||||
|
||||
- 🐞 修复 Tag.CheckableTag 不支持 `onClick` 和 `stopPropagation` 的问题。[#24743](https://github.com/ant-design/ant-design/pull/24743)
|
||||
- 🐞 修复 Drawer 支持通过 ConfigProvider 来全局设置 `getPrefixCls` 和 `getPopupContainer`。[#24727](https://github.com/ant-design/ant-design/pull/24727)
|
||||
- 🐞 修复 Button 在父组件重新渲染时 `loading.delay` 会重复触发的问题。[#24713](https://github.com/ant-design/ant-design/pull/24713)
|
||||
- 🐞 修复 Dropdown 带图标 `icon` 菜单项的链接色彩。[#24707](https://github.com/ant-design/ant-design/pull/24707) [#24702](https://github.com/ant-design/ant-design/pull/24702)
|
||||
- Select
|
||||
- 🐞 修复 Select 在紧凑模式下表现不正常。[#24706](https://github.com/ant-design/ant-design/pull/24706)
|
||||
- ⚡️ 优化 Select 多选模式的性能。[#24785](https://github.com/ant-design/ant-design/pull/24785) [@Kermit-Xuan](https://github.com/Kermit-Xuan)
|
||||
- 🐞 修复 Calendar 在同一个面板下选择日期也会触发 `onPanelChange` 的问题。[#24695](https://github.com/ant-design/ant-design/pull/24695)
|
||||
- 🐞 修复 Input 组件在 IE11 中高度异常问题。[#24673](https://github.com/ant-design/ant-design/pull/24673) [@xiaosongxiaosong](https://github.com/xiaosongxiaosong)
|
||||
- 🐞 修复 Radio 的 TypeScript 定义错误。[#24693](https://github.com/ant-design/ant-design/pull/24693) [@hengkx](https://github.com/hengkx)
|
||||
- 🐞 修复 Statistic 不能包裹 Tooltip 的问题。[#24782](https://github.com/ant-design/ant-design/pull/24782)
|
||||
- 🐞 修复 TimePicker.RangePicker 指定 `className` 后无边框样式失效的问题。[#24781](https://github.com/ant-design/ant-design/pull/24781)
|
||||
- 🐞 修复 List 翻页时 `onChange` 不触发的问题。[#24514](https://github.com/ant-design/ant-design/pull/24514)
|
||||
- 🌐 国际化
|
||||
- 🇮🇱 Form 校验文案增加希伯来语(以色列)。[#24716](https://github.com/ant-design/ant-design/pull/24716) [@israelKusayev](https://github.com/israelKusayev)
|
||||
- 🇰🇷 Form 校验文案增加韩文。[#24783](https://github.com/ant-design/ant-design/pull/24783) [@Jaewoook](https://github.com/Jaewoook)
|
||||
- 💄 新增 less 变量 `@table-font-size`,`@table-font-size-md` 和 `@table-font-size-sm`,用于自定义 Table 文字大小。[#24714](https://github.com/ant-design/ant-design/pull/24714) [@morenyang](https://github.com/morenyang)
|
||||
- RTL
|
||||
- 💄 优化 Tabs 标签下拉框在 RTL 模式下样式。[#24715](https://github.com/ant-design/ant-design/pull/24715)
|
||||
- 💄 增加 `Modal.method()` RTL 模式支持,仅限 hooks 用法。[#24682](https://github.com/ant-design/ant-design/pull/24682)
|
||||
- 💄 修复 Badge RTL 模式位置偏移量设置。[#24724](https://github.com/ant-design/ant-design/pull/24724)
|
||||
|
||||
## 4.3.1
|
||||
|
||||
`2020-06-02`
|
||||
|
||||
@@ -42,8 +42,8 @@ An enterprise-class UI design language and React UI library.
|
||||
[gitter-english-url]: https://gitter.im/ant-design/ant-design-english?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
|
||||
[gitter-chinese-image]: https://img.shields.io/gitter/room/ant-design/ant-design.svg?style=flat-square&logoWidth=18&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjkwMCIgaGVpZ2h0PSI2MDAiIHZpZXdCb3g9IjAgMCAzMCAyMCI%2BDQo8ZGVmcz4NCjxwYXRoIGlkPSJzIiBkPSJNMCwtMSAwLjU4Nzc4NSwwLjgwOTAxNyAtMC45NTEwNTcsLTAuMzA5MDE3SDAuOTUxMDU3TC0wLjU4Nzc4NSwwLjgwOTAxN3oiIGZpbGw9IiNmZmRlMDAiLz4NCjwvZGVmcz4NCjxyZWN0IHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgZmlsbD0iI2RlMjkxMCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNSw1KSBzY2FsZSgzKSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsMikgcm90YXRlKDIzLjAzNjI0MykiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEyLDQpIHJvdGF0ZSg0NS44Njk4OTgpIi8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMiw3KSByb3RhdGUoNjkuOTQ1Mzk2KSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsOSkgcm90YXRlKDIwLjY1OTgwOCkiLz4NCjwvc3ZnPg%3D%3D
|
||||
[gitter-chinese-url]: https://gitter.im/ant-design/ant-design?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
||||
[semver-stability-url]: https://dependabot.com/compatibility-score.html/?dependency-name=antd&package-manager=npm_and_yarn&new-version=latest
|
||||
[semver-stability-image]: https://api.dependabot.com/badges/compatibility_score?dependency-name=antd&package-manager=npm_and_yarn&target-version=latest&version-scheme=semver
|
||||
[semver-stability-url]: https://dependabot.com/compatibility-score.html/?dependency-name=antd&package-manager=npm_and_yarn
|
||||
[semver-stability-image]: https://api.dependabot.com/badges/compatibility_score?dependency-name=antd&package-manager=npm_and_yarn&version-scheme=semver
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -5,5 +5,6 @@ export function easeInOutCubic(t: number, b: number, c: number, d: number) {
|
||||
if (t < 1) {
|
||||
return (cc / 2) * t * t * t + b;
|
||||
}
|
||||
// eslint-disable-next-line no-return-assign
|
||||
return (cc / 2) * ((t -= 2) * t * t + 2) + b;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
|
||||
export const isValidElement = React.isValidElement;
|
||||
export const { isValidElement } = React;
|
||||
|
||||
export function replaceElement(
|
||||
element: React.ReactNode,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
category: Components
|
||||
type: Navigation
|
||||
title: Affix
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/SQGCQ7gOO/Affix.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/tX6-md4H6/Affix.svg
|
||||
---
|
||||
|
||||
Wrap Affix around another component to make it stick the viewport.
|
||||
|
||||
@@ -107,6 +107,7 @@ class Affix extends React.Component<AffixProps, AffixState> {
|
||||
this.updatePosition();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react/no-did-update-set-state
|
||||
this.setState({ prevTarget: newTarget });
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ category: Components
|
||||
subtitle: 固钉
|
||||
type: 导航
|
||||
title: Affix
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/SQGCQ7gOO/Affix.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/tX6-md4H6/Affix.svg
|
||||
---
|
||||
|
||||
将页面元素钉在可视范围。
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
category: Components
|
||||
type: Feedback
|
||||
title: Alert
|
||||
cover: https://gw.alipayobjects.com/zos/antfincdn/nuhf3vdRno/Alert.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/8emPa3fjl/Alert.svg
|
||||
---
|
||||
|
||||
Alert component for feedback.
|
||||
|
||||
@@ -3,7 +3,7 @@ category: Components
|
||||
subtitle: 警告提示
|
||||
type: 反馈
|
||||
title: Alert
|
||||
cover: https://gw.alipayobjects.com/zos/antfincdn/nuhf3vdRno/Alert.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/8emPa3fjl/Alert.svg
|
||||
---
|
||||
|
||||
警告提示,展现需要关注的信息。
|
||||
|
||||
@@ -307,7 +307,8 @@ describe('Anchor Render', () => {
|
||||
let start = 0;
|
||||
|
||||
const handler = () => {
|
||||
return (start += 1000);
|
||||
start += 1000;
|
||||
return start;
|
||||
};
|
||||
|
||||
return jest.spyOn(Date, 'now').mockImplementation(handler);
|
||||
@@ -384,7 +385,8 @@ describe('Anchor Render', () => {
|
||||
let start = 0;
|
||||
|
||||
const handler = () => {
|
||||
return (start += 1000);
|
||||
start += 1000;
|
||||
return start;
|
||||
};
|
||||
|
||||
return jest.spyOn(Date, 'now').mockImplementation(handler);
|
||||
@@ -432,7 +434,8 @@ describe('Anchor Render', () => {
|
||||
let start = 0;
|
||||
|
||||
const handler = () => {
|
||||
return (start += 1000);
|
||||
start += 1000;
|
||||
return start;
|
||||
};
|
||||
|
||||
return jest.spyOn(Date, 'now').mockImplementation(handler);
|
||||
|
||||
@@ -3,7 +3,7 @@ category: Components
|
||||
type: Other
|
||||
cols: 2
|
||||
title: Anchor
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/ep_L42LFy/Anchor.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/_1-C1JwsC/Anchor.svg
|
||||
---
|
||||
|
||||
Hyperlinks to scroll on one page.
|
||||
|
||||
@@ -4,7 +4,7 @@ subtitle: 锚点
|
||||
cols: 2
|
||||
type: 其他
|
||||
title: Anchor
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/ep_L42LFy/Anchor.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/_1-C1JwsC/Anchor.svg
|
||||
---
|
||||
|
||||
用于跳转到页面指定位置。
|
||||
|
||||
@@ -3,7 +3,7 @@ category: Components
|
||||
type: Data Entry
|
||||
cols: 2
|
||||
title: AutoComplete
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/gtGCgVDKv/AutoComplete.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/qtJm4yt45/AutoComplete.svg
|
||||
---
|
||||
|
||||
Autocomplete function of input field.
|
||||
|
||||
@@ -37,7 +37,7 @@ function isSelectOptionOrSelectOptGroup(child: any): Boolean {
|
||||
return child && child.type && (child.type.isSelectOption || child.type.isSelectOptGroup);
|
||||
}
|
||||
|
||||
const AutoComplete: React.RefForwardingComponent<Select, AutoCompleteProps> = (props, ref) => {
|
||||
const AutoComplete: React.ForwardRefRenderFunction<Select, AutoCompleteProps> = (props, ref) => {
|
||||
const { prefixCls: customizePrefixCls, className, children, dataSource } = props;
|
||||
const childNodes: React.ReactElement[] = toArray(children);
|
||||
|
||||
@@ -53,7 +53,7 @@ const AutoComplete: React.RefForwardingComponent<Select, AutoCompleteProps> = (p
|
||||
isValidElement(childNodes[0]) &&
|
||||
!isSelectOptionOrSelectOptGroup(childNodes[0])
|
||||
) {
|
||||
customizeInput = childNodes[0];
|
||||
[customizeInput] = childNodes;
|
||||
}
|
||||
|
||||
const getInputElement = (): React.ReactElement => customizeInput;
|
||||
|
||||
@@ -4,7 +4,7 @@ subtitle: 自动完成
|
||||
type: 数据录入
|
||||
cols: 2
|
||||
title: AutoComplete
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/gtGCgVDKv/AutoComplete.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/qtJm4yt45/AutoComplete.svg
|
||||
---
|
||||
|
||||
输入框自动完成功能。
|
||||
|
||||
@@ -75,11 +75,12 @@ describe('Avatar Render', () => {
|
||||
}
|
||||
|
||||
const wrapper = mount(<Foo />, { attachTo: div });
|
||||
expect(div.querySelector('img').getAttribute('src')).toBe(LOAD_FAILURE_SRC);
|
||||
// mock img load Error, since jsdom do not load resource by default
|
||||
// https://github.com/jsdom/jsdom/issues/1816
|
||||
wrapper.find('img').simulate('error');
|
||||
|
||||
expect(wrapper.find(Avatar).instance().state.isImgExist).toBe(true);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(div.querySelector('img').getAttribute('src')).toBe(LOAD_SUCCESS_SRC);
|
||||
|
||||
wrapper.detach();
|
||||
@@ -97,14 +98,16 @@ describe('Avatar Render', () => {
|
||||
const wrapper = mount(<Avatar src={LOAD_FAILURE_SRC}>Fallback</Avatar>, { attachTo: div });
|
||||
wrapper.find('img').simulate('error');
|
||||
|
||||
expect(wrapper.find(Avatar).instance().state.isImgExist).toBe(false);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(wrapper.find('.ant-avatar-string').length).toBe(1);
|
||||
// children should show, when image load error without onError return false
|
||||
expect(wrapper.find('.ant-avatar-string').prop('style')).not.toHaveProperty('opacity', 0);
|
||||
|
||||
// simulate successful src url
|
||||
wrapper.setProps({ src: LOAD_SUCCESS_SRC });
|
||||
wrapper.update();
|
||||
|
||||
expect(wrapper.find(Avatar).instance().state.isImgExist).toBe(true);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(wrapper.find('.ant-avatar-image').length).toBe(1);
|
||||
|
||||
// cleanup
|
||||
@@ -114,7 +117,8 @@ describe('Avatar Render', () => {
|
||||
|
||||
it('should calculate scale of avatar children correctly', () => {
|
||||
const wrapper = mount(<Avatar>Avatar</Avatar>);
|
||||
expect(wrapper.state().scale).toBe(0.72);
|
||||
expect(wrapper.find('.ant-avatar-string')).toMatchSnapshot();
|
||||
|
||||
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
|
||||
get() {
|
||||
if (this.className === 'ant-avatar-string') {
|
||||
@@ -124,12 +128,12 @@ describe('Avatar Render', () => {
|
||||
},
|
||||
});
|
||||
wrapper.setProps({ children: 'xx' });
|
||||
expect(wrapper.state().scale).toBe(0.32);
|
||||
expect(wrapper.find('.ant-avatar-string')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should calculate scale of avatar children correctly with gap', () => {
|
||||
const wrapper = mount(<Avatar gap={2}>Avatar</Avatar>);
|
||||
expect(wrapper.state().scale).toBe(0.36);
|
||||
expect(wrapper.find('.ant-avatar-string')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should warning when pass a string as icon props', () => {
|
||||
|
||||
@@ -11,6 +11,116 @@ exports[`Avatar Render rtl render component should be rendered correctly in RTL
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`Avatar Render should calculate scale of avatar children correctly 1`] = `
|
||||
<span
|
||||
className="ant-avatar-string"
|
||||
style={
|
||||
Object {
|
||||
"WebkitTransform": "scale(0.72) translateX(-50%)",
|
||||
"msTransform": "scale(0.72) translateX(-50%)",
|
||||
"transform": "scale(0.72) translateX(-50%)",
|
||||
}
|
||||
}
|
||||
>
|
||||
Avatar
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`Avatar Render should calculate scale of avatar children correctly 2`] = `
|
||||
<span
|
||||
className="ant-avatar-string"
|
||||
style={
|
||||
Object {
|
||||
"WebkitTransform": "scale(0.72) translateX(-50%)",
|
||||
"msTransform": "scale(0.72) translateX(-50%)",
|
||||
"transform": "scale(0.72) translateX(-50%)",
|
||||
}
|
||||
}
|
||||
>
|
||||
xx
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`Avatar Render should calculate scale of avatar children correctly with gap 1`] = `
|
||||
<span
|
||||
className="ant-avatar-string"
|
||||
style={
|
||||
Object {
|
||||
"WebkitTransform": "scale(0.36) translateX(-50%)",
|
||||
"msTransform": "scale(0.36) translateX(-50%)",
|
||||
"transform": "scale(0.36) translateX(-50%)",
|
||||
}
|
||||
}
|
||||
>
|
||||
Avatar
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`Avatar Render should handle onError correctly 1`] = `
|
||||
<Foo>
|
||||
<Avatar
|
||||
onError={[Function]}
|
||||
shape="circle"
|
||||
size="default"
|
||||
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||
>
|
||||
<span
|
||||
className="ant-avatar ant-avatar-circle ant-avatar-image"
|
||||
style={Object {}}
|
||||
>
|
||||
<img
|
||||
onError={[Function]}
|
||||
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||
/>
|
||||
</span>
|
||||
</Avatar>
|
||||
</Foo>
|
||||
`;
|
||||
|
||||
exports[`Avatar Render should show image on success after a failure state 1`] = `
|
||||
<Avatar
|
||||
shape="circle"
|
||||
size="default"
|
||||
src="http://error.url"
|
||||
>
|
||||
<span
|
||||
className="ant-avatar ant-avatar-circle"
|
||||
style={Object {}}
|
||||
>
|
||||
<span
|
||||
className="ant-avatar-string"
|
||||
style={
|
||||
Object {
|
||||
"WebkitTransform": "scale(0.72) translateX(-50%)",
|
||||
"msTransform": "scale(0.72) translateX(-50%)",
|
||||
"transform": "scale(0.72) translateX(-50%)",
|
||||
}
|
||||
}
|
||||
>
|
||||
Fallback
|
||||
</span>
|
||||
</span>
|
||||
</Avatar>
|
||||
`;
|
||||
|
||||
exports[`Avatar Render should show image on success after a failure state 2`] = `
|
||||
<Avatar
|
||||
shape="circle"
|
||||
size="default"
|
||||
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||
>
|
||||
<span
|
||||
className="ant-avatar ant-avatar-circle ant-avatar-image"
|
||||
style={Object {}}
|
||||
>
|
||||
<img
|
||||
onError={[Function]}
|
||||
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
|
||||
/>
|
||||
</span>
|
||||
</Avatar>
|
||||
`;
|
||||
|
||||
exports[`Avatar Render support size is number 1`] = `
|
||||
<span
|
||||
class="ant-avatar ant-avatar-circle"
|
||||
|
||||
@@ -19,3 +19,5 @@ Avatars can be used to represent people or objects. It supports images, `Icon`s,
|
||||
| alt | This attribute defines the alternative text describing the image | string | - | |
|
||||
| onError | handler when img load error, return false to prevent default fallback behavior | () => boolean | - | |
|
||||
| gap | Letter type unit distance between left and right sides | number | 4 | 4.3.0 |
|
||||
|
||||
> Tip: You can set `icon` or `children` as the fallback for image load error, with the priority of `icon` > `children`
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
||||
import { ConfigContext } from '../config-provider';
|
||||
import devWarning from '../_util/devWarning';
|
||||
|
||||
export interface AvatarProps {
|
||||
@@ -30,197 +30,186 @@ export interface AvatarProps {
|
||||
onError?: () => boolean;
|
||||
}
|
||||
|
||||
export interface AvatarState {
|
||||
scale: number;
|
||||
mounted: boolean;
|
||||
isImgExist: boolean;
|
||||
}
|
||||
const Avatar: React.FC<AvatarProps> = props => {
|
||||
const [scale, setScale] = React.useState(1);
|
||||
const [mounted, setMounted] = React.useState(false);
|
||||
const [isImgExist, setIsImgExist] = React.useState(true);
|
||||
|
||||
export default class Avatar extends React.Component<AvatarProps, AvatarState> {
|
||||
static defaultProps = {
|
||||
shape: 'circle' as AvatarProps['shape'],
|
||||
size: 'default' as AvatarProps['size'],
|
||||
};
|
||||
const avatarNodeRef = React.useRef<HTMLElement>();
|
||||
const avatarChildrenRef = React.useRef<HTMLElement>();
|
||||
|
||||
state = {
|
||||
scale: 1,
|
||||
mounted: false,
|
||||
isImgExist: true,
|
||||
};
|
||||
let lastChildrenWidth: number;
|
||||
let lastNodeWidth: number;
|
||||
|
||||
private avatarNode: HTMLElement;
|
||||
const { getPrefixCls } = React.useContext(ConfigContext);
|
||||
|
||||
private avatarChildren: HTMLElement;
|
||||
|
||||
private lastChildrenWidth: number;
|
||||
|
||||
private lastNodeWidth: number;
|
||||
|
||||
componentDidMount() {
|
||||
this.setScale();
|
||||
this.setState({ mounted: true });
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: AvatarProps) {
|
||||
if (prevProps.src !== this.props.src) {
|
||||
this.setState({ isImgExist: true, scale: 1 });
|
||||
}
|
||||
if (prevProps.children !== this.props.children || prevProps.gap !== this.props.gap) {
|
||||
this.setScale();
|
||||
}
|
||||
}
|
||||
|
||||
setScale = () => {
|
||||
if (!this.avatarChildren || !this.avatarNode) {
|
||||
const setScaleParam = () => {
|
||||
if (!avatarChildrenRef.current || !avatarNodeRef.current) {
|
||||
return;
|
||||
}
|
||||
const childrenWidth = this.avatarChildren.offsetWidth; // offsetWidth avoid affecting be transform scale
|
||||
const nodeWidth = this.avatarNode.offsetWidth;
|
||||
const { gap = 4 } = this.props;
|
||||
const childrenWidth = avatarChildrenRef.current.offsetWidth; // offsetWidth avoid affecting be transform scale
|
||||
const nodeWidth = avatarNodeRef.current.offsetWidth;
|
||||
const { gap = 4 } = props;
|
||||
// denominator is 0 is no meaning
|
||||
if (
|
||||
childrenWidth !== 0 &&
|
||||
nodeWidth !== 0 &&
|
||||
(this.lastChildrenWidth !== childrenWidth || this.lastNodeWidth !== nodeWidth)
|
||||
(lastChildrenWidth !== childrenWidth || lastNodeWidth !== nodeWidth)
|
||||
) {
|
||||
this.lastChildrenWidth = childrenWidth;
|
||||
this.lastNodeWidth = nodeWidth;
|
||||
lastChildrenWidth = childrenWidth;
|
||||
lastNodeWidth = nodeWidth;
|
||||
}
|
||||
|
||||
if (gap * 2 < nodeWidth) {
|
||||
this.setState({
|
||||
scale: nodeWidth - gap * 2 < childrenWidth ? (nodeWidth - gap * 2) / childrenWidth : 1,
|
||||
});
|
||||
setScale(nodeWidth - gap * 2 < childrenWidth ? (nodeWidth - gap * 2) / childrenWidth : 1);
|
||||
}
|
||||
};
|
||||
|
||||
handleImgLoadError = () => {
|
||||
const { onError } = this.props;
|
||||
React.useEffect(() => {
|
||||
setScaleParam();
|
||||
setMounted(true);
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
setIsImgExist(true);
|
||||
setScale(1);
|
||||
}, [props.src]);
|
||||
|
||||
React.useEffect(() => {
|
||||
setScaleParam();
|
||||
}, [props.children, props.gap]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (props.children) {
|
||||
setScaleParam();
|
||||
}
|
||||
}, [isImgExist]);
|
||||
|
||||
const handleImgLoadError = () => {
|
||||
const { onError } = props;
|
||||
const errorFlag = onError ? onError() : undefined;
|
||||
if (errorFlag !== false) {
|
||||
this.setState({ isImgExist: false });
|
||||
setIsImgExist(false);
|
||||
}
|
||||
};
|
||||
|
||||
renderAvatar = ({ getPrefixCls }: ConfigConsumerProps) => {
|
||||
const {
|
||||
prefixCls: customizePrefixCls,
|
||||
shape,
|
||||
size,
|
||||
src,
|
||||
srcSet,
|
||||
icon,
|
||||
className,
|
||||
alt,
|
||||
draggable,
|
||||
...others
|
||||
} = this.props;
|
||||
const {
|
||||
prefixCls: customizePrefixCls,
|
||||
shape,
|
||||
size,
|
||||
src,
|
||||
srcSet,
|
||||
icon,
|
||||
className,
|
||||
alt,
|
||||
draggable,
|
||||
...others
|
||||
} = props;
|
||||
|
||||
devWarning(
|
||||
!(typeof icon === 'string' && icon.length > 2),
|
||||
'Avatar',
|
||||
`\`icon\` is using ReactNode instead of string naming in v4. Please check \`${icon}\` at https://ant.design/components/icon`,
|
||||
);
|
||||
devWarning(
|
||||
!(typeof icon === 'string' && icon.length > 2),
|
||||
'Avatar',
|
||||
`\`icon\` is using ReactNode instead of string naming in v4. Please check \`${icon}\` at https://ant.design/components/icon`,
|
||||
);
|
||||
|
||||
const { isImgExist, scale, mounted } = this.state;
|
||||
const prefixCls = getPrefixCls('avatar', customizePrefixCls);
|
||||
|
||||
const prefixCls = getPrefixCls('avatar', customizePrefixCls);
|
||||
const sizeCls = classNames({
|
||||
[`${prefixCls}-lg`]: size === 'large',
|
||||
[`${prefixCls}-sm`]: size === 'small',
|
||||
});
|
||||
|
||||
const sizeCls = classNames({
|
||||
[`${prefixCls}-lg`]: size === 'large',
|
||||
[`${prefixCls}-sm`]: size === 'small',
|
||||
});
|
||||
const classString = classNames(prefixCls, className, sizeCls, {
|
||||
[`${prefixCls}-${shape}`]: shape,
|
||||
[`${prefixCls}-image`]: src && isImgExist,
|
||||
[`${prefixCls}-icon`]: icon,
|
||||
});
|
||||
|
||||
const classString = classNames(prefixCls, className, sizeCls, {
|
||||
[`${prefixCls}-${shape}`]: shape,
|
||||
[`${prefixCls}-image`]: src && isImgExist,
|
||||
[`${prefixCls}-icon`]: icon,
|
||||
});
|
||||
|
||||
const sizeStyle: React.CSSProperties =
|
||||
typeof size === 'number'
|
||||
? {
|
||||
width: size,
|
||||
height: size,
|
||||
lineHeight: `${size}px`,
|
||||
fontSize: icon ? size / 2 : 18,
|
||||
}
|
||||
: {};
|
||||
|
||||
let { children } = this.props;
|
||||
if (src && isImgExist) {
|
||||
children = (
|
||||
<img
|
||||
src={src}
|
||||
draggable={draggable}
|
||||
srcSet={srcSet}
|
||||
onError={this.handleImgLoadError}
|
||||
alt={alt}
|
||||
/>
|
||||
);
|
||||
} else if (icon) {
|
||||
children = icon;
|
||||
} else {
|
||||
const childrenNode = this.avatarChildren;
|
||||
if (childrenNode || scale !== 1) {
|
||||
const transformString = `scale(${scale}) translateX(-50%)`;
|
||||
const childrenStyle: React.CSSProperties = {
|
||||
msTransform: transformString,
|
||||
WebkitTransform: transformString,
|
||||
transform: transformString,
|
||||
};
|
||||
|
||||
const sizeChildrenStyle: React.CSSProperties =
|
||||
typeof size === 'number'
|
||||
? {
|
||||
lineHeight: `${size}px`,
|
||||
}
|
||||
: {};
|
||||
children = (
|
||||
<span
|
||||
className={`${prefixCls}-string`}
|
||||
ref={(node: HTMLElement) => (this.avatarChildren = node)}
|
||||
style={{ ...sizeChildrenStyle, ...childrenStyle }}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
const childrenStyle: React.CSSProperties = {};
|
||||
if (!mounted) {
|
||||
childrenStyle.opacity = 0;
|
||||
const sizeStyle: React.CSSProperties =
|
||||
typeof size === 'number'
|
||||
? {
|
||||
width: size,
|
||||
height: size,
|
||||
lineHeight: `${size}px`,
|
||||
fontSize: icon ? size / 2 : 18,
|
||||
}
|
||||
: {};
|
||||
|
||||
children = (
|
||||
<span
|
||||
className={`${prefixCls}-string`}
|
||||
style={{ opacity: 0 }}
|
||||
ref={(node: HTMLElement) => (this.avatarChildren = node)}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// The event is triggered twice from bubbling up the DOM tree.
|
||||
// see https://codesandbox.io/s/kind-snow-9lidz
|
||||
delete others.onError;
|
||||
delete others.gap;
|
||||
|
||||
return (
|
||||
<span
|
||||
{...others}
|
||||
style={{ ...sizeStyle, ...others.style }}
|
||||
className={classString}
|
||||
ref={(node: HTMLElement) => (this.avatarNode = node)}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
let { children } = props;
|
||||
if (src && isImgExist) {
|
||||
children = (
|
||||
<img src={src} draggable={draggable} srcSet={srcSet} onError={handleImgLoadError} alt={alt} />
|
||||
);
|
||||
};
|
||||
} else if (icon) {
|
||||
children = icon;
|
||||
} else {
|
||||
const childrenNode = avatarChildrenRef.current;
|
||||
if (childrenNode || scale !== 1) {
|
||||
const transformString = `scale(${scale}) translateX(-50%)`;
|
||||
const childrenStyle: React.CSSProperties = {
|
||||
msTransform: transformString,
|
||||
WebkitTransform: transformString,
|
||||
transform: transformString,
|
||||
};
|
||||
|
||||
render() {
|
||||
return <ConfigConsumer>{this.renderAvatar}</ConfigConsumer>;
|
||||
const sizeChildrenStyle: React.CSSProperties =
|
||||
typeof size === 'number'
|
||||
? {
|
||||
lineHeight: `${size}px`,
|
||||
}
|
||||
: {};
|
||||
children = (
|
||||
<span
|
||||
className={`${prefixCls}-string`}
|
||||
ref={(node: HTMLElement) => {
|
||||
avatarChildrenRef.current = node;
|
||||
}}
|
||||
style={{ ...sizeChildrenStyle, ...childrenStyle }}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
const childrenStyle: React.CSSProperties = {};
|
||||
if (!mounted) {
|
||||
childrenStyle.opacity = 0;
|
||||
}
|
||||
|
||||
children = (
|
||||
<span
|
||||
className={`${prefixCls}-string`}
|
||||
style={{ opacity: 0 }}
|
||||
ref={(node: HTMLElement) => {
|
||||
avatarChildrenRef.current = node;
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The event is triggered twice from bubbling up the DOM tree.
|
||||
// see https://codesandbox.io/s/kind-snow-9lidz
|
||||
delete others.onError;
|
||||
delete others.gap;
|
||||
return (
|
||||
<span
|
||||
{...others}
|
||||
style={{ ...sizeStyle, ...others.style }}
|
||||
className={classString}
|
||||
ref={(node: HTMLElement) => {
|
||||
avatarNodeRef.current = node;
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
Avatar.defaultProps = {
|
||||
shape: 'circle' as AvatarProps['shape'],
|
||||
size: 'default' as AvatarProps['size'],
|
||||
};
|
||||
|
||||
export default Avatar;
|
||||
|
||||
@@ -24,3 +24,5 @@ cover: https://gw.alipayobjects.com/zos/antfincdn/aBcnbw68hP/Avatar.svg
|
||||
| alt | 图像无法显示时的替代文本 | string | - | |
|
||||
| onError | 图片加载失败的事件,返回 false 会关闭组件默认的 fallback 行为 | () => boolean | - | |
|
||||
| gap | 字符类型距离左右两侧边界单位像素 | number | 4 | 4.3.0 |
|
||||
|
||||
> Tip:你可以设置 `icon` 或 `children` 作为图片加载失败的默认 fallback 行为,优先级为 `icon` > `children`
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
category: Components
|
||||
type: Other
|
||||
title: BackTop
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/Ji3PnAAMT/BackTop.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/tJZ5jbTwX/BackTop.svg
|
||||
---
|
||||
|
||||
`BackTop` makes it easy to go back to the top of the page.
|
||||
|
||||
@@ -3,7 +3,7 @@ category: Components
|
||||
type: 其他
|
||||
subtitle: 回到顶部
|
||||
title: BackTop
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/Ji3PnAAMT/BackTop.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/tJZ5jbTwX/BackTop.svg
|
||||
---
|
||||
|
||||
返回页面顶部的操作按钮。
|
||||
|
||||
@@ -1497,6 +1497,179 @@ exports[`renders ./components/badge/demo/no-wrapper.md correctly 1`] = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`renders ./components/badge/demo/offset.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-badge"
|
||||
>
|
||||
<a
|
||||
class="head-example"
|
||||
href="#"
|
||||
/>
|
||||
<sup
|
||||
class="ant-scroll-number ant-badge-count"
|
||||
data-show="true"
|
||||
style="right:-10px;margin-top:10px"
|
||||
title="5"
|
||||
>
|
||||
<span
|
||||
class="ant-scroll-number-only"
|
||||
style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)"
|
||||
>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
0
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
1
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
2
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
3
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
4
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
5
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
6
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
7
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
8
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
9
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
0
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
1
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
2
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
3
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
4
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit current"
|
||||
>
|
||||
5
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
6
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
7
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
8
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
9
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
0
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
1
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
2
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
3
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
4
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
5
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
6
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
7
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
8
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
9
|
||||
</p>
|
||||
</span>
|
||||
</sup>
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`renders ./components/badge/demo/overflow.md correctly 1`] = `
|
||||
<div>
|
||||
<span
|
||||
|
||||
@@ -762,6 +762,181 @@ exports[`Badge rtl render component should be rendered correctly in RTL directio
|
||||
/>
|
||||
`;
|
||||
|
||||
exports[`Badge rtl render component should be rendered correctly in RTL direction 2`] = `
|
||||
<span
|
||||
class="ant-badge ant-badge-rtl"
|
||||
>
|
||||
<a
|
||||
class="head-example"
|
||||
href="#"
|
||||
>
|
||||
head
|
||||
</a>
|
||||
<sup
|
||||
class="ant-scroll-number ant-badge-count"
|
||||
data-show="true"
|
||||
style="left:10px;margin-top:10px"
|
||||
title="5"
|
||||
>
|
||||
<span
|
||||
class="ant-scroll-number-only"
|
||||
style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)"
|
||||
>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
0
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
1
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
2
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
3
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
4
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
5
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
6
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
7
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
8
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
9
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
0
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
1
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
2
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
3
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
4
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit current"
|
||||
>
|
||||
5
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
6
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
7
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
8
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
9
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
0
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
1
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
2
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
3
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
4
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
5
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
6
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
7
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
8
|
||||
</p>
|
||||
<p
|
||||
class="ant-scroll-number-only-unit"
|
||||
>
|
||||
9
|
||||
</p>
|
||||
</span>
|
||||
</sup>
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`Badge should be compatible with borderColor style 1`] = `
|
||||
<span
|
||||
class="ant-badge ant-badge-not-a-wrapper"
|
||||
|
||||
@@ -8,6 +8,13 @@ import rtlTest from '../../../tests/shared/rtlTest';
|
||||
describe('Badge', () => {
|
||||
mountTest(Badge);
|
||||
rtlTest(Badge);
|
||||
rtlTest(() => (
|
||||
<Badge count={5} offset={[10, 10]}>
|
||||
<a href="#" className="head-example">
|
||||
head
|
||||
</a>
|
||||
</Badge>
|
||||
));
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers();
|
||||
|
||||
27
components/badge/demo/offset.md
Normal file
27
components/badge/demo/offset.md
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
order: 5
|
||||
title:
|
||||
zh-CN: 自定义位置偏移
|
||||
en-US: Offset
|
||||
---
|
||||
|
||||
## zh-CN
|
||||
|
||||
设置状态点的位置偏移,格式为 `[left, top]`,表示状态点距默认位置左侧、上方的偏移量。
|
||||
|
||||
## en-US
|
||||
|
||||
Set offset of the badge dot, the format is `[left, top]`, which represents the offset of the status dot from the left and top of the default position.
|
||||
|
||||
```jsx
|
||||
import { Badge } from 'antd';
|
||||
|
||||
ReactDOM.render(
|
||||
<>
|
||||
<Badge count={5} offset={[10, 10]}>
|
||||
<a href="#" className="head-example" />
|
||||
</Badge>
|
||||
</>,
|
||||
mountNode,
|
||||
);
|
||||
```
|
||||
@@ -13,22 +13,12 @@ Badge normally appears in proximity to notifications or user avatars with eye-ca
|
||||
|
||||
## API
|
||||
|
||||
```jsx
|
||||
<Badge count={5}>
|
||||
<a href="#" className="head-example" />
|
||||
</Badge>
|
||||
```
|
||||
|
||||
```jsx
|
||||
<Badge count={5} />
|
||||
```
|
||||
|
||||
| Property | Description | Type | Default | Version |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| color | Customize Badge dot color | string | - | |
|
||||
| count | Number to show in badge | ReactNode | | |
|
||||
| dot | Whether to display a red dot instead of `count` | boolean | `false` | |
|
||||
| offset | set offset of the badge dot, like`[x, y]` | `[number, number]` | - | |
|
||||
| offset | set offset of the badge dot | `[number, number]` | - | |
|
||||
| overflowCount | Max count to show | number | 99 | |
|
||||
| showZero | Whether to show badge when `count` is zero | boolean | `false` | |
|
||||
| status | Set Badge as a status dot | `success` \| `processing` \| `default` \| `error` \| `warning` | `''` | |
|
||||
|
||||
@@ -87,6 +87,15 @@ const Badge: React.FC<BadgeProps> = ({
|
||||
};
|
||||
|
||||
const getStyleWithOffset = () => {
|
||||
if (direction === 'rtl') {
|
||||
return offset
|
||||
? {
|
||||
left: parseInt(offset[0] as string, 10),
|
||||
marginTop: offset[1],
|
||||
...style,
|
||||
}
|
||||
: style;
|
||||
}
|
||||
return offset
|
||||
? {
|
||||
right: -parseInt(offset[0] as string, 10),
|
||||
|
||||
@@ -14,22 +14,12 @@ cover: https://gw.alipayobjects.com/zos/antfincdn/6%26GF9WHwvY/Badge.svg
|
||||
|
||||
## API
|
||||
|
||||
```jsx
|
||||
<Badge count={5}>
|
||||
<a href="#" className="head-example" />
|
||||
</Badge>
|
||||
```
|
||||
|
||||
```jsx
|
||||
<Badge count={5} />
|
||||
```
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| color | 自定义小圆点的颜色 | string | - | |
|
||||
| count | 展示的数字,大于 overflowCount 时显示为 `${overflowCount}+`,为 0 时隐藏 | ReactNode | | |
|
||||
| dot | 不展示数字,只有一个小红点 | boolean | false | |
|
||||
| offset | 设置状态点的位置偏移,格式为 `[x, y]` | `[number, number]` | - | |
|
||||
| offset | 设置状态点的位置偏移 | `[number, number]` | - | |
|
||||
| overflowCount | 展示封顶的数字值 | number | 99 | |
|
||||
| showZero | 当数值为 0 时,是否展示 Badge | boolean | false | |
|
||||
| status | 设置 Badge 为状态点 | `success` \| `processing` \| `default` \| `error` \| `warning` | '' | |
|
||||
|
||||
@@ -47,7 +47,7 @@ Array [
|
||||
`;
|
||||
|
||||
exports[`renders ./components/button/demo/block.md correctly 1`] = `
|
||||
<div>
|
||||
Array [
|
||||
<button
|
||||
class="ant-btn ant-btn-primary ant-btn-block"
|
||||
type="button"
|
||||
@@ -55,7 +55,7 @@ exports[`renders ./components/button/demo/block.md correctly 1`] = `
|
||||
<span>
|
||||
Primary
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-block"
|
||||
type="button"
|
||||
@@ -63,7 +63,7 @@ exports[`renders ./components/button/demo/block.md correctly 1`] = `
|
||||
<span>
|
||||
Default
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-dashed ant-btn-block"
|
||||
type="button"
|
||||
@@ -71,7 +71,7 @@ exports[`renders ./components/button/demo/block.md correctly 1`] = `
|
||||
<span>
|
||||
Dashed
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-link ant-btn-block"
|
||||
type="button"
|
||||
@@ -79,8 +79,8 @@ exports[`renders ./components/button/demo/block.md correctly 1`] = `
|
||||
<span>
|
||||
Link
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</button>,
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`renders ./components/button/demo/danger.md correctly 1`] = `
|
||||
@@ -129,7 +129,7 @@ Array [
|
||||
`;
|
||||
|
||||
exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<div>
|
||||
Array [
|
||||
<button
|
||||
class="ant-btn ant-btn-primary"
|
||||
type="button"
|
||||
@@ -137,7 +137,7 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Primary
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-primary"
|
||||
disabled=""
|
||||
@@ -146,8 +146,8 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Primary(disabled)
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
</button>,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn"
|
||||
type="button"
|
||||
@@ -155,7 +155,7 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Default
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn"
|
||||
disabled=""
|
||||
@@ -164,8 +164,8 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Default(disabled)
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
</button>,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn ant-btn-dashed"
|
||||
type="button"
|
||||
@@ -173,7 +173,7 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Dashed
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-dashed"
|
||||
disabled=""
|
||||
@@ -182,8 +182,8 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Dashed(disabled)
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
</button>,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn ant-btn-text"
|
||||
type="button"
|
||||
@@ -191,7 +191,7 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Text
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-text"
|
||||
disabled=""
|
||||
@@ -200,8 +200,8 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Text(disabled)
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
</button>,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn ant-btn-link"
|
||||
type="button"
|
||||
@@ -209,7 +209,7 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Link
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-link"
|
||||
disabled=""
|
||||
@@ -218,8 +218,8 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Link(disabled)
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
</button>,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn ant-btn-dangerous"
|
||||
type="button"
|
||||
@@ -227,7 +227,7 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Danger Default
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-dangerous"
|
||||
disabled=""
|
||||
@@ -236,8 +236,8 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Danger Default(disabled)
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
</button>,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn ant-btn-text ant-btn-dangerous"
|
||||
type="button"
|
||||
@@ -245,7 +245,7 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Danger Text
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-text ant-btn-dangerous"
|
||||
disabled=""
|
||||
@@ -254,8 +254,8 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Danger Text(disabled)
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
</button>,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn ant-btn-link ant-btn-dangerous"
|
||||
type="button"
|
||||
@@ -263,7 +263,7 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Danger Link
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-link ant-btn-dangerous"
|
||||
disabled=""
|
||||
@@ -272,7 +272,7 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
<span>
|
||||
Danger Link(disabled)
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<div
|
||||
class="site-button-ghost-wrapper"
|
||||
>
|
||||
@@ -293,8 +293,8 @@ exports[`renders ./components/button/demo/disabled.md correctly 1`] = `
|
||||
Ghost(disabled)
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`renders ./components/button/demo/ghost.md correctly 1`] = `
|
||||
@@ -345,7 +345,7 @@ exports[`renders ./components/button/demo/ghost.md correctly 1`] = `
|
||||
`;
|
||||
|
||||
exports[`renders ./components/button/demo/icon.md correctly 1`] = `
|
||||
<div>
|
||||
Array [
|
||||
<button
|
||||
class="ant-btn ant-btn-primary ant-btn-circle ant-btn-icon-only"
|
||||
type="button"
|
||||
@@ -370,7 +370,7 @@ exports[`renders ./components/button/demo/icon.md correctly 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-primary ant-btn-circle"
|
||||
type="button"
|
||||
@@ -378,7 +378,7 @@ exports[`renders ./components/button/demo/icon.md correctly 1`] = `
|
||||
<span>
|
||||
A
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-primary"
|
||||
type="button"
|
||||
@@ -406,7 +406,7 @@ exports[`renders ./components/button/demo/icon.md correctly 1`] = `
|
||||
<span>
|
||||
Search
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-circle ant-btn-icon-only"
|
||||
type="button"
|
||||
@@ -431,7 +431,7 @@ exports[`renders ./components/button/demo/icon.md correctly 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn"
|
||||
type="button"
|
||||
@@ -459,8 +459,8 @@ exports[`renders ./components/button/demo/icon.md correctly 1`] = `
|
||||
<span>
|
||||
Search
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
</button>,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn ant-btn-circle ant-btn-icon-only"
|
||||
type="button"
|
||||
@@ -485,7 +485,7 @@ exports[`renders ./components/button/demo/icon.md correctly 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn"
|
||||
type="button"
|
||||
@@ -513,7 +513,7 @@ exports[`renders ./components/button/demo/icon.md correctly 1`] = `
|
||||
<span>
|
||||
Search
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-dashed ant-btn-circle ant-btn-icon-only"
|
||||
type="button"
|
||||
@@ -538,7 +538,7 @@ exports[`renders ./components/button/demo/icon.md correctly 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-dashed"
|
||||
type="button"
|
||||
@@ -566,12 +566,12 @@ exports[`renders ./components/button/demo/icon.md correctly 1`] = `
|
||||
<span>
|
||||
Search
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</button>,
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`renders ./components/button/demo/legacy-group.md correctly 1`] = `
|
||||
<div>
|
||||
Array [
|
||||
<div>
|
||||
<div
|
||||
class="ant-btn-group ant-btn-group-sm"
|
||||
@@ -650,8 +650,8 @@ exports[`renders ./components/button/demo/legacy-group.md correctly 1`] = `
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
</div>,
|
||||
<br />,
|
||||
<div>
|
||||
<div
|
||||
class="ant-btn-group"
|
||||
@@ -730,8 +730,8 @@ exports[`renders ./components/button/demo/legacy-group.md correctly 1`] = `
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
</div>,
|
||||
<br />,
|
||||
<div>
|
||||
<div
|
||||
class="ant-btn-group ant-btn-group-lg"
|
||||
@@ -810,8 +810,8 @@ exports[`renders ./components/button/demo/legacy-group.md correctly 1`] = `
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`renders ./components/button/demo/loading.md correctly 1`] = `
|
||||
@@ -975,7 +975,7 @@ Array [
|
||||
`;
|
||||
|
||||
exports[`renders ./components/button/demo/multiple.md correctly 1`] = `
|
||||
<div>
|
||||
Array [
|
||||
<button
|
||||
class="ant-btn ant-btn-primary"
|
||||
type="button"
|
||||
@@ -983,7 +983,7 @@ exports[`renders ./components/button/demo/multiple.md correctly 1`] = `
|
||||
<span>
|
||||
primary
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn"
|
||||
type="button"
|
||||
@@ -991,7 +991,7 @@ exports[`renders ./components/button/demo/multiple.md correctly 1`] = `
|
||||
<span>
|
||||
secondary
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-dropdown-trigger"
|
||||
type="button"
|
||||
@@ -1019,12 +1019,12 @@ exports[`renders ./components/button/demo/multiple.md correctly 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</button>,
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
<div>
|
||||
Array [
|
||||
<div
|
||||
class="ant-radio-group ant-radio-group-outline"
|
||||
>
|
||||
@@ -1086,9 +1086,9 @@ exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
Small
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
</div>,
|
||||
<br />,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn ant-btn-primary ant-btn-lg"
|
||||
type="button"
|
||||
@@ -1096,7 +1096,7 @@ exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
<span>
|
||||
Primary
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-lg"
|
||||
type="button"
|
||||
@@ -1104,7 +1104,7 @@ exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
<span>
|
||||
Default
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-dashed ant-btn-lg"
|
||||
type="button"
|
||||
@@ -1112,8 +1112,8 @@ exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
<span>
|
||||
Dashed
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
</button>,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn ant-btn-link ant-btn-lg"
|
||||
type="button"
|
||||
@@ -1121,8 +1121,8 @@ exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
<span>
|
||||
Link
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
</button>,
|
||||
<br />,
|
||||
<button
|
||||
class="ant-btn ant-btn-primary ant-btn-lg ant-btn-icon-only"
|
||||
type="button"
|
||||
@@ -1147,7 +1147,7 @@ exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-primary ant-btn-circle ant-btn-lg ant-btn-icon-only"
|
||||
type="button"
|
||||
@@ -1172,7 +1172,7 @@ exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-primary ant-btn-round ant-btn-lg ant-btn-icon-only"
|
||||
type="button"
|
||||
@@ -1197,7 +1197,7 @@ exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-primary ant-btn-round ant-btn-lg"
|
||||
type="button"
|
||||
@@ -1225,7 +1225,7 @@ exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
<span>
|
||||
Download
|
||||
</span>
|
||||
</button>
|
||||
</button>,
|
||||
<button
|
||||
class="ant-btn ant-btn-primary ant-btn-lg"
|
||||
type="button"
|
||||
@@ -1253,6 +1253,6 @@ exports[`renders ./components/button/demo/size.md correctly 1`] = `
|
||||
<span>
|
||||
Download
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</button>,
|
||||
]
|
||||
`;
|
||||
|
||||
@@ -170,6 +170,8 @@ describe('Button', () => {
|
||||
jest.useFakeTimers();
|
||||
const wrapper = mount(<Button loading={{ delay: 1000 }} />);
|
||||
wrapper.update();
|
||||
wrapper.setProps({ loading: { delay: 2000 } });
|
||||
wrapper.update();
|
||||
wrapper.setProps({ loading: false });
|
||||
|
||||
act(() => {
|
||||
|
||||
@@ -121,6 +121,8 @@ interface CompoundedComponent
|
||||
__ANT_BUTTON: boolean;
|
||||
}
|
||||
|
||||
type Loading = number | boolean;
|
||||
|
||||
const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (props, ref) => {
|
||||
const {
|
||||
loading,
|
||||
@@ -138,7 +140,7 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
|
||||
} = props;
|
||||
|
||||
const size = React.useContext(SizeContext);
|
||||
const [innerLoading, setLoading] = React.useState(loading);
|
||||
const [innerLoading, setLoading] = React.useState<Loading>(!!loading);
|
||||
const [hasTwoCNChar, setHasTwoCNChar] = React.useState(false);
|
||||
const { getPrefixCls, autoInsertSpaceInButton, direction } = React.useContext(ConfigContext);
|
||||
const buttonRef = (ref as any) || React.createRef<HTMLElement>();
|
||||
@@ -163,16 +165,24 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
|
||||
}
|
||||
};
|
||||
|
||||
// =============== Update Loading ===============
|
||||
let loadingOrDelay: Loading;
|
||||
if (typeof loading === 'object' && loading.delay) {
|
||||
loadingOrDelay = loading.delay || true;
|
||||
} else {
|
||||
loadingOrDelay = !!loading;
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
if (typeof loading === 'object' && loading.delay) {
|
||||
clearTimeout(delayTimeoutRef.current);
|
||||
if (typeof loadingOrDelay === 'number') {
|
||||
delayTimeoutRef.current = window.setTimeout(() => {
|
||||
setLoading(loading);
|
||||
}, loading.delay);
|
||||
setLoading(loadingOrDelay);
|
||||
}, loadingOrDelay);
|
||||
} else {
|
||||
clearTimeout(delayTimeoutRef.current);
|
||||
setLoading(loading);
|
||||
setLoading(loadingOrDelay);
|
||||
}
|
||||
}, [loading]);
|
||||
}, [loadingOrDelay]);
|
||||
|
||||
React.useEffect(() => {
|
||||
fixTwoCNChar();
|
||||
@@ -230,7 +240,7 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
|
||||
icon && !innerLoading ? (
|
||||
icon
|
||||
) : (
|
||||
<LoadingIcon existIcon={!!icon} prefixCls={prefixCls} loading={innerLoading} />
|
||||
<LoadingIcon existIcon={!!icon} prefixCls={prefixCls} loading={!!innerLoading} />
|
||||
);
|
||||
|
||||
const kids =
|
||||
|
||||
@@ -17,7 +17,7 @@ title:
|
||||
import { Button } from 'antd';
|
||||
|
||||
ReactDOM.render(
|
||||
<div>
|
||||
<>
|
||||
<Button type="primary" block>
|
||||
Primary
|
||||
</Button>
|
||||
@@ -28,7 +28,7 @@ ReactDOM.render(
|
||||
<Button type="link" block>
|
||||
Link
|
||||
</Button>
|
||||
</div>,
|
||||
</>,
|
||||
mountNode,
|
||||
);
|
||||
```
|
||||
|
||||
@@ -17,7 +17,7 @@ To mark a button as disabled, add the `disabled` property to the `Button`.
|
||||
import { Button } from 'antd';
|
||||
|
||||
ReactDOM.render(
|
||||
<div>
|
||||
<>
|
||||
<Button type="primary">Primary</Button>
|
||||
<Button type="primary" disabled>
|
||||
Primary(disabled)
|
||||
@@ -65,7 +65,7 @@ ReactDOM.render(
|
||||
Ghost(disabled)
|
||||
</Button>
|
||||
</div>
|
||||
</div>,
|
||||
</>,
|
||||
mountNode,
|
||||
);
|
||||
```
|
||||
|
||||
@@ -22,7 +22,7 @@ import { Button, Tooltip } from 'antd';
|
||||
import { SearchOutlined } from '@ant-design/icons';
|
||||
|
||||
ReactDOM.render(
|
||||
<div>
|
||||
<>
|
||||
<Tooltip title="search">
|
||||
<Button type="primary" shape="circle" icon={<SearchOutlined />} />
|
||||
</Tooltip>
|
||||
@@ -47,7 +47,7 @@ ReactDOM.render(
|
||||
<Button type="dashed" icon={<SearchOutlined />}>
|
||||
Search
|
||||
</Button>
|
||||
</div>,
|
||||
</>,
|
||||
mountNode,
|
||||
);
|
||||
```
|
||||
|
||||
@@ -36,13 +36,13 @@ function getGroup(props) {
|
||||
}
|
||||
|
||||
ReactDOM.render(
|
||||
<div>
|
||||
<>
|
||||
{getGroup({ size: 'small' })}
|
||||
<br />
|
||||
{getGroup()}
|
||||
<br />
|
||||
{getGroup({ size: 'large' })}
|
||||
</div>,
|
||||
</>,
|
||||
mountNode,
|
||||
);
|
||||
```
|
||||
|
||||
@@ -30,7 +30,7 @@ const menu = (
|
||||
);
|
||||
|
||||
ReactDOM.render(
|
||||
<div>
|
||||
<>
|
||||
<Button type="primary">primary</Button>
|
||||
<Button>secondary</Button>
|
||||
<Dropdown overlay={menu}>
|
||||
@@ -38,7 +38,7 @@ ReactDOM.render(
|
||||
Actions <DownOutlined />
|
||||
</Button>
|
||||
</Dropdown>
|
||||
</div>,
|
||||
</>,
|
||||
mountNode,
|
||||
);
|
||||
```
|
||||
|
||||
@@ -33,7 +33,7 @@ class ButtonSize extends React.Component {
|
||||
render() {
|
||||
const { size } = this.state;
|
||||
return (
|
||||
<div>
|
||||
<>
|
||||
<Radio.Group value={size} onChange={this.handleSizeChange}>
|
||||
<Radio.Button value="large">Large</Radio.Button>
|
||||
<Radio.Button value="default">Default</Radio.Button>
|
||||
@@ -62,7 +62,7 @@ class ButtonSize extends React.Component {
|
||||
<Button type="primary" icon={<DownloadOutlined />} size={size}>
|
||||
Download
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
category: Components
|
||||
type: General
|
||||
title: Button
|
||||
cover: https://gw.alipayobjects.com/zos/antfincdn/qZWIjVIkQ7/Button.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/fNUKzY1sk/Button.svg
|
||||
---
|
||||
|
||||
To trigger an operation.
|
||||
|
||||
@@ -3,7 +3,7 @@ category: Components
|
||||
type: 通用
|
||||
title: Button
|
||||
subtitle: 按钮
|
||||
cover: https://gw.alipayobjects.com/zos/antfincdn/qZWIjVIkQ7/Button.svg
|
||||
cover: https://gw.alipayobjects.com/zos/alicdn/fNUKzY1sk/Button.svg
|
||||
---
|
||||
|
||||
按钮用于开始一个即时操作。
|
||||
|
||||
@@ -127,15 +127,27 @@ describe('Calendar', () => {
|
||||
MockDate.reset();
|
||||
});
|
||||
|
||||
it('should trigger onPanelChange when click last month of date', () => {
|
||||
const onPanelChange = jest.fn();
|
||||
const date = new Moment('1990-09-03');
|
||||
const wrapper = mount(<Calendar onPanelChange={onPanelChange} value={date} />);
|
||||
describe('onPanelChange', () => {
|
||||
it('trigger when click last month of date', () => {
|
||||
const onPanelChange = jest.fn();
|
||||
const date = new Moment('1990-09-03');
|
||||
const wrapper = mount(<Calendar onPanelChange={onPanelChange} value={date} />);
|
||||
|
||||
wrapper.find('.ant-picker-cell').at(0).simulate('click');
|
||||
wrapper.find('.ant-picker-cell').at(0).simulate('click');
|
||||
|
||||
expect(onPanelChange).toHaveBeenCalled();
|
||||
expect(onPanelChange.mock.calls[0][0].month()).toEqual(date.month() - 1);
|
||||
expect(onPanelChange).toHaveBeenCalled();
|
||||
expect(onPanelChange.mock.calls[0][0].month()).toEqual(date.month() - 1);
|
||||
});
|
||||
|
||||
it('not trigger when in same month', () => {
|
||||
const onPanelChange = jest.fn();
|
||||
const date = new Moment('1990-09-03');
|
||||
const wrapper = mount(<Calendar onPanelChange={onPanelChange} value={date} />);
|
||||
|
||||
wrapper.find('.ant-picker-cell').at(10).simulate('click');
|
||||
|
||||
expect(onPanelChange).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('switch should work correctly without prop mode', async () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import useMergedState from 'rc-util/lib/hooks/useMergedState';
|
||||
import classNames from 'classnames';
|
||||
import padStart from 'lodash/padStart';
|
||||
import { PickerPanel as RCPickerPanel } from 'rc-picker';
|
||||
@@ -62,13 +63,13 @@ export interface CalendarProps<DateType> {
|
||||
}
|
||||
|
||||
function generateCalendar<DateType>(generateConfig: GenerateConfig<DateType>) {
|
||||
function isSameYear(date1: DateType, date2: DateType) {
|
||||
return date1 && date2 && generateConfig.getYear(date1) === generateConfig.getYear(date2);
|
||||
}
|
||||
|
||||
function isSameMonth(date1: DateType, date2: DateType) {
|
||||
return (
|
||||
date1 === date2 ||
|
||||
(date1 &&
|
||||
date2 &&
|
||||
generateConfig.getYear(date1) === generateConfig.getYear(date2) &&
|
||||
generateConfig.getMonth(date1) === generateConfig.getMonth(date2))
|
||||
isSameYear(date1, date2) && generateConfig.getMonth(date1) === generateConfig.getMonth(date2)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -106,15 +107,15 @@ function generateCalendar<DateType>(generateConfig: GenerateConfig<DateType>) {
|
||||
// ====================== State =======================
|
||||
|
||||
// Value
|
||||
const [innerValue, setInnerValue] = React.useState(
|
||||
() => value || defaultValue || generateConfig.getNow(),
|
||||
);
|
||||
|
||||
const mergedValue = value || innerValue;
|
||||
const [mergedValue, setMergedValue] = useMergedState(() => value || generateConfig.getNow(), {
|
||||
defaultValue,
|
||||
value,
|
||||
});
|
||||
|
||||
// Mode
|
||||
const [innerMode, setInnerMode] = React.useState(() => mode || 'month');
|
||||
const mergedMode = mode || innerMode;
|
||||
const [mergedMode, setMergedMode] = useMergedState('month', {
|
||||
value: mode,
|
||||
});
|
||||
const panelMode = React.useMemo<'month' | 'date'>(
|
||||
() => (mergedMode === 'year' ? 'month' : 'date'),
|
||||
[mergedMode],
|
||||
@@ -142,10 +143,16 @@ function generateCalendar<DateType>(generateConfig: GenerateConfig<DateType>) {
|
||||
};
|
||||
|
||||
const triggerChange = (date: DateType) => {
|
||||
setInnerValue(date);
|
||||
setMergedValue(date);
|
||||
|
||||
if (!isSameDate(date, mergedValue)) {
|
||||
triggerPanelChange(date, mergedMode);
|
||||
// Trigger when month panel switch month
|
||||
if (
|
||||
(panelMode === 'date' && !isSameMonth(date, mergedValue)) ||
|
||||
(panelMode === 'month' && !isSameYear(date, mergedValue))
|
||||
) {
|
||||
triggerPanelChange(date, mergedMode);
|
||||
}
|
||||
|
||||
if (onChange) {
|
||||
onChange(date);
|
||||
@@ -154,7 +161,7 @@ function generateCalendar<DateType>(generateConfig: GenerateConfig<DateType>) {
|
||||
};
|
||||
|
||||
const triggerModeChange = (newMode: CalendarMode) => {
|
||||
setInnerMode(newMode);
|
||||
setMergedMode(newMode);
|
||||
triggerPanelChange(mergedValue, newMode);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import ar_EG from '../../date-picker/locale/ar_EG';
|
||||
import arEG from '../../date-picker/locale/ar_EG';
|
||||
|
||||
export default ar_EG;
|
||||
export default arEG;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import az_AZ from '../../date-picker/locale/az_AZ';
|
||||
import azAZ from '../../date-picker/locale/az_AZ';
|
||||
|
||||
export default az_AZ;
|
||||
export default azAZ;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import bg_BG from '../../date-picker/locale/bg_BG';
|
||||
import bgBG from '../../date-picker/locale/bg_BG';
|
||||
|
||||
export default bg_BG;
|
||||
export default bgBG;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import ca_ES from '../../date-picker/locale/ca_ES';
|
||||
import caES from '../../date-picker/locale/ca_ES';
|
||||
|
||||
export default ca_ES;
|
||||
export default caES;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import cs_CZ from '../../date-picker/locale/cs_CZ';
|
||||
import csCZ from '../../date-picker/locale/cs_CZ';
|
||||
|
||||
export default cs_CZ;
|
||||
export default csCZ;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import da_DK from '../../date-picker/locale/da_DK';
|
||||
import daDK from '../../date-picker/locale/da_DK';
|
||||
|
||||
export default da_DK;
|
||||
export default daDK;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import de_DE from '../../date-picker/locale/de_DE';
|
||||
import deDE from '../../date-picker/locale/de_DE';
|
||||
|
||||
export default de_DE;
|
||||
export default deDE;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import el_GR from '../../date-picker/locale/el_GR';
|
||||
import elGR from '../../date-picker/locale/el_GR';
|
||||
|
||||
export default el_GR;
|
||||
export default elGR;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import en_GB from '../../date-picker/locale/en_GB';
|
||||
import enGB from '../../date-picker/locale/en_GB';
|
||||
|
||||
export default en_GB;
|
||||
export default enGB;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import en_US from '../../date-picker/locale/en_US';
|
||||
import enUS from '../../date-picker/locale/en_US';
|
||||
|
||||
export default en_US;
|
||||
export default enUS;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import es_ES from '../../date-picker/locale/es_ES';
|
||||
import esES from '../../date-picker/locale/es_ES';
|
||||
|
||||
export default es_ES;
|
||||
export default esES;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import et_EE from '../../date-picker/locale/et_EE';
|
||||
import etEE from '../../date-picker/locale/et_EE';
|
||||
|
||||
export default et_EE;
|
||||
export default etEE;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import fa_IR from '../../date-picker/locale/fa_IR';
|
||||
import faIR from '../../date-picker/locale/fa_IR';
|
||||
|
||||
export default fa_IR;
|
||||
export default faIR;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import fi_FI from '../../date-picker/locale/fi_FI';
|
||||
import fiFI from '../../date-picker/locale/fi_FI';
|
||||
|
||||
export default fi_FI;
|
||||
export default fiFI;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import fr_BE from '../../date-picker/locale/fr_BE';
|
||||
import frBE from '../../date-picker/locale/fr_BE';
|
||||
|
||||
export default fr_BE;
|
||||
export default frBE;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import fr_FR from '../../date-picker/locale/fr_FR';
|
||||
import frFR from '../../date-picker/locale/fr_FR';
|
||||
|
||||
export default fr_FR;
|
||||
export default frFR;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import ga_IE from '../../date-picker/locale/ga_IE';
|
||||
import gaIE from '../../date-picker/locale/ga_IE';
|
||||
|
||||
export default ga_IE;
|
||||
export default gaIE;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import he_IL from '../../date-picker/locale/he_IL';
|
||||
import heIL from '../../date-picker/locale/he_IL';
|
||||
|
||||
export default he_IL;
|
||||
export default heIL;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import hi_IN from '../../date-picker/locale/hi_IN';
|
||||
import hiIN from '../../date-picker/locale/hi_IN';
|
||||
|
||||
export default hi_IN;
|
||||
export default hiIN;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import hr_HR from '../../date-picker/locale/hr_HR';
|
||||
import hrHR from '../../date-picker/locale/hr_HR';
|
||||
|
||||
export default hr_HR;
|
||||
export default hrHR;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import hu_HU from '../../date-picker/locale/hu_HU';
|
||||
import huHU from '../../date-picker/locale/hu_HU';
|
||||
|
||||
export default hu_HU;
|
||||
export default huHU;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import id_ID from '../../date-picker/locale/id_ID';
|
||||
import idID from '../../date-picker/locale/id_ID';
|
||||
|
||||
export default id_ID;
|
||||
export default idID;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import is_IS from '../../date-picker/locale/is_IS';
|
||||
import isIS from '../../date-picker/locale/is_IS';
|
||||
|
||||
export default is_IS;
|
||||
export default isIS;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import it_IT from '../../date-picker/locale/it_IT';
|
||||
import itIT from '../../date-picker/locale/it_IT';
|
||||
|
||||
export default it_IT;
|
||||
export default itIT;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import ja_JP from '../../date-picker/locale/ja_JP';
|
||||
import jaJP from '../../date-picker/locale/ja_JP';
|
||||
|
||||
export default ja_JP;
|
||||
export default jaJP;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import kn_IN from '../../date-picker/locale/kn_IN';
|
||||
import knIN from '../../date-picker/locale/kn_IN';
|
||||
|
||||
export default kn_IN;
|
||||
export default knIN;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import ko_KR from '../../date-picker/locale/ko_KR';
|
||||
import koKR from '../../date-picker/locale/ko_KR';
|
||||
|
||||
export default ko_KR;
|
||||
export default koKR;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import ku_IQ from '../../date-picker/locale/ku_IQ';
|
||||
import kuIQ from '../../date-picker/locale/ku_IQ';
|
||||
|
||||
export default ku_IQ;
|
||||
export default kuIQ;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import lv_LV from '../../date-picker/locale/lv_LV';
|
||||
import lvLV from '../../date-picker/locale/lv_LV';
|
||||
|
||||
export default lv_LV;
|
||||
export default lvLV;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import mk_MK from '../../date-picker/locale/mk_MK';
|
||||
import mkMK from '../../date-picker/locale/mk_MK';
|
||||
|
||||
export default mk_MK;
|
||||
export default mkMK;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import mn_MN from '../../date-picker/locale/mn_MN';
|
||||
import mnMN from '../../date-picker/locale/mn_MN';
|
||||
|
||||
export default mn_MN;
|
||||
export default mnMN;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import ms_MY from '../../date-picker/locale/ms_MY';
|
||||
import msMY from '../../date-picker/locale/ms_MY';
|
||||
|
||||
export default ms_MY;
|
||||
export default msMY;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import nb_NO from '../../date-picker/locale/nb_NO';
|
||||
import nbNO from '../../date-picker/locale/nb_NO';
|
||||
|
||||
export default nb_NO;
|
||||
export default nbNO;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import nl_BE from '../../date-picker/locale/nl_BE';
|
||||
import nlBE from '../../date-picker/locale/nl_BE';
|
||||
|
||||
export default nl_BE;
|
||||
export default nlBE;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import nl_NL from '../../date-picker/locale/nl_NL';
|
||||
import nlNL from '../../date-picker/locale/nl_NL';
|
||||
|
||||
export default nl_NL;
|
||||
export default nlNL;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import pl_PL from '../../date-picker/locale/pl_PL';
|
||||
import plPL from '../../date-picker/locale/pl_PL';
|
||||
|
||||
export default pl_PL;
|
||||
export default plPL;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import pt_BR from '../../date-picker/locale/pt_BR';
|
||||
import ptBR from '../../date-picker/locale/pt_BR';
|
||||
|
||||
export default pt_BR;
|
||||
export default ptBR;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import pt_PT from '../../date-picker/locale/pt_PT';
|
||||
import ptPT from '../../date-picker/locale/pt_PT';
|
||||
|
||||
export default pt_PT;
|
||||
export default ptPT;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import ro_RO from '../../date-picker/locale/ro_RO';
|
||||
import roRO from '../../date-picker/locale/ro_RO';
|
||||
|
||||
export default ro_RO;
|
||||
export default roRO;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import ru_RU from '../../date-picker/locale/ru_RU';
|
||||
import ruRU from '../../date-picker/locale/ru_RU';
|
||||
|
||||
export default ru_RU;
|
||||
export default ruRU;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import sk_SK from '../../date-picker/locale/sk_SK';
|
||||
import skSK from '../../date-picker/locale/sk_SK';
|
||||
|
||||
export default sk_SK;
|
||||
export default skSK;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import sl_SI from '../../date-picker/locale/sl_SI';
|
||||
import slSI from '../../date-picker/locale/sl_SI';
|
||||
|
||||
export default sl_SI;
|
||||
export default slSI;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import sr_RS from '../../date-picker/locale/sr_RS';
|
||||
import srRS from '../../date-picker/locale/sr_RS';
|
||||
|
||||
export default sr_RS;
|
||||
export default srRS;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import sv_SE from '../../date-picker/locale/sv_SE';
|
||||
import svSE from '../../date-picker/locale/sv_SE';
|
||||
|
||||
export default sv_SE;
|
||||
export default svSE;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import ta_IN from '../../date-picker/locale/ta_IN';
|
||||
import taIN from '../../date-picker/locale/ta_IN';
|
||||
|
||||
export default ta_IN;
|
||||
export default taIN;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import th_TH from '../../date-picker/locale/th_TH';
|
||||
import thTH from '../../date-picker/locale/th_TH';
|
||||
|
||||
export default th_TH;
|
||||
export default thTH;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import tr_TR from '../../date-picker/locale/tr_TR';
|
||||
import trTR from '../../date-picker/locale/tr_TR';
|
||||
|
||||
export default tr_TR;
|
||||
export default trTR;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import uk_UA from '../../date-picker/locale/uk_UA';
|
||||
import ukUA from '../../date-picker/locale/uk_UA';
|
||||
|
||||
export default uk_UA;
|
||||
export default ukUA;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import vi_VN from '../../date-picker/locale/vi_VN';
|
||||
import viVN from '../../date-picker/locale/vi_VN';
|
||||
|
||||
export default vi_VN;
|
||||
export default viVN;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import zh_CN from '../../date-picker/locale/zh_CN';
|
||||
import zhCN from '../../date-picker/locale/zh_CN';
|
||||
|
||||
export default zh_CN;
|
||||
export default zhCN;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import zh_TW from '../../date-picker/locale/zh_TW';
|
||||
import zhTW from '../../date-picker/locale/zh_TW';
|
||||
|
||||
export default zh_TW;
|
||||
export default zhTW;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`renders ./components/card/demo/basic.md correctly 1`] = `
|
||||
<div>
|
||||
Array [
|
||||
<div
|
||||
class="ant-card ant-card-bordered"
|
||||
style="width:300px"
|
||||
@@ -41,7 +41,7 @@ exports[`renders ./components/card/demo/basic.md correctly 1`] = `
|
||||
Card content
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
<div
|
||||
class="ant-card ant-card-bordered ant-card-small"
|
||||
style="width:300px"
|
||||
@@ -81,8 +81,8 @@ exports[`renders ./components/card/demo/basic.md correctly 1`] = `
|
||||
Card content
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`renders ./components/card/demo/border-less.md correctly 1`] = `
|
||||
@@ -408,7 +408,7 @@ exports[`renders ./components/card/demo/inner.md correctly 1`] = `
|
||||
`;
|
||||
|
||||
exports[`renders ./components/card/demo/loading.md correctly 1`] = `
|
||||
<div>
|
||||
Array [
|
||||
<button
|
||||
aria-checked="false"
|
||||
class="ant-switch"
|
||||
@@ -421,7 +421,7 @@ exports[`renders ./components/card/demo/loading.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-switch-inner"
|
||||
/>
|
||||
</button>
|
||||
</button>,
|
||||
<div
|
||||
class="ant-card ant-card-loading ant-card-bordered"
|
||||
style="width:300px;margin-top:16px"
|
||||
@@ -539,7 +539,7 @@ exports[`renders ./components/card/demo/loading.md correctly 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
<div
|
||||
class="ant-card ant-card-bordered"
|
||||
style="width:300px;margin-top:16px"
|
||||
@@ -655,8 +655,8 @@ exports[`renders ./components/card/demo/loading.md correctly 1`] = `
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`renders ./components/card/demo/meta.md correctly 1`] = `
|
||||
@@ -812,7 +812,7 @@ exports[`renders ./components/card/demo/simple.md correctly 1`] = `
|
||||
`;
|
||||
|
||||
exports[`renders ./components/card/demo/tabs.md correctly 1`] = `
|
||||
<div>
|
||||
Array [
|
||||
<div
|
||||
class="ant-card ant-card-bordered ant-card-contain-tabs"
|
||||
style="width:100%"
|
||||
@@ -928,7 +928,7 @@ exports[`renders ./components/card/demo/tabs.md correctly 1`] = `
|
||||
aria-hidden="true"
|
||||
class="ant-tabs-tabpane"
|
||||
role="tabpanel"
|
||||
style="display:none"
|
||||
style="visibility:hidden;height:0;overflow-y:hidden"
|
||||
tabindex="-1"
|
||||
/>
|
||||
</div>
|
||||
@@ -942,9 +942,9 @@ exports[`renders ./components/card/demo/tabs.md correctly 1`] = `
|
||||
content1
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
</div>,
|
||||
<br />,
|
||||
<br />,
|
||||
<div
|
||||
class="ant-card ant-card-bordered ant-card-contain-tabs"
|
||||
style="width:100%"
|
||||
@@ -1052,12 +1052,13 @@ exports[`renders ./components/card/demo/tabs.md correctly 1`] = `
|
||||
>
|
||||
<div
|
||||
class="ant-tabs-content ant-tabs-content-top"
|
||||
style="margin-left:-100%"
|
||||
>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="ant-tabs-tabpane"
|
||||
role="tabpanel"
|
||||
style="display:none"
|
||||
style="visibility:hidden;height:0;overflow-y:hidden"
|
||||
tabindex="-1"
|
||||
/>
|
||||
<div
|
||||
@@ -1070,7 +1071,7 @@ exports[`renders ./components/card/demo/tabs.md correctly 1`] = `
|
||||
aria-hidden="true"
|
||||
class="ant-tabs-tabpane"
|
||||
role="tabpanel"
|
||||
style="display:none"
|
||||
style="visibility:hidden;height:0;overflow-y:hidden"
|
||||
tabindex="-1"
|
||||
/>
|
||||
</div>
|
||||
@@ -1084,6 +1085,6 @@ exports[`renders ./components/card/demo/tabs.md correctly 1`] = `
|
||||
app content
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
]
|
||||
`;
|
||||
|
||||
@@ -17,7 +17,7 @@ A basic card containing a title, content and an extra corner content. Supports t
|
||||
import { Card } from 'antd';
|
||||
|
||||
ReactDOM.render(
|
||||
<div>
|
||||
<>
|
||||
<Card title="Default size card" extra={<a href="#">More</a>} style={{ width: 300 }}>
|
||||
<p>Card content</p>
|
||||
<p>Card content</p>
|
||||
@@ -28,7 +28,7 @@ ReactDOM.render(
|
||||
<p>Card content</p>
|
||||
<p>Card content</p>
|
||||
</Card>
|
||||
</div>,
|
||||
</>,
|
||||
mountNode,
|
||||
);
|
||||
```
|
||||
|
||||
@@ -30,8 +30,8 @@ ReactDOM.render(
|
||||
|
||||
```css
|
||||
.site-card-border-less-wrapper {
|
||||
background: #ececec;
|
||||
padding: 30px;
|
||||
background: #ececec;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -40,15 +40,13 @@ ReactDOM.render(
|
||||
);
|
||||
```
|
||||
|
||||
```css
|
||||
.site-card-wrapper {
|
||||
background: #ececec;
|
||||
padding: 30px;
|
||||
}
|
||||
```
|
||||
|
||||
<style>
|
||||
[data-theme="dark"] .site-card-wrapper {
|
||||
background: #303030;
|
||||
}
|
||||
.site-card-wrapper {
|
||||
padding: 30px;
|
||||
background: #ececec;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .site-card-wrapper {
|
||||
background: #303030;
|
||||
}
|
||||
</style>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user