forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: layout token (ant-design#44174)
* feat: layout token * feat: layout component token
- Loading branch information
Showing
10 changed files
with
1,535 additions
and
68 deletions.
There are no files selected for viewing
959 changes: 959 additions & 0 deletions
959
components/layout/__tests__/__snapshots__/demo-extend.test.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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,7 @@ | ||
## zh-CN | ||
|
||
组件 Token | ||
|
||
## en-US | ||
|
||
Component Token |
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,86 @@ | ||
import React from 'react'; | ||
import { LaptopOutlined, NotificationOutlined, UserOutlined } from '@ant-design/icons'; | ||
import type { MenuProps } from 'antd'; | ||
import { Breadcrumb, ConfigProvider, Layout, Menu, theme } from 'antd'; | ||
|
||
const { Header, Content, Sider } = Layout; | ||
|
||
const items2: MenuProps['items'] = [UserOutlined, LaptopOutlined, NotificationOutlined].map( | ||
(icon, index) => { | ||
const key = String(index + 1); | ||
|
||
return { | ||
key: `sub${key}`, | ||
icon: React.createElement(icon), | ||
label: `subnav ${key}`, | ||
|
||
children: new Array(4).fill(null).map((_, j) => { | ||
const subKey = index * 4 + j + 1; | ||
return { | ||
key: subKey, | ||
label: `option${subKey}`, | ||
}; | ||
}), | ||
}; | ||
}, | ||
); | ||
|
||
const App: React.FC = () => { | ||
const { | ||
token: { colorBgContainer }, | ||
} = theme.useToken(); | ||
|
||
return ( | ||
<ConfigProvider | ||
theme={{ | ||
components: { | ||
Layout: { | ||
bodyBg: '#fff', | ||
headerBg: '#1677ff', | ||
headerHeight: 64, | ||
headerPadding: `0 24px`, | ||
headerColor: '#fff', | ||
siderBg: '#fff', | ||
}, | ||
}, | ||
}} | ||
> | ||
<Layout> | ||
<Header style={{ display: 'flex', alignItems: 'center' }}> | ||
<div className="demo-logo" /> | ||
<div style={{ marginLeft: 24, fontSize: 24 }}>Ant Design</div> | ||
</Header> | ||
<Layout> | ||
<Sider width={200} style={{ background: colorBgContainer }}> | ||
<Menu | ||
mode="inline" | ||
defaultSelectedKeys={['1']} | ||
defaultOpenKeys={['sub1']} | ||
style={{ height: '100%', borderRight: 0 }} | ||
items={items2} | ||
/> | ||
</Sider> | ||
<Layout style={{ padding: '0 24px 24px' }}> | ||
<Breadcrumb style={{ margin: '16px 0' }}> | ||
<Breadcrumb.Item>Home</Breadcrumb.Item> | ||
<Breadcrumb.Item>List</Breadcrumb.Item> | ||
<Breadcrumb.Item>App</Breadcrumb.Item> | ||
</Breadcrumb> | ||
<Content | ||
style={{ | ||
padding: 24, | ||
margin: 0, | ||
minHeight: 280, | ||
background: colorBgContainer, | ||
}} | ||
> | ||
Content | ||
</Content> | ||
</Layout> | ||
</Layout> | ||
</Layout> | ||
</ConfigProvider> | ||
); | ||
}; | ||
|
||
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
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
Oops, something went wrong.