Skip to content

Commit

Permalink
fix: moved referendum name into description section
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Zhuravlev committed Aug 12, 2024
1 parent 1403a81 commit e2a7b27
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/renderer/features/governance/aggregates/details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const detailsAggregate = {
$timelines: timelineModel.$currentChainTimelines,
$votes: votingAggregate.$activeWalletVotes,
$proposers: proposerIdentityAggregate.$proposers,
$isTitlesLoading: titleModel.$isTitlesLoading,
$isTimelinesLoading: timelineModel.$isTimelineLoading,
$isProposersLoading: proposerIdentityAggregate.$isProposersLoading,
$isDescriptionLoading: descriptionsModel.$isDescriptionLoading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useStoreMap, useUnit } from 'effector-react';

import { type ChainId, type Referendum } from '@shared/core';
import { pickNestedValue } from '@shared/lib/utils';
import { Markdown, Shimmering } from '@shared/ui';
import { HeaderTitleText, Markdown, Shimmering } from '@shared/ui';
import { TrackInfo, referendumService } from '@entities/governance';
import { detailsAggregate } from '../../aggregates/details';

Expand All @@ -19,29 +19,39 @@ export const ProposalDescription = ({ chainId, addressPrefix, referendum }: Prop
const description = useStoreMap({
store: detailsAggregate.$descriptions,
keys: [chainId, referendum.referendumId],
fn: (x, [chainId, index]) => pickNestedValue(x, chainId, index),
fn: (descriptions, [chainId, index]) => pickNestedValue(descriptions, chainId, index),
});

const isTitlesLoading = useUnit(detailsAggregate.$isTitlesLoading);
const title = useStoreMap({
store: detailsAggregate.$titles,
keys: [referendum.referendumId],
fn: (titles, [index]) => titles[index],
});

return (
<div>
<div className="mb-4 flex items-center">
<div className="flex flex-col gap-4">
<div className="flex items-center">
<ProposerName referendum={referendum} addressPrefix={addressPrefix} />
<div className="grow" />
{referendumService.isOngoing(referendum) && <TrackInfo trackId={referendum.track} />}
</div>

{isDescriptionLoading && (
<div className="flex flex-col gap-4">
<Shimmering height={44} />
<div className="flex flex-col gap-4">
<HeaderTitleText className="text-balance">
{isTitlesLoading ? <Shimmering height="1em" /> : title}
</HeaderTitleText>

{isDescriptionLoading && (
<div className="flex flex-col gap-3">
<Shimmering height={18} />
<Shimmering height={18} width={240} />
<Shimmering height={300} />
</div>
</div>
)}
)}

{!isDescriptionLoading && description && <Markdown>{description}</Markdown>}
{!isDescriptionLoading && description && <Markdown>{description}</Markdown>}
</div>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ export const ReferendumDetailsDialog = ({ chain, referendum, onVoteRequest, onCl
const votingAsset = useUnit(detailsAggregate.$votingAsset);
const canVote = useUnit(detailsAggregate.$canVote);

const title = useStoreMap({
store: detailsAggregate.$titles,
keys: [referendum.referendumId],
fn: (titles, [referendumId]) => titles[referendumId] ?? '',
});

const votes = useStoreMap({
store: detailsAggregate.$votes,
keys: [referendum.referendumId],
Expand All @@ -63,7 +57,7 @@ export const ReferendumDetailsDialog = ({ chain, referendum, onVoteRequest, onCl
return (
<BaseModal
isOpen={isModalOpen}
title={title || t('governance.referendums.referendumTitle', { index: referendum.referendumId })}
title={t('governance.referendums.referendumTitle', { index: referendum.referendumId })}
contentClass="min-h-0 h-full w-full bg-main-app-background overflow-y-auto"
panelClass="flex flex-col w-[944px] h-[678px]"
headerClass="pl-5 pr-3 py-4 shrink-0"
Expand Down
19 changes: 14 additions & 5 deletions src/renderer/shared/ui/Markdown/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@ const remarkPlugins: Options['remarkPlugins'] = [remarkGfm];

const components: Components = {
h1: ({ node: _, className, ...props }) => (
<h1 className={cnTw('mt-6 border-b pb-2 text-large-title', className)} {...props} />
<h1
className={cnTw('text-balance border-b pb-2 text-button-small [&:not(:first-child)]:mt-6', className)}
{...props}
/>
),
h2: ({ node: _, className, ...props }) => (
<h2 className={cnTw('text-balance text-header-title [&:not(:first-child)]:mt-4', className)} {...props} />
),
h3: ({ node: _, className, ...props }) => (
<h3 className={cnTw('text-balance text-footnote [&:not(:first-child)]:mt-2', className)} {...props} />
),
h4: ({ node: _, className, ...props }) => (
<h4 className={cnTw('text-balance text-small-title [&:not(:first-child)]:mt-2', className)} {...props} />
),
h2: ({ node: _, className, ...props }) => <h2 className={cnTw('mt-4 text-title', className)} {...props} />,
h3: ({ node: _, className, ...props }) => <h3 className={cnTw('mt-2 text-medium-title', className)} {...props} />,
h4: ({ node: _, className, ...props }) => <h4 className={cnTw('mt-2 text-small-title', className)} {...props} />,
ul: ({ node: _, className, ...props }) => (
<ul
className={cnTw(
Expand Down Expand Up @@ -55,7 +64,7 @@ const components: Components = {
</InfoLink>
),
p: ({ node: _, className, ...props }) => (
<BodyText as="p" className={cnTw('overflow-hidden overflow-ellipsis', className)} {...props} />
<BodyText as="p" className={cnTw('overflow-hidden overflow-ellipsis text-balance', className)} {...props} />
),
hr: () => <hr className="bg-current" />,
input: ({ node: _, type, ...props }) => (type === 'checkbox' ? <Checkbox {...props} /> : <input {...props} />),
Expand Down

0 comments on commit e2a7b27

Please sign in to comment.