Skip to content

Commit

Permalink
tauri certs + styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Plebtech committed Jan 21, 2023
1 parent e4a5371 commit 18dd320
Show file tree
Hide file tree
Showing 32 changed files with 1,087 additions and 33,582 deletions.
Binary file added .DS_Store
Binary file not shown.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ packages/seeds/**/*.js

firebase-export-*

!**/**/.gitkeep
!**/**/.gitkeep

# Added by cargo

/target
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "sway"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
14,209 changes: 299 additions & 13,910 deletions functions/package-lock.json

Large diffs are not rendered by default.

19,830 changes: 459 additions & 19,371 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,24 @@
"lint": "npx eslint -c .eslintrc.js --ignore-path .eslintignore '**/*'",
"TAURI": "",
"tauri": "tauri",
"tauri:start:emulate": "REACT_APP_EMULATE=1 tauri dev",
"SCRIPTS PACKAGE": "",
"scripts:congress:emulate": "npm -C ./packages/scripts run congress:emulate",
"scripts:congress:dev": "npm -C ./packages/scripts congress:dev"
},
"devDependencies": {
"@tauri-apps/cli": "^1.2.2",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"@tauri-apps/cli": "^1.2.3",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"autoprefixer": "10.4.5",
"eslint": "^8.31.0",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.26.0",
"eslint": "^8.32.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-unused-imports": "^2.0.0",
"npm-check-updates": "^16.6.2",
"prettier": "^2.8.3",
"source-map-explorer": "^2.5.3",
"typescript": "^4.9.4"
},
"dependencies": {
"fire": "file:../fire"
}
}
3 changes: 1 addition & 2 deletions packages/fire/src/fire_users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ class FireUsers extends AbstractFireSway {
...data,
createdAt: data.createdAt
? data.createdAt instanceof Timestamp
? // @t-ignore
data.createdAt.toDate()
? data?.createdAt?.toDate()
: data.createdAt
: new Date(),
updatedAt: new Date(),
Expand Down
16 changes: 8 additions & 8 deletions packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"@sentry/tracing": "^7.31.1",
"@sway/constants": "file:../constants",
"@sway/fire": "file:../fire",
"bootstrap": "^5.2.3",
"chart.js": "^4.1.2",
"bootstrap": "^5.3.0-alpha1",
"chart.js": "^4.2.0",
"copy-to-clipboard": "^3.3.3",
"emoji-name-map": "^1.2.9",
"firebase": "^9.15.0",
"firebase": "^9.16.0",
"formik": "^2.2.9",
"immer": "^9.0.18",
"lodash.get": "^4.4.2",
Expand All @@ -30,8 +30,8 @@
"react-icons": "^4.7.1",
"react-markdown": "^8.0.5",
"react-redux": "^8.0.5",
"react-router": "^6.6.2",
"react-router-dom": "^6.6.2",
"react-router": "^6.7.0",
"react-router-dom": "^6.7.0",
"react-scripts": "^5.0.1",
"react-select": "^5.7.0",
"react-simple-animate": "^3.5.2",
Expand Down Expand Up @@ -75,11 +75,11 @@
"devDependencies": {
"@sway/utils": "file:../utils",
"@types/bootstrap": "^5.2.6",
"@types/jest": "^29.2.5",
"@types/jest": "^29.2.6",
"@types/lodash": "^4.14.191",
"@types/lodash.get": "^4.4.7",
"@types/node": "^16.18.11",
"@types/react": "^18.0.26",
"@types/react": "^18.0.27",
"@types/react-bootstrap": "^0.32.32",
"@types/react-datepicker": "^4.8.0",
"@types/react-dom": "^18.0.10",
Expand All @@ -97,7 +97,7 @@
"eslint-plugin-unused-imports": "^2.0.0",
"npm-check-updates": "^16.6.2",
"sass": "^1.57.1",
"snyk": "^1.1087.0",
"snyk": "^1.1088.0",
"source-map-explorer": "^2.5.3",
"typescript": "^4.9.4"
}
Expand Down
59 changes: 26 additions & 33 deletions packages/webapp/src/components/bill/Bill.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
/** @format */
import Image from "react-bootstrap/Image";
import {
CONGRESS_LOCALE,
DEFAULT_ORGANIZATION,
ROUTES,
VOTING_WEBSITES_BY_LOCALE,
} from "@sway/constants";
import { findLocale, isEmptyObject, logDev, titleize, userLocaleFromLocales } from "@sway/utils";
import { Timestamp } from "firebase/firestore";
import { useEffect, useMemo, useState } from "react";
import { Navbar } from "react-bootstrap";
import Image from "react-bootstrap/Image";
import { FiExternalLink } from "react-icons/fi";
import { useNavigate, useParams } from "react-router-dom";
import { sway } from "sway";
import { useBill } from "../../hooks/bills";
import { useCancellable } from "../../hooks/cancellable";
import { anonymousSignIn } from "../../users/signinAnonymously";
import { handleError, IS_MOBILE_PHONE } from "../../utils";
import FullWindowLoading from "../dialogs/FullWindowLoading";
import { handleError } from "../../utils";
import FullScreenLoading from "../dialogs/FullScreenLoading";
import ShareButtons from "../social/ShareButtons";
import { ILocaleUserProps } from "../user/UserRouter";
import VoteButtonsContainer from "../uservote/VoteButtonsContainer";
import BillActionLinks from "./BillActionLinks";
import BillArguments from "./BillArguments";
import BillSummaryAudio from "./BillSummaryAudio";
import BillSummaryModal from "./BillSummaryModal";
import BillChartsContainer from "./charts/BillChartsContainer";
import BillMobileChartsContainer from "./charts/BillMobileChartsContainer";
import { FiExternalLink } from "react-icons/fi";
import { Timestamp } from "firebase/firestore";

interface IProps extends ILocaleUserProps {
bill: sway.IBill;
Expand Down Expand Up @@ -87,11 +87,11 @@ const Bill: React.FC<IProps> = ({ locale, user, bill, organizations, userVote, i
const selectedUserVote = hookedBill?.userVote || userVote;
if (!selectedBill) {
logDev("BILL.tsx - NO SELECTED BILL");
return <FullWindowLoading message={"Loading Bill..."} />;
return <FullScreenLoading message={"Loading Bill..."} />;
}
if (user && !user.locales && !user.isAnonymous) {
logDev("BILL.tsx - LOADING USER");
return <FullWindowLoading message={"Loading Bill..."} />;
return <FullScreenLoading message={"Loading Bill..."} />;
}

const handleNavigate = (pathname: string) => {
Expand Down Expand Up @@ -131,23 +131,13 @@ const Bill: React.FC<IProps> = ({ locale, user, bill, organizations, userVote, i
const userLocale = user && userLocaleFromLocales(user, locale.name);
if (!userLocale) return null;

if (IS_MOBILE_PHONE) {
return (
<BillMobileChartsContainer
bill={selectedBill}
userLocale={userLocale}
userVote={selectedUserVote}
/>
);
} else {
return (
<BillChartsContainer
bill={selectedBill}
userLocale={userLocale}
userVote={selectedUserVote}
/>
);
}
return (
<BillMobileChartsContainer
bill={selectedBill}
userLocale={userLocale}
userVote={selectedUserVote}
/>
);
})();

const { summary } = getSummary();
Expand Down Expand Up @@ -189,9 +179,10 @@ const Bill: React.FC<IProps> = ({ locale, user, bill, organizations, userVote, i
return b.createdAt;
} else if (typeof b.createdAt === "string") {
return new Date(b.createdAt);
} else if (typeof b.createdAt === "object" && "seconds" in b.createdAt) {
return new Date(Number((b.createdAt as { seconds: number }).seconds * 1000));
} else {
// @ts-ignore
return (b.createdAt as Timestamp).toDate();
return (b.createdAt as Timestamp)?.toDate();
}
};

Expand Down Expand Up @@ -257,12 +248,14 @@ const Bill: React.FC<IProps> = ({ locale, user, bill, organizations, userVote, i
<div className="col">
<div className="row">
<div className="col">
<div className="row align-items-center">
<div className="col-2 pe-0" style={{ maxWidth: 100 }}>
<Image roundedCircle thumbnail src="/logo300.png" />
</div>
<div className="col-10 bold">Sway Summary</div>
</div>
<Navbar.Brand>
<Image
src={"/logo300.png"}
style={{ maxWidth: 30 }}
className="d-inline-block align-top"
/>
<span className="ms-2">Sway</span>
</Navbar.Brand>
{selectedLocale && selectedBill?.summaries?.swayAudioBucketPath && (
<BillSummaryAudio
localeName={selectedLocale.name}
Expand Down
4 changes: 2 additions & 2 deletions packages/webapp/src/components/bill/BillOfTheWeek.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useBillOfTheWeek } from "../../hooks/bills";
import { useCancellable } from "../../hooks/cancellable";
import { anonymousSignIn } from "../../users/signinAnonymously";
import { handleError, localSet } from "../../utils";
import FullWindowLoading from "../dialogs/FullWindowLoading";
import FullScreenLoading from "../dialogs/FullScreenLoading";
import LocaleSelector from "../user/LocaleSelector";
import { ILocaleUserProps } from "../user/UserRouter";
import Bill from "./Bill";
Expand Down Expand Up @@ -91,7 +91,7 @@ const BillOfTheWeek: React.FC<ILocaleUserProps> = ({ user }) => {
};

if (isLoading()) {
return <FullWindowLoading message="Loading Bill of the Week..." />;
return <FullScreenLoading message="Loading Bill of the Week..." />;
}

// Handled in isLoading but Typescript doesn't recognize that
Expand Down
5 changes: 4 additions & 1 deletion packages/webapp/src/components/bill/BillsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { getUserLocales, isEmptyObject } from "@sway/utils";
import React, { useEffect, useState } from "react";
import { Animate } from "react-simple-animate";
import { sway } from "sway";
import { useLocale } from "../../hooks";
import { useBills } from "../../hooks/bills";
Expand Down Expand Up @@ -93,7 +94,9 @@ const BillsList: React.FC<ILocaleUserProps> = ({ user }) => {
</div>
</div>
<div className="row border-top mt-5">
<div className="col">{render()}</div>
<Animate play={!isLoading} start={{ opacity: "0%" }} end={{ opacity: "100%" }}>
<div className="col">{render()}</div>
</Animate>
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions packages/webapp/src/components/bill/BillsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const BillsListItem: React.FC<IProps> = ({
<div className="col text-center w-100">
<Button
variant="outline-primary"
style={{ opacity: "70%" }}
onClick={handleGoToSingleBill}
className="p-3"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/** @format */

import { STATE_CODES_NAMES } from "@sway/constants";
import { getTextDistrict, isCongressLocale, isEmptyObject, titleize } from "@sway/utils";
import { useRef, useState } from "react";
import { FiBarChart, FiBarChart2, FiMap } from "react-icons/fi";
import { FiBarChart, FiBarChart2, FiFlag, FiMap } from "react-icons/fi";
import { sway } from "sway";
import { useOpenCloseElement } from "../../../hooks";
import { swayBlue } from "../../../utils";
import { isEmptyScore } from "../../../utils/charts";
import DialogWrapper from "../../dialogs/DialogWrapper";
import { SwaySvgIcon } from "../../SwaySvg";
import {
collectDistrictScoresForState,
setUserLocaleDistrictAsState,
Expand Down Expand Up @@ -68,8 +68,13 @@ const BillMobileChartsContainer: React.FC<IProps> = ({ bill, userLocale, userVot
};

const getStateTotalLabel = () => {
// return `${userLocale.district} Total`
const textDistrict = getTextDistrict(userLocale.district);
return `${textDistrict} Total`;
if (textDistrict) {
return `${STATE_CODES_NAMES[textDistrict]} Total`;
} else {
return "Region Total";
}
};

const components = [
Expand All @@ -90,9 +95,7 @@ const BillMobileChartsContainer: React.FC<IProps> = ({ bill, userLocale, userVot
{
key: BillChartFilters.total,
Component: TotalVotes,
Icon: isCongressLocale(userLocale)
? () => <SwaySvgIcon src={"/united_states.svg"} />
: FiBarChart2,
Icon: isCongressLocale(userLocale) ? FiFlag : FiBarChart2,
label: isCongressLocale(userLocale)
? "Congress Total"
: `${titleize(userLocale.city)} Total`,
Expand Down Expand Up @@ -120,7 +123,7 @@ const BillMobileChartsContainer: React.FC<IProps> = ({ bill, userLocale, userVot

return (
<div ref={ref} className="col">
<div className="row">
<div className="row mb-2">
{charts.map((item: IChartChoice, index: number) => {
const isSelected = index === selected;
return (
Expand All @@ -143,41 +146,51 @@ const BillMobileChartsContainer: React.FC<IProps> = ({ bill, userLocale, userVot
);
})}
</div>
{charts.map((item: IChartChoice, index: number) => {
if (index !== selected) return null;
<div className="row">
{charts.map((item: IChartChoice, index: number) => {
if (index !== selected) return null;

if (isCongressLocale(userLocale) && index === 1) {
return (
<div
key={index}
className="col hover-chart"
onClick={handleSetExpanded}
>
<item.Component
key={index}
score={collectDistrictScoresForState(
userLocale,
userVote,
bill.score,
)}
billFirestoreId={bill.firestoreId}
handleClick={handleSetExpanded}
userLocale={setUserLocaleDistrictAsState(userLocale)}
isEmptyScore={isEmptyScore(bill.score)}
/>
</div>
);
}

if (isCongressLocale(userLocale) && index === 1) {
return (
<div key={index} className="col hover-chart" onClick={handleSetExpanded}>
<item.Component
key={index}
score={collectDistrictScoresForState(
score={updateBillScoreWithUserVote(
userLocale,
userVote,
bill.score,
)}
billFirestoreId={bill.firestoreId}
handleClick={handleSetExpanded}
userLocale={setUserLocaleDistrictAsState(userLocale)}
userLocale={userLocale}
isEmptyScore={isEmptyScore(bill.score)}
/>
</div>
);
}

return (
<div key={index} className="col hover-chart" onClick={handleSetExpanded}>
<item.Component
key={index}
score={updateBillScoreWithUserVote(userLocale, userVote, bill.score)}
billFirestoreId={bill.firestoreId}
handleClick={handleSetExpanded}
userLocale={userLocale}
isEmptyScore={isEmptyScore(bill.score)}
/>
</div>
);
})}
})}
</div>
{selectedChart && (
<DialogWrapper open={open} setOpen={handleClose}>
<selectedChart.Component
Expand Down
Loading

0 comments on commit 18dd320

Please sign in to comment.