Skip to content

Commit

Permalink
SupportView
Browse files Browse the repository at this point in the history
  • Loading branch information
nuuuwan committed Aug 7, 2024
1 parent cf444d0 commit fad3472
Show file tree
Hide file tree
Showing 10 changed files with 178 additions and 141 deletions.
52 changes: 26 additions & 26 deletions src/nonview/base/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// Auto-generated by add_indices.py
import AudioX from "./AudioX";
import Cache from "./Cache";
import DICTIONARY from "./DICTIONARY";
import DictUtils from "./DictUtils";
import I18N from "./I18N";
import IDX from "./IDX";
import MathX from "./MathX";
import Random from "./Random";
import TimeX from "./TimeX";
import URLContext from "./URLContext";
import WWW from "./WWW";

export {
AudioX,
Cache,
DICTIONARY,
DictUtils,
I18N,
IDX,
MathX,
Random,
TimeX,
URLContext,
WWW,
};
// Auto-generated by add_indices.py
import AudioX from './AudioX'
import Cache from './Cache'
import DICTIONARY from './DICTIONARY'
import DictUtils from './DictUtils'
import I18N from './I18N'
import IDX from './IDX'
import MathX from './MathX'
import Random from './Random'
import TimeX from './TimeX'
import URLContext from './URLContext'
import WWW from './WWW'

export {
AudioX,
Cache,
DICTIONARY,
DictUtils,
I18N,
IDX,
MathX,
Random,
TimeX,
URLContext,
WWW,
}
10 changes: 6 additions & 4 deletions src/nonview/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Auto-generated by add_indices.py
import VERSION from "./VERSION";

export { VERSION };
// Auto-generated by add_indices.py
import VERSION from './VERSION'

export {
VERSION,
}
8 changes: 7 additions & 1 deletion src/nonview/core/Party.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ const PARTY_D_LIST = [
{ id: "SLFP", color: "blue" },
{ id: "ITAK", color: "yellow" },
{ id: "NPP", color: "red" },

{ id: "JVP", color: "red" },
{ id: "UCPF", color: "#f40" },
{ id: "MEP", color: "red" },
{ id: "EPDP", color: "red" },
{ id: "TPA", color: "#f80" },
{ id: "Independent", color: "gray" },
{ id: "SLMC", color: "#041" },
{ id: "FSP", color: "red" },
];

const PARTY_LIST = PARTY_D_LIST.map((d) => Party.fromDict(d));
Expand Down
36 changes: 18 additions & 18 deletions src/nonview/core/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Auto-generated by add_indices.py
import Candidate from "./Candidate";
import Criterion from "./Criterion";
import GroundTruth from "./GroundTruth";
import HomePageContext from "./HomePageContext";
import Party from "./Party";
import Version from "./Version";
import Weight from "./Weight";

export {
Candidate,
Criterion,
GroundTruth,
HomePageContext,
Party,
Version,
Weight,
};
// Auto-generated by add_indices.py
import Candidate from './Candidate'
import Criterion from './Criterion'
import GroundTruth from './GroundTruth'
import HomePageContext from './HomePageContext'
import Party from './Party'
import Version from './Version'
import Weight from './Weight'

export {
Candidate,
Criterion,
GroundTruth,
HomePageContext,
Party,
Version,
Weight,
}
60 changes: 30 additions & 30 deletions src/view/atoms/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// Auto-generated by add_indices.py
import AlignCenter from "./AlignCenter";
import AlignRight from "./AlignRight";
import ButtonGoogleSearch from "./ButtonGoogleSearch";
import ButtonLinkedIn from "./ButtonLinkedIn";
import ButtonManthriLK from "./ButtonManthriLK";
import ButtonPage from "./ButtonPage";
import ButtonParliamentLK from "./ButtonParliamentLK";
import ButtonRandomWeights from "./ButtonRandomWeights";
import ButtonRefreshWeights from "./ButtonRefreshWeights";
import ButtonWikipedia from "./ButtonWikipedia";
import ButtonXTwitter from "./ButtonXTwitter";
import GenericButtonLink from "./GenericButtonLink";
import TimeView from "./TimeView";

