From 55b6eef96dd49310a93d22ea241118f54a446edc Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 29 Oct 2017 15:42:01 +0800 Subject: [PATCH] Add screen reponsive className --- package.json | 1 + src/layouts/BasicLayout.js | 275 ++++++++++++++++++++----------------- 2 files changed, 153 insertions(+), 123 deletions(-) diff --git a/package.json b/package.json index faa1a45f..52450c13 100755 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "jest": "^21.0.1", "lint-staged": "^4.3.0", "mockjs": "^1.0.1-beta3", + "react-container-query": "^0.9.1", "react-test-renderer": "^16.0.0", "redbox-react": "^1.3.2", "roadhog": "^1.2.1", diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 6860d19f..dde4c996 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -6,6 +6,8 @@ import { connect } from 'dva'; import { Link, routerRedux, Route, Redirect, Switch } from 'dva/router'; import moment from 'moment'; import groupBy from 'lodash/groupBy'; +import { ContainerQuery } from 'react-container-query'; +import classNames from 'classnames'; import styles from './BasicLayout.less'; import HeaderSearch from '../components/HeaderSearch'; import NoticeIcon from '../components/NoticeIcon'; @@ -16,6 +18,27 @@ import { getRouteData } from '../utils/utils'; const { Header, Sider, Content } = Layout; const { SubMenu } = Menu; +const query = { + 'screen-xs': { + maxWidth: 575, + }, + 'screen-sm': { + minWidth: 576, + maxWidth: 767, + }, + 'screen-md': { + minWidth: 768, + maxWidth: 991, + }, + 'screen-lg': { + minWidth: 992, + maxWidth: 1199, + }, + 'screen-xl': { + minWidth: 1200, + }, +}; + class BasicLayout extends React.PureComponent { static childContextTypes = { location: PropTypes.object, @@ -211,134 +234,140 @@ class BasicLayout extends React.PureComponent { openKeys: this.state.openKeys, }; - return ( - - - + +
+ + logo +

Ant Design Pro

+ +
+ -
- - logo -

Ant Design Pro

- -
- - {this.getNavMenuItems(this.menus)} - - - -
- + + +
+ +
+ { + console.log('input', value); // eslint-disable-line + }} + onPressEnter={(value) => { + console.log('enter', value); // eslint-disable-line + }} /> -
- { - console.log('input', value); // eslint-disable-line - }} - onPressEnter={(value) => { - console.log('enter', value); // eslint-disable-line - }} + { + console.log(item, tabProps); // eslint-disable-line + }} + onClear={this.handleNoticeClear} + onPopupVisibleChange={this.handleNoticeVisibleChange} + loading={fetchingNotices} + popupAlign={{ offset: [20, -16] }} + > + + - { - console.log(item, tabProps); // eslint-disable-line - }} - onClear={this.handleNoticeClear} - onPopupVisibleChange={this.handleNoticeVisibleChange} - loading={fetchingNotices} - popupAlign={{ offset: [20, -16] }} - > - - - - - {currentUser.name ? ( - - - - {currentUser.name} - - - ) : } -
-
- - - { - getRouteData('BasicLayout').map(item => - ( - - ) + + + {currentUser.name ? ( + + + + {currentUser.name} + + + ) : } + +
+ + + { + getRouteData('BasicLayout').map(item => + ( + ) - } - - - - Copyright 2017 蚂蚁金服体验技术部出品 - - } - /> - -
+ ) + } + + + + Copyright 2017 蚂蚁金服体验技术部出品 + + } + /> + + + ); + + return ( + + + {params =>
{layout}
} +
); } -- GitLab