rework/lightweight #12

Merged
GauthierWebDev merged 106 commits from rework/lightweight into main 2025-04-21 16:27:38 +00:00
5 changed files with 16 additions and 26 deletions
Showing only changes of commit d4df6f5c11 - Show all commits

View File

@ -7,7 +7,8 @@ import { PluginsIcon } from "@/icons/PluginsIcon";
import { PresetsIcon } from "@/icons/PresetsIcon"; import { PresetsIcon } from "@/icons/PresetsIcon";
import { ThemingIcon } from "@/icons/ThemingIcon"; import { ThemingIcon } from "@/icons/ThemingIcon";
import { WarningIcon } from "@/icons/WarningIcon"; import { WarningIcon } from "@/icons/WarningIcon";
import { createUniqueId, For } from "solid-js"; import { useId } from "@/hooks/useId";
import { For } from "solid-js";
import clsx from "clsx"; import clsx from "clsx";
const icons = { const icons = {
@ -34,7 +35,7 @@ export type IconProps = JSX.IntrinsicElements["svg"] & {
}; };
export function Icon(props: IconProps) { export function Icon(props: IconProps) {
const id = createUniqueId(); const id = useId();
const IconComponent = icons[props.icon]; const IconComponent = icons[props.icon];
return ( return (

View File

@ -1,9 +1,9 @@
import type { JSX } from "solid-js"; import type { JSX } from "solid-js";
import { createUniqueId } from "solid-js"; import { useId } from "@/hooks/useId";
function LogomarkPaths() { function LogomarkPaths() {
const id = createUniqueId(); const id = useId();
return ( return (
<> <>

View File

@ -1,16 +1,7 @@
import type { SearchResult } from "@/services/FlexSearchService"; import type { SearchResult } from "@/services/FlexSearchService";
import type { JSX, Accessor, Setter } from "solid-js"; import type { JSX, Accessor, Setter } from "solid-js";
// import React, {
// useId,
// createSignal,
// createEffect,
// createContext,
// useContext,
// Fragment,
// } from "react";
import { import {
createUniqueId,
createContext, createContext,
useContext, useContext,
For, For,
@ -20,9 +11,9 @@ import {
import { Dialog, DialogPanel } from "terracotta"; import { Dialog, DialogPanel } from "terracotta";
import { useDebounce } from "@/hooks/useDebounce"; import { useDebounce } from "@/hooks/useDebounce";
import { Highlighter } from "solid-highlight-words"; import { Highlighter } from "solid-highlight-words";
// import { navigation } from "@/lib/navigation";
import { navigate } from "vike/client/router"; import { navigate } from "vike/client/router";
import { onSearch } from "./Search.telefunc"; import { onSearch } from "./Search.telefunc";
import { useId } from "@/hooks/useId";
import clsx from "clsx"; import clsx from "clsx";
const SearchContext = createContext<{ const SearchContext = createContext<{
@ -56,7 +47,7 @@ function SearchIcon(props: JSX.IntrinsicElements["svg"]) {
} }
function LoadingIcon(props: JSX.IntrinsicElements["svg"]) { function LoadingIcon(props: JSX.IntrinsicElements["svg"]) {
const id = createUniqueId(); const id = useId();
return ( return (
<svg viewBox="0 0 20 20" fill="none" aria-hidden="true" {...props}> <svg viewBox="0 0 20 20" fill="none" aria-hidden="true" {...props}>
@ -135,15 +126,7 @@ function HighlightQuery({ text, query }: { text: string; query: string }) {
function SearchResultItem(props: { result: SearchResult; query: string }) { function SearchResultItem(props: { result: SearchResult; query: string }) {
const { close } = useContext(SearchContext); const { close } = useContext(SearchContext);
const id = createUniqueId(); const id = useId();
// const sectionTitle = navigation.find((section) =>
// section.links.find((link) => link.href === result.url.split("#")[0]),
// )?.title;
// const hierarchy = [sectionTitle, result.pageTitle].filter(
// (x): x is string => typeof x === "string",
// );
return ( return (
<li <li

6
app/hooks/useId.tsx Normal file
View File

@ -0,0 +1,6 @@
import { createUniqueId } from "solid-js";
export function useId() {
const id = createUniqueId();
return `memento-${id}`;
}

View File

@ -1,9 +1,9 @@
import type { JSX } from "solid-js"; import type { JSX } from "solid-js";
import { createUniqueId } from "solid-js"; import { useId } from "@/hooks/useId";
export function HeroBackground(props: JSX.IntrinsicElements["svg"]) { export function HeroBackground(props: JSX.IntrinsicElements["svg"]) {
const id = createUniqueId(); const id = useId();
return ( return (
<svg <svg