Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: styles update #2126

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
"react-helmet-async": "^2.0.3",
"react-hook-form": "^7.45.2",
"react-hooks-visible": "^1.1.1",
"react-intersection-observer": "^9.8.2",
"react-intl": "^6.6.1",
"react-modal": "^3.15.1",
"react-popper": "^2.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const UserHubButton: FC = () => {
splitWalletAddress(walletAddress ?? ADDRESS_ZERO);

return (
<div ref={ref}>
<div ref={ref} className="flex-shrink-0">
<Button
mode="tertiary"
size="large"
Expand All @@ -155,11 +155,12 @@ const UserHubButton: FC = () => {
)}
onClick={handleButtonClick}
>
<div className="flex items-center">
<div className="flex flex-shrink-0 items-center">
{/* If there's a user, there's a wallet */}
{walletAddress ? (
<>
<UserAvatar
className="flex-shrink-0"
userAvatarSrc={user?.profile?.avatar ?? undefined}
userName={userName}
userAddress={wallet.address}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ const MemberReputation: FC<MemberReputationProps> = ({
{percentageReputation === ZeroValue.NearZero && percentageReputation}
{percentageReputation &&
percentageReputation !== ZeroValue.NearZero && (
<Numeral value={percentageReputation} suffix=" %" />
<>
<Numeral value={percentageReputation} />%
</>
)}
</span>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/shared/Extensions/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const displayName = 'Extensions.Tooltip';
const Tooltip: FC<PropsWithChildren<TooltipProps>> = ({
children,
tooltipContent,
tooltipStyle,
Copy link
Member

Choose a reason for hiding this comment

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

This is not the right approach here, as we are already passing in a className prop, that just sets classes on the wrapper. Plus we have isSuccess and isFullWidthContent which are just switches for yet more styles

The solution here is to refactor Tooltip to accept either themes, or the className prop to be more configurable and account for all the places we need to customize styles.

Otherwise, we'll just end up jamming in various props when we need to customize more things (like the arrow color for example)

Copy link
Contributor

Choose a reason for hiding this comment

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

I couldn't make it work using className, it had to be done by styles.

placement = 'auto',
popperOptions,
interactive,
Expand Down Expand Up @@ -68,6 +69,7 @@ const Tooltip: FC<PropsWithChildren<TooltipProps>> = ({
'bg-gray-900 [&_a]:underline': !isSuccess,
},
),
style: tooltipStyle,
})}
>
<div
Expand Down
1 change: 1 addition & 0 deletions src/components/shared/Extensions/Tooltip/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { type PopperOptions, type TriggerType } from 'react-popper-tooltip';

export interface TooltipProps {
tooltipContent: ReactNode;
tooltipStyle?: React.CSSProperties;
trigger?: TriggerType | TriggerType[] | null;
placement?: PlacementType;
offset?: [number, number];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const PermissionSidebar: FC<PermissionSidebarProps> = ({ transactionId }) => {
id: 'action.executed.permissions.description',
}),
iconAlignment: 'top',
textClassName: 'text-4',
textClassName: 'text-4 text-gray-900',
}}
sections={[
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MotionState as NetworkMotionState } from '@colony/colony-js';
import { ThumbsDown, ThumbsUp } from '@phosphor-icons/react';
import { left as LeftPlacementType } from '@popperjs/core';
import { right as RightPlacementType } from '@popperjs/core';
import clsx from 'clsx';
import { BigNumber } from 'ethers';
import React, { type FC, useEffect, useMemo, useState } from 'react';
Expand Down Expand Up @@ -114,7 +114,7 @@ const Motions: FC<MotionsProps> = ({ transactionId }) => {
networkMotionState,
motionData,
),
placement: LeftPlacementType,
placement: RightPlacementType,
className: 'z-10',
},
},
Expand Down Expand Up @@ -145,7 +145,7 @@ const Motions: FC<MotionsProps> = ({ transactionId }) => {
networkMotionState,
motionData,
),
placement: LeftPlacementType,
placement: RightPlacementType,
className: 'z-10',
},
},
Expand Down Expand Up @@ -180,7 +180,7 @@ const Motions: FC<MotionsProps> = ({ transactionId }) => {
networkMotionState,
motionData,
),
placement: LeftPlacementType,
placement: RightPlacementType,
className: 'z-10',
},
},
Expand Down Expand Up @@ -244,7 +244,7 @@ const Motions: FC<MotionsProps> = ({ transactionId }) => {
networkMotionState,
motionData,
),
placement: LeftPlacementType,
placement: RightPlacementType,
className: 'z-10',
},
},
Expand All @@ -269,7 +269,7 @@ const Motions: FC<MotionsProps> = ({ transactionId }) => {
networkMotionState,
motionData,
),
placement: LeftPlacementType,
placement: RightPlacementType,
className: 'z-10',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,28 @@ const ExitRecoveryStep: FC = () => {
<MenuWithStatusText
statusTextSectionProps={{
status: StatusTypes.Info,
children: formatText(
{ id: 'motion.exitRecovery.statusText' },
{ signatures: 2 },
children: (
<>
<p className="text-4">
{formatText(
{ id: 'motion.exitRecovery.statusText' },
{ signatures: 2 },
)}
</p>
<ProgressBar
progress={0}
progressLabel={formatText(
{
id: 'motion.exitRecovery.additionalText',
},
{ signatures: 2 },
)}
max={2}
className="mt-2"
/>
</>
),
textClassName: 'text-4',
iconAlignment: 'top',
content: (
<ProgressBar
progress={0}
additionalText={formatText(
{
id: 'motion.exitRecovery.additionalText',
},
{ signatures: 2 },
)}
max={2}
className="ml-1"
/>
),
}}
sections={[
{
Expand Down Expand Up @@ -107,7 +110,7 @@ const ExitRecoveryStep: FC = () => {
children: formatText({
id: 'motion.exitRecovery.storageSlots.statusText',
}),
textClassName: 'text-4',
textClassName: 'text-4 text-gray-900',
iconAlignment: 'top',
}}
sections={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const FinalizeStep: FC<FinalizeStepProps> = ({
? 'motion.finalizeStep.failed.statusText'
: 'motion.finalizeStep.statusText',
}),
textClassName: 'text-4',
textClassName: 'text-4 text-gray-900',
iconAlignment: 'top',
content: (
<div />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ const getOutcomeStepTitle = (

const OutcomeStep: FC<OutcomeStepProps> = ({ motionData }) => {
const { wallet } = useAppContext();
const { voteStatuses } = useOutcomeStep(motionData);
const { voteStatuses, stakingData } = useOutcomeStep(motionData);
const { stakers, stakeVoteStatuses } = stakingData || {};

const voters: UserAvatarsItem[] =
motionData?.voterRecord.map((voter) => ({
Expand All @@ -73,6 +74,8 @@ const OutcomeStep: FC<OutcomeStepProps> = ({ motionData }) => {
? MotionVote.Yay
: MotionVote.Nay;

const showVotingData = voters.length !== 0;

return (
<MenuWithSections
sections={[
Expand All @@ -83,7 +86,10 @@ const OutcomeStep: FC<OutcomeStepProps> = ({ motionData }) => {
<h3 className="mb-4 text-center text-1">
{formatText(getOutcomeStepTitle(currentUserVote, winningSide))}
</h3>
<VoteStatuses items={voteStatuses} voters={voters} />
<VoteStatuses
items={showVotingData ? voteStatuses : stakeVoteStatuses || []}
voters={showVotingData ? voters : stakers || []}
/>
</div>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useMemo } from 'react';

import { type ColonyMotion } from '~types/graphql.ts';
import { MotionVote } from '~utils/colonyMotions.ts';
import { type UserAvatarsItem } from '~v5/shared/UserAvatars/types.ts';

import { supportOption, opposeOption } from '../../consts.ts';

Expand Down Expand Up @@ -34,7 +35,55 @@ export const useOutcomeStep = (motionData: ColonyMotion | null | undefined) => {
];
}, [motionData]);

const stakingData = useMemo(() => {
if (!motionData) return undefined;

const { usersStakes } = motionData;

const stakers = usersStakes.flatMap((userStakes) => {
const { address, stakes } = userStakes;

const yay = Number(stakes.percentage.yay);
const nay = Number(stakes.percentage.nay);
const addresses: UserAvatarsItem[] = [];

if (yay > 0) {
addresses.push({ address, voteCount: '1', vote: MotionVote.Yay });
}

if (nay > 0) {
addresses.push({ address, voteCount: '1', vote: MotionVote.Nay });
}

return addresses;
});

// 100 is hardcoded because in userStakes total wasn't 100% (it was like 98%). Probably because of rounding.
const stakeVoteStatuses: VoteStatuses[] = [
{
key: supportOption.id,
icon: supportOption.icon,
label: supportOption.label || '',
progress: 100,
status: MotionVote.Yay,
},
{
key: opposeOption.id,
icon: opposeOption.icon,
label: opposeOption.label || '',
progress: 100,
status: MotionVote.Nay,
},
];

return {
stakers,
stakeVoteStatuses,
};
}, [motionData]);

return {
voteStatuses,
stakingData,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const VoteStatuses: FC<VoteStatusesProps> = ({ items, voters }) => {
);

return (
<div className="flex flex-col gap-5">
<div className="grid grid-cols-[1fr_auto] gap-8">
{items.map(({ key, icon: Icon, label, progress, status }) => (
<div key={key} className="flex w-full items-center gap-8">
<div className="flex max-w-[182px] grow flex-col gap-1">
<React.Fragment key={key}>
<div className="flex w-full grow flex-col gap-1">
<span className="flex items-start gap-[0.375rem]">
<Icon
className={clsx('h-[1em] w-[1em] text-[1.125rem]', {
Expand All @@ -51,8 +51,8 @@ const VoteStatuses: FC<VoteStatusesProps> = ({ items, voters }) => {
</span>
<ProgressBar
progress={progress}
progressLabel={`${progress}%`}
max={100}
additionalText="%"
barClassName={clsx({
'bg-purple-200': status === MotionVote.Yay,
'bg-negative-300': status === MotionVote.Nay,
Expand All @@ -72,7 +72,7 @@ const VoteStatuses: FC<VoteStatusesProps> = ({ items, voters }) => {
size={26}
/>
)}
</div>
</React.Fragment>
))}
</div>
);
Expand Down
Loading
Loading