feat: update color variables

Use color variables to set color in less and jsx, this makes it easy to change the theme for all pages.

Change-Id: I9b82c4624826854d40d11da4e6ce4a9137b86085
This commit is contained in:
Jingwei.Zhang 2023-05-24 16:48:56 +08:00
parent 8ecf24e69f
commit ec59419f4f
36 changed files with 130 additions and 74 deletions

View File

@ -74,6 +74,10 @@
[ [
"asset", "asset",
"./src/asset" "./src/asset"
],
[
"styles",
"./src/styles"
] ]
], ],
"extensions": [ "extensions": [
@ -134,6 +138,7 @@
"t": true, "t": true,
"globals": true, "globals": true,
"request": true, "request": true,
"METRICDICT": true "METRICDICT": true,
"globalCSS": true
} }
} }

View File

@ -10,6 +10,12 @@
"rules": { "rules": {
"no-descending-specificity": null, "no-descending-specificity": null,
"at-rule-no-unknown": null, "at-rule-no-unknown": null,
"color-function-notation": "legacy" "color-function-notation": "legacy",
"property-no-unknown": [
true,
{
"ignoreProperties": ["/Color$/"]
}
]
} }
} }

View File

@ -18,7 +18,7 @@
vertical-align: top; vertical-align: top;
:global .h1 { :global .h1 {
color: #abb4be; color: @light-color08;
font-size: 120px; font-size: 120px;
line-height: 1.4; line-height: 1.4;
text-align: left; text-align: left;

View File

@ -8,11 +8,6 @@
@resource-box-bg: #fbfdff; @resource-box-bg: #fbfdff;
@resource-box-border: 1px solid #cfe1ff; @resource-box-border: 1px solid #cfe1ff;
@success: #57e39b;
@warning: #fedf40;
@error: #eb354d;
@link: #0068ff;
.card { .card {
flex: 1; flex: 1;
margin-bottom: @mid-space; margin-bottom: @mid-space;

View File

@ -100,7 +100,7 @@
.tips-icon { .tips-icon {
margin-top: 2px; margin-top: 2px;
margin-right: 4px; margin-right: 4px;
color: #0068ff; color: @primary-color;
} }
.footer-left { .footer-left {

View File

@ -28,8 +28,8 @@ export default class index extends Component {
get progress() { get progress() {
return { return {
strokeColor: { strokeColor: {
'0%': '#108ee9', '0%': globalCSS.primaryColor,
'100%': '#87d068', '100%': globalCSS.successColor,
}, },
strokeWidth: 3, strokeWidth: 3,
format: (percent) => `${parseFloat(percent.toFixed(2))}%`, format: (percent) => `${parseFloat(percent.toFixed(2))}%`,

View File

@ -82,7 +82,7 @@ export class Token extends ModalAction {
const now = Date.now(); const now = Date.now();
if (now > this.keystoneTokenExp) { if (now > this.keystoneTokenExp) {
return ( return (
<span style={{ color: 'rgb(232, 104, 74)' }}> <span style={globalCSS.warnDarkColor}>
{t('Keystone token is expired.')} {t('Keystone token is expired.')}
</span> </span>
); );

View File

@ -28,7 +28,7 @@ const Loading = ({ pastDelay, timedOut, error }) => {
> >
<Icon <Icon
type="loading" type="loading"
style={{ fontSize: 32, color: '#1890ff' }} style={{ fontSize: 32, color: globalCSS.primaryColor }}
theme="outlined" theme="outlined"
/> />
<p>Loading...</p> <p>Loading...</p>

View File

@ -42,19 +42,19 @@ const open = (args) => {
let icon = null; let icon = null;
if (type === 'info') { if (type === 'info') {
iconColor = '#0068FF'; iconColor = globalCSS.primaryColor;
icon = <InfoCircleOutlined theme="filled" style={{ color: iconColor }} />; icon = <InfoCircleOutlined theme="filled" style={{ color: iconColor }} />;
} else if (type === 'success') { } else if (type === 'success') {
iconColor = '#57E39B'; iconColor = globalCSS.successColor;
icon = <CheckCircleOutlined theme="filled" style={{ color: iconColor }} />; icon = <CheckCircleOutlined theme="filled" style={{ color: iconColor }} />;
} else if (type === 'error') { } else if (type === 'error') {
iconColor = '#EB354D'; iconColor = globalCSS.errorColor;
icon = <CloseCircleOutlined theme="filled" style={{ color: iconColor }} />; icon = <CloseCircleOutlined theme="filled" style={{ color: iconColor }} />;
} else if (type === 'process') { } else if (type === 'process') {
iconColor = '#0068FF'; iconColor = globalCSS.primaryColor;
icon = <LoadingOutlined style={{ color: iconColor }} />; icon = <LoadingOutlined style={{ color: iconColor }} />;
} else if (type === 'warn') { } else if (type === 'warn') {
iconColor = '#FEDF40'; iconColor = globalCSS.warnColor;
icon = <InfoCircleOutlined theme="filled" style={{ color: iconColor }} />; icon = <InfoCircleOutlined theme="filled" style={{ color: iconColor }} />;
} }

View File

@ -30,9 +30,9 @@ export default class index extends Component {
static defaultProps = { static defaultProps = {
wanValue: 70, wanValue: 70,
dangerValue: 90, dangerValue: 90,
infoColor: 'rgba(0, 104, 255, 0.65)', infoColor: globalCSS.primaryColor,
warnColor: 'rgba(254, 223, 64, 0.65)', warnColor: globalCSS.warnDarkColor,
dangerColor: 'rgba(235, 53, 77, 0.65)', dangerColor: globalCSS.dangerColor,
label: '', label: '',
}; };

View File

@ -30,9 +30,9 @@ export default class index extends Component {
static defaultProps = { static defaultProps = {
wanValue: 70, wanValue: 70,
dangerValue: 90, dangerValue: 90,
infoColor: 'rgba(0, 104, 255, 0.65)', infoColor: globalCSS.primaryColor,
warnColor: 'rgba(254, 223, 64, 0.65)', warnColor: globalCSS.warnDarkColor,
dangerColor: 'rgba(235, 53, 77, 0.65)', dangerColor: globalCSS.dangerColor,
label: '', label: '',
}; };

View File

@ -25,11 +25,11 @@ import {
import { Tooltip as AntTooltip } from 'antd'; import { Tooltip as AntTooltip } from 'antd';
export const typeColors = { export const typeColors = {
used: '#5B8FF9', used: globalCSS.primaryColor,
reserved: '#5D7092', reserved: '#5D7092',
add: '#5AD8A6', add: globalCSS.successColor,
left: '#eee', left: '#eee',
danger: '#E8684A', danger: globalCSS.warnDarkColor,
}; };
export const getAddValueColor = (percent) => { export const getAddValueColor = (percent) => {

View File

@ -337,7 +337,7 @@ export class BaseTable extends React.Component {
} }
return (value) => { return (value) => {
const valueStr = isString(value) ? value : (value || 0).toFixed(2); const valueStr = isString(value) ? value : (value || 0).toFixed(2);
return <span style={{ color: '#f50' }}>{valueStr}</span>; return <span style={{ color: globalCSS.moneyColor }}>{valueStr}</span>;
}; };
}; };

View File

@ -171,7 +171,7 @@ export default class SimpleTable extends React.Component {
} }
return (value) => { return (value) => {
const valueStr = isString(value) ? value : (value || 0).toFixed(2); const valueStr = isString(value) ? value : (value || 0).toFixed(2);
return <span style={{ color: '#f50' }}>{valueStr}</span>; return <span style={{ color: globalCSS.moneyColor }}>{valueStr}</span>;
}; };
}; };

View File

@ -17,7 +17,7 @@
border: 1px solid #ffe58f; border: 1px solid #ffe58f;
.ant-alert-icon { .ant-alert-icon {
color: #faad14; color: @warn-color;
} }
} }
} }

View File

@ -22,11 +22,13 @@ import enUS from 'antd/es/locale/en_US';
import globalRootStore from 'stores/root'; import globalRootStore from 'stores/root';
import PageLoading from 'components/PageLoading'; import PageLoading from 'components/PageLoading';
import metricDict from 'resources/prometheus/metricDict'; import metricDict from 'resources/prometheus/metricDict';
import variables from 'styles/variables.less';
import i18n from './i18n'; import i18n from './i18n';
import App from './App'; import App from './App';
window.t = i18n.t; window.t = i18n.t;
window.METRICDICT = metricDict; window.METRICDICT = metricDict;
window.globalCSS = variables;
const store = globalRootStore; const store = globalRootStore;
const browserHistory = createBrowserHistory(); const browserHistory = createBrowserHistory();

View File

@ -312,7 +312,7 @@
margin-bottom: 16px; margin-bottom: 16px;
padding: 16px 24px; padding: 16px 24px;
overflow: hidden; overflow: hidden;
color: #0068ff; color: @primary-color;
font-size: 18px; font-size: 18px;
line-height: 24px; line-height: 24px;
word-wrap: break-word; word-wrap: break-word;

View File

@ -138,7 +138,7 @@ export class Password extends Component {
name: 'hint', name: 'hint',
render: () => ( render: () => (
<div className={styles.hint}> <div className={styles.hint}>
<InfoCircleFilled style={{ color: '#FAAD14' }} /> <InfoCircleFilled style={{ color: globalCSS.warnColor }} />
{t('User need to change password')} {t('User need to change password')}
</div> </div>
), ),

View File

@ -1,3 +1,5 @@
@import '~styles/variables';
.register { .register {
float: right; float: right;
} }
@ -47,11 +49,11 @@
.error { .error {
padding-left: 12px; padding-left: 12px;
color: #a43a39; color: @login-error;
font-size: 14px; font-size: 14px;
line-height: 38px; line-height: 38px;
background: #f2dede; background: #f2dede;
border: 1px solid #a43a39; border: 1px solid @login-error;
border-radius: 4px; border-radius: 4px;
:global { :global {

View File

@ -1,3 +1,5 @@
@import '~styles/variables';
.register { .register {
float: right; float: right;
} }
@ -13,11 +15,11 @@
.login-error { .login-error {
padding: 8px 12px; padding: 8px 12px;
color: #a43a39; color: @login-error;
font-size: 14px; font-size: 14px;
line-height: 1.5; line-height: 1.5;
background: #f2dede; background: #f2dede;
border: 1px solid #a43a39; border: 1px solid @login-error;
border-radius: 4px; border-radius: 4px;
:global { :global {

View File

@ -68,17 +68,17 @@ export const smallCard = [
]; ];
const instanceColors = { const instanceColors = {
active: { color: '#52C41A', text: t('Active Status') }, active: { color: globalCSS.successColor, text: t('Active Status') },
error: { color: '#E8684A', text: t('Error') }, error: { color: globalCSS.errorColor, text: t('Error') },
shutoff: { color: '#E6F2E0', text: t('Shutoff') }, shutoff: { color: '#E6F2E0', text: t('Shutoff') },
other: { color: '#F6B23D', text: t('Others') }, other: { color: globalCSS.warnLightColor, text: t('Others') },
}; };
const volumeColors = { const volumeColors = {
active: { color: '#52C41A', text: t('Attaching') }, active: { color: globalCSS.successColor, text: t('Attaching') },
error: { color: '#E8684A', text: t('Error') }, error: { color: globalCSS.errorColor, text: t('Error') },
available: { color: '#E6F2E0', text: t('Unattached') }, available: { color: '#E6F2E0', text: t('Unattached') },
other: { color: '#F6B23D', text: t('Others') }, other: { color: globalCSS.warnLightColor, text: t('Others') },
}; };
export class virtualResourceInfo extends Component { export class virtualResourceInfo extends Component {

View File

@ -31,9 +31,9 @@ export const resourceCircle = [
]; ];
export const color = { export const color = {
infoColor: 'rgba(0, 104, 255, 0.65)', infoColor: globalCSS.primaryColor,
warnColor: '#FE9901', warnColor: globalCSS.warnDarkColor,
dangerColor: '#D93126', dangerColor: globalCSS.errorColor,
}; };
export class ResourceCircle extends Component { export class ResourceCircle extends Component {
@ -56,9 +56,9 @@ export class ResourceCircle extends Component {
const used = overview[item.used]; const used = overview[item.used];
const percentNum = parseFloat(((used / resource) * 100).toFixed(2)); const percentNum = parseFloat(((used / resource) * 100).toFixed(2));
const unUsed = parseFloat((resource - used).toFixed(2)); const unUsed = parseFloat((resource - used).toFixed(2));
let circleColor = color.infoColor; let circleColor = color.primaryColor;
if (percentNum > 70) { if (percentNum > 70) {
circleColor = color.warnColor; circleColor = color.warnDarkColor;
} }
if (percentNum > 90) { if (percentNum > 90) {
circleColor = color.dangerColor; circleColor = color.dangerColor;

View File

@ -23,9 +23,9 @@ import { isNumber } from 'lodash';
import styles from '../style.less'; import styles from '../style.less';
const colors = { const colors = {
normal: { color: '#4CC9F0', text: t('Normal') }, normal: { color: globalCSS.primaryColor, text: t('Normal') },
danger: { color: '#4361EE', text: t('Danger') }, danger: { color: globalCSS.warnDarkColor, text: t('Danger') },
full: { color: '#E8684A', text: t('Full') }, full: { color: globalCSS.errorColor, text: t('Full') },
}; };
const keyPairTitle = ( const keyPairTitle = (

View File

@ -137,7 +137,7 @@
.action { .action {
float: right; float: right;
margin-top: 6px; margin-top: 6px;
color: #0068ff; color: @primary-color;
font-size: 12px; font-size: 12px;
cursor: pointer; cursor: pointer;
} }

View File

@ -143,7 +143,7 @@ export class Resize extends ModalAction {
get tips() { get tips() {
return ( return (
<div> <div>
<p style={{ color: '#0068FF' }}> <p style={{ color: globalCSS.primaryColor }}>
{t('The current operation requires the instance to be shut down:')} {t('The current operation requires the instance to be shut down:')}
</p> </p>
<p> <p>

View File

@ -30,7 +30,7 @@ const statusToIcon = {
down: ( down: (
<InfoCircleTwoTone <InfoCircleTwoTone
style={{ fontSize: 24, marginLeft: 36 }} style={{ fontSize: 24, marginLeft: 36 }}
twoToneColor="#EB354D" twoToneColor={globalCSS.errorColor}
/> />
), ),
}; };

View File

@ -23,7 +23,8 @@ export const renderTopProgress = ({ data }) => {
<Row style={{ height: '100%' }}> <Row style={{ height: '100%' }}>
{data.map((d) => { {data.map((d) => {
const percentage = get(d, 'y', 0); const percentage = get(d, 'y', 0);
const percentageColor = percentage > 80 ? '#FAAD14' : '#1890FF'; const percentageColor =
percentage > 80 ? globalCSS.warnDarkColor : globalCSS.primaryColor;
return ( return (
<Col span={24} key={d.type}> <Col span={24} key={d.type}>
<div>{d.type}</div> <div>{d.type}</div>

View File

@ -137,7 +137,11 @@ export const physicalNodeLeftTopCardList = [
<Progress <Progress
style={{ width: '95%' }} style={{ width: '95%' }}
percent={progressPercentage} percent={progressPercentage}
strokeColor={progressPercentage > 80 ? '#FAAD14' : '#1890FF'} strokeColor={
progressPercentage > 80
? globalCSS.warnDarkColor
: globalCSS.primaryColor
}
showInfo={progressPercentage !== 100} showInfo={progressPercentage !== 100}
/> />
</Row> </Row>

View File

@ -99,7 +99,8 @@ export const topCardList = [
> >
{(value.data || []).map((item, index) => { {(value.data || []).map((item, index) => {
const percentage = computePercentage(item.avail, item.total); const percentage = computePercentage(item.avail, item.total);
const percentageColor = percentage > 80 ? '#FAAD14' : '#1890FF'; const percentageColor =
percentage > 80 ? globalCSS.warnDarkColor : globalCSS.primaryColor;
return ( return (
<div <div
key={item.mountpoint} key={item.mountpoint}

View File

@ -211,7 +211,11 @@ const StorageCluster = () => {
<Progress <Progress
style={{ width: '95%' }} style={{ width: '95%' }}
percent={progressPercentage} percent={progressPercentage}
strokeColor={progressPercentage > 80 ? '#FAAD14' : '#1890FF'} strokeColor={
progressPercentage > 80
? globalCSS.warnDarkColor
: globalCSS.primaryColor
}
showInfo={progressPercentage !== 100} showInfo={progressPercentage !== 100}
/> />
</Row> </Row>

View File

@ -1,3 +1,5 @@
@import '~styles/variables';
.osd { .osd {
height: 100%; height: 100%;
color: rgba(0, 0, 0, 85%); color: rgba(0, 0, 0, 85%);
@ -17,7 +19,7 @@
} }
.ant-radio-button-wrapper-checked { .ant-radio-button-wrapper-checked {
color: #0068ff; color: @primary-color;
} }
} }
} }

View File

@ -96,7 +96,7 @@ export class CreateAction extends ModalAction {
get tips() { get tips() {
return ( return (
<div style={{ display: 'inline-table' }}> <div style={{ display: 'inline-table' }}>
<p style={{ color: '#0068FF' }}> <p style={{ color: globalCSS.primaryColor }}>
{t( {t(
'The amphora instance is required for load balancing service setup and is not recommended' 'The amphora instance is required for load balancing service setup and is not recommended'
)} )}

View File

@ -43,6 +43,10 @@ import NodeCard from './NodeCard';
let graph = null; let graph = null;
const { isIpInRangeAll } = ipValidate; 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 { export class Topology extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -142,11 +146,12 @@ export class Topology extends React.Component {
style: { style: {
radius: 4, radius: 4,
fill: '#FFFFFFFF', fill: '#FFFFFFFF',
stroke: router.status === 'ACTIVE' ? '#57E39B' : '#DB3A3A', stroke:
shadowColor:
router.status === 'ACTIVE' router.status === 'ACTIVE'
? 'rgba(87,227,155,0.61)' ? globalCSS.successColor
: 'rgba(237,33,48,1)', : errorStrokeColor,
shadowColor:
router.status === 'ACTIVE' ? activeShadowColor : errorShadowColor,
shadowBlur: router.status === 'ACTIVE' ? 5 : 4, shadowBlur: router.status === 'ACTIVE' ? 5 : 4,
}, },
anchorPoints: [[0.5, 0]], anchorPoints: [[0.5, 0]],
@ -336,11 +341,14 @@ export class Topology extends React.Component {
style: { style: {
radius: 4, radius: 4,
fill: '#FFFFFFFF', fill: '#FFFFFFFF',
stroke: server.vm_state === 'active' ? '#57E39B' : '#DB3A3A', stroke:
server.vm_state === 'active'
? globalCSS.successColor
: errorStrokeColor,
shadowColor: shadowColor:
server.vm_state === 'active' server.vm_state === 'active'
? 'rgba(87,227,155,0.61)' ? activeShadowColor
: 'rgba(237,33,48,1)', : errorShadowColor,
shadowBlur: server.vm_state === 'active' ? 5 : 4, shadowBlur: server.vm_state === 'active' ? 5 : 4,
}, },
}); });
@ -403,11 +411,14 @@ export class Topology extends React.Component {
style: { style: {
radius: 4, radius: 4,
fill: '#FFFFFFFF', fill: '#FFFFFFFF',
stroke: server.vm_state === 'active' ? '#57E39B' : '#DB3A3A', stroke:
server.vm_state === 'active'
? globalCSS.successColor
: errorStrokeColor,
shadowColor: shadowColor:
server.vm_state === 'active' server.vm_state === 'active'
? 'rgba(87,227,155,0.61)' ? activeShadowColor
: 'rgba(237,33,48,1)', : errorShadowColor,
shadowBlur: server.vm_state === 'active' ? 5 : 4, shadowBlur: server.vm_state === 'active' ? 5 : 4,
}, },
}); });

View File

@ -391,7 +391,7 @@ export const cephStatusMap = {
}; };
export const cephStatusColorMap = { export const cephStatusColorMap = {
0: '#379738', 0: globalCSS.successColor,
1: '#FAAD14', 1: globalCSS.warnDarkColor,
2: '#D93126', 2: globalCSS.errorColor,
}; };

View File

@ -64,7 +64,7 @@
&:hover { &:hover {
svg { svg {
color: #1890ff; color: @primary-color;
fill: #6fb4f5; fill: #6fb4f5;
} }
} }

View File

@ -4,6 +4,7 @@
@blue-3: rgba(89, 157, 255, 35%); @blue-3: rgba(89, 157, 255, 35%);
@blue-4: #005ade; @blue-4: #005ade;
@primary-color: @blue-1; @primary-color: @blue-1;
@info-color: @blue-2;
@hover-color: @blue-4; @hover-color: @blue-4;
@green-1: #57e39b; @green-1: #57e39b;
@ -16,6 +17,9 @@
@yellow-3: rgba(254, 223, 64, 35%); @yellow-3: rgba(254, 223, 64, 35%);
@warn-color: @yellow-1; @warn-color: @yellow-1;
@warn-light-color: #f6b23d;
@warn-dark-color: #fa8c16;
@red-1: #eb354d; @red-1: #eb354d;
@red-2: rgba(235, 53, 77, 65%); @red-2: rgba(235, 53, 77, 65%);
@red-3: rgba(235, 53, 77, 35%); @red-3: rgba(235, 53, 77, 35%);
@ -124,3 +128,20 @@
/* sider */ /* sider */
@sider-background: #26262b; @sider-background: #26262b;
@sider-open-background: #222121; @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;
}