-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(design): Customize ConfigProvider renderEmpty for all components
- Loading branch information
1 parent
2069fa7
commit 8a5b120
Showing
6 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/design/src/config-provider/DefaultRenderEmpty.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { useContext } from 'react'; | ||
import type { ConfigConsumerProps } from '.'; | ||
import { ConfigContext } from '.'; | ||
import Empty from '../empty'; | ||
|
||
interface EmptyProps { | ||
componentName?: string; | ||
} | ||
|
||
/* refer to: https://github.com/ant-design/ant-design/blob/master/components/config-provider/defaultRenderEmpty.tsx */ | ||
const DefaultRenderEmpty: React.FC<EmptyProps> = props => { | ||
const { componentName } = props; | ||
const { getPrefixCls } = useContext<ConfigConsumerProps>(ConfigContext); | ||
const prefix = getPrefixCls('empty'); | ||
switch (componentName) { | ||
case 'Select': | ||
case 'TreeSelect': | ||
case 'Cascader': | ||
case 'Transfer': | ||
case 'Mentions': | ||
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} className={`${prefix}-small`} />; | ||
default: | ||
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />; | ||
} | ||
}; | ||
|
||
export type RenderEmptyHandler = (componentName?: string) => React.ReactNode; | ||
|
||
export default DefaultRenderEmpty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import { Cascader, List, Select, Space, Table, Transfer, TreeSelect } from '@oceanbase/design'; | ||
|
||
const style: React.CSSProperties = { width: 200 }; | ||
|
||
const App: React.FC = () => { | ||
return ( | ||
<Space direction="vertical" style={{ width: '100%' }}> | ||
<h4>Select</h4> | ||
<Select style={style} /> | ||
<h4>TreeSelect</h4> | ||
<TreeSelect style={style} treeData={[]} /> | ||
<h4>Cascader</h4> | ||
<Cascader style={style} options={[]} showSearch /> | ||
<h4>Transfer</h4> | ||
<Transfer /> | ||
<h4>Table</h4> | ||
<Table | ||
style={{ marginTop: 8 }} | ||
columns={[ | ||
{ title: 'Name', dataIndex: 'name', key: 'name' }, | ||
{ title: 'Age', dataIndex: 'age', key: 'age' }, | ||
]} | ||
/> | ||
<h4>List</h4> | ||
<List /> | ||
</Space> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters