Skip to content

Commit

Permalink
Chore: css
Browse files Browse the repository at this point in the history
  • Loading branch information
baomastr committed Jun 1, 2022
1 parent fd47db8 commit 1183040
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/v2/ProgressBar/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ValidProgressBar = () => (

export const ProgressBarWithCustomProgressColor = () => (
<ProgressBar
progressColorOverride="yellow"
successColor="yellow"
value={50}
step={5}
mark={75}
Expand Down
7 changes: 4 additions & 3 deletions src/components/v2/ProgressBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SliderTypeMap } from '@mui/material/Slider/Slider';

import { Tooltip, ITooltipProps } from '../Tooltip';
import { useStyles } from './styles';
import { PALETTE } from '../../../theme/MuiThemeProvider/muiTheme';

export interface IProgressBarProps {
value: number;
Expand All @@ -19,7 +20,7 @@ export interface IProgressBarProps {
markTooltip?: ITooltipProps['title'];
className?: string;
tooltipPlacement?: ITooltipProps['placement'];
progressColorOverride?: string;
successColor?: string;
}

export const ProgressBar = ({
Expand All @@ -34,15 +35,15 @@ export const ProgressBar = ({
markTooltip,
className,
tooltipPlacement = 'top',
progressColorOverride,
successColor = PALETTE.interactive.success,
}: IProgressBarProps) => {
const safeValue = value < max ? value : max;

const marks = mark ? [{ value: mark }] : undefined;
const styles = useStyles({
over: mark ? safeValue > mark : false,
secondaryOver: mark ? !!(secondaryValue && secondaryValue > mark) : false,
progressColorOverride,
successColor,
});

const renderMark = (props?: NonNullable<SliderTypeMap['props']['componentsProps']>['mark']) => (
Expand Down
15 changes: 5 additions & 10 deletions src/components/v2/ProgressBar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,25 @@ import { useTheme } from '@mui/material';
export const useStyles = ({
over,
secondaryOver,
progressColorOverride,
successColor,
}: {
over: boolean;
secondaryOver: boolean;
progressColorOverride?: string;
successColor: string;
}) => {
const theme = useTheme();
return {
slider: css`
display: block;
color: ${over ? theme.palette.interactive.error50 : theme.palette.interactive.success};
color: ${progressColorOverride};
color: ${over ? theme.palette.interactive.error50 : successColor};
background-color: ${theme.palette.background.default};
height: ${theme.spacing(2)};
padding: 0 !important;
&.Mui-disabled {
color: ${over ? theme.palette.interactive.error50 : theme.palette.interactive.success};
color: ${progressColorOverride};
color: ${over ? theme.palette.interactive.error50 : successColor};
}
.MuiSlider-track {
background-color: ${over
? theme.palette.interactive.error50
: theme.palette.interactive.success};
background-color: ${progressColorOverride};
background-color: ${over ? theme.palette.interactive.error50 : successColor};
height: ${theme.spacing(2)};
border-radius: ${theme.spacing(1)};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const ActiveVotingProgress: React.FC<IActiveVotingProgressProps> = ({
label: t('voteProposalUi.statusCard.against'),
value: getValueString(tokenId, votedAgainstWei),
progressBarProps: {
progressColorOverride: PALETTE.interactive.error50,
successColor: PALETTE.interactive.error50,
ariaLabel: t('voteProposalUi.statusCard.ariaLabelAgainst'),
value: getValueNumber(tokenId, votedAgainstWei),
},
Expand All @@ -82,7 +82,7 @@ export const ActiveVotingProgress: React.FC<IActiveVotingProgressProps> = ({
label: t('voteProposalUi.statusCard.abstain'),
value: getValueString(tokenId, abstainedWei),
progressBarProps: {
progressColorOverride: PALETTE.text.secondary,
successColor: PALETTE.text.secondary,
ariaLabel: t('voteProposalUi.statusCard.ariaLabelAbstain'),
value: getValueNumber(tokenId, abstainedWei),
},
Expand All @@ -92,7 +92,7 @@ export const ActiveVotingProgress: React.FC<IActiveVotingProgressProps> = ({
);

return (
<>
<div css={styles.votesWrapper}>
{activeProposalVotingData.map(({ id, label, value, progressBarProps }) => {
if (!value) {
return null;
Expand All @@ -112,6 +112,6 @@ export const ActiveVotingProgress: React.FC<IActiveVotingProgressProps> = ({
</React.Fragment>
);
})}
</>
</div>
);
};
6 changes: 6 additions & 0 deletions src/components/v2/VoteProposalUi/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const useStyles = () => {
cardHeader: css`
display: flex;
justify-content: space-between;
align-items: center;
`,
cardBadges: css`
/* TODO */
Expand Down Expand Up @@ -80,6 +81,11 @@ export const useStyles = () => {
`,

/* StatusCard styles */
votesWrapper: css`
display: flex;
flex-direction: column;
width: 100%;
`,
voteRow: css`
display: flex;
justify-content: space-between;
Expand Down

1 comment on commit 1183040

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🔴 Statements 38.24% 1812/4739
🔴 Branches 32.31% 724/2241
🔴 Functions 33.05% 471/1425
🔴 Lines 38.79% 1778/4584

Test suite run success

176 tests passing in 66 suites.

Report generated by 🧪jest coverage report action from 1183040

Please sign in to comment.