1
Fork 0

Factor the logged out warning to a separate component.

This commit is contained in:
Bauke 2023-07-01 12:30:02 +02:00
parent 02af7391e7
commit 1b063e6e90
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
3 changed files with 27 additions and 21 deletions

View File

@ -5,30 +5,11 @@ import {
removeAllDatasetCounters,
renderInContainer,
} from "../utilities.js";
const userIsLoggedIn =
document.querySelector(".logged-in-user-username") !== null;
import {LoggedOutWarning} from "../shared/logged-out-warning.js";
const step01 = renderInContainer(
<>
{userIsLoggedIn ? (
""
) : (
<p class="tish-warning">
It looks like you aren't logged in to Tildes. Tildes Shepherd assumes
that you are logged in as a lot of the Tildes interface isn't shown to
logged out users.
<br />
To still let anyone without an account benefit from the extension you
may continue, however, know that certain parts of the tour <b>
will
</b>{" "}
break and look weird.
<br />
It's highly recommended that you exit the tour, log in and start it
again.
</p>
)}
<LoggedOutWarning />
<h1>The Homepage</h1>

View File

@ -0,0 +1 @@
export * from "./logged-out-warning.js";

View File

@ -0,0 +1,24 @@
import {type JSX} from "preact";
export function LoggedOutWarning(): JSX.Element {
const userIsLoggedIn =
document.querySelector(".logged-in-user-username") !== null;
if (userIsLoggedIn) {
return <></>;
}
return (
<p class="tish-warning">
It looks like you aren't logged in to Tildes. Tildes Shepherd assumes that
you are logged in as a lot of the Tildes interface isn't shown to logged
out users.
<br />
To still let anyone without an account benefit from the extension you may
continue, however, know that certain parts of the tour <b>will</b> break
and look weird.
<br />
It's highly recommended that you exit the tour, log in and start it again.
</p>
);
}