From 8ffcbe468a0dc782e10a93aa1aa206af7592f11f Mon Sep 17 00:00:00 2001 From: ycjcl868 <45808948@qq.com> Date: Wed, 18 Dec 2019 18:45:05 +0800 Subject: [PATCH] feat: change theme --- components/style/themes/default.less | 2 -- site/theme/static/common.less | 14 ++++++++++++++ site/theme/template/Content/MainContent.jsx | 17 +++++++++++++++-- site/theme/template/Layout/index.jsx | 20 ++++++++++++++++---- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/components/style/themes/default.less b/components/style/themes/default.less index 7a822d40b5..b84f647d84 100644 --- a/components/style/themes/default.less +++ b/components/style/themes/default.less @@ -767,5 +767,3 @@ // Notification // --- @notification-bg: @component-background; - -@import './dark.less'; diff --git a/site/theme/static/common.less b/site/theme/static/common.less index 089e843bbf..0ed640729d 100644 --- a/site/theme/static/common.less +++ b/site/theme/static/common.less @@ -125,6 +125,10 @@ a { width: 100%; padding: 0; overflow: hidden; + &.page-theme-dark { + @import (inline) '../../../components/style/dark.less'; + @import (less) '../../../dist/antd.dark.css'; + } } .drawer-content { @@ -143,3 +147,13 @@ a { color: #fff !important; } } + +.fixed-widgets { + position: fixed; + z-index: 2147483640; + bottom: 102px; + right: 30px; + & > div { + display: block; + } +} diff --git a/site/theme/template/Content/MainContent.jsx b/site/theme/template/Content/MainContent.jsx index a776eee9da..4e06c85dc2 100644 --- a/site/theme/template/Content/MainContent.jsx +++ b/site/theme/template/Content/MainContent.jsx @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Link } from 'bisheng/router'; -import { Row, Col, Menu, Affix } from 'antd'; +import { Row, Col, Menu, Affix, Button } from 'antd'; import { FormattedMessage, injectIntl } from 'react-intl'; import classNames from 'classnames'; import get from 'lodash/get'; @@ -73,6 +73,8 @@ const getSubMenuTitle = menuItem => { class MainContent extends Component { static contextTypes = { isMobile: PropTypes.bool.isRequired, + theme: PropTypes.oneOf(['default', 'dark']), + setTheme: PropTypes.func, }; state = { @@ -282,8 +284,13 @@ class MainContent extends Component { return this.flattenMenu((menu.props && menu.props.children) || menu.children); } + changeTheme = () => { + const { theme, setTheme } = this.context; + setTheme(theme !== 'dark' ? 'dark' : 'default'); + }; + render() { - const { isMobile } = this.context; + const { isMobile, theme, setTheme } = this.context; const { openKeys } = this.state; const { localizedPageData, demos } = this.props; const activeMenuItem = this.getActiveMenuItem(); @@ -308,6 +315,7 @@ class MainContent extends Component { {menuItems} ); + return (
@@ -330,6 +338,11 @@ class MainContent extends Component {
)} +
+
+ +
+