-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from LMacPhail/sort-by-winning-likelihood
Sort by winning likelihood
- Loading branch information
Showing
16 changed files
with
131 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const TextLink: React.FC<{ children: React.ReactNode; link: string }> = ({ | ||
children, | ||
link, | ||
}) => ( | ||
<a className="text-link" href={link} target="_blank" rel="noreferrer"> | ||
{children} | ||
</a> | ||
); | ||
|
||
export default TextLink; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,54 @@ | ||
import React from "react"; | ||
import { SearchInput } from "../SearchInput"; | ||
import React, { useState } from "react"; | ||
import { useDispatch } from "react-redux"; | ||
import { SET_SORTBY_ACTION } from "../../state/actions"; | ||
import TextLink from "../atoms/Link"; | ||
|
||
export const Filters: React.FC = () => { | ||
return ( | ||
<div className=""> | ||
<SearchInput /> | ||
</div> | ||
); | ||
}; | ||
|
||
// type SelectedSortDirection = "ascending" | "descending"; | ||
type SelectedSortDirection = "ascending" | "descending"; | ||
const DESCENDING_OPT_TEXT = "Most Likely"; | ||
const ASCENDING_OPT_TEXT = "Least Likely"; | ||
|
||
// TODO: Not make this break everything | ||
// const SortByDropdown: React.FC = () => { | ||
// const dispatch = useDispatch(); | ||
// const profiles = useSelector((state: AppState) => state.data.profiles); | ||
export const SortByDropdown: React.FC = () => { | ||
const dispatch = useDispatch(); | ||
|
||
// const [sortDirection, setSortDirection] = useState< | ||
// SelectedSortDirection | undefined | ||
// >(undefined); | ||
const [sortDirection, setSortDirection] = useState< | ||
SelectedSortDirection | undefined | ||
>("descending"); | ||
|
||
// const handleSelectChange = (value: SelectedSortDirection) => { | ||
// const sortedProfiles = sortByWin(profiles, value === "descending"); | ||
// dispatch({ | ||
// type: SET_DATA_ACTION, | ||
// payload: { profiles: sortedProfiles, status: "complete" }, | ||
// }); | ||
// setSortDirection(value); | ||
// }; | ||
const handleSelectChange = (value: SelectedSortDirection) => { | ||
dispatch({ | ||
type: SET_SORTBY_ACTION, | ||
payload: { descending: value === "descending" }, | ||
}); | ||
setSortDirection(value); | ||
}; | ||
|
||
// return ( | ||
// <select | ||
// className="select select-ghost-primary" | ||
// value={sortDirection} | ||
// onChange={(event) => | ||
// handleSelectChange(event.target.value as SelectedSortDirection) | ||
// } | ||
// aria-label="sort profiles" | ||
// > | ||
// {sortDirection === undefined && ( | ||
// <option>Sort by chance of winning</option> | ||
// )} | ||
// <option>Most Likely to Win</option> | ||
// <option>Least Likely to Win</option> | ||
// </select> | ||
// ); | ||
// }; | ||
return ( | ||
<div> | ||
<span className="text-xs"> | ||
Sort by likeliness to win:{" "} | ||
<TextLink link="https://www.electoralcalculus.co.uk/"> | ||
(source) | ||
</TextLink> | ||
</span> | ||
<select | ||
className="select select-ghost-primary select-sm" | ||
value={ | ||
sortDirection === "descending" | ||
? DESCENDING_OPT_TEXT | ||
: ASCENDING_OPT_TEXT | ||
} | ||
onChange={(event) => | ||
handleSelectChange( | ||
event.target.value === DESCENDING_OPT_TEXT | ||
? "descending" | ||
: "ascending" | ||
) | ||
} | ||
aria-label="sort profiles" | ||
> | ||
<option key={"descending"}>{DESCENDING_OPT_TEXT}</option> | ||
<option key={"ascending"}>{ASCENDING_OPT_TEXT}</option> | ||
</select> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,31 @@ | ||
import React from "react"; | ||
import TextLink from "../atoms/Link"; | ||
import { GithubLogo } from "@phosphor-icons/react"; | ||
|
||
// TODO: Make templates for some of these links that get reused | ||
export const Footer: React.FC = () => { | ||
return ( | ||
<div className="text-sm flex flex-col gap-2"> | ||
<div className="divider"></div> | ||
<p> | ||
Built by volunteers at the{" "} | ||
<a | ||
className="text-link" | ||
href="http://mvmtresearch.org" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Movement Research Unit. | ||
</a> | ||
<TextLink link="http://mvmtresearch.org"> | ||
Movement Research Unit | ||
</TextLink> | ||
. | ||
</p> | ||
<p>Questions or changes: [email protected]</p> | ||
<a | ||
className="text-link" | ||
href="https://donate.stripe.com/bIY6rig2w5ohat24gg" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
<TextLink link="https://donate.stripe.com/bIY6rig2w5ohat24gg"> | ||
Support our work. | ||
</a> | ||
<a | ||
className="text-link" | ||
href="https://go.mvmtresearch.org/join" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Get involved. | ||
</a> | ||
</TextLink> | ||
<TextLink link="https://go.mvmtresearch.org/join">Get involved.</TextLink> | ||
<TextLink link="https://github.com/LMacPhail/labour-mru"> | ||
<span className="flex flex-row gap-2 items-center"> | ||
Contribute on Github{" "} | ||
<span> | ||
<GithubLogo size={18} /> | ||
</span> | ||
</span> | ||
</TextLink> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.