Skip to content

Commit

Permalink
Merge branch 'staging' into add-voting-validators-page
Browse files Browse the repository at this point in the history
  • Loading branch information
pdp2121 committed Nov 15, 2023
2 parents 62232b7 + a296037 commit c119f0a
Show file tree
Hide file tree
Showing 26 changed files with 1,262 additions and 151 deletions.
24 changes: 23 additions & 1 deletion public/locales/en-US/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@
"transaction_empty_title": "No transaction hash supplied",
"transaction_empty_hint": "Enter a transaction hash in the search box",
"validator_not_found": "Validator not found",
"check_transaction_hash": "Please check your transaction hash",
"check_transaction_hash": "Please check your transaction hash or CTID.",
"wrong_network": "This CTID applies to a different network.",
"check_validator_key": "Please check your validator key",
"transaction": "Transaction",
"success": "Success",
Expand Down Expand Up @@ -493,8 +494,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/>"
}
26 changes: 26 additions & 0 deletions public/locales/es-ES/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"transaction_empty_hint": "Introduce un hash de transacción en la caja de búsqueda",
"validator_not_found": "Validador no encontrado",
"check_transaction_hash": "Por favor, comprueba tu hash de transacción",
"wrong_network": null,
"check_validator_key": "Por favor, comprueba la clave de tu validador",
"transaction": "Transacción",
"success": "Éxito",
Expand Down Expand Up @@ -489,6 +490,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
}
22 changes: 22 additions & 0 deletions public/locales/fr-FR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
"transaction_empty_hint": "Entrez un hash de transaction dans la zone de recherche",
"validator_not_found": "Validateur non trouvé",
"check_transaction_hash": "Veuillez vérifier le hash de la transaction",
"wrong_network": null,
"check_validator_key": "Veuillez vérifier la clé du validateur",
"transaction": "Transaction",
"success": "Succès",
Expand Down Expand Up @@ -492,6 +493,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
}
22 changes: 22 additions & 0 deletions public/locales/ja-JP/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
"transaction_empty_hint": "検索欄にトランザクションハッシュを入力してください",
"validator_not_found": "バリデータが見つかりません",
"check_transaction_hash": "トランザクションのハッシュ値を確認してください",
"wrong_network": null,
"check_validator_key": "バリデータのキーを確認してください",
"transaction": "トランザクション",
"success": "成功",
Expand Down Expand Up @@ -491,6 +492,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
}
22 changes: 22 additions & 0 deletions public/locales/ko-KR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"transaction_empty_hint": "검색창에 트랜잭션 해시를 입력해 주세요",
"validator_not_found": "검증자를 찾을 수 없습니다",
"check_transaction_hash": "트랜잭션 해시를 확인해 주세요",
"wrong_network": null,
"check_validator_key": "검증자 키를 확인해주세요",
"transaction": "트랜잭션",
"success": "성공",
Expand Down Expand Up @@ -489,6 +490,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 c119f0a

Please sign in to comment.