Skip to content

Latest commit

 

History

History
505 lines (287 loc) · 14.6 KB

README.md

File metadata and controls

505 lines (287 loc) · 14.6 KB

browser-ui-stores

browser-ui-stores

Table of contents

Interfaces

Type Aliases

Variables

Functions

Type Aliases

ColorScheme

Ƭ ColorScheme: "light" | "dark"

Defined in

src/lib/appearance/prefers-color-scheme.ts:4


Orientation

Ƭ Orientation: "landscape" | "portrait"

Defined in

src/lib/viewport/orientation.ts:4


ReadonlyStore

Ƭ ReadonlyStore<T>: Object

A store that can have subscribers and emit values to them. It also provides the current value upon subscription. It's readonly in the sense that it doesn't provide direct set/update methods, unlike {@link Store}, therefore its value can only be changed by a {@link StartHandler} (see also {@link makeReadonlyStore}).

Type parameters

Name
T

Type declaration

Name Type
content () => T
nOfSubscriptions () => number
subscribe (subscriber: Subscriber<T>) => Unsubscribe

Defined in

node_modules/universal-stores/dist/index.d.ts:33


Subscriber

Ƭ Subscriber<T>: (current: T) => void

Type parameters

Name
T

Type declaration

▸ (current): void

A generic subscriber that takes a value emitted by a signal as its only parameter.

Parameters
Name Type
current T
Returns

void

Defined in

node_modules/@cdellacqua/signals/dist/index.d.ts:2


Unsubscribe

Ƭ Unsubscribe: () => void

Type declaration

▸ (): void

A function that's used to unsubscribe a subscriber from a signal.

Returns

void

Defined in

node_modules/@cdellacqua/signals/dist/index.d.ts:4

Variables

bodyScrollHeight$

Const bodyScrollHeight$: ReadonlyStore<number>

A readonly store that contains the scrollHeight of the body.

Note that using this store will append a style element to the head of the document to position the body in 'relative' mode element will be appended to the head of the document, so that you can still override when needed by editing the body inline style.

Defined in

src/lib/body/size.ts:106


bodyScrollHeightPassive$

Const bodyScrollHeightPassive$: ReadonlyStore<number>

A readonly store that contains the scrollHeight of the body (uses a passive event listener).

Note that using this store will append a style element to the head of the document to position the body in 'relative' mode element will be appended to the head of the document, so that you can still override when needed by editing the body inline style.

Defined in

src/lib/body/size.ts:117


bodyScrollSize$

Const bodyScrollSize$: ReadonlyStore<{ height: number ; width: number }>

A readonly store that contains the scroll size of the body.

Note that using this store will append a style element to the head of the document to position the body in 'relative' mode element will be appended to the head of the document, so that you can still override when needed by editing the body inline style.

Defined in

src/lib/body/size.ts:67


bodyScrollSizePassive$

Const bodyScrollSizePassive$: ReadonlyStore<{ height: number ; width: number }>

A readonly store that contains the scroll size of the body (uses a passive event listener).

Note that using this store will append a style element to the head of the document to position the body in 'relative' mode element will be appended to the head of the document, so that you can still override when needed by editing the body inline style.

Defined in

src/lib/body/size.ts:75


bodyScrollWidth$

Const bodyScrollWidth$: ReadonlyStore<number>

A readonly store that contains the scrollWidth of the body.

Note that using this store will append a style element to the head of the document to position the body in 'relative' mode element will be appended to the head of the document, so that you can still override when needed by editing the body inline style.

Defined in

src/lib/body/size.ts:83


bodyScrollWidthPassive$

Const bodyScrollWidthPassive$: ReadonlyStore<number>

A readonly store that contains the scrollWidth of the body (uses a passive event listener).

Note that using this store will append a style element to the head of the document to position the body in 'relative' mode. You will still be able to override tp needed by editing the body inline style.

Defined in

src/lib/body/size.ts:95


documentVisible$

Const documentVisible$: ReadonlyStore<boolean>

A readonly store that contains true if the document is visible, false otherwise.

Defined in

src/lib/document/visible.ts:7


innerHeight$

Const innerHeight$: ReadonlyStore<number>

A readonly store that contains the innerHeight of the window.

Defined in

src/lib/viewport/size.ts:51


innerHeightPassive$

Const innerHeightPassive$: ReadonlyStore<number>

A readonly store that contains the innerHeight of the window (uses a passive event listener).

Defined in

src/lib/viewport/size.ts:59


innerWidth$

Const innerWidth$: ReadonlyStore<number>

A readonly store that contains the innerWidth of the window.

Defined in

src/lib/viewport/size.ts:38


innerWidthPassive$

Const innerWidthPassive$: ReadonlyStore<number>

A readonly store that contains the innerWidth of the window (uses a passive event listener).

Defined in

src/lib/viewport/size.ts:43


orientation$

Const orientation$: ReadonlyStore<Orientation>

A readonly store that indicates whether the viewport is in landscape or portrait mode.

Defined in

src/lib/viewport/orientation.ts:9


prefersColorScheme$

Const prefersColorScheme$: ReadonlyStore<ColorScheme>

A readonly store that contains the preferred color scheme. It defaults to 'light' if no explicit preference has been set by the user agent.

Defined in

src/lib/appearance/prefers-color-scheme.ts:11


prefersColorSchemeDarkDefault$

Const prefersColorSchemeDarkDefault$: ReadonlyStore<ColorScheme>

A readonly store that contains the preferred color scheme. It defaults to 'dark' if no explicit preference has been set by the user agent.

Defined in

src/lib/appearance/prefers-color-scheme.ts:21


scrollX$

Const scrollX$: ReadonlyStore<number>

A readonly store that contains the current scrolling position on the X axis.

Defined in

src/lib/viewport/scroll.ts:37


scrollXPassive$

Const scrollXPassive$: ReadonlyStore<number>

A readonly store that contains the current scrolling position on the X axis (uses a passive event listener).

Defined in

src/lib/viewport/scroll.ts:42


scrollY$

Const scrollY$: ReadonlyStore<number>

A readonly store that contains the current scrolling position on the Y axis.

Defined in

src/lib/viewport/scroll.ts:50


scrollYPassive$

Const scrollYPassive$: ReadonlyStore<number>

A readonly store that contains the current scrolling position on the Y axis (uses a passive event listener).

Defined in

src/lib/viewport/scroll.ts:55


viewportSize$

Const viewportSize$: ReadonlyStore<{ height: number ; width: number }>

A readonly store that contains the size of the viewport (innerWidth and innerHeight of the window).

Defined in

src/lib/viewport/size.ts:28


viewportSizePassive$

Const viewportSizePassive$: ReadonlyStore<{ height: number ; width: number }>

A readonly store that contains the size of the viewport (innerWidth and innerHeight of the window) (uses a passive event listener).

Defined in

src/lib/viewport/size.ts:33


windowScroll$

Const windowScroll$: ReadonlyStore<{ x: number ; y: number }>

A readonly store that contains the current scrolling position (x and y).

Defined in

src/lib/viewport/scroll.ts:27


windowScrollPassive$

Const windowScrollPassive$: ReadonlyStore<{ x: number ; y: number }>

A readonly store that contains the current scrolling position (x and y) (uses a passive event listener).

Defined in

src/lib/viewport/scroll.ts:32

Functions

makeMediaQueryStore

makeMediaQueryStore(mediaQueryString): ReadonlyStore<boolean>

Create a boolean ReadonlyStore whose value corresponds to whether or not a media query "matches".

Example usage:

const prefersLightTheme$ = makeMediaQueryStore('(prefers-color-scheme: light)');
console.log(prefersLightTheme$.content()); // true or false depending on the browser/system settings.

prefersLightTheme$.subscribe(console.log); // will print true or false immediately and every time the preference changes.

Parameters

Name Type Description
mediaQueryString string a media query string compatible with window.matchMedia.

Returns

ReadonlyStore<boolean>

a boolean ReadonlyStore

Defined in

src/lib/utils/media-query.ts:19


makeScreenSizeStore

makeScreenSizeStore(__namedParameters): ReadonlyStore<ScreenSize>

Creates a store that indicates the screen size based on the width or height of the viewport.

Example usage:

const screenSize$ = makeScreenSizeStore({
	names: ['sm', 'md', 'lg'],
	thresholds: [768, 992],
});

screenSize$.subscribe(({name}) =>
	console.log(`Your screen is categorized as ${name}`),
);

Parameters

Name Type
__namedParameters MakeScreenSizeStoreParams

Returns

ReadonlyStore<ScreenSize>

a readonly store

Defined in

src/lib/viewport/screen.ts:59