Skip to content

Commit

Permalink
modal is w-full on mobile, still doesn't take full screen as it uses …
Browse files Browse the repository at this point in the history
…<Dialog>
  • Loading branch information
AarifLamat committed Jun 13, 2024
1 parent 04dff94 commit 5cc3f2f
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 86 deletions.
145 changes: 78 additions & 67 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 46 additions & 5 deletions src/components/EventBox/request-view.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useCallback, useEffect, useState } from "react";
import { Disclosure, Transition } from "@headlessui/react";
import { FaChevronDown } from "react-icons/fa6";

Expand Down Expand Up @@ -27,8 +27,49 @@ const RequestView = ({
repairAttemptProps
}: RequestProps) => {
const [showRepairRequestModal, setShowRepairRequestModal] = useState(false);
function manageModal() {
setShowRepairRequestModal(true);
// function manageModal() {
// setShowRepairRequestModal(true);
// }

const useWindowDimensions = () => {
const hasWindow = typeof window !== "undefined";

const getWindowDimensions = useCallback(() => {
const width = hasWindow ? window.innerWidth : null;
const height = hasWindow ? window.innerHeight : null;
return {
width,
height
};
}, [hasWindow]);

const [windowDimensions, setWindowDimensions] = useState(
getWindowDimensions()
);

useEffect(() => {
if (hasWindow) {
const handleResize = () => {
setWindowDimensions(getWindowDimensions());
};

window.addEventListener("resize", handleResize);
return () => window.removeEventListener("resize", handleResize);
}
}, [hasWindow, getWindowDimensions]);

return windowDimensions;
};

const { height, width } = useWindowDimensions();

Check warning on line 64 in src/components/EventBox/request-view.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint

'height' is assigned a value but never used. Allowed unused vars must match /^_/u

function handleRepairClick() {
if (width > 640) {

Check failure on line 67 in src/components/EventBox/request-view.tsx

View workflow job for this annotation

GitHub Actions / Run Type Check

'width' is possibly 'null'.
setShowRepairRequestModal(true);
} else {
// this is for if we want to optionally render a seperate page on mobile view
setShowRepairRequestModal(false);
}
}
return (
<div className="mx-5 mt-4 rounded-lg bg-slate-200 shadow-lg">
Expand Down Expand Up @@ -83,8 +124,8 @@ const RequestView = ({
<div className="flex justify-center mt-1">
<button
className="bg-primary-700 px-4 py-1 rounded-lg text-white text-md hover:bg-primary-600"
onClick={manageModal}
onKeyDown={manageModal}
onClick={handleRepairClick}
// onKeyDown={handleRepairClick}
>
Repair
</button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormFields/field-radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function FieldRadio<T extends FieldValues = FieldValues>({
const baseStyle = `relative flex ${width} ${height} mb-2 items-center justify-between rounded-lg bg-white px-3 py-2.5 text-sm font-medium text-gray-900 border shadow-sm hover:shadow-grey-300`;
const errorBorderStyle = `border-red-500`;
const normalBorderStyle = `border-grey-300`;
const radioStyle = `my-auto flex ${axis} items-start gap-4 text-xs`;
const radioStyle = `m-auto flex ${axis} items-start gap-4 text-xs justify-center`;

return (
<div
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormFields/field-text-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function FieldTextArea<T extends FieldValues = FieldValues>({
}: FormProps<T>) {
const { field, fieldState } = useController(props);

const baseStyle = `relative flex ${height} ${width} justify-between rounded-lg bg-white px-3 py-2.5 text-sm font-medium text-gray-900 shadow-sm border border-grey-300 hover:shadow-grey-300`;
const baseStyle = `relative flex ${height} ${width} justify-between rounded-lg bg-white px-3 py-2.5 text-base font-medium text-gray-900 shadow-sm border border-grey-300 hover:shadow-grey-300`;
const errorBorderStyle = `border-red-500`;
const normalBorderStyle = `border-grey-300`;
const textAreaStyle = `overflow-wrap:break-word pt-3 h-full w-full resize-none overflow-y-auto text-base placeholder:text-gray-500 placeholder:font-normal focus:outline-none focus:ring-0`;
Expand Down
Empty file removed src/components/Forms/repair
Empty file.
Loading

0 comments on commit 5cc3f2f

Please sign in to comment.