Skip to content

Commit

Permalink
refactor: new UI
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasMaupin committed Dec 13, 2024
1 parent 08e4b92 commit c59ed0a
Show file tree
Hide file tree
Showing 31 changed files with 727 additions and 145 deletions.
19 changes: 16 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { BrowserRouter, Routes, Route } from "react-router-dom";
import styled from "@emotion/styled";
import { useState } from "react";
import { ErrorPage } from "./components/router-error.tsx";
import { useDevicePermissions } from "./use-device-permission.ts";
import { useDevicePermissions } from "./hooks/use-device-permission.ts";
import { LandingPage } from "./components/landing-page/landing-page.tsx";
import { useInitializeGlobalStateReducer } from "./global-state/global-state-reducer.ts";
import { GlobalStateContext } from "./global-state/context-provider.tsx";
import { Header } from "./components/header.tsx";
import { ErrorBanner } from "./components/error";
import { useFetchDevices } from "./use-fetch-devices.ts";
import { useFetchDevices } from "./hooks/use-fetch-devices.ts";
import {
DisplayContainer,
FlexContainer,
Expand All @@ -19,6 +18,9 @@ import { isValidBrowser } from "./bowser.ts";
import { DisplayContainerHeader } from "./components/landing-page/display-container-header.tsx";
import { NavigateToRootButton } from "./components/navigate-to-root-button/navigate-to-root-button.tsx";
import { CallsPage } from "./components/calls-page/calls-page.tsx";
import { CreateProductionPage } from "./components/create-production/create-production-page.tsx";
import { Header } from "./components/header.tsx";
import { useLocalUserSettings } from "./hooks/use-local-user-settings.ts";

const DisplayBoxPositioningContainer = styled(FlexContainer)`
justify-content: center;
Expand Down Expand Up @@ -57,6 +59,8 @@ const App = () => {
permission,
});

useLocalUserSettings({ dispatch });

return (
<GlobalStateContext.Provider value={initializedGlobalState}>
<BrowserRouter>
Expand Down Expand Up @@ -120,6 +124,15 @@ const App = () => {
}
errorElement={<ErrorPage />}
/>
<Route
path="/create-production"
element={
<CreateProductionPage
setApiError={() => setApiError(true)}
/>
}
errorElement={<ErrorPage />}
/>
<Route
path="/manage-productions"
element={<ManageProductions />}
Expand Down
1 change: 1 addition & 0 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type TLine = {
export type TBasicProductionResponse = {
name: string;
productionId: string;
lines?: TLine[];
};

type TFetchProductionResponse = TBasicProductionResponse & {
Expand Down
1 change: 1 addition & 0 deletions src/assets/icons/add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion src/assets/icons/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ import ConfirmSvg from "./done.svg?react";
import StepLeftSvg from "./chevron_left.svg?react";
import StepRightSvg from "./navigate_next.svg?react";
import Settings from "./settings.svg?react";
import Headset from "./headset.svg?react";
import UserSettings from "./user_settings.svg?react";
import ChevronDown from "./chevron_down.svg?react";
import ChevronUp from "./chevron_up.svg?react";
import Headset from "./headset.svg?react";
import Person from "./person.svg?react";
import Users from "./users.svg?react";
import Add from "./add.svg?react";
import Edit from "./edit.svg?react";

export const MicMuted = () => <MicMute />;

Expand All @@ -35,8 +40,18 @@ export const StepRightIcon = () => <StepRightSvg />;

export const SettingsIcon = () => <Settings />;

export const UserSettingsIcon = () => <UserSettings />;

export const ChevronDownIcon = () => <ChevronDown />;

export const ChevronUpIcon = () => <ChevronUp />;

export const HeadsetIcon = () => <Headset />;

export const PersonIcon = () => <Person />;

export const UsersIcon = () => <Users />;

export const AddIcon = () => <Add />;

export const EditIcon = () => <Edit />;
1 change: 1 addition & 0 deletions src/assets/icons/person.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/user_settings.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/users.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/components/create-production/create-production-page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useEffect } from "react";
import { useGlobalState } from "../../global-state/context-provider";
import { CreateProduction } from "./create-production";

export const CreateProductionPage = ({
setApiError,
}: {
setApiError: () => void;
}) => {
const [{ apiError }] = useGlobalState();

useEffect(() => {
if (apiError) {
setApiError();
}
}, [apiError, setApiError]);

return <CreateProduction />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,42 @@ import { SubmitHandler, useFieldArray, useForm } from "react-hook-form";
import { useEffect, useState } from "react";
import styled from "@emotion/styled";
import { ErrorMessage } from "@hookform/error-message";
import { DisplayContainerHeader } from "./display-container-header.tsx";
import { DisplayContainerHeader } from "../landing-page/display-container-header.tsx";
import {
DecorativeLabel,
FormContainer,
FormInput,
FormLabel,
StyledWarningMessage,
PrimaryButton,
SecondaryButton,
} from "./form-elements.tsx";
} from "../landing-page/form-elements.tsx";
import { API } from "../../api/api.ts";
import { useGlobalState } from "../../global-state/context-provider.tsx";
import { Spinner } from "../loader/loader.tsx";
import { FlexContainer } from "../generic-components.ts";
import { RemoveLineButton } from "../remove-line-button/remove-line-button.tsx";
import { useFetchProduction } from "./use-fetch-production.ts";
import { useFetchProduction } from "../landing-page/use-fetch-production.ts";
import { darkText, errorColour } from "../../css-helpers/defaults.ts";
import { NavigateToRootButton } from "../navigate-to-root-button/navigate-to-root-button.tsx";
import { ResponsiveFormContainer } from "../user-settings/user-settings.tsx";
import { isMobile } from "../../bowser.ts";

type FormValues = {
productionName: string;
defaultLine: string;
lines: { name: string }[];
};

const HeaderWrapper = styled.div`
display: flex;
margin-bottom: 2rem;
align-items: center;
h2 {
margin: 0;
margin-left: 1rem;
}
`;

const ListItemWrapper = styled.div`
position: relative;
`;
Expand Down Expand Up @@ -151,8 +163,11 @@ export const CreateProduction = () => {
};

return (
<FormContainer>
<DisplayContainerHeader>Create Production</DisplayContainerHeader>
<ResponsiveFormContainer className={isMobile ? "" : "desktop"}>
<HeaderWrapper>
<NavigateToRootButton />
<DisplayContainerHeader>Create Production</DisplayContainerHeader>
</HeaderWrapper>
<FormLabel>
<DecorativeLabel>Production Name</DecorativeLabel>
<FormInput
Expand Down Expand Up @@ -265,6 +280,6 @@ export const CreateProduction = () => {
)}
</>
)}
</FormContainer>
</ResponsiveFormContainer>
);
};
4 changes: 2 additions & 2 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Logo = styled.svg`
width: 2.4rem;
height: 2.4rem;
margin-right: 1rem;
margin-left: 2rem;
margin-left: 1rem;
`;

export const Header: FC = () => {
Expand All @@ -51,7 +51,7 @@ export const Header: FC = () => {
};

const returnToRoot = () => {
if (location.pathname.includes("/production")) {
if (location.pathname.includes("/line")) {
setConfirmExitModalOpen(true);
} else {
navigate("/");
Expand Down
6 changes: 3 additions & 3 deletions src/components/landing-page/form-elements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export const ActionButton = styled.button`
`;

export const PrimaryButton = styled(ActionButton)`
background: rgba(89, 203, 232, 1);
&:active:enabled {
background: #1db954;
transform: translateY(0.125rem);
}
Expand Down Expand Up @@ -157,13 +157,14 @@ export const PrimaryButton = styled(ActionButton)`
`;

export const SecondaryButton = styled(ActionButton)`
// background: #1db954;
background: white;
&:before,
&:after {
border-radius: 0.5rem;
}
&:before {
background: rgba(89, 203, 232, 1);
content: "";
display: block;
height: 100%;
Expand All @@ -176,7 +177,6 @@ export const SecondaryButton = styled(ActionButton)`
}
&:after {
background: rgba(89, 203, 232, 1)
content: "";
display: block;
overflow: hidden;
Expand Down
35 changes: 17 additions & 18 deletions src/components/landing-page/landing-page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { useEffect } from "react";
import { JoinProduction } from "./join-production.tsx";
import { CreateProduction } from "./create-production.tsx";
import { useEffect, useState } from "react";
import { ProductionsListContainer } from "./productions-list-container.tsx";
import { DisplayContainer, FlexContainer } from "../generic-components.ts";
import { useGlobalState } from "../../global-state/context-provider.tsx";
import { isMobile } from "../../bowser.ts";
import { UserSettings } from "../user-settings/user-settings.tsx";
import { UserSettingsButton } from "./user-settings-button.tsx";

export const LandingPage = ({ setApiError }: { setApiError: () => void }) => {
const [{ apiError }] = useGlobalState();
const [showSettings, setShowSettings] = useState<boolean>(false);

useEffect(() => {
if (apiError) {
Expand All @@ -16,18 +15,18 @@ export const LandingPage = ({ setApiError }: { setApiError: () => void }) => {
}, [apiError, setApiError]);

return (
<>
<FlexContainer>
<DisplayContainer>
<JoinProduction />
</DisplayContainer>
{!isMobile && (
<DisplayContainer>
<CreateProduction />
</DisplayContainer>
)}
</FlexContainer>
<ProductionsListContainer />
</>
<div>
{((showSettings || !window.localStorage?.getItem("username")) && (
<UserSettings
buttonText={showSettings ? "Save" : "Next"}
onSave={() => setShowSettings(false)}
/>
)) || (
<>
<UserSettingsButton onClick={() => setShowSettings(!showSettings)} />
<ProductionsListContainer />
</>
)}
</div>
);
};
Loading

0 comments on commit c59ed0a

Please sign in to comment.