mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 12:45:47 +00:00
refactor: update domain warning layout
This commit is contained in:
@@ -28,7 +28,7 @@ export const DomainWarning = (props: Props) => {
|
||||
</CardHeader>
|
||||
<CardFooter className="flex flex-col items-stretch">
|
||||
<Button onClick={onClick} variant="warning">
|
||||
Continue
|
||||
Ignore
|
||||
</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
|
||||
@@ -4,10 +4,8 @@ import { Outlet } from "react-router";
|
||||
import { useState } from "react";
|
||||
import { DomainWarning } from "../domain-warning/domain-warning";
|
||||
|
||||
export const Layout = () => {
|
||||
const { backgroundImage, appUrl } = useAppContext();
|
||||
const [ignoreDomainWarning, setIgnoreDomainWarning] = useState(false);
|
||||
const currentUrl = window.location.origin;
|
||||
const BaseLayout = ({ children }: { children: React.ReactNode }) => {
|
||||
const { backgroundImage } = useAppContext();
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -19,15 +17,41 @@ export const Layout = () => {
|
||||
}}
|
||||
>
|
||||
<LanguageSelector />
|
||||
{appUrl !== currentUrl && !ignoreDomainWarning ? (
|
||||
<DomainWarning
|
||||
onClick={() => setIgnoreDomainWarning(true)}
|
||||
appUrl={appUrl}
|
||||
currentUrl={currentUrl}
|
||||
/>
|
||||
) : (
|
||||
<Outlet />
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const Layout = () => {
|
||||
const { appUrl } = useAppContext();
|
||||
const [ignoreDomainWarning, setIgnoreDomainWarning] = useState(false);
|
||||
const currentUrl = window.location.origin;
|
||||
const sessionIgnore = window.sessionStorage.getItem("ignoreDomainWarning");
|
||||
|
||||
const handleIgnore = () => {
|
||||
window.sessionStorage.setItem("ignoreDomainWarning", "true");
|
||||
setIgnoreDomainWarning(true);
|
||||
};
|
||||
|
||||
if (
|
||||
!ignoreDomainWarning &&
|
||||
appUrl !== currentUrl &&
|
||||
sessionIgnore !== "true"
|
||||
) {
|
||||
return (
|
||||
<BaseLayout>
|
||||
<DomainWarning
|
||||
appUrl={appUrl}
|
||||
currentUrl={currentUrl}
|
||||
onClick={() => handleIgnore()}
|
||||
/>
|
||||
</BaseLayout>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseLayout>
|
||||
<Outlet />
|
||||
</BaseLayout>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -156,7 +156,7 @@ ul {
|
||||
}
|
||||
|
||||
code {
|
||||
@apply relative rounded bg-muted px-[0.2rem] py-[0.1rem] font-mono text-sm font-semibold;
|
||||
@apply relative rounded bg-muted px-[0.2rem] py-[0.1rem] font-mono text-sm font-semibold break-all;
|
||||
}
|
||||
|
||||
.lead {
|
||||
|
||||
Reference in New Issue
Block a user