Merge pull request #1345 from 0xProject/fix/instant/progress-bar-bg
[instant] Progress bar background
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
import { transparentize } from 'polished';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { PROGRESS_FINISH_ANIMATION_TIME_MS, PROGRESS_STALL_AT_WIDTH } from '../constants';
|
import { PROGRESS_FINISH_ANIMATION_TIME_MS, PROGRESS_STALL_AT_WIDTH } from '../constants';
|
||||||
import { ColorOption, css, keyframes, styled } from '../style/theme';
|
import { ColorOption, css, keyframes, styled, ThemeConsumer } from '../style/theme';
|
||||||
|
|
||||||
import { Container } from './ui/container';
|
import { Container } from './ui/container';
|
||||||
|
|
||||||
@@ -93,8 +94,16 @@ export interface ProgressBarProps extends ProgressProps {}
|
|||||||
|
|
||||||
export const ProgressBar: React.ComponentType<ProgressBarProps & React.ClassAttributes<{}>> = React.forwardRef(
|
export const ProgressBar: React.ComponentType<ProgressBarProps & React.ClassAttributes<{}>> = React.forwardRef(
|
||||||
(props, ref) => (
|
(props, ref) => (
|
||||||
<Container width="100%" backgroundColor={ColorOption.lightGrey} borderRadius="6px">
|
<ThemeConsumer>
|
||||||
<Progress {...props} ref={ref as any} />
|
{theme => (
|
||||||
</Container>
|
<Container
|
||||||
|
width="100%"
|
||||||
|
borderRadius="6px"
|
||||||
|
rawBackgroundColor={transparentize(0.5, theme[ColorOption.primaryColor])}
|
||||||
|
>
|
||||||
|
<Progress {...props} ref={ref as any} />
|
||||||
|
</Container>
|
||||||
|
)}
|
||||||
|
</ThemeConsumer>
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@@ -27,6 +27,7 @@ export interface ContainerProps {
|
|||||||
borderBottom?: string;
|
borderBottom?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
backgroundColor?: ColorOption;
|
backgroundColor?: ColorOption;
|
||||||
|
rawBackgroundColor?: string;
|
||||||
hasBoxShadow?: boolean;
|
hasBoxShadow?: boolean;
|
||||||
zIndex?: number;
|
zIndex?: number;
|
||||||
whiteSpace?: string;
|
whiteSpace?: string;
|
||||||
@@ -38,6 +39,16 @@ export interface ContainerProps {
|
|||||||
flexGrow?: string | number;
|
flexGrow?: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getBackgroundColor = (theme: any, backgroundColor?: ColorOption, rawBackgroundColor?: string): string => {
|
||||||
|
if (backgroundColor) {
|
||||||
|
return theme[backgroundColor] as string;
|
||||||
|
}
|
||||||
|
if (rawBackgroundColor) {
|
||||||
|
return rawBackgroundColor;
|
||||||
|
}
|
||||||
|
return 'none';
|
||||||
|
};
|
||||||
|
|
||||||
export const Container =
|
export const Container =
|
||||||
styled.div <
|
styled.div <
|
||||||
ContainerProps >
|
ContainerProps >
|
||||||
@@ -70,7 +81,7 @@ export const Container =
|
|||||||
${props => props.width && stylesForMedia<string>('width', props.width)}
|
${props => props.width && stylesForMedia<string>('width', props.width)}
|
||||||
${props => props.height && stylesForMedia<string>('height', props.height)}
|
${props => props.height && stylesForMedia<string>('height', props.height)}
|
||||||
${props => props.borderRadius && stylesForMedia<string>('border-radius', props.borderRadius)}
|
${props => props.borderRadius && stylesForMedia<string>('border-radius', props.borderRadius)}
|
||||||
background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')};
|
background-color: ${props => getBackgroundColor(props.theme, props.backgroundColor, props.rawBackgroundColor)};
|
||||||
border-color: ${props => (props.borderColor ? props.theme[props.borderColor] : 'none')};
|
border-color: ${props => (props.borderColor ? props.theme[props.borderColor] : 'none')};
|
||||||
&:hover {
|
&:hover {
|
||||||
${props =>
|
${props =>
|
||||||
|
@@ -1,6 +1,14 @@
|
|||||||
import * as styledComponents from 'styled-components';
|
import * as styledComponents from 'styled-components';
|
||||||
|
|
||||||
const { default: styled, css, keyframes, withTheme, createGlobalStyle, ThemeProvider } = styledComponents;
|
const {
|
||||||
|
default: styled,
|
||||||
|
css,
|
||||||
|
keyframes,
|
||||||
|
withTheme,
|
||||||
|
createGlobalStyle,
|
||||||
|
ThemeConsumer,
|
||||||
|
ThemeProvider,
|
||||||
|
} = styledComponents;
|
||||||
|
|
||||||
export type Theme = { [key in ColorOption]: string };
|
export type Theme = { [key in ColorOption]: string };
|
||||||
|
|
||||||
@@ -45,4 +53,4 @@ export const generateOverlayBlack = (opacity = 0.6) => {
|
|||||||
return `rgba(0, 0, 0, ${opacity})`;
|
return `rgba(0, 0, 0, ${opacity})`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export { styled, css, keyframes, withTheme, createGlobalStyle, ThemeProvider };
|
export { styled, css, keyframes, withTheme, createGlobalStyle, ThemeConsumer, ThemeProvider };
|
||||||
|
Reference in New Issue
Block a user