Cleanup style expansion (#3943)
* cleanup style expansion * ThemeDef * Don't create unneeded objects Co-authored-by: Jaco Greeff <jacogr@gmail.com>
This commit is contained in:
parent
b9058fbf17
commit
08196d3093
@ -1,13 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/react-components authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ThemeProps } from '../types';
|
||||
import { ThemeDef } from '../types';
|
||||
|
||||
import { css } from 'styled-components';
|
||||
|
||||
export default css`
|
||||
export default (theme: ThemeDef): string => `
|
||||
.ui--output {
|
||||
background: ${({ theme }: ThemeProps) => theme.bgInput};
|
||||
background: ${theme.bgInput};
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #eee;
|
||||
box-sizing: border-box;
|
||||
@ -19,7 +17,7 @@ export default css`
|
||||
word-break: break-all;
|
||||
|
||||
&.error {
|
||||
background: ${({ theme }: ThemeProps) => theme.bgInputError};
|
||||
background: ${theme.bgInputError};
|
||||
border-color: #e0b4b4;
|
||||
}
|
||||
|
||||
@ -52,7 +50,7 @@ export default css`
|
||||
}
|
||||
|
||||
button.ui--Button {
|
||||
font-family: ${({ theme }: ThemeProps) => theme.fontSans};
|
||||
font-family: ${theme.fontSans};
|
||||
}
|
||||
|
||||
.editable {
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/react-components authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { css } from 'styled-components';
|
||||
|
||||
export default css`
|
||||
export default `
|
||||
.ui--grid,
|
||||
.ui--row {
|
||||
width: 100%;
|
||||
|
||||
@ -22,12 +22,12 @@ const PARTS = [0, 2, 4];
|
||||
|
||||
const defaultHighlight = '#f19135'; // '#f19135'; // #999
|
||||
|
||||
function getHighlight ({ uiHighlight }: Props): string {
|
||||
function getHighlight (uiHighlight: string | undefined): string {
|
||||
return (uiHighlight || defaultHighlight);
|
||||
}
|
||||
|
||||
function getContrast (props: Props): string {
|
||||
const hc = getHighlight(props).replace('#', '').toLowerCase();
|
||||
function getContrast (uiHighlight: string | undefined): string {
|
||||
const hc = getHighlight(uiHighlight).replace('#', '').toLowerCase();
|
||||
const brightness = PARTS.reduce((b, p, index) => b + (parseInt(hc.substr(p, 2), 16) * FACTORS[index]), 0);
|
||||
|
||||
return brightness > BRIGHTNESS
|
||||
@ -35,36 +35,36 @@ function getContrast (props: Props): string {
|
||||
: 'rgba(255, 253, 251, 0.875)';
|
||||
}
|
||||
|
||||
export default createGlobalStyle<Props & ThemeProps>`
|
||||
export default createGlobalStyle<Props & ThemeProps>(({ theme, uiHighlight }: Props & ThemeProps) => `
|
||||
.highlight--all {
|
||||
background: ${getHighlight} !important;
|
||||
border-color: ${getHighlight} !important;
|
||||
color: ${getHighlight} !important;
|
||||
background: ${getHighlight(uiHighlight)} !important;
|
||||
border-color: ${getHighlight(uiHighlight)} !important;
|
||||
color: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.highlight--before:before {
|
||||
background: ${getHighlight} !important;
|
||||
background: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.highlight--before-border:before {
|
||||
border-color: ${getHighlight} !important;
|
||||
border-color: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.highlight--bg {
|
||||
background: ${getHighlight} !important;
|
||||
background: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.highlight--bg-contrast {
|
||||
background: ${getContrast};
|
||||
background: ${getContrast(uiHighlight)};
|
||||
}
|
||||
|
||||
.highlight--bg-faint,
|
||||
.highlight--bg-light {
|
||||
background: ${({ theme }) => theme.bgTable};
|
||||
background: ${theme.bgTable};
|
||||
position: relative;
|
||||
|
||||
&:before {
|
||||
background: ${getHighlight};
|
||||
background: ${getHighlight(uiHighlight)};
|
||||
bottom: 0;
|
||||
content: ' ';
|
||||
left: 0;
|
||||
@ -84,74 +84,74 @@ export default createGlobalStyle<Props & ThemeProps>`
|
||||
}
|
||||
|
||||
.highlight--border {
|
||||
border-color: ${getHighlight} !important;
|
||||
border-color: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.highlight--color {
|
||||
color: ${getHighlight} !important;
|
||||
color: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.highlight--color-contrast {
|
||||
color: ${getContrast};
|
||||
color: ${getContrast(uiHighlight)};
|
||||
}
|
||||
|
||||
.highlight--fill {
|
||||
fill: ${getHighlight} !important;
|
||||
fill: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.highlight--gradient {
|
||||
background: ${({ uiHighlight }: Props) => `linear-gradient(90deg, ${uiHighlight || defaultHighlight}, transparent)`};
|
||||
background: ${`linear-gradient(90deg, ${uiHighlight || defaultHighlight}, transparent)`};
|
||||
}
|
||||
|
||||
.highlight--hover-bg:hover {
|
||||
background: ${getHighlight} !important;
|
||||
background: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.highlight--hover-color:hover {
|
||||
color: ${getHighlight} !important;
|
||||
color: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.highlight--icon {
|
||||
.ui--Icon {
|
||||
color: ${getHighlight} !important;
|
||||
color: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
}
|
||||
|
||||
.highlight--shadow {
|
||||
box-shadow: 0 0 1px ${getHighlight} !important;
|
||||
box-shadow: 0 0 1px ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.highlight--stroke {
|
||||
stroke: ${getHighlight} !important;
|
||||
stroke: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
|
||||
.ui--Button {
|
||||
&:not(.isDisabled):not(.isIcon):not(.isBasic),
|
||||
&.withoutLink:not(.isDisabled) {
|
||||
.ui--Icon {
|
||||
background: ${getHighlight};
|
||||
color: ${getContrast};
|
||||
background: ${getHighlight(uiHighlight)};
|
||||
color: ${getContrast(uiHighlight)};
|
||||
}
|
||||
}
|
||||
|
||||
&.isBasic:not(.isDisabled):not(.isIcon):not(.isSelected) {
|
||||
&:not(.isReadOnly) {
|
||||
box-shadow: 0 0 1px ${getHighlight};
|
||||
box-shadow: 0 0 1px ${getHighlight(uiHighlight)};
|
||||
}
|
||||
|
||||
.ui--Icon {
|
||||
color: ${getHighlight};
|
||||
color: ${getHighlight(uiHighlight)};
|
||||
}
|
||||
}
|
||||
|
||||
&.isSelected {
|
||||
box-shadow: 0 0 1px ${getHighlight};
|
||||
box-shadow: 0 0 1px ${getHighlight(uiHighlight)};
|
||||
}
|
||||
|
||||
&:hover:not(.isDisabled):not(.isReadOnly),
|
||||
&.isSelected {
|
||||
background: ${getHighlight};
|
||||
color: ${getContrast};
|
||||
background: ${getHighlight(uiHighlight)};
|
||||
color: ${getContrast(uiHighlight)};
|
||||
text-shadow: none;
|
||||
|
||||
&:not(.isIcon),
|
||||
@ -168,13 +168,13 @@ export default createGlobalStyle<Props & ThemeProps>`
|
||||
&.withoutLink:not(.isDisabled) {
|
||||
&:hover {
|
||||
.ui--Icon {
|
||||
color: ${getContrast};
|
||||
color: ${getContrast(uiHighlight)};
|
||||
}
|
||||
}
|
||||
|
||||
.ui--Icon {
|
||||
background: transparent;
|
||||
color: ${getHighlight};
|
||||
color: ${getHighlight(uiHighlight)};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -183,29 +183,29 @@ export default createGlobalStyle<Props & ThemeProps>`
|
||||
.theme--light {
|
||||
.ui--Tabs {
|
||||
.ui--Tab.tabLinkActive {
|
||||
border-bottom-color: ${getHighlight};
|
||||
border-bottom-color: ${getHighlight(uiHighlight)};
|
||||
}
|
||||
}
|
||||
|
||||
.ui.primary.button,
|
||||
.ui.buttons .primary.button {
|
||||
background: ${getHighlight};
|
||||
background: ${getHighlight(uiHighlight)};
|
||||
|
||||
&.active,
|
||||
&:active,
|
||||
&:focus,
|
||||
&:hover {
|
||||
background-color: ${getHighlight};
|
||||
background-color: ${getHighlight(uiHighlight)};
|
||||
}
|
||||
}
|
||||
|
||||
.ui--Toggle.isChecked {
|
||||
&:not(.isRadio) {
|
||||
.ui--Toggle-Slider {
|
||||
background-color: ${getHighlight} !important;
|
||||
background-color: ${getHighlight(uiHighlight)} !important;
|
||||
|
||||
&:before {
|
||||
border-color: ${getHighlight} !important;
|
||||
border-color: ${getHighlight(uiHighlight)} !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,9 +213,9 @@ export default createGlobalStyle<Props & ThemeProps>`
|
||||
}
|
||||
|
||||
#root {
|
||||
background: ${({ theme }) => theme.bgPage};
|
||||
color: ${({ theme }) => theme.color};
|
||||
font-family: ${({ theme }) => theme.fontSans};
|
||||
background: ${theme.bgPage};
|
||||
color: ${theme.color};
|
||||
font-family: ${theme.fontSans};
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ export default createGlobalStyle<Props & ThemeProps>`
|
||||
}
|
||||
|
||||
article {
|
||||
background: ${({ theme }) => theme.bgTable};
|
||||
background: ${theme.bgTable};
|
||||
border: 1px solid #f2f2f2;
|
||||
border-radius: 0.25rem;
|
||||
box-sizing: border-box;
|
||||
@ -300,7 +300,7 @@ export default createGlobalStyle<Props & ThemeProps>`
|
||||
body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
font-family: ${({ theme }) => theme.fontSans};
|
||||
font-family: ${theme.fontSans};
|
||||
}
|
||||
|
||||
br {
|
||||
@ -331,8 +331,8 @@ export default createGlobalStyle<Props & ThemeProps>`
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
color: ${({ theme }) => theme.colorSummary};
|
||||
font-family: ${({ theme }) => theme.fontSans};
|
||||
color: ${theme.colorSummary};
|
||||
font-family: ${theme.fontSans};
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
@ -364,9 +364,9 @@ export default createGlobalStyle<Props & ThemeProps>`
|
||||
|
||||
label {
|
||||
box-sizing: border-box;
|
||||
color: ${({ theme }) => theme.colorLabel};
|
||||
color: ${theme.colorLabel};
|
||||
display: block;
|
||||
font-family: ${({ theme }) => theme.fontSans};
|
||||
font-family: ${theme.fontSans};
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
}
|
||||
@ -378,10 +378,10 @@ export default createGlobalStyle<Props & ThemeProps>`
|
||||
}
|
||||
|
||||
/* Add our overrides */
|
||||
${cssSemantic}
|
||||
${cssSemantic(theme)}
|
||||
${cssTheme}
|
||||
${cssForm}
|
||||
${cssMedia}
|
||||
${cssRx}
|
||||
${cssComponents}
|
||||
`;
|
||||
${cssComponents(theme)}
|
||||
`);
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/react-components authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { css } from 'styled-components';
|
||||
|
||||
export default css`
|
||||
export default `
|
||||
.media--2000 {
|
||||
@media only screen and (max-width: 2000px) {
|
||||
display: none !important;
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/react-components authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { css } from 'styled-components';
|
||||
|
||||
export default css`
|
||||
export default `
|
||||
.rx--updated {
|
||||
background: #ffffe0 !important;
|
||||
transition: all 0.7s ease-out;
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/react-components authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ThemeProps } from '../types';
|
||||
import { ThemeDef } from '../types';
|
||||
|
||||
import { css } from 'styled-components';
|
||||
|
||||
export default css`
|
||||
export default (theme: ThemeDef): string => `
|
||||
.ui.hidden.divider {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
@ -24,13 +22,13 @@ export default css`
|
||||
.ui.selection.dropdown,
|
||||
.ui.input > input,
|
||||
.ui.selection.dropdown > input {
|
||||
background: ${({ theme }: ThemeProps) => theme.bgInput};
|
||||
color: ${({ theme }: ThemeProps) => theme.color};
|
||||
font-family: ${({ theme }: ThemeProps) => theme.fontSans};
|
||||
background: ${theme.bgInput};
|
||||
color: ${theme.color};
|
||||
font-family: ${theme.fontSans};
|
||||
|
||||
&:focus {
|
||||
background: ${({ theme }: ThemeProps) => theme.bgInput};
|
||||
color: ${({ theme }: ThemeProps) => theme.color};
|
||||
background: ${theme.bgInput};
|
||||
color: ${theme.color};
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,17 +48,17 @@ export default css`
|
||||
}
|
||||
|
||||
&.selection.visible {
|
||||
background: ${({ theme }: ThemeProps) => theme.bgInput};
|
||||
color: ${({ theme }: ThemeProps) => theme.color};
|
||||
background: ${theme.bgInput};
|
||||
color: ${theme.color};
|
||||
}
|
||||
|
||||
.menu {
|
||||
background: ${({ theme }: ThemeProps) => theme.bgInput};
|
||||
color: ${({ theme }: ThemeProps) => theme.color};
|
||||
background: ${theme.bgInput};
|
||||
color: ${theme.color};
|
||||
|
||||
> .item {
|
||||
border-color: transparent !important;
|
||||
color: ${({ theme }: ThemeProps) => theme.color} !important;
|
||||
color: ${theme.color} !important;
|
||||
|
||||
&.header.disabled {
|
||||
margin: 1em 0 0 0;
|
||||
@ -68,7 +66,7 @@ export default css`
|
||||
|
||||
&:hover,
|
||||
&.selected {
|
||||
background: ${({ theme }: ThemeProps) => theme.bgInput};
|
||||
background: ${theme.bgInput};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -78,7 +76,7 @@ export default css`
|
||||
min-height: 1em;
|
||||
|
||||
&:not(.default) {
|
||||
color: ${({ theme }: ThemeProps) => theme.color} !important;
|
||||
color: ${theme.color} !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,7 +105,7 @@ export default css`
|
||||
}
|
||||
|
||||
&.error input {
|
||||
background-color: ${({ theme }: ThemeProps) => theme.bgInputError};
|
||||
background-color: ${theme.bgInputError};
|
||||
border-color: #e0b4b4;
|
||||
}
|
||||
|
||||
@ -124,10 +122,10 @@ export default css`
|
||||
}
|
||||
|
||||
.ui.modal {
|
||||
background: ${({ theme }: ThemeProps) => theme.bgPage};
|
||||
background: ${theme.bgPage};
|
||||
box-shadow: none;
|
||||
color: ${({ theme }: ThemeProps) => theme.color};
|
||||
font-family: ${({ theme }: ThemeProps) => theme.fontSans};
|
||||
color: ${theme.color};
|
||||
font-family: ${theme.fontSans};
|
||||
|
||||
> .actions,
|
||||
> .content {
|
||||
@ -144,8 +142,8 @@ export default css`
|
||||
> .header:not(.ui) {
|
||||
background: transparent;
|
||||
border-bottom: none;
|
||||
color: ${({ theme }: ThemeProps) => theme.colorSummary};
|
||||
font-family: ${({ theme }: ThemeProps) => theme.fontSans};
|
||||
color: ${theme.colorSummary};
|
||||
font-family: ${theme.fontSans};
|
||||
font-size: 1.75rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.25rem;
|
||||
@ -168,11 +166,11 @@ export default css`
|
||||
}
|
||||
|
||||
.ui.popup {
|
||||
background: ${({ theme }: ThemeProps) => theme.bgMenu};
|
||||
color: ${({ theme }: ThemeProps) => theme.color};
|
||||
background: ${theme.bgMenu};
|
||||
color: ${theme.color};
|
||||
|
||||
.ui.text.menu .item {
|
||||
color: ${({ theme }: ThemeProps) => theme.color};
|
||||
color: ${theme.color};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/react-components authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { css } from 'styled-components';
|
||||
|
||||
/* default buttons, dark gray */
|
||||
export const colorBtnDefault = '#767778';
|
||||
|
||||
@ -19,7 +17,7 @@ export const colorBtnText = '#f9f8f7';
|
||||
|
||||
export const colorLink = '#2e86ab';
|
||||
|
||||
export default css`
|
||||
export default `
|
||||
.theme--dark,
|
||||
.theme--light {
|
||||
a:not(.ui--Tab) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user