diff --git a/packages/react-components/src/styles/components.ts b/packages/react-components/src/styles/components.ts index 767cb79cab..b4a1952be8 100644 --- a/packages/react-components/src/styles/components.ts +++ b/packages/react-components/src/styles/components.ts @@ -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 { diff --git a/packages/react-components/src/styles/form.ts b/packages/react-components/src/styles/form.ts index 36c6c43650..47d0c3dee1 100644 --- a/packages/react-components/src/styles/form.ts +++ b/packages/react-components/src/styles/form.ts @@ -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%; diff --git a/packages/react-components/src/styles/index.ts b/packages/react-components/src/styles/index.ts index 2030dec5d7..c0e7649617 100644 --- a/packages/react-components/src/styles/index.ts +++ b/packages/react-components/src/styles/index.ts @@ -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` +export default createGlobalStyle(({ 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` } .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` &.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` .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` } #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` } 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` body { height: 100%; margin: 0; - font-family: ${({ theme }) => theme.fontSans}; + font-family: ${theme.fontSans}; } br { @@ -331,8 +331,8 @@ export default createGlobalStyle` } 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` 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` } /* Add our overrides */ - ${cssSemantic} + ${cssSemantic(theme)} ${cssTheme} ${cssForm} ${cssMedia} ${cssRx} - ${cssComponents} -`; + ${cssComponents(theme)} +`); diff --git a/packages/react-components/src/styles/media.ts b/packages/react-components/src/styles/media.ts index 8805367fc5..62661bd844 100644 --- a/packages/react-components/src/styles/media.ts +++ b/packages/react-components/src/styles/media.ts @@ -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; diff --git a/packages/react-components/src/styles/rx.ts b/packages/react-components/src/styles/rx.ts index 7b245c65c4..410a40a5ba 100644 --- a/packages/react-components/src/styles/rx.ts +++ b/packages/react-components/src/styles/rx.ts @@ -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; diff --git a/packages/react-components/src/styles/semantic.ts b/packages/react-components/src/styles/semantic.ts index 71426b2024..d54fafbe0e 100644 --- a/packages/react-components/src/styles/semantic.ts +++ b/packages/react-components/src/styles/semantic.ts @@ -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}; } } diff --git a/packages/react-components/src/styles/theme.ts b/packages/react-components/src/styles/theme.ts index 1f2975a035..a2c7f0e805 100644 --- a/packages/react-components/src/styles/theme.ts +++ b/packages/react-components/src/styles/theme.ts @@ -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) {