Background gradients, migrate from CSS to SCSS, remove !important

This commit is contained in:
Maksim Eltyshev
2020-05-29 19:31:19 +05:00
parent 8534ed292c
commit 5bfff3865f
312 changed files with 4295 additions and 2989 deletions

View File

@@ -1,10 +1,13 @@
import upperFirst from 'lodash/upperFirst';
import camelCase from 'lodash/camelCase';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import LabelColors from '../../constants/LabelColors';
import styles from './Label.module.css';
import styles from './Label.module.scss';
import globalStyles from '../../styles.module.scss';
const SIZES = {
TINY: 'tiny',
@@ -12,39 +15,16 @@ const SIZES = {
MEDIUM: 'medium',
};
// TODO: move to styles
const STYLES = {
tiny: {
fontSize: '12px',
lineHeight: '20px',
maxWidth: '176px',
padding: '0px 6px',
},
small: {
fontSize: '12px',
lineHeight: '20px',
maxWidth: '176px',
padding: '2px 8px',
},
medium: {
fontSize: '14px',
lineHeight: '32px',
maxWidth: '230px',
padding: '0 12px',
},
};
const Label = React.memo(({ name, color, size, isDisabled, onClick }) => {
const style = {
...STYLES[size],
background: LabelColors.MAP[color],
};
const contentNode = (
<div
title={name}
className={classNames(styles.wrapper, onClick && styles.hoverable)}
style={style}
className={classNames(
styles.wrapper,
styles[`wrapper${upperFirst(size)}`],
onClick && styles.wrapperHoverable,
globalStyles[`background${upperFirst(camelCase(color))}`],
)}
>
{name || '\u00A0'}
</div>
@@ -61,7 +41,7 @@ const Label = React.memo(({ name, color, size, isDisabled, onClick }) => {
Label.propTypes = {
name: PropTypes.string,
color: PropTypes.oneOf(LabelColors.KEYS).isRequired,
color: PropTypes.oneOf(LabelColors).isRequired,
size: PropTypes.oneOf(Object.values(SIZES)),
isDisabled: PropTypes.bool,
onClick: PropTypes.func,

View File

@@ -1,26 +0,0 @@
.button {
background: transparent;
border: none;
cursor: pointer;
display: inline-block;
max-width: 100%;
outline: none;
padding: 0;
}
.hoverable:hover {
opacity: 0.75;
}
.wrapper {
border-radius: 3px;
box-sizing: border-box;
color: #fff;
display: inline-block;
font-weight: 400;
min-width: 40px;
outline: none;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

View File

@@ -0,0 +1,51 @@
:global(#app) {
.button {
background: transparent;
border: none;
cursor: pointer;
display: inline-block;
max-width: 100%;
outline: none;
padding: 0;
}
.wrapper {
border-radius: 3px;
box-sizing: border-box;
color: #fff;
display: inline-block;
font-weight: 400;
min-width: 40px;
outline: none;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.wrapperHoverable:hover {
opacity: 0.75;
}
/* Sizes */
.wrapperTiny {
font-size: 12px;
line-height: 20px;
max-width: 176px;
padding: 0 6px;
}
.wrapperSmall {
font-size: 12px;
line-height: 20px;
max-width: 176px;
padding: 2px 8px;
}
.wrapperMedium {
font-size: 14px;
line-height: 32px;
max-width: 230px;
padding: 0 12px;
}
}