Skip to main content

utils

Documentation / lib/utils

DeviceInfo

type DeviceInfo = object;

Defined in: apps/web/src/lib/utils.ts:52

Device information object

Properties

isMobile?

optional isMobile: boolean;

Defined in: apps/web/src/lib/utils.ts:54

True if the screen is small size like on mobile web, updated on resize

os?

optional os: "Windows" | "Mac" | "Linux" | "Android" | "iOS" | "Other";

Defined in: apps/web/src/lib/utils.ts:56

The user's device OS


WithoutChild<T>

type WithoutChild<T> = T extends object ? Omit<T, "child"> : T;

Defined in: apps/web/src/lib/utils.ts:88

eslint-disable-next-line @typescript-eslint/no-explicit-any

Type Parameters

Type Parameter

T


WithoutChildren<T>

type WithoutChildren<T> = T extends object ? Omit<T, "children"> : T;

Defined in: apps/web/src/lib/utils.ts:90

eslint-disable-next-line @typescript-eslint/no-explicit-any

Type Parameters

Type Parameter

T


WithoutChildrenOrChild<T>

type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;

Defined in: apps/web/src/lib/utils.ts:93

Type Parameters

Type Parameter

T


WithElementRef<T, U>

type WithElementRef<T, U> = T & object;

Defined in: apps/web/src/lib/utils.ts:94

Type declaration

NameTypeDefined in

ref?

U | null

apps/web/src/lib/utils.ts:95

Type Parameters

Type ParameterDefault type

T

U extends HTMLElement

HTMLElement


setStateInURL()

function setStateInURL(stateObject: Record<string, string>, addToBrowserHistory: boolean): object;

Defined in: apps/web/src/lib/utils.ts:20

Adds variable state (like query, active tab. etc) to the URL so that the state is preserved in a sharable URL which when clicked resumes from those same state variables. Pass in nothing to get the current URL state variables.

Parameters

ParameterTypeDefault valueDescription

stateObject

Record<string, string>

null

The state object to sync to the URL like view: "search"

addToBrowserHistory

boolean

false

default false.

  • If true, add the new state to the browser history

Returns

object

stateObject

  • Always returns the current URL state object

Example

let {view, q} = setStateInURL();
setStateInURL({ view: "search" });

cn()

function cn(...inputs: ClassValue[]): string;

Defined in: apps/web/src/lib/utils.ts:45

Utility function for merging Tailwind classes, needed for shadcn-svelte.

Parameters

ParameterTypeDescription

...inputs

ClassValue[]

Returns

string

class name


setupMobileView()

function setupMobileView(deviceInfo: DeviceInfo): void;

Defined in: apps/web/src/lib/utils.ts:65

Checks if the current view is a mobile view Updates deviceInfo.isMobile state based on the window width Updates deviceInfo.os based on the user's device OS

Parameters

ParameterTypeDescription

deviceInfo

DeviceInfo

The device information object

Returns

void


loadHeadTags()

function loadHeadTags(options: LoadHeadTagsOptions): string;

Defined in: apps/web/src/lib/utils.ts:115

Generates HTML head tags including fonts, analytics, and meta tags

Parameters

ParameterTypeDescription

options

LoadHeadTagsOptions

Configuration options for head tags

Returns

string

Complete HTML head tags string if shouldAppend is false, otherwise void