Skip to content

Instantly share code, notes, and snippets.

View brob's full-sized avatar

Bryan Robinson brob

View GitHub Profile
import { useFusionAuth } from "@fusionauth/react-sdk";
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
export default function AccountPage() {
const navigate = useNavigate();
const { isLoggedIn, isFetchingUserInfo } = useFusionAuth();
import { useNavigate } from "react-router-dom";
import { useFusionAuth } from "@fusionauth/react-sdk";
import { useEffect } from "react";
export default function HomePage() {
const navigate = useNavigate();
const { isLoggedIn, isFetchingUserInfo, startLogin, startRegister } =
useFusionAuth();
@brob
brob / App.tsx
Created December 17, 2025 18:41
import { Navigate, Route, Routes } from "react-router-dom";
import HomePage from "./pages/HomePage";
import AccountPage from "./pages/AccountPage";
import { useFusionAuth } from "@fusionauth/react-sdk";
function App() {
const { isFetchingUserInfo } = useFusionAuth();
@brob
brob / search.html
Created September 17, 2021 15:59
Simple 11ty Serverless template for a search page.
---
layout: "base.html"
title: Search Page
permalink:
search: /search/
---
<h2>{{ eleventy.serverless.query.query }}</h2>
{% assign results = eleventy.serverless.query.query | getResults %}
{% for result in results %}
@brob
brob / App.js
Created August 26, 2021 13:19
Item template with new component
templates: {
item({ item }) {
return <Action hit={item} />;
}
}
@brob
brob / app.js
Created August 24, 2021 15:45
use the enabled item in the template
function Action({ hit }) {
// Component to display the items
return (
<div className="aa-ItemWrapper">
<div className="aa-ItemContent">
<div className="aa-ItemIcon">{hit.icon}</div>
<div className="aa-ItemContentBody">
<div className="aa-ItemContentTitle">
<span>{hit.highlighted}</span>
{hit.enabled && (
@brob
brob / app.js
Created August 24, 2021 15:44
onSelect set context
onSelect({ setContext }) {
document.querySelector("body").classList.remove("dark");
setContext({ dark: false });
}
@brob
brob / app.js
Created August 24, 2021 15:44
enabled data state
{ //...
label: "/dark",
enabled: state.context.dark,
// ...
},
{ //...
label: "/light",
enabled: !state.context.dark,
// ...
}
@brob
brob / app.js
Created August 24, 2021 15:43
Full Items in data
return [
{
icon: (
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"
/>
@brob
brob / app.js
Created August 24, 2021 15:42
bigger template
function Action({ hit }) {
// Component to display the items
return (
<div className="aa-ItemWrapper">
<div className="aa-ItemContent">
<div className="aa-ItemIcon">{hit.icon}</div>
<div className="aa-ItemContentBody">
<div className="aa-ItemContentTitle">
<span>{hit.highlighted}</span>
</div>