Layout 页面布局
如果项目中使用的是 1.x 版本的基础组件(@alifd/next),请在左侧导航顶部切换组件版本。
安装方法
- 在命令行中执行以下命令
npm install @icedesign/layout@0.1.7 -S
提供页面框架性的 Layout 以及基础区块布局,除了 Layout.Main
必须以外, 其它的组件在页面中可以按需自由搭配使用。
Layout
import Layout from '@icedesign/layout';
页面布局,一个页面有且只能有一个 Layout
组件。
参数(props)
参数名 | 说明 | 类型 | 默认值 |
---|---|---|---|
fixable | 开启布局模块滚动跟随模式 | boolean | false |
fixable
一旦设置为 true
则整个页面所有模块都固定高度,内容区域不可滚动。子组件通过 scrollable
props 使其可滚动,以此实现主体内容滚动,其余模块 fixed 的效果。
Layout.Section
辅助布局组件,会创建 100% 宽度的一整行。当某一块区域需要两个模块左右排列,则需要使用 Layout.Section
组件包裹。
如:
<Layout.Section>
<Layout.Aside />
<Layout.Main />
</Layout.Section>
参数(props)
参数名 | 说明 | 类型 | 默认值 |
---|---|---|---|
scrollable | 区域可滚动 (<Layout fixable={true} /> 下可用) | boolean | false |
Layout.Header
顶部布局,默认内部元素居中对其。
参数(props)
参数名 | 说明 | 类型 | 默认值 |
---|---|---|---|
alignItems | 内部元素垂直对其方式 | string | center |
theme | 配置 Header 皮肤色 | string | - |
alignItems:
flex-start
flex-end
center
baseline
stretch
theme:
dark, light
Layout.Aside
侧边栏,根据嵌套顺序,可左右布局。
参数(props)
参数名 | 说明 | 类型 | 默认值 |
---|---|---|---|
width | 展开状态下的宽度 | number/string | 200 |
theme | 配置 Aside 皮肤色 | string | - |
- theme:
dark, light
Layout.Main
参数(props)
参数名 | 说明 | 类型 | 默认值 |
---|---|---|---|
scrollable | 区域可滚动 (<Layout fixable={true} /> 下可用) | boolean | false |
主体内容。
Layout.Footer
页脚布局。
代码示例
基础组件 Header
Main
Footer
,默认宽度都是 100%。当需要侧边栏 Aside
组件,需要使用辅助布局组件 Section
包裹起来。
通过各组件的先后顺序实现多样性布局。
查看源码在线预览
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Layout from '@icedesign/layout';
class App extends Component {
render() {
return (
<div>
<Layout>
<Layout.Header> header</Layout.Header>
<Layout.Main>Main</Layout.Main>
<Layout.Footer>Footer</Layout.Footer>
</Layout>
<Layout>
<Layout.Header> header</Layout.Header>
<Layout.Section>
<Layout.Aside>Aside</Layout.Aside>
<Layout.Main>Main</Layout.Main>
</Layout.Section>
<Layout.Footer>Footer</Layout.Footer>
</Layout>
<Layout>
<Layout.Header> header</Layout.Header>
<Layout.Section style={{ padding: '20px 40px' }}>
<Layout.Aside>Aside</Layout.Aside>
<Layout.Main>Main</Layout.Main>
</Layout.Section>
<Layout.Footer>Footer</Layout.Footer>
</Layout>
<Layout>
<Layout.Header> header</Layout.Header>
<Layout.Section>
<Layout.Aside>Aside</Layout.Aside>
<Layout.Main>Main</Layout.Main>
<Layout.Aside>Aside</Layout.Aside>
</Layout.Section>
<Layout.Footer>Footer</Layout.Footer>
</Layout>
<Layout>
<Layout.Aside>Aside</Layout.Aside>
<Layout.Section>
<Layout.Header> header</Layout.Header>
<Layout.Main>Main</Layout.Main>
<Layout.Footer>Footer</Layout.Footer>
</Layout.Section>
</Layout>
</div>
);
}
}
ReactDOM.render(<App />, mountNode);
.ice-layout {
color: #fff;
text-align: center;
margin-bottom: 50px;
background-color: #eee;
}
.ice-layout-header {
line-height: 50px;
background-color: rgba(27, 115, 225, 0.5) !important;;
}
.ice-layout-aside {
line-height: 120px;
background-color: rgba(27, 115, 225, 0.7) !important;;
}
.ice-layout-main {
line-height: 120px;
background-color: rgba(27, 115, 225, 1);
}
.ice-layout-footer {
line-height: 50px;
background-color: rgba(27, 115, 225, 0.5);
}
Aside Header Footer 固定位置布局。
查看源码在线预览
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Layout from '@icedesign/layout';
class App extends Component {
render() {
return (
<Layout fixable={true}>
<Layout.Aside>
<br />
Aside
</Layout.Aside>
<Layout.Section scrollable={true}>
<Layout.Header> Header</Layout.Header>
<Layout.Main>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
</Layout.Main>
<Layout.Footer>Footer</Layout.Footer>
</Layout.Section>
</Layout>
);
}
}
ReactDOM.render(<App />, mountNode);
.ice-layout {
color: #fff;
text-align: center;
background-color: #eee;
}
.ice-layout-header {
line-height: 50px;
background-color: #84B0E7 !important;;
}
.ice-layout-aside {
background-color: rgba(27, 115, 225, 0.7) !important;;
}
.ice-layout-main {
line-height: 120px;
background-color: rgba(27, 115, 225, 1);
}
.ice-layout-footer {
line-height: 50px;
background-color: #84B0E7;
}
Aside Header 固定位置布局。
将 Footer 放在 Main 里一同滚动。
查看源码在线预览
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Layout from '@icedesign/layout';
class App extends Component {
render() {
return (
<Layout fixable={true}>
<Layout.Aside>
<br />
Aside
</Layout.Aside>
<Layout.Section>
<Layout.Header> Header</Layout.Header>
<Layout.Main scrollable={true}>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<Layout.Footer>Footer</Layout.Footer>
</Layout.Main>
</Layout.Section>
</Layout>
);
}
}
ReactDOM.render(<App />, mountNode);
.ice-layout {
color: #fff;
text-align: center;
background-color: #eee;
}
.ice-layout-header {
line-height: 50px;
background-color: #84B0E7 !important;;
}
.ice-layout-aside {
background-color: rgba(27, 115, 225, 0.7) !important;;
}
.ice-layout-main {
line-height: 120px;
background-color: rgba(27, 115, 225, 1);
}
.ice-layout-footer {
line-height: 50px;
background-color: #84B0E7;
}
Header Aside Footer 固定位置布局。
查看源码在线预览
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Layout from '@icedesign/layout';
class App extends Component {
render() {
return (
<Layout fixable={true}>
<Layout.Header> Header</Layout.Header>
<Layout.Section scrollable={true}>
<Layout.Aside>
<br />
Aside
</Layout.Aside>
<Layout.Main>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动 end</p>
<Layout.Footer>Footer</Layout.Footer>
</Layout.Main>
</Layout.Section>
</Layout>
);
}
}
ReactDOM.render(<App />, mountNode);
.ice-layout {
color: #fff;
text-align: center;
background-color: #eee;
}
.ice-layout-header {
line-height: 50px;
background-color: #84B0E7 !important;;
}
.ice-layout-aside {
background-color: rgba(27, 115, 225, 0.7) !important;;
}
.ice-layout-main {
line-height: 120px;
background-color: rgba(27, 115, 225, 1);
}
.ice-layout-footer {
line-height: 50px;
background-color: #84B0E7;
}
Header Aside 固定位置布局。
将 Footer 放在 Main 里一同滚动。
查看源码在线预览
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Layout from '@icedesign/layout';
class App extends Component {
render() {
return (
<Layout fixable={true}>
<Layout.Header> Header</Layout.Header>
<Layout.Section>
<Layout.Aside scrollable={true}>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
</Layout.Aside>
<Layout.Main scrollable={true}>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动</p>
<p style={{ height: 200 }}>内容可滚动 end</p>
<Layout.Footer>Footer</Layout.Footer>
</Layout.Main>
</Layout.Section>
</Layout>
);
}
}
ReactDOM.render(<App />, mountNode);
.ice-layout {
color: #fff;
text-align: center;
background-color: #eee;
}
.ice-layout-header {
line-height: 50px;
background-color: #84B0E7 !important;
}
.ice-layout-aside {
background-color: rgba(27, 115, 225, 0.7) !important;;
}
.ice-layout-main {
line-height: 120px;
background-color: rgba(27, 115, 225, 1);
}
.ice-layout-footer {
line-height: 50px;
background-color: #84B0E7;
}
查看源码在线预览
import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import Layout from '@icedesign/layout';
import { Breadcrumb, Icon, Button, Dropdown, Select } from '@icedesign/base';
import Img from '@icedesign/img';
import StyledMenu, {
SubMenu,
ItemGroup as MenuItemGroup,
Item as MenuItem
} from '@icedesign/styled-menu';
class App extends Component {
state = {
current: 'setting:1',
mode: 'inline',
headerTheme: 'light',
headerColor: '',
asideTheme: 'dark',
asideColor: '',
};
handleClick = e => {
this.setState({
current: e.key
});
};
headerThemeChange = value => {
this.setState({ headerTheme: value });
};
headerColorChange = value => {
this.setState({ headerColor: value });
};
asideThemeChange = value => {
this.setState({ asideTheme: value });
};
asideColorChange = value => {
this.setState({ asideColor: value });
};
render() {
return (
<Layout style={{ minHeight: '100vh' }}>
<Layout.Aside theme={this.state.asideTheme} color={this.state.asideColor}>
<Logo {...getDefaultFontColor(this.state.asideTheme)} />
<StyledMenu theme={this.state.asideTheme} color={this.state.asideColor} mode={this.state.mode}>
<SubMenu
key="sub1"
title={
<span>
<Icon size="xs" type="similar-product" /><span>侧边菜单一</span>
</span>
}
>
<MenuItemGroup title="Item 1">
<MenuItem key="1">子菜单一</MenuItem>
<MenuItem key="2">子菜单二</MenuItem>
</MenuItemGroup>
<MenuItemGroup title="Iteom 2">
<MenuItem key="3">子菜单三</MenuItem>
<MenuItem key="4">子菜单四</MenuItem>
</MenuItemGroup>
</SubMenu>
<SubMenu
key="sub2"
title={
<span>
<Icon size="xs" type="bags" /><span>侧边菜单二</span>
</span>
}
>
<MenuItem key="5">子菜单一</MenuItem>
<MenuItem key="6">子菜单二</MenuItem>
<SubMenu key="sub3" title="Submenu">
<MenuItem key="7">子菜单三</MenuItem>
<MenuItem key="8">子菜单四</MenuItem>
</SubMenu>
</SubMenu>
<SubMenu
key="sub4"
title={
<span>
<Icon size="xs" type="history" /><span>侧边菜单三</span>
</span>
}
>
<MenuItem key="9">子菜单一</MenuItem>
<MenuItem key="10">子菜单二</MenuItem>
<MenuItem key="11">子菜单三</MenuItem>
<MenuItem key="12">子菜单四</MenuItem>
</SubMenu>
</StyledMenu>
</Layout.Aside>
<Layout.Section>
<Layout.Header
theme={this.state.headerTheme}
color={this.state.headerColor}
style={{
height: '56px',
padding: '0 24px 0 0',
justifyContent: 'space-between'
}}
>
<StyledMenu
theme={this.state.headerTheme}
color={this.state.headerColor}
onClick={this.handleClick}
selectedKeys={[this.state.current]}
mode="horizontal"
>
<MenuItem key="mail">
<Icon type="service" />首页
</MenuItem>
<MenuItem key="app" disabled>
<Icon type="training" />分类
</MenuItem>
<SubMenu key="favorite" title={<span><Icon type="favorite" />收藏</span>}>
<MenuItemGroup title="购买清单">
<MenuItem key="setting:1">家电</MenuItem>
<MenuItem key="setting:2">床品</MenuItem>
</MenuItemGroup>
<MenuItemGroup title="心愿单">
<MenuItem key="setting:3">童装</MenuItem>
<MenuItem key="setting:4">女装</MenuItem>
</MenuItemGroup>
</SubMenu>
<MenuItem key="ice">
<a
href="http://ice.alibaba-inc.com/"
target="_blank"
rel="noopener noreferrer"
>
ICE 官网
</a>
</MenuItem>
</StyledMenu>
<div className="ice-layout-header-right" {...getDefaultFontColor(this.state.headerTheme)}>
<span style={{ paddingRight: 12 }}>
下午好,内容管理后台。
</span>
<UserPanel
offset={[0, 11]}
size={36}
shape="circle"
userName="Jack Ma"
avatar="//img.alicdn.com/tfs/TB1JLbBQXXXXXcUapXXXXXXXXXX-215-185.png"
>
<div>
<StyledMenu
style={{
minWidth: 120,
boxShadow: '0 0 2px #ccc'
}}
>
<MenuItem>
<a href="/">信息中心</a>
</MenuItem>
<MenuItem>
<a href="/">设置</a>
</MenuItem>
<MenuItem>
<a href="/">退出</a>
</MenuItem>
</StyledMenu>
</div>
</UserPanel>
</div>
</Layout.Header>
<Breadcrumb style={{ margin: '12px 24px' }}>
<Breadcrumb.Item link="javascript:void(0);">
首页
</Breadcrumb.Item>
<Breadcrumb.Item link="javascript:void(0);">
分类
</Breadcrumb.Item>
<Breadcrumb.Item link="javascript:void(0);">
收藏
</Breadcrumb.Item>
</Breadcrumb>
<Layout.Main
style={{
padding: 20,
margin: '0 24px',
backgroundColor: '#fff'
}}
>
<table>
<thead>
<tr>
<td colSpan="4">
<p>
通过配置 Layout.Header、Layout.Aside 以及 IceMenu 的 theme 和 color props 实现组合配色
</p>
<p>
为了达到视觉美观,推荐 Layout.Header、Layout.Aside 与内部 IceMenu 使用统一的配色配置。
</p>
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
</thead>
<tbody style={{ color: '#999' }}>
<tr>
<td>切换 Header theme:</td>
<td>
<Select
style={{width: 200}}
onChange={this.headerThemeChange}
defaultValue={this.state.headerTheme}
>
<Select.Option value="dark">
dark
</Select.Option>
<Select.Option value="light">
light
</Select.Option>
</Select>
</td>
</tr>
<tr>
<td>
切换 Aside theme:
</td>
<td>
<Select
style={{width: 200}}
onChange={this.asideThemeChange}
defaultValue={this.state.asideTheme}
>
<Select.Option value="dark">
dark
</Select.Option>
<Select.Option value="light">
light
</Select.Option>
</Select>
</td>
</tr>
</tbody>
</table>
{this.props.children}
</Layout.Main>
<Layout.Footer
style={{
textAlign: 'center',
lineHeight: '36px'
}}
>
<p style={{ color: '#999' }}>
© 2017-2018 xxxx团队 版权所有 系统维护者:@xx 如有问题随时联系!
<br />
由 <a href="//ice.alibaba-inc.com" target="_blank"> ICE </a> 提供技术支持
</p>
</Layout.Footer>
</Layout.Section>
</Layout>
);
}
}
// 项目内敛 Logo 组件
class Logo extends Component {
render() {
return (
<div
className="logo"
style={{
overflow: 'hidden',
height: 60,
color: '#f40',
textAlign: 'center',
...this.props.style
}}
>
<a href="/">
<div
style={{
height: 60,
lineHeight: '60px',
fontSize: 20,
...this.props.style
}}
>
Your Logo
</div>
</a>
</div>
);
}
}
// 项目内敛 用户面板 组件
class UserPanel extends Component {
static displayName = 'UserPanel';
static propTypes = {};
static defaultProps = {
size: 50,
shape: 'sharp',
type: 'cover',
avatar: ''
};
constructor(props) {
super(props);
this.state = {
dropdownVisible: false
};
}
handleDropChange = value => {
this.setState({
dropdownVisible: value
});
};
render() {
const {
offset,
size,
shape,
type,
avatar,
style,
children,
className = ''
} = this.props;
const hasChildren = React.Children.count(children) > 0;
const trigger = (
<div
className={`ice-user-panel ${className}`}
style={{
...style,
overflow: 'hidden',
cursor: hasChildren ? 'pointer' : 'default'
}}
>
<div className="avatar" style={{ float: 'left' }}>
<Img
height={size}
width={size}
type={type}
shape={shape}
src={avatar}
/>
</div>
<div
className="user-name"
style={{
float: 'left',
height: size,
lineHeight: `${size}px`
}}
>
<span style={{ padding: '10px' }}>
{this.props.userName}
</span>
<Icon
type={this.state.dropdownVisible ? 'arrow-up' : 'arrow-down'}
size="xxs"
/>
</div>
</div>
);
if (hasChildren) {
return (
<Dropdown
offset={offset}
align="tr br"
trigger={trigger}
onVisibleChange={this.handleDropChange}
>
{this.props.children}
</Dropdown>
);
} else {
return trigger;
}
}
}
function getDefaultFontColor(theme) {
let result = {
style: {
color: '#fff',
}
};
if (theme.indexOf('light') > -1) {
result = {
style: {
color: '#000',
}
};
}
return result;
}
ReactDOM.render(<App />, mountNode);
查看源码在线预览
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Layout from '@icedesign/layout';
import { Breadcrumb, Icon } from '@icedesign/base';
import Img from '@icedesign/img';
import StyledMenu, {
SubMenu,
ItemGroup as MenuItemGroup,
Item as MenuItem
} from '@icedesign/styled-menu';
class App extends Component {
state = {
current: 'mail'
};
handleNavClick = e => {
this.setState({
current: e.key
});
};
render() {
return (
<Layout style={{ minHeight: '100vh' }}>
<Layout.Header style={{ padding: '12px 50px' }} theme="dark">
<Logo />
<StyledMenu
theme="dark"
onClick={this.handleNavClick}
selectedKeys={[this.state.current]}
mode="horizontal"
>
<MenuItem key="mail">
<Icon type="service" />首页
</MenuItem>
<MenuItem key="app" disabled>
<Icon type="training" />分类
</MenuItem>
<SubMenu title={<span><Icon type="favorite" />收藏</span>}>
<MenuItemGroup title="购买清单">
<MenuItem key="setting:1">家电</MenuItem>
<MenuItem key="setting:2">床品</MenuItem>
</MenuItemGroup>
<MenuItemGroup title="心愿单">
<MenuItem key="setting:3">童装</MenuItem>
<MenuItem key="setting:4">女装</MenuItem>
</MenuItemGroup>
</SubMenu>
<MenuItem key="ice">
<a
href="http://ice.alibaba-inc.com/"
target="_blank"
rel="noopener noreferrer"
>
ICE 官网
</a>
</MenuItem>
</StyledMenu>
</Layout.Header>
<Layout.Section style={{ padding: '0 50px' }}>
<Breadcrumb style={{ margin: '12px 0' }}>
<Breadcrumb.Item link="javascript:void(0);">
首页
</Breadcrumb.Item>
<Breadcrumb.Item link="javascript:void(0);">
分类
</Breadcrumb.Item>
<Breadcrumb.Item link="javascript:void(0);">
收藏
</Breadcrumb.Item>
</Breadcrumb>
<Layout.Section style={{ background: '#fff', minHeight: 280 }}>
<Layout.Aside theme="light">
<StyledMenu
mode="inline"
defaultSelectedKeys={['1']}
defaultOpenKeys={['sub1']}
>
<SubMenu
key="sub1"
title={
<span>
<Icon type="mail" />
<span>侧边菜单一</span>
</span>
}
>
<MenuItemGroup title="Item 1">
<MenuItem key="1">子菜单一</MenuItem>
<MenuItem key="2">子菜单二</MenuItem>
</MenuItemGroup>
<MenuItemGroup title="Iteom 2">
<MenuItem key="3">子菜单三</MenuItem>
<MenuItem key="4">子菜单四</MenuItem>
</MenuItemGroup>
</SubMenu>
<SubMenu
key="sub2"
title={
<span>
<Icon type="appstore" />
<span>侧边菜单二</span>
</span>
}
>
<MenuItem key="5">子菜单一</MenuItem>
<MenuItem key="6">子菜单二</MenuItem>
<SubMenu key="sub3" title="Submenu">
<MenuItem key="7">子菜单三</MenuItem>
<MenuItem key="8">子菜单四</MenuItem>
</SubMenu>
</SubMenu>
<SubMenu
key="sub4"
title={
<span>
<icon type="setting" />
<span>侧边菜单三</span>
</span>
}
>
<MenuItem key="9">子菜单一</MenuItem>
<MenuItem key="10">子菜单二</MenuItem>
<MenuItem key="11">子菜单三</MenuItem>
<MenuItem key="12">子菜单四</MenuItem>
</SubMenu>
</StyledMenu>
</Layout.Aside>
<Layout.Main style={{ padding: 24 }}>
Main
</Layout.Main>
</Layout.Section>
</Layout.Section>
<Layout.Footer
style={{
textAlign: 'center',
lineHeight: '36px'
}}
>
<p style={{ color: '#999' }}>
© 2017-2018 xxxx团队 版权所有 系统维护者:@xx 如有问题随时联系!
<br />
由
{' '}
<a href="//ice.alibaba-inc.com" target="_blank">ICE</a>
{' '}
提供技术支持
</p>
</Layout.Footer>
</Layout>
);
}
}
class Logo extends Component {
render() {
return (
<div
className="logo"
style={{
overflow: 'hidden',
height: 35,
margin: 10,
color: '#f40',
textAlign: 'left',
minWidth: 200
}}
>
<a href="/">
<Img
style={{ display: 'inline-block' }}
height={35}
width={129}
src="https://img.alicdn.com/tps/TB1k.vjNpXXXXc6XXXXXXXXXXXX-258-70.png"
type="contain"
/>
</a>
</div>
);
}
}
ReactDOM.render(<App />, mountNode);
查看源码在线预览
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import Layout from '@icedesign/layout';
import { Breadcrumb, Icon } from '@icedesign/base';
import Img from '@icedesign/img';
import StyledMenu, {
SubMenu,
ItemGroup as MenuItemGroup,
Item as MenuItem
} from '@icedesign/styled-menu';
class App extends Component {
state = {
current: 'mail'
};
handleClick = e => {
console.log('click ', e);
this.setState({
current: e.key
});
};
render() {
return (
<Layout>
<Layout.Header style={{ padding: '12px 50px' }} theme="dark">
<Logo />
<StyledMenu
theme="dark"
onClick={this.handleClick}
selectedKeys={[this.state.current]}
mode="horizontal"
>
<MenuItem key="mail">
<Icon type="service" />首页
</MenuItem>
<MenuItem key="app" disabled>
<Icon type="training" />分类
</MenuItem>
<SubMenu title={<span><Icon type="favorite" />收藏</span>}>
<MenuItemGroup title="购买清单">
<MenuItem key="setting:1">家电</MenuItem>
<MenuItem key="setting:2">床品</MenuItem>
</MenuItemGroup>
<MenuItemGroup title="心愿单">
<MenuItem key="setting:3">童装</MenuItem>
<MenuItem key="setting:4">女装</MenuItem>
</MenuItemGroup>
</SubMenu>
<MenuItem key="ice">
<a
href="http://ice.alibaba-inc.com/"
target="_blank"
rel="noopener noreferrer"
>
ICE 官网
</a>
</MenuItem>
</StyledMenu>
</Layout.Header>
<Layout.Section style={{ padding: '0 50px' }}>
<Breadcrumb style={{ margin: '12px 0' }}>
<Breadcrumb.Item link="javascript:void(0);">
首页
</Breadcrumb.Item>
<Breadcrumb.Item link="javascript:void(0);">
分类
</Breadcrumb.Item>
<Breadcrumb.Item link="javascript:void(0);">
收藏
</Breadcrumb.Item>
</Breadcrumb>
<Layout.Main
style={{
background: '#fff',
padding: 24,
minHeight: 280
}}
>
Main
</Layout.Main>
</Layout.Section>
<Layout.Footer
style={{
textAlign: 'center',
lineHeight: '36px'
}}
>
<p style={{ color: '#999' }}>
© 2017-2018 xxxx团队 版权所有 系统维护者:@xx 如有问题随时联系!
<br />
由
{' '}
<a href="//ice.alibaba-inc.com" target="_blank">ICE</a>
{' '}
提供技术支持
</p>
</Layout.Footer>
</Layout>
);
}
}
class Logo extends Component {
render() {
return (
<div
className="logo"
style={{
overflow: 'hidden',
height: 35,
margin: 10,
color: '#f40',
textAlign: 'left',
minWidth: 200
}}
>
<a href="/">
<Img
style={{ display: 'inline-block' }}
height={35}
width={129}
src="https://img.alicdn.com/tps/TB1k.vjNpXXXXc6XXXXXXXXXXXX-258-70.png"
type="contain"
/>
</a>
</div>
);
}
}
ReactDOM.render(<App />, mountNode);