mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-09 22:14:29 +09:00
## Description Pure renaming, nothing else. ## Code Review - [ ] hi @TrySound , I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env.example` and the `builder/env-check.js` if mandatory
35 lines
954 B
TypeScript
35 lines
954 B
TypeScript
import { atom, computed } from "nanostores";
|
|
import type { Breakpoint, Breakpoints } from "@webstudio-is/sdk";
|
|
import { isBaseBreakpoint } from "../breakpoints";
|
|
|
|
export const $breakpoints = atom<Breakpoints>(new Map());
|
|
|
|
export const $selectedBreakpointId = atom<undefined | Breakpoint["id"]>(
|
|
undefined
|
|
);
|
|
|
|
export const $selectedBreakpoint = computed(
|
|
[$breakpoints, $selectedBreakpointId],
|
|
(breakpoints, selectedBreakpointId) => {
|
|
const selectedBreakpoint =
|
|
selectedBreakpointId === undefined
|
|
? undefined
|
|
: breakpoints.get(selectedBreakpointId);
|
|
|
|
if (breakpoints.size === 0) {
|
|
return;
|
|
}
|
|
const breakpointsArray = Array.from(breakpoints.values());
|
|
return (
|
|
selectedBreakpoint ??
|
|
breakpointsArray.find(isBaseBreakpoint) ??
|
|
breakpointsArray[0] ??
|
|
undefined
|
|
);
|
|
}
|
|
);
|
|
|
|
export const $synchronizedBreakpoints = [
|
|
["selectedBreakpointId", $selectedBreakpointId],
|
|
] as const;
|