Skip to content

Instantly share code, notes, and snippets.

@RoyalIcing
Created January 20, 2022 01:43
Show Gist options
  • Save RoyalIcing/d4c4bef2f0063defadf4498ae0feefa8 to your computer and use it in GitHub Desktop.
Save RoyalIcing/d4c4bef2f0063defadf4498ae0feefa8 to your computer and use it in GitHub Desktop.
Remorse: Focused on web fundamentals and archaic UX
<?php
function loader($request) {
return getProjects();
}
function action($request) {
$form = $request.formData();
return createProject([ "title" => $form.get("title") ]);
}
function Projects($request) {
$projects = loader($loader);
$state = useTransition($request)["state"];
$busy = $state == "submitting";
?>
<div>
<?php foreach($projects as $project) { ?>
<a href="<?= $project.slug ?>"><?= $project.title ?></a>
<?php } ?>
<form method="post">
<input name="title">
<button type="submit" disabled="<?= $busy ?>">
<?= $busy ? "Creating..." : "Create New Project"; ?>
</button>
</form>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment