Skip to content

Commit

Permalink
feat: add amendment summary page (#855)
Browse files Browse the repository at this point in the history
## High Level Overview of Change

<!--
Please include a summary/list of the changes.
If too broad, please consider splitting into multiple PRs.
-->

The page would include:

- Information about the amendment
- List of voted Yes and No validators (for amendments in voting)
- A graph showing distribution of votes broken down by UNL and non-UNL
validators (for amendments in voting)

This PR would also include search by Amendment Id/Name

### Type of Change

<!--
Please check relevant options, delete irrelevant ones.
-->

- [x] New feature (non-breaking change which adds functionality)

## Before / After

<!--
If just refactoring / back-end changes, this can be just an in-English
description of the change at a technical level.
If a UI change, screenshots should be included.
-->

### Amendment in voting (Desktop)

![localhost_3001_amendment_Clawback
(1)](https://github.com/ripple/explorer/assets/71317875/81e6bf71-29fa-4556-8234-46dff0810579)



### Amendment in voting (Mobile)


![localhost_3001_amendment_Clawback(iPhone 12 Pro)
(1)](https://github.com/ripple/explorer/assets/71317875/b0c21b47-3cbb-492a-88de-5a35b6e9faae)



### Amendment enabled
![Screenshot 2023-10-03 at 7 09 56
PM](https://github.com/ripple/explorer/assets/71317875/74f282ba-d181-4a0d-9f87-ef7f3c3cd772)

### Chart legend

<img width="1294" alt="Screenshot 2023-10-04 at 11 49 39 AM"
src="https://github.com/ripple/explorer/assets/71317875/819d8a40-11a2-49f2-8784-e1d0568a965b">

### Footnote

<img width="1298" alt="Screenshot 2023-10-04 at 4 36 09 PM"
src="https://github.com/ripple/explorer/assets/71317875/4437b640-90d0-486e-8251-3241bab171d2">
  • Loading branch information
pdp2121 authored Nov 15, 2023
1 parent 020cb60 commit a296037
Show file tree
Hide file tree
Showing 20 changed files with 1,129 additions and 1 deletion.
21 changes: 21 additions & 0 deletions public/locales/en-US/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,29 @@
"namespace": "Namespace",
"api_version": "API Version",
"triggered_on": "Triggered On",
"name": "name",
"amendment_id": "Amendment ID",
"introduced_in": "Introduced In",
"threshold": "threshold",
"voting": "Voting",
"yeas": "yeas",
"nays": "nays",
"eta": "eta",
"consensus": "consensus",
"amendment_summary": "Amendment Summary",
"not": "not",
"enabled": "Enabled",
"tx": "tx",
"all": "all",
"yeas_count": "# of Yea Votes: {{yeas_count}}",
"nays_count": "# of Nay Votes: {{nays_count}}",
"no_of_validators": "# of Validators",
"amendment_not_found": "Amendment not found",
"check_amendment_key": "Please check your amendment key",
"did_document": "DID Document",
"attestation": "Attestation",
"note": "Note",
"indicate_unl": "indicates a validator on an UNL",
"transaction_tokens_involved": "<Currency/> and <Currency2/>",
"transaction_tokens_swapped": "<Currency/> for <Currency2/>"
}
25 changes: 25 additions & 0 deletions public/locales/es-ES/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,31 @@
"namespace": "Espacio de Nombres",
"api_version": "Versión API",
"triggered_on": "Activado En",
"name": null,
"amendment_id": null,
"introduced_in": null,
"threshold": null,
"voting": null,
"yeas": null,
"nays": null,
"eta": null,
"consensus": null,
"amendment_summary": null,
"not_enabled": null,
"enabled": null,
"enabled_on": null,
"tx": null,
"yeas_all": null,
"nays_all": null,
"yeas_unl": null,
"nays_unl": null,
"yeas_count": null,
"nays_count": null,
"no_of_validators": null,
"amendment_not_found": null,
"check_amendment_key": null,
"note": null,
"indicate_unl": null,
"transaction_tokens_involved": null,
"transaction_tokens_swapped": null
}
21 changes: 21 additions & 0 deletions public/locales/fr-FR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,27 @@
"namespace": "Espace de noms",
"api_version": "Version API",
"triggered_on": "Déclenché Par",
"name": null,
"amendment_id": null,
"introduced_in": null,
"threshold": null,
"voting": null,
"yeas": null,
"nays": null,
"eta": null,
"consensus": null,
"amendment_summary": null,
"enabled": null,
"not": null,
"tx": null,
"all": null,
"yeas_count": null,
"nays_count": null,
"no_of_validators": null,
"amendment_not_found": null,
"check_amendment_key": null,
"note": null,
"indicate_unl": null,
"transaction_tokens_involved": null,
"transaction_tokens_swapped": null
}
21 changes: 21 additions & 0 deletions public/locales/ja-JP/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,27 @@
"namespace": "ネームスペース",
"api_version": "APIバージョン",
"triggered_on": null,
"name": null,
"amendment_id": null,
"introduced_in": null,
"threshold": null,
"voting": null,
"yeas": null,
"nays": null,
"eta": null,
"consensus": null,
"amendment_summary": null,
"enabled": null,
"not": null,
"tx": null,
"all": null,
"yeas_count": null,
"nays_count": null,
"no_of_validators": null,
"amendment_not_found": null,
"check_amendment_key": null,
"note": null,
"indicate_unl": null,
"transaction_tokens_involved": null,
"transaction_tokens_swapped": null
}
21 changes: 21 additions & 0 deletions public/locales/ko-KR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,27 @@
"namespace": "Namespace",
"api_version": "API 버전",
"triggered_on": "Triggered On",
"name": null,
"amendment_id": null,
"introduced_in": null,
"threshold": null,
"voting": null,
"yeas": null,
"nays": null,
"eta": null,
"consensus": null,
"amendment_summary": null,
"enabled": null,
"not": null,
"tx": null,
"all": null,
"yeas_count": null,
"nays_count": null,
"no_of_validators": null,
"amendment_not_found": null,
"check_amendment_key": null,
"note": null,
"indicate_unl": null,
"transaction_tokens_involved": null,
"transaction_tokens_swapped": null
}
146 changes: 146 additions & 0 deletions src/containers/Amendment/BarChartVoting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import {
BarChart,
Bar,
XAxis,
YAxis,
Tooltip,
TooltipProps,
Label,
ResponsiveContainer,
// Text,
// Cell,
} from 'recharts'
import {
BLACK_600,
GREEN_400,
GREY_0,
GREY_600,
GREY_800,
MAGENTA_500,
} from '../shared/utils'

