Skip to content

Commit

Permalink
Merge pull request #1786 from decentdao/reskin-1695-countdown-timer-w…
Browse files Browse the repository at this point in the history
…idth

`Reskin` Moves ProposalCountdown from the Badge component
  • Loading branch information
adamgall authored May 15, 2024
2 parents 6e1c7bf + c5bc25b commit 5f25eba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
5 changes: 5 additions & 0 deletions src/components/Proposals/ProposalCard/ProposalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ActivityDescription } from '../../Activity/ActivityDescription';
import { Badge } from '../../ui/badges/Badge';
import QuorumBadge from '../../ui/badges/QuorumBadge';
import { SnapshotIcon } from '../../ui/badges/Snapshot';
import { ProposalCountdown } from '../../ui/proposal/ProposalCountdown';

function ProposalCard({ proposal }: { proposal: FractalProposal }) {
const {
Expand Down Expand Up @@ -66,7 +67,11 @@ function ProposalCard({ proposal }: { proposal: FractalProposal }) {
<Badge
labelKey={proposal.state!}
size="sm"
/>
<ProposalCountdown
proposal={proposal}
showIcon={false}
textColor="neutral-7"
/>
{isSnapshotProposal && (
<Box ml={1}>
Expand Down
9 changes: 7 additions & 2 deletions src/components/Proposals/ProposalInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Badge } from '../ui/badges/Badge';
import { SnapshotButton } from '../ui/badges/Snapshot';
import { ModalType } from '../ui/modals/ModalProvider';
import { useFractalModal } from '../ui/modals/useFractalModal';
import { ProposalCountdown } from '../ui/proposal/ProposalCountdown';
import ProposalExecutableCode from '../ui/proposal/ProposalExecutableCode';
import CeleryButtonWithIcon from '../ui/utils/CeleryButtonWithIcon';

Expand All @@ -36,16 +37,20 @@ export function ProposalInfo({
padding="1.5rem"
>
<Flex
gap={4}
gap={2}
alignItems="center"
>
{proposal.state && (
<Badge
size="base"
labelKey={proposal.state}
proposal={proposal}
/>
)}
<ProposalCountdown
proposal={proposal}
showIcon={false}
textColor="neutral-7"
/>
{isSnapshotProposal && (
<>
<SnapshotButton snapshotENS={`${daoSnapshotENS}/proposal/${proposal.proposalId}`} />
Expand Down
14 changes: 2 additions & 12 deletions src/components/ui/badges/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Box, Flex, Text, Tooltip } from '@chakra-ui/react';
import { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { TOOLTIP_MAXW } from '../../../constants/common';
import { FractalProposalState, DAOState, FractalProposal } from '../../../types';
import { ProposalCountdown } from '../proposal/ProposalCountdown';
import { FractalProposalState, DAOState } from '../../../types';

type BadgeType = {
tooltipKey?: string;
Expand Down Expand Up @@ -109,10 +108,9 @@ interface IBadge {
size: Size;
labelKey: keyof typeof BADGE_MAPPING;
children?: ReactNode;
proposal?: FractalProposal;
}

export function Badge({ labelKey, children, size, proposal }: IBadge) {
export function Badge({ labelKey, children, size }: IBadge) {
const { tooltipKey, ...colors } = BADGE_MAPPING[labelKey];
const sizes = BADGE_SIZES[size];

Expand Down Expand Up @@ -147,14 +145,6 @@ export function Badge({ labelKey, children, size, proposal }: IBadge) {
>
{children || t(labelKey)}
</Text>
{proposal && (
<ProposalCountdown
proposal={proposal}
showIcon={false}
textColor={colors.textColor}
textStyle="label-base"
/>
)}
</Flex>
</Tooltip>
);
Expand Down
4 changes: 1 addition & 3 deletions src/components/ui/proposal/ProposalCountdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ export function ProposalCountdown({
proposal,
showIcon = true,
textColor = 'white-0',
textStyle = 'label-base', // previous default
}: {
proposal: FractalProposal;
showIcon?: boolean;
// custom text color and style
textColor?: string;
textStyle?: string;
}) {
const totalSecondsLeft = useProposalCountdown(proposal);
const { t } = useTranslation('proposal');
Expand Down Expand Up @@ -91,7 +89,7 @@ export function ProposalCountdown({
>
<Text
color={textColor}
textStyle={textStyle}
textStyle="label-base"
>
{showDays && `${zeroPad(daysLeft)}:`}
{showHours && `${zeroPad(hoursLeft)}:`}
Expand Down

0 comments on commit 5f25eba

Please sign in to comment.