export {
AlignCenter,
AlignRight,
ButtonGoogleSearch,
ButtonLinkedIn,
ButtonManthriLK,
ButtonPage,
ButtonParliamentLK,
ButtonRandomWeights,
ButtonRefreshWeights,
ButtonWikipedia,
ButtonXTwitter,
GenericButtonLink,
TimeView,
};
// Auto-generated by add_indices.py
import AlignCenter from './AlignCenter'
import AlignRight from './AlignRight'
import ButtonGoogleSearch from './ButtonGoogleSearch'
import ButtonLinkedIn from './ButtonLinkedIn'
import ButtonManthriLK from './ButtonManthriLK'
import ButtonPage from './ButtonPage'
import ButtonParliamentLK from './ButtonParliamentLK'
import ButtonRandomWeights from './ButtonRandomWeights'
import ButtonRefreshWeights from './ButtonRefreshWeights'
import ButtonWikipedia from './ButtonWikipedia'
import ButtonXTwitter from './ButtonXTwitter'
import GenericButtonLink from './GenericButtonLink'
import TimeView from './TimeView'

export {
AlignCenter,
AlignRight,
ButtonGoogleSearch,
ButtonLinkedIn,
ButtonManthriLK,
ButtonPage,
ButtonParliamentLK,
ButtonRandomWeights,
ButtonRefreshWeights,
ButtonWikipedia,
ButtonXTwitter,
GenericButtonLink,
TimeView,
}
7 changes: 3 additions & 4 deletions src/view/molecules/CandidateProfileView.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import PartyView from "./PartyView";

import AppColors from "../_constants/AppColors";
import { GroundTruth } from "../../nonview/core";
import SupportView from "./SupportView";

const AVATAR_SIZE = 48;