interface Props {
data: any
}

type ValueType = number | string | Array<number | string>
type NameType = number | string

const CustomTooltip = ({
active,
payload,
label,
}: TooltipProps<ValueType, NameType>) => {
const { t } = useTranslation()
if (active) {
return (
<div className="custom-tooltip">
<p className="label">{label}</p>
<p className="value">
{t('yeas_count', {
yeas_count: payload ? payload[0].payload.yeas : 0,
})}
</p>
<p className="value">
{t('nays_count', {
nays_count: payload ? payload[0].payload.nays : 0,
})}
</p>
</div>
)
}
return null
}

const CustomLegend = () => {
const { t } = useTranslation()
return (
<div className="custom-legend">
<div className="legend-color">
<div className="segment">
<span className="icon yea" />
<span className="text">{t('yeas')}</span>
</div>
<div className="segment">
<span className="icon nay" />
<span className="text">{t('nays')}</span>
</div>
</div>
</div>
)
}

export const BarChartVoting = ({ data }: Props) => {
const { t } = useTranslation()
const [showTooltips, setShowTooltips] = useState(false)

return (
<div className="barchart">
<CustomLegend />
<ResponsiveContainer height={532} width="100%">
<BarChart
data={data}
margin={{ top: 5, right: 20, bottom: 5, left: 0 }}
>
<XAxis
dataKey="label"
dy={12}
height={90}
tickLine={false}
minTickGap={-1}
stroke={BLACK_600}
interval={0}
tick={{ fill: GREY_0 }}
/>
<YAxis
className="yAxis"
tickLine={false}
stroke={BLACK_600}
tick={{ fill: GREY_0 }}
>
<Label
className="y-label"
value={t('no_of_validators')}
angle={-90}
position="insideTop"
dx={45}
dy={55}
style={{ fill: GREY_0 }}
/>
</YAxis>
<Bar
dataKey="yeas"
barSize={30}
fill={GREEN_400}
radius={[4, 4, 0, 0]}
isAnimationActive={false}
onMouseOver={() => setShowTooltips(true)}
onMouseLeave={() => setShowTooltips(false)}
/>
<Bar
dataKey="nays"
barSize={30}
fill={MAGENTA_500}
radius={[4, 4, 0, 0]}
isAnimationActive={false}
onMouseOver={() => setShowTooltips(true)}
onMouseLeave={() => setShowTooltips(false)}
/>
<Tooltip
content={CustomTooltip}
cursor={false}
offset={-10}
wrapperStyle={{
backgroundColor: GREY_600,
borderRadius: 8,
border: `1px solid ${GREY_800}`,
opacity: showTooltips ? '100%' : '0',
}}
/>
</BarChart>
</ResponsiveContainer>
</div>
)
}
Loading

0 comments on commit a296037

Please sign in to comment.