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 |
---|
|
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 |
---|
|
WithoutChildrenOrChild<T>
type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;
Defined in: apps/web/src/lib/utils.ts:93
Type Parameters
Type Parameter |
---|
|
WithElementRef<T, U>
type WithElementRef<T, U> = T & object;
Defined in: apps/web/src/lib/utils.ts:94
Type declaration
Name | Type | Defined in |
---|---|---|
|
|
Type Parameters
Type Parameter | Default type |
---|---|
| ‐ |
|
|
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
Parameter | Type | Default value | Description |
---|---|---|---|
|
|
| The state object to sync to the URL like view: "search" |
|
|
| default false.
|
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
Parameter | Type | Description |
---|---|---|
... |
|
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
Parameter | Type | Description |
---|---|---|
| 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
Parameter | Type | Description |
---|---|---|
|
| Configuration options for head tags |
Returns
string
Complete HTML head tags string if shouldAppend is false, otherwise void