diff --git a/.eslintrc b/.eslintrc index 1d38d6cd..9dd1c002 100644 --- a/.eslintrc +++ b/.eslintrc @@ -74,6 +74,10 @@ [ "asset", "./src/asset" + ], + [ + "styles", + "./src/styles" ] ], "extensions": [ @@ -134,6 +138,7 @@ "t": true, "globals": true, "request": true, - "METRICDICT": true + "METRICDICT": true, + "globalCSS": true } -} \ No newline at end of file +} diff --git a/.stylelintrc.json b/.stylelintrc.json index 272b50ba..e827d7d0 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -10,6 +10,12 @@ "rules": { "no-descending-specificity": null, "at-rule-no-unknown": null, - "color-function-notation": "legacy" + "color-function-notation": "legacy", + "property-no-unknown": [ + true, + { + "ignoreProperties": ["/Color$/"] + } + ] } } diff --git a/src/components/Cards/NotFound/index.less b/src/components/Cards/NotFound/index.less index 27097108..37638739 100644 --- a/src/components/Cards/NotFound/index.less +++ b/src/components/Cards/NotFound/index.less @@ -18,7 +18,7 @@ vertical-align: top; :global .h1 { - color: #abb4be; + color: @light-color08; font-size: 120px; line-height: 1.4; text-align: left; diff --git a/src/components/DetailCard/index.less b/src/components/DetailCard/index.less index c96f7198..106a0416 100644 --- a/src/components/DetailCard/index.less +++ b/src/components/DetailCard/index.less @@ -8,11 +8,6 @@ @resource-box-bg: #fbfdff; @resource-box-border: 1px solid #cfe1ff; -@success: #57e39b; -@warning: #fedf40; -@error: #eb354d; -@link: #0068ff; - .card { flex: 1; margin-bottom: @mid-space; diff --git a/src/components/Form/index.less b/src/components/Form/index.less index 47cc91eb..49b49a90 100644 --- a/src/components/Form/index.less +++ b/src/components/Form/index.less @@ -100,7 +100,7 @@ .tips-icon { margin-top: 2px; margin-right: 4px; - color: #0068ff; + color: @primary-color; } .footer-left { diff --git a/src/components/FormItem/Upload/index.jsx b/src/components/FormItem/Upload/index.jsx index 7ae6359f..9d4761c3 100644 --- a/src/components/FormItem/Upload/index.jsx +++ b/src/components/FormItem/Upload/index.jsx @@ -28,8 +28,8 @@ export default class index extends Component { get progress() { return { strokeColor: { - '0%': '#108ee9', - '100%': '#87d068', + '0%': globalCSS.primaryColor, + '100%': globalCSS.successColor, }, strokeWidth: 3, format: (percent) => `${parseFloat(percent.toFixed(2))}%`, diff --git a/src/components/Layout/GlobalHeader/Token.jsx b/src/components/Layout/GlobalHeader/Token.jsx index 1325c16f..79f1d2ff 100644 --- a/src/components/Layout/GlobalHeader/Token.jsx +++ b/src/components/Layout/GlobalHeader/Token.jsx @@ -82,7 +82,7 @@ export class Token extends ModalAction { const now = Date.now(); if (now > this.keystoneTokenExp) { return ( - + {t('Keystone token is expired.')} ); diff --git a/src/components/Loading/index.jsx b/src/components/Loading/index.jsx index c126d457..35e7158a 100644 --- a/src/components/Loading/index.jsx +++ b/src/components/Loading/index.jsx @@ -28,7 +28,7 @@ const Loading = ({ pastDelay, timedOut, error }) => { >

Loading...

diff --git a/src/components/Notify/index.jsx b/src/components/Notify/index.jsx index 3f90e218..c2535038 100644 --- a/src/components/Notify/index.jsx +++ b/src/components/Notify/index.jsx @@ -42,19 +42,19 @@ const open = (args) => { let icon = null; if (type === 'info') { - iconColor = '#0068FF'; + iconColor = globalCSS.primaryColor; icon = ; } else if (type === 'success') { - iconColor = '#57E39B'; + iconColor = globalCSS.successColor; icon = ; } else if (type === 'error') { - iconColor = '#EB354D'; + iconColor = globalCSS.errorColor; icon = ; } else if (type === 'process') { - iconColor = '#0068FF'; + iconColor = globalCSS.primaryColor; icon = ; } else if (type === 'warn') { - iconColor = '#FEDF40'; + iconColor = globalCSS.warnColor; icon = ; } diff --git a/src/components/Progress/index.jsx b/src/components/Progress/index.jsx index 4998ba70..5e1e965f 100644 --- a/src/components/Progress/index.jsx +++ b/src/components/Progress/index.jsx @@ -30,9 +30,9 @@ export default class index extends Component { static defaultProps = { wanValue: 70, dangerValue: 90, - infoColor: 'rgba(0, 104, 255, 0.65)', - warnColor: 'rgba(254, 223, 64, 0.65)', - dangerColor: 'rgba(235, 53, 77, 0.65)', + infoColor: globalCSS.primaryColor, + warnColor: globalCSS.warnDarkColor, + dangerColor: globalCSS.dangerColor, label: '', }; diff --git a/src/components/ProjectProgress/index.jsx b/src/components/ProjectProgress/index.jsx index 84e1c211..319feb60 100644 --- a/src/components/ProjectProgress/index.jsx +++ b/src/components/ProjectProgress/index.jsx @@ -30,9 +30,9 @@ export default class index extends Component { static defaultProps = { wanValue: 70, dangerValue: 90, - infoColor: 'rgba(0, 104, 255, 0.65)', - warnColor: 'rgba(254, 223, 64, 0.65)', - dangerColor: 'rgba(235, 53, 77, 0.65)', + infoColor: globalCSS.primaryColor, + warnColor: globalCSS.warnDarkColor, + dangerColor: globalCSS.dangerColor, label: '', }; diff --git a/src/components/QuotaChart/Ring.jsx b/src/components/QuotaChart/Ring.jsx index ac3ccf6e..f83b5b7f 100644 --- a/src/components/QuotaChart/Ring.jsx +++ b/src/components/QuotaChart/Ring.jsx @@ -25,11 +25,11 @@ import { import { Tooltip as AntTooltip } from 'antd'; export const typeColors = { - used: '#5B8FF9', + used: globalCSS.primaryColor, reserved: '#5D7092', - add: '#5AD8A6', + add: globalCSS.successColor, left: '#eee', - danger: '#E8684A', + danger: globalCSS.warnDarkColor, }; export const getAddValueColor = (percent) => { diff --git a/src/components/Tables/Base/index.jsx b/src/components/Tables/Base/index.jsx index b723ef29..f92da191 100644 --- a/src/components/Tables/Base/index.jsx +++ b/src/components/Tables/Base/index.jsx @@ -337,7 +337,7 @@ export class BaseTable extends React.Component { } return (value) => { const valueStr = isString(value) ? value : (value || 0).toFixed(2); - return {valueStr}; + return {valueStr}; }; }; diff --git a/src/components/Tables/SimpleTable/index.jsx b/src/components/Tables/SimpleTable/index.jsx index 360e3319..36fd6be9 100644 --- a/src/components/Tables/SimpleTable/index.jsx +++ b/src/components/Tables/SimpleTable/index.jsx @@ -171,7 +171,7 @@ export default class SimpleTable extends React.Component { } return (value) => { const valueStr = isString(value) ? value : (value || 0).toFixed(2); - return {valueStr}; + return {valueStr}; }; }; diff --git a/src/containers/List/index.less b/src/containers/List/index.less index f27ea2e7..e58bbcb2 100644 --- a/src/containers/List/index.less +++ b/src/containers/List/index.less @@ -17,7 +17,7 @@ border: 1px solid #ffe58f; .ant-alert-icon { - color: #faad14; + color: @warn-color; } } } diff --git a/src/core/index.jsx b/src/core/index.jsx index 02b50815..429a53e3 100644 --- a/src/core/index.jsx +++ b/src/core/index.jsx @@ -22,11 +22,13 @@ import enUS from 'antd/es/locale/en_US'; import globalRootStore from 'stores/root'; import PageLoading from 'components/PageLoading'; import metricDict from 'resources/prometheus/metricDict'; +import variables from 'styles/variables.less'; import i18n from './i18n'; import App from './App'; window.t = i18n.t; window.METRICDICT = metricDict; +window.globalCSS = variables; const store = globalRootStore; const browserHistory = createBrowserHistory(); diff --git a/src/layouts/Base/index.less b/src/layouts/Base/index.less index cd646e18..872f3ce9 100644 --- a/src/layouts/Base/index.less +++ b/src/layouts/Base/index.less @@ -312,7 +312,7 @@ margin-bottom: 16px; padding: 16px 24px; overflow: hidden; - color: #0068ff; + color: @primary-color; font-size: 18px; line-height: 24px; word-wrap: break-word; diff --git a/src/pages/auth/containers/ChangePassword/index.jsx b/src/pages/auth/containers/ChangePassword/index.jsx index 63601c73..5a3df781 100644 --- a/src/pages/auth/containers/ChangePassword/index.jsx +++ b/src/pages/auth/containers/ChangePassword/index.jsx @@ -138,7 +138,7 @@ export class Password extends Component { name: 'hint', render: () => (
- + {t('User need to change password')}
), diff --git a/src/pages/auth/containers/ChangePassword/index.less b/src/pages/auth/containers/ChangePassword/index.less index 4638a3f6..9715849e 100644 --- a/src/pages/auth/containers/ChangePassword/index.less +++ b/src/pages/auth/containers/ChangePassword/index.less @@ -1,3 +1,5 @@ +@import '~styles/variables'; + .register { float: right; } @@ -47,11 +49,11 @@ .error { padding-left: 12px; - color: #a43a39; + color: @login-error; font-size: 14px; line-height: 38px; background: #f2dede; - border: 1px solid #a43a39; + border: 1px solid @login-error; border-radius: 4px; :global { diff --git a/src/pages/auth/containers/Login/index.less b/src/pages/auth/containers/Login/index.less index 2eeb04ad..501bae17 100644 --- a/src/pages/auth/containers/Login/index.less +++ b/src/pages/auth/containers/Login/index.less @@ -1,3 +1,5 @@ +@import '~styles/variables'; + .register { float: right; } @@ -13,11 +15,11 @@ .login-error { padding: 8px 12px; - color: #a43a39; + color: @login-error; font-size: 14px; line-height: 1.5; background: #f2dede; - border: 1px solid #a43a39; + border: 1px solid @login-error; border-radius: 4px; :global { diff --git a/src/pages/base/containers/AdminOverview/components/ResourceOverview.jsx b/src/pages/base/containers/AdminOverview/components/ResourceOverview.jsx index d5385845..e219bf2f 100644 --- a/src/pages/base/containers/AdminOverview/components/ResourceOverview.jsx +++ b/src/pages/base/containers/AdminOverview/components/ResourceOverview.jsx @@ -68,17 +68,17 @@ export const smallCard = [ ]; const instanceColors = { - active: { color: '#52C41A', text: t('Active Status') }, - error: { color: '#E8684A', text: t('Error') }, + active: { color: globalCSS.successColor, text: t('Active Status') }, + error: { color: globalCSS.errorColor, text: t('Error') }, shutoff: { color: '#E6F2E0', text: t('Shutoff') }, - other: { color: '#F6B23D', text: t('Others') }, + other: { color: globalCSS.warnLightColor, text: t('Others') }, }; const volumeColors = { - active: { color: '#52C41A', text: t('Attaching') }, - error: { color: '#E8684A', text: t('Error') }, + active: { color: globalCSS.successColor, text: t('Attaching') }, + error: { color: globalCSS.errorColor, text: t('Error') }, available: { color: '#E6F2E0', text: t('Unattached') }, - other: { color: '#F6B23D', text: t('Others') }, + other: { color: globalCSS.warnLightColor, text: t('Others') }, }; export class virtualResourceInfo extends Component { diff --git a/src/pages/base/containers/AdminOverview/components/VirtualResource.jsx b/src/pages/base/containers/AdminOverview/components/VirtualResource.jsx index 6ef0b1b9..9c25c5af 100644 --- a/src/pages/base/containers/AdminOverview/components/VirtualResource.jsx +++ b/src/pages/base/containers/AdminOverview/components/VirtualResource.jsx @@ -31,9 +31,9 @@ export const resourceCircle = [ ]; export const color = { - infoColor: 'rgba(0, 104, 255, 0.65)', - warnColor: '#FE9901', - dangerColor: '#D93126', + infoColor: globalCSS.primaryColor, + warnColor: globalCSS.warnDarkColor, + dangerColor: globalCSS.errorColor, }; export class ResourceCircle extends Component { @@ -56,9 +56,9 @@ export class ResourceCircle extends Component { const used = overview[item.used]; const percentNum = parseFloat(((used / resource) * 100).toFixed(2)); const unUsed = parseFloat((resource - used).toFixed(2)); - let circleColor = color.infoColor; + let circleColor = color.primaryColor; if (percentNum > 70) { - circleColor = color.warnColor; + circleColor = color.warnDarkColor; } if (percentNum > 90) { circleColor = color.dangerColor; diff --git a/src/pages/base/containers/Overview/components/QuotaOverview.jsx b/src/pages/base/containers/Overview/components/QuotaOverview.jsx index 2df6bfdb..f6aab24f 100644 --- a/src/pages/base/containers/Overview/components/QuotaOverview.jsx +++ b/src/pages/base/containers/Overview/components/QuotaOverview.jsx @@ -23,9 +23,9 @@ import { isNumber } from 'lodash'; import styles from '../style.less'; const colors = { - normal: { color: '#4CC9F0', text: t('Normal') }, - danger: { color: '#4361EE', text: t('Danger') }, - full: { color: '#E8684A', text: t('Full') }, + normal: { color: globalCSS.primaryColor, text: t('Normal') }, + danger: { color: globalCSS.warnDarkColor, text: t('Danger') }, + full: { color: globalCSS.errorColor, text: t('Full') }, }; const keyPairTitle = ( diff --git a/src/pages/base/containers/Overview/style.less b/src/pages/base/containers/Overview/style.less index f5427e95..87e81bee 100644 --- a/src/pages/base/containers/Overview/style.less +++ b/src/pages/base/containers/Overview/style.less @@ -137,7 +137,7 @@ .action { float: right; margin-top: 6px; - color: #0068ff; + color: @primary-color; font-size: 12px; cursor: pointer; } diff --git a/src/pages/compute/containers/Instance/actions/Resize.jsx b/src/pages/compute/containers/Instance/actions/Resize.jsx index 1b4e1d05..a50631de 100644 --- a/src/pages/compute/containers/Instance/actions/Resize.jsx +++ b/src/pages/compute/containers/Instance/actions/Resize.jsx @@ -143,7 +143,7 @@ export class Resize extends ModalAction { get tips() { return (
-

+

{t('The current operation requires the instance to be shut down:')}

diff --git a/src/pages/monitor/containers/OpenstackService/Services.jsx b/src/pages/monitor/containers/OpenstackService/Services.jsx index bb2088d8..23274ea1 100644 --- a/src/pages/monitor/containers/OpenstackService/Services.jsx +++ b/src/pages/monitor/containers/OpenstackService/Services.jsx @@ -30,7 +30,7 @@ const statusToIcon = { down: ( ), }; diff --git a/src/pages/monitor/containers/Overview/components/Tops/index.jsx b/src/pages/monitor/containers/Overview/components/Tops/index.jsx index d5af93e9..a496265f 100644 --- a/src/pages/monitor/containers/Overview/components/Tops/index.jsx +++ b/src/pages/monitor/containers/Overview/components/Tops/index.jsx @@ -23,7 +23,8 @@ export const renderTopProgress = ({ data }) => { {data.map((d) => { const percentage = get(d, 'y', 0); - const percentageColor = percentage > 80 ? '#FAAD14' : '#1890FF'; + const percentageColor = + percentage > 80 ? globalCSS.warnDarkColor : globalCSS.primaryColor; return (

{d.type}
diff --git a/src/pages/monitor/containers/Overview/config.jsx b/src/pages/monitor/containers/Overview/config.jsx index 6e1d4885..3ef2a306 100644 --- a/src/pages/monitor/containers/Overview/config.jsx +++ b/src/pages/monitor/containers/Overview/config.jsx @@ -137,7 +137,11 @@ export const physicalNodeLeftTopCardList = [ 80 ? '#FAAD14' : '#1890FF'} + strokeColor={ + progressPercentage > 80 + ? globalCSS.warnDarkColor + : globalCSS.primaryColor + } showInfo={progressPercentage !== 100} /> diff --git a/src/pages/monitor/containers/PhysicalNode/index.jsx b/src/pages/monitor/containers/PhysicalNode/index.jsx index 6b75eea2..1e41da99 100644 --- a/src/pages/monitor/containers/PhysicalNode/index.jsx +++ b/src/pages/monitor/containers/PhysicalNode/index.jsx @@ -99,7 +99,8 @@ export const topCardList = [ > {(value.data || []).map((item, index) => { const percentage = computePercentage(item.avail, item.total); - const percentageColor = percentage > 80 ? '#FAAD14' : '#1890FF'; + const percentageColor = + percentage > 80 ? globalCSS.warnDarkColor : globalCSS.primaryColor; return (
{ 80 ? '#FAAD14' : '#1890FF'} + strokeColor={ + progressPercentage > 80 + ? globalCSS.warnDarkColor + : globalCSS.primaryColor + } showInfo={progressPercentage !== 100} /> diff --git a/src/pages/monitor/containers/StorageCluster/index.less b/src/pages/monitor/containers/StorageCluster/index.less index 9b4eeb78..32805265 100644 --- a/src/pages/monitor/containers/StorageCluster/index.less +++ b/src/pages/monitor/containers/StorageCluster/index.less @@ -1,3 +1,5 @@ +@import '~styles/variables'; + .osd { height: 100%; color: rgba(0, 0, 0, 85%); @@ -17,7 +19,7 @@ } .ant-radio-button-wrapper-checked { - color: #0068ff; + color: @primary-color; } } } diff --git a/src/pages/network/containers/LoadBalancers/Listener/Detail/Member/Actions/CreateMember.jsx b/src/pages/network/containers/LoadBalancers/Listener/Detail/Member/Actions/CreateMember.jsx index 5976fe72..d4f2bc02 100644 --- a/src/pages/network/containers/LoadBalancers/Listener/Detail/Member/Actions/CreateMember.jsx +++ b/src/pages/network/containers/LoadBalancers/Listener/Detail/Member/Actions/CreateMember.jsx @@ -96,7 +96,7 @@ export class CreateAction extends ModalAction { get tips() { return (
-

+

{t( 'The amphora instance is required for load balancing service setup and is not recommended' )} diff --git a/src/pages/network/containers/Topology/index.jsx b/src/pages/network/containers/Topology/index.jsx index 60b65915..b323e107 100644 --- a/src/pages/network/containers/Topology/index.jsx +++ b/src/pages/network/containers/Topology/index.jsx @@ -43,6 +43,10 @@ import NodeCard from './NodeCard'; let graph = null; const { isIpInRangeAll } = ipValidate; +export const activeShadowColor = 'rgba(87,227,155,0.61)'; +export const errorShadowColor = 'rgba(237,33,48,1)'; +export const errorStrokeColor = '#DB3A3A'; + export class Topology extends React.Component { constructor(props) { super(props); @@ -142,11 +146,12 @@ export class Topology extends React.Component { style: { radius: 4, fill: '#FFFFFFFF', - stroke: router.status === 'ACTIVE' ? '#57E39B' : '#DB3A3A', - shadowColor: + stroke: router.status === 'ACTIVE' - ? 'rgba(87,227,155,0.61)' - : 'rgba(237,33,48,1)', + ? globalCSS.successColor + : errorStrokeColor, + shadowColor: + router.status === 'ACTIVE' ? activeShadowColor : errorShadowColor, shadowBlur: router.status === 'ACTIVE' ? 5 : 4, }, anchorPoints: [[0.5, 0]], @@ -336,11 +341,14 @@ export class Topology extends React.Component { style: { radius: 4, fill: '#FFFFFFFF', - stroke: server.vm_state === 'active' ? '#57E39B' : '#DB3A3A', + stroke: + server.vm_state === 'active' + ? globalCSS.successColor + : errorStrokeColor, shadowColor: server.vm_state === 'active' - ? 'rgba(87,227,155,0.61)' - : 'rgba(237,33,48,1)', + ? activeShadowColor + : errorShadowColor, shadowBlur: server.vm_state === 'active' ? 5 : 4, }, }); @@ -403,11 +411,14 @@ export class Topology extends React.Component { style: { radius: 4, fill: '#FFFFFFFF', - stroke: server.vm_state === 'active' ? '#57E39B' : '#DB3A3A', + stroke: + server.vm_state === 'active' + ? globalCSS.successColor + : errorStrokeColor, shadowColor: server.vm_state === 'active' - ? 'rgba(87,227,155,0.61)' - : 'rgba(237,33,48,1)', + ? activeShadowColor + : errorShadowColor, shadowBlur: server.vm_state === 'active' ? 5 : 4, }, }); diff --git a/src/resources/prometheus/monitoring.js b/src/resources/prometheus/monitoring.js index a0c3fb6f..84cd5e77 100644 --- a/src/resources/prometheus/monitoring.js +++ b/src/resources/prometheus/monitoring.js @@ -391,7 +391,7 @@ export const cephStatusMap = { }; export const cephStatusColorMap = { - 0: '#379738', - 1: '#FAAD14', - 2: '#D93126', + 0: globalCSS.successColor, + 1: globalCSS.warnDarkColor, + 2: globalCSS.errorColor, }; diff --git a/src/styles/base.less b/src/styles/base.less index 011624ca..730b0109 100644 --- a/src/styles/base.less +++ b/src/styles/base.less @@ -64,7 +64,7 @@ &:hover { svg { - color: #1890ff; + color: @primary-color; fill: #6fb4f5; } } diff --git a/src/styles/variables.less b/src/styles/variables.less index 2188e2ed..7ab6a1c3 100644 --- a/src/styles/variables.less +++ b/src/styles/variables.less @@ -4,6 +4,7 @@ @blue-3: rgba(89, 157, 255, 35%); @blue-4: #005ade; @primary-color: @blue-1; +@info-color: @blue-2; @hover-color: @blue-4; @green-1: #57e39b; @@ -16,6 +17,9 @@ @yellow-3: rgba(254, 223, 64, 35%); @warn-color: @yellow-1; +@warn-light-color: #f6b23d; +@warn-dark-color: #fa8c16; + @red-1: #eb354d; @red-2: rgba(235, 53, 77, 65%); @red-3: rgba(235, 53, 77, 35%); @@ -124,3 +128,20 @@ /* sider */ @sider-background: #26262b; @sider-open-background: #222121; + +/* login */ +@login-error: #a43a39; + +@money-color: #f50; + +:export { + primaryColor: @primary-color; + successColor: @success-color; + warnColor: @warn-color; + warnDarkColor: @warn-dark-color; + warnLightColor: @warn-light-color; + errorColor: @error-color; + dangerColor: @danger-color; + moneyColor: @money-color; + infoColor: @info-color; +}