frontend client for gemstone. decentralised workplace app
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: better typing for palette variant use

serenity 7b6e58b1 081a9e7d

+6 -3
+5 -2
src/lib/facet/src/providers.tsx
··· 1 1 import type { Facet } from "@/lib/facet/src/facet"; 2 + import type { FacetVariants } from "@/lib/facet/src/variants"; 2 3 import type { ReactNode } from "react"; 3 4 import { createContext, useContext } from "react"; 4 5 ··· 18 19 return atoms; 19 20 }; 20 21 21 - export const useVariant = (variantName: string) => { 22 + type VariantName = keyof FacetVariants 23 + 24 + export const useVariant = (variantName: VariantName) => { 22 25 const { variants } = useFacet(); 23 26 const variant = variants[variantName]; 24 27 if (!variant) 25 28 throw new Error( 26 - `Provided variant ${variantName} does not exist in the configured Facet. Check the configuration init object.`, 29 + `Provided variant ${variantName.toString()} does not exist in the configured Facet. Check the configuration init object.`, 27 30 ); 28 31 return variant; 29 32 };
+1 -1
src/lib/facet/src/variants.ts
··· 6 6 export interface FacetVariants { 7 7 pearl?: FacetPalette; 8 8 obsidian?: FacetPalette; 9 - [x: string]: FacetPalette | undefined; 9 + [x: string & {}]: FacetPalette | undefined; 10 10 } 11 11 12 12 // const DEFAULT_LIGHT_MODE: FacetPalette = {