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

gov(fix): fix gov proposal markdown #1033

Merged
merged 2 commits into from
Jan 2, 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
3 changes: 1 addition & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"eslint-config-next": "13.5.2",
"jsonschema": "^1.4.1",
"lodash": "^4.17.21",
"markdown": "^0.5.0",
"mathjs": "^12.0.0",
"moment": "^2.29.4",
"next": "^14.0.1",
Expand All @@ -41,9 +40,9 @@
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.47.0",
"react-markdown": "^9.0.1",
"react-particles": "^2.12.2",
"react-redux": "^8.1.3",
"react-remark": "^2.1.0",
"react-router-dom": "^6.18.0",
"sharp": "^0.33.1",
"tailwindcss": "3.3.3",
Expand Down
32 changes: 22 additions & 10 deletions frontend/src/app/(routes)/governance/ProposalOverviewVote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import React, { useState, useEffect } from 'react';
import Image from 'next/image';
import Link from 'next/link';
import ReactMarkdown from 'react-markdown';
import ProposalViewRaw from './ProposalViewRaw';
import { RootState } from '@/store/store';
import CustomPieChart from './CustomPiechart';
Expand Down Expand Up @@ -30,6 +29,7 @@ import DepositPopup from './DepositPopup';
import { setSelectedNetwork } from '@/store/features/common/commonSlice';
import ProposalProjection from './ProposalProjection';
import TopNav from '@/components/TopNav';
import { useRemark } from 'react-remark';

const emptyTallyResult = {
yes: '',
Expand All @@ -52,6 +52,7 @@ const ProposalOverviewVote = ({
);

const chainID = nameToChainIDs[chainName];
const [proposalMarkdown, setProposalMarkdown] = useRemark();

const dispatch = useAppDispatch();
const proposalInfo = useAppSelector(
Expand Down Expand Up @@ -217,6 +218,11 @@ const ProposalOverviewVote = ({
}
}, [chainName]);

useEffect(() => {
const proposalDescription = get(proposalInfo, 'content.description', '');
setProposalMarkdown(proposalDescription.replace(/\\n/g, '\n'));
}, [proposalInfo]);

return (
<div className=" px-10 py-6">
<div className="flex gap-10 h-screen">
Expand Down Expand Up @@ -273,21 +279,25 @@ const ProposalOverviewVote = ({
</div>
<div className="space-y-6 mt-4">
<div className="font-bold text-[20px] leading-6">
<ReactMarkdown>
{get(proposalInfo, 'content.title') ||
get(proposalInfo, 'content.@type')}
</ReactMarkdown>
{get(proposalInfo, 'content.title') ||
get(proposalInfo, 'content.@type')}
</div>

<ReactMarkdown className="text-[#FFFFFFCC] leading-6 text-[16px]">
{get(proposalInfo, 'content.description')}
</ReactMarkdown>
<div
style={{
padding: 8,
whiteSpace: 'pre-line',
}}
className="proposal-description-markdown"
>
{proposalMarkdown}
</div>
</div>
<div
className=" view-full flex w-full justify-end items-end"
onClick={() => setShowRawData(true)}
>
View_Raw
View Raw
</div>
{showRawData && (
<ProposalViewRaw
Expand Down Expand Up @@ -376,7 +386,9 @@ const ProposalOverviewVote = ({
{quorumPercent ? (
<Tooltip title={`${quorumPercent}%`}>
<div className="flex w-full flex-col ">
<div style={{ width: `${quorumPercent.toString()}%` }}></div>
<div
style={{ width: `${quorumPercent.toString()}%` }}
></div>
<div className="flex flex-col items-center space-y-4">
<div className="flex flex-row space-x-2">
<div className="flex-row flex space-x-2">
Expand Down
35 changes: 34 additions & 1 deletion frontend/src/app/(routes)/governance/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
background-color: #8f8a8a1a;
}
.search-validator-input {
@apply w-full pl-2 border-none cursor-pointer focus:outline-none bg-transparent placeholder:text-[16px] placeholder:text-[#FFFFFFBF] ;
@apply w-full pl-2 border-none cursor-pointer focus:outline-none bg-transparent placeholder:text-[16px] placeholder:text-[#FFFFFFBF];
}
.amount-chip {
@apply opacity-80 rounded-lg text-[#E57575] text-center text-sm not-italic font-normal leading-[normal] max-w-fit py-1 px-2 truncate;
Expand All @@ -190,3 +190,36 @@
@apply rounded-2xl w-52 h-10 p-4 pb-8;
background: rgba(255, 255, 255, 0.1);
}

.proposal-description-markdown p,
.proposal-description-markdown h1,
.proposal-description-markdown h2,
.proposal-description-markdown ul,
.proposal-description-markdown ol {
margin: 0;
}

.proposal-description-markdown h1 {
@apply text-2xl font-bold;
}
.proposal-description-markdown h2 {
@apply text-xl font-bold;
}
.proposal-description-markdown h3 {
@apply text-lg font-bold;
}
.proposal-description-markdown a {
@apply text-blue-600 underline;
}

.proposal-description-markdown ol {
list-style: decimal;
list-style-position: inside;
margin-left: 1em;
}

.proposal-description-markdown ul {
list-style-type: disc;
list-style-position: inside;
margin-left: 1em;
}
Loading