Expand All @@ -26,14 +27,12 @@ function ProfileTextView({ candidate }) {
</Typography>
<Typography sx={{ fontSize: "120%" }}>{t(candidate.lastName)}</Typography>
<Stack direction="row" gap={1} sx={{ alignItems: "center" }}>
<PartyView id={candidate.party} />
<PartyView partyCode={candidate.party} />
<Typography variant="caption" color={AppColors.MoreLight}>
{candidate.depositInfo}
</Typography>
</Stack>{" "}
<Typography variant="caption" color={AppColors.MoreLight}>
{candidate.support ? "Also supported by " + candidate.support : null}
</Typography>
<SupportView support={candidate.support} />
<Stack direction="row" gap={0} sx={{ alignItems: "center" }}>
<ButtonParliamentLK parliamentNum={candidate.parliamentNum} />
<ButtonManthriLK manthriLKID={candidate.manthriLKID} />
Expand Down
14 changes: 6 additions & 8 deletions src/view/molecules/PartyView.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ import Party from "../../nonview/core/Party";

import AlignCenter from "../../view/atoms/AlignCenter";

export default function PartyView({ id }) {
const party = Party.fromID(id);
export default function PartyView({ partyCode }) {
const partyId = partyCode.split("(")[0].trim();
const party = Party.fromID(partyId);
if (!party) {
throw new Error("Invalid party ID: " + id);
throw new Error("Invalid party ID: " + partyCode);
}
const color = party.color;
return (
<AlignCenter>
<Typography
variant="caption"
sx={{ color: "white", backgroundColor: color, p: 0.3, fontSize: "50%" }}
>
{t(id)}
<Typography variant="caption" sx={{ color }}>
{t(partyCode)}
</Typography>
</AlignCenter>
);
Expand Down
30 changes: 30 additions & 0 deletions src/view/molecules/SupportView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Stack, Typography, Divider } from "@mui/material";
import PartyView from "./PartyView";
import AppColors from "../_constants/AppColors";

export default function SupportView({ support }) {
if (!support) {
return null;
}
const partyCodeList = support.split(",").map((party) => party.trim());
return (
<Stack direction="row" gap={0.5}>
<Typography
variant="caption"
component="span"
color={AppColors.MoreLight}
>
Support from
</Typography>
<Stack
direction="row"
gap={0.5}
divider={<Divider orientation="vertical" flexItem variant="middle" />}
>
{partyCodeList.map(function (partyCode) {
return <PartyView key={partyCode} partyCode={partyCode} />;
})}
</Stack>{" "}
</Stack>
);
}
62 changes: 32 additions & 30 deletions src/view/molecules/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
// Auto-generated by add_indices.py
import CandidateProfileView from "./CandidateProfileView";
import CandidateView from "./CandidateView";
import CandidatesLeaderBoard from "./CandidatesLeaderBoard";
import CandidatesLeaderBoardShort from "./CandidatesLeaderBoardShort";
import CriteriaView from "./CriteriaView";
import CriterionToWeightView from "./CriterionToWeightView";
import CriterionView from "./CriterionView";
import CustomAppBar from "./CustomAppBar";
import GroundTruthView from "./GroundTruthView";
import HelpMenu from "./HelpMenu";
import HomePageBottomNavigation from "./HomePageBottomNavigation";
import PartyView from "./PartyView";
import WeightView from "./WeightView";

export {
CandidateProfileView,
CandidateView,
CandidatesLeaderBoard,
CandidatesLeaderBoardShort,
CriteriaView,
CriterionToWeightView,
CriterionView,
CustomAppBar,
GroundTruthView,
HelpMenu,
HomePageBottomNavigation,
PartyView,
WeightView,
};
// Auto-generated by add_indices.py
import CandidateProfileView from './CandidateProfileView'
import CandidateView from './CandidateView'
import CandidatesLeaderBoard from './CandidatesLeaderBoard'
import CandidatesLeaderBoardShort from './CandidatesLeaderBoardShort'
import CriteriaView from './CriteriaView'
import CriterionToWeightView from './CriterionToWeightView'
import CriterionView from './CriterionView'
import CustomAppBar from './CustomAppBar'
import GroundTruthView from './GroundTruthView'
import HelpMenu from './HelpMenu'
import HomePageBottomNavigation from './HomePageBottomNavigation'
import PartyView from './PartyView'
import SupportView from './SupportView'
import WeightView from './WeightView'

export {
CandidateProfileView,
CandidateView,
CandidatesLeaderBoard,
CandidatesLeaderBoardShort,
CriteriaView,
CriterionToWeightView,
CriterionView,
CustomAppBar,
GroundTruthView,
HelpMenu,
HomePageBottomNavigation,
PartyView,
SupportView,
WeightView,
}
40 changes: 20 additions & 20 deletions src/view/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Auto-generated by add_indices.py
import AbstractInnerPage from "./AbstractInnerPage";
import AbstractStepPage from "./AbstractStepPage";
import CandidatePage from "./CandidatePage";
import CriteriaPage from "./CriteriaPage";
import GroundTruthPage from "./GroundTruthPage";
import HomePage from "./HomePage";
import PAGE_CONFIG_LIST from "./PAGE_CONFIG_LIST";
import StartPage from "./StartPage";

export {
AbstractInnerPage,
AbstractStepPage,
CandidatePage,
CriteriaPage,
GroundTruthPage,
HomePage,
PAGE_CONFIG_LIST,
StartPage,
};
// Auto-generated by add_indices.py
import AbstractInnerPage from './AbstractInnerPage'
import AbstractStepPage from './AbstractStepPage'
import CandidatePage from './CandidatePage'
import CriteriaPage from './CriteriaPage'
import GroundTruthPage from './GroundTruthPage'
import HomePage from './HomePage'
import PAGE_CONFIG_LIST from './PAGE_CONFIG_LIST'
import StartPage from './StartPage'

export {
AbstractInnerPage,
AbstractStepPage,
CandidatePage,
CriteriaPage,
GroundTruthPage,
HomePage,
PAGE_CONFIG_LIST,
StartPage,
}

0 comments on commit fad3472

Please sign in to comment.