webcoreui
Version:
UI component and template library for Astro, Svelte, and React apps styled with Sass.
18 lines (12 loc) • 469 B
text/typescript
import { isOneOf } from './isOneOf'
const breakpoints = ['xs', 'sm', 'md', 'lg'] as const
export type Breakpoint = typeof breakpoints[number]
export const getBreakpoint = (): Breakpoint => {
const value = getComputedStyle(document.documentElement)
.getPropertyValue('--w-breakpoint')
.trim()
if (isOneOf<Breakpoint>(breakpoints)(value)) {
return value
}
throw new Error(`Unexpected breakpoint: ${value}`)
}