Implement breakpointObserver.

Drop breakpoints constant export from Breakpoint component.
Expose breakpoints constant separately and freeze it.
Change `match` event to 'change`, because it is now based on store and captures initial value change.

Issues:
- Wrong exports in types/index.d.ts
- Typedefs lost from docs.
This commit is contained in:
Harald Brunner 2022-02-12 16:31:08 +01:00
commit 2cd2872274
10 changed files with 115 additions and 121 deletions

View file

@ -1,10 +1,6 @@
/// <reference types="svelte" />
import { SvelteComponentTyped } from "svelte";
export type BreakpointSize = "sm" | "md" | "lg" | "xlg" | "max";
export type BreakpointValue = 320 | 672 | 1056 | 1312 | 1584;
export interface BreakpointProps {
/**
* Determine the current Carbon grid breakpoint size
@ -22,15 +18,10 @@ export interface BreakpointProps {
export default class Breakpoint extends SvelteComponentTyped<
BreakpointProps,
{
match: CustomEvent<{
change: CustomEvent<{
size: BreakpointSize;
breakpointValue: BreakpointValue;
}>;
},
{ default: { size: BreakpointSize; sizes: Record<BreakpointSize, boolean> } }
> {
/**
* Reference the Carbon grid breakpoints
*/
breakpoints: Record<BreakpointSize, BreakpointValue>;
}
> {}