Navigates? | declarative? | Makes GET, triggers loader | Makes POST, triggers action | No requests |
---|---|---|---|---|
navigates | declarative | <Link to=""> <Form method="get"> |
<Form method="post"> |
<Link to="#..."> |
navigates | imperative | navigate() setSearchParams() |
submit() |
navigate("#") |
stays | declarative | <fetcher.Form method="get"> |
<fetcher.Form method="post"> |
(doesn't make sense) |
s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AnimatePresence, usePresence } from "framer-motion"; | |
import { classNames } from "~/lib/utils/class-names"; | |
import { useCounter } from "@kyleshevlin/use-common"; | |
import { useCallback } from "react"; | |
const Box = ({ count }: { count: number }) => { | |
const [isPresent, safeToRemove] = usePresence(); | |
const onAnimationEnd = useCallback(() => { | |
if (!isPresent) safeToRemove(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function useIsPendingPathname(to) { | |
let { location } = useTransition(); | |
let { pathname } = useResolvedPath(to); | |
return location?.pathname === pathname; | |
} | |
function useIsSlowTransition(ms = 300) { | |
let transition = useTransition(); | |
let [isSlow, setIsSlow] = useState(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// root.tsx | |
import { getUserSession, requireUser, logout } from "~/session"; | |
export function loader({ request }) { | |
// use case: know if the user is logged in, no redirect to /login | |
let userSession = await getUserSession(request); | |
let isAuthenticated = userSession.has("userId"); | |
return { isAuthenticated }; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const htm = require('htm'); | |
const vhtml = require('vhtml'); | |
// create an html`` tag function for vhtml: | |
const html = htm.bind(vhtml); | |
const App = (props) => html` | |
<div class="app"> | |
<h1>This is an app</h1> |
- Location - The location of the application. Usually just a URL, but the location can contain multiple pieces of information that can be used by an app
- pathname - The "file/directory" portion of the URL, like
invoices/123
- search - The stuff after
?
in a URL like/assignments?showGrades=1
. - query - A parsed version of search, usually an object but not a standard browser feature.
- hash - The
#
portion of the URL. This is not available to servers inrequest.url
so its client only. By default it means which part of the page the user should be scrolled to, but developers use it for various things. - state - Object associated with a location. Think of it like a hidden URL query. It's state you want to keep with a specific location, but you don't want it to be visible in the URL.
- pathname - The "file/directory" portion of the URL, like
In 5 minutes, you’ll have a brand new clean Statamic site, with Tailwind CSS and PurgeCSS configured.
It assumes that you work on a Mac, you put your site in ~/sites and you use Laravel Valet.
All the credit go to Jack McDade and philipboomy, from whom I stole and adapt the build scripts and the PurgeCSS config, because I have really absolutely no idea what I am doing with all this Terminal Black Magic ™; this is only a detailed write up of the process.
You'll need Yarn and Node. You can install them both in one command via Brew: brew install yarn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<script type="module"> | |
import { h, text, app } from "https://unpkg.com/hyperapp" | |
app({ | |
init: () => 0, | |
view: state => | |
h("main", {}, [ |
NewerOlder