storybook-addon-colab 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to `storybook-addon-colab` are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Releases are published under npm's default dist-tag, `latest`; only a pre-release version (one with a `-`, such as `1.0.0-rc.1`) goes to `next`.
4
4
 
5
+ ## [0.2.1] - 2026-12-04
6
+
7
+ ### Fixed
8
+
9
+ - **Grid shows viewport names again.** In 0.2.0 a story's viewport menu showed only its icon whenever its Grid card was under 400 pixels wide, so at common window sizes no Grid card named its viewport. The menu now goes by the story's own width, in every view: a Tablet or Desktop story names its viewport on any card, and only a story narrower than 400 pixels shows just the icon.
10
+ - **A reload clears temporary canvas widths.** A width set with a story's width handle on the Canvas view is now kept only while the page stays loaded (still across view switches). A reload or a new tab starts without any, so an old temporary width can no longer hide a viewport saved meanwhile by an agent or another tab. Widths 0.2.0 left in the tab's session storage are ignored and deleted. The canvas pan and zoom are still remembered for the tab.
11
+ - The toolbar viewport menu's note about stories that set a viewport in their story file no longer ends with "it." alone on its last line.
12
+
5
13
  ## [0.2.0] - 2026-12-03
6
14
 
7
15
  What 0.1.0 called a canvas is now a **collection**: stories to review and discuss together, shown as a grid, as rows, as columns or on a canvas. The 0.1.0 board (free-size frames and drawing) and the Chrome 157 requirement are gone; "canvas" is now the name of one view of a collection. Install it with `npm install -D storybook-addon-colab`.
@@ -87,5 +95,6 @@ The first pre-release. Install it with `npm install -D storybook-addon-colab@nex
87
95
 
88
96
  See [Known limitations](https://github.com/winkerVSbecks/addon-colab#known-limitations) and [How comment pins find their element](https://github.com/winkerVSbecks/addon-colab#how-comment-pins-find-their-element-and-when-they-dont) in the README for the full list.
89
97
 
98
+ [0.2.1]: https://github.com/winkerVSbecks/addon-colab/compare/v0.2.0...v0.2.1
90
99
  [0.2.0]: https://github.com/winkerVSbecks/addon-colab/compare/v0.1.0...v0.2.0
91
100
  [0.1.0]: https://github.com/winkerVSbecks/addon-colab/releases/tag/v0.1.0
package/README.md CHANGED
@@ -139,7 +139,7 @@ The folder is created when the dev server starts. You don't need to add it to `s
139
139
  By default each view uses its own size: Grid lays every story out at 1280 × 800 and scales it into a card, Rows uses the page's width, and Columns uses 480 pixels. You can render stories at a viewport instead:
140
140
 
141
141
  - **Every story:** the viewport menu in the collection toolbar (**Auto** = each view's default). Choosing here applies to every story: it also clears each story's own choice in this collection (set in its header, or by an agent), in the same save. Choosing the entry that is already checked does this too. Only stories that set a viewport in their story file keep it; the menu says how many. Choosing in this menu also resets any temporary widths (see the Canvas view), and **Reset temporary widths** there resets them without choosing.
142
- - **One story:** the viewport menu in its header sets that story apart, ahead of the toolbar's choice, until the next choice in the toolbar. While a story has its own choice, the menu's button is in the accent colour and the menu says so; **Use collection viewport** removes the choice (**Use story's viewport** when its story file sets one, which then applies). In a story narrower than 400 pixels the button shows only its icon, so the title keeps room. Choosing here also resets that story's temporary width.
142
+ - **One story:** the viewport menu in its header sets that story apart, ahead of the toolbar's choice, until the next choice in the toolbar. While a story has its own choice, the menu's button is in the accent colour and the menu says so; **Use collection viewport** removes the choice (**Use story's viewport** when its story file sets one, which then applies). When the story itself is narrower than 400 pixels the button shows only its icon, so the title keeps room. This goes by the story's width, not the size it is drawn at: in Grid, a Tablet or Desktop story scaled down into a small card still shows its viewport's name. Choosing here also resets that story's temporary width.
143
143
 
144
144
  The menus are how a viewport is saved in the collection file, for everyone who opens it. The Canvas view's width handle only tries a width in your browser tab.
145
145
 
@@ -177,11 +177,11 @@ The story is loaded with Storybook's `viewport` global set to the chosen viewpor
177
177
  - **Zoom** with a pinch, <kbd>⌘</kbd>/<kbd>Ctrl</kbd>+wheel (around the pointer), or the zoom panel in the canvas's bottom-right corner: zoom out, the zoom level (click for 100%), zoom in, and zoom to fit every story. <kbd>Tab</kbd> reaches the panel after the last story. Keys, with the canvas focused: <kbd>+</kbd> and <kbd>-</kbd>, <kbd>0</kbd> for 100%, <kbd>Shift</kbd>+<kbd>1</kbd> to fit. Zoom only scales the picture: each story keeps rendering at its own width.
178
178
  - **Move a story** by dragging its title bar, or focus its grip and press the arrow keys (10 pixels; 50 with <kbd>Shift</kbd>). The new position is read out. Drop a story from Storybook's sidebar where you want it on the canvas.
179
179
  - **Try a story at another width** with the handle on its right edge. Drag it, or focus it and press <kbd>←</kbd>/<kbd>→</kbd> (10 pixels; 50 with <kbd>Shift</kbd>) or <kbd>Page Up</kbd>/<kbd>Page Down</kbd> for the next larger or smaller viewport. The story really re-lays out at that width (it isn't scaled). The width shows while you drag, and so does the viewport's name when the width snaps to one of your viewports (within 8 screen pixels, at any zoom); hold <kbd>Alt</kbd>/<kbd>⌥</kbd> to drag without snapping, and press <kbd>Esc</kbd> to cancel the drag. The story doesn't move while you resize it.
180
- The width is **temporary**: it is only in your browser tab and is never saved, so other people, other tabs and agents don't see it. While a story has one, its title bar shows the width (and the viewport's name when the width is one of your viewports and the story is at least 560 pixels wide) with a reset button that puts it back at its saved viewport; **Reset temporary widths** in the toolbar's viewport menu resets every story. It lasts while the tab is open, across view switches and reloads, like the pan and zoom. It applies in the Canvas view only: Grid, Rows and Columns show each story at its saved viewport. To keep a width, choose it in the story's viewport menu (or the toolbar's): that saves it and clears the temporary width. A viewport saved anywhere else clears it the same way, so the saved choice always shows: by an agent (`set_story_viewport` clears that story's, `update_collection { viewport }` every story's) or in another tab.
180
+ The width is **temporary**: it is only in your browser tab and is never saved, so other people, other tabs and agents don't see it. While a story has one, its title bar shows the width (and the viewport's name when the width is one of your viewports and the story is at least 560 pixels wide) with a reset button that puts it back at its saved viewport; **Reset temporary widths** in the toolbar's viewport menu resets every story. It lasts across view switches until the page is reloaded or closed: a reload or a new tab starts without any (unlike the pan and zoom, which the tab remembers), so a temporary width never hides a viewport saved meanwhile. It applies in the Canvas view only: Grid, Rows and Columns show each story at its saved viewport. To keep a width, choose it in the story's viewport menu (or the toolbar's): that saves it and clears the temporary width. A viewport saved anywhere else clears it the same way, so the saved choice always shows: by an agent (`set_story_viewport` clears that story's, `update_collection { viewport }` every story's) or in another tab.
181
181
  A temporary width changes only the frame's width: inside the story, Storybook's `viewport` global stays the saved viewport, so a story that reads that global (rather than a media query or its own width) still sees the saved one.
182
182
  - <kbd>Tab</kbd> goes through the stories in reading order (top to bottom, then left to right), and the canvas pans to whatever gets focus.
183
183
  - **Comments** work as in the other views. Pins stay on their elements at any pan and zoom. Opening a thread from the sidebar pans its story into view, and in comment mode the wheel scrolls a scrollable box inside a story before it pans the canvas.
184
- - **What is saved.** Positions are saved in the collection file when you move a story, and kept when you switch views (the other views ignore them). Opening the canvas, panning, zooming and the width handle write nothing. The pan, zoom and temporary widths are remembered for the browser tab; the first time, the canvas zooms to fit, never past 100%.
184
+ - **What is saved.** Positions are saved in the collection file when you move a story, and kept when you switch views (the other views ignore them). Opening the canvas, panning, zooming and the width handle write nothing. The pan and zoom are remembered for the browser tab (temporary widths are not: a reload clears them); the first time, the canvas zooms to fit, never past 100%.
185
185
 
186
186
  ## Comments and threads
187
187
 
@@ -1755,26 +1755,9 @@ function WidthHandle({ width, options, title, zoom, onPreview, onCommit, onDragg
1755
1755
  );
1756
1756
  }
1757
1757
  var EMPTY = /* @__PURE__ */ new Map();
1758
- function temporaryWidthsKey(collectionId) {
1759
- return `addon-colab/canvas-widths/${collectionId}`;
1760
- }
1761
1758
  function isWidth(value) {
1762
1759
  return typeof value === "number" && Number.isInteger(value) && value >= MIN_VIEWPORT_WIDTH && value <= MAX_VIEWPORT_WIDTH;
1763
1760
  }
1764
- function parseTemporaryWidths(text) {
1765
- if (!text) return EMPTY;
1766
- try {
1767
- const value = JSON.parse(text);
1768
- if (!value || typeof value !== "object" || Array.isArray(value)) return EMPTY;
1769
- const widths = Object.entries(value).filter((entry) => isWidth(entry[1]));
1770
- return widths.length ? new Map(widths) : EMPTY;
1771
- } catch {
1772
- return EMPTY;
1773
- }
1774
- }
1775
- function serializeTemporaryWidths(widths) {
1776
- return widths.size ? JSON.stringify(Object.fromEntries(widths)) : null;
1777
- }
1778
1761
  function withTemporaryWidth(widths, itemId, width) {
1779
1762
  if (width === null) {
1780
1763
  if (!widths.has(itemId)) return widths;
@@ -1800,31 +1783,29 @@ function clearedByViewportChange(before, after) {
1800
1783
  return !!was && !sameViewport(was.viewport, item.viewport);
1801
1784
  }).map((item) => item.id);
1802
1785
  }
1803
- function read(collectionId) {
1786
+ var LEGACY_STORAGE_PREFIX = "addon-colab/canvas-widths/";
1787
+ function forgetStoredTemporaryWidths(storage = globalThis.sessionStorage) {
1804
1788
  try {
1805
- return parseTemporaryWidths(sessionStorage.getItem(temporaryWidthsKey(collectionId)));
1806
- } catch {
1807
- return EMPTY;
1808
- }
1809
- }
1810
- function write(collectionId, widths) {
1811
- try {
1812
- const text = serializeTemporaryWidths(widths);
1813
- if (text === null) sessionStorage.removeItem(temporaryWidthsKey(collectionId));
1814
- else sessionStorage.setItem(temporaryWidthsKey(collectionId), text);
1789
+ if (!storage) return;
1790
+ const keys = [];
1791
+ for (let index = 0; index < storage.length; index++) {
1792
+ const key = storage.key(index);
1793
+ if (key?.startsWith(LEGACY_STORAGE_PREFIX)) keys.push(key);
1794
+ }
1795
+ for (const key of keys) storage.removeItem(key);
1815
1796
  } catch {
1816
1797
  }
1817
1798
  }
1818
1799
  function useTemporaryWidths(collectionId, itemIds) {
1819
- const [state, setState] = useState(() => ({ collectionId, widths: read(collectionId) }));
1820
- const stored = state.collectionId === collectionId ? state.widths : read(collectionId);
1821
- if (state.collectionId !== collectionId) setState({ collectionId, widths: stored });
1800
+ const [state, setState] = useState(() => ({ collectionId, widths: EMPTY }));
1801
+ useEffect(() => forgetStoredTemporaryWidths(), []);
1802
+ const current = state.collectionId === collectionId ? state.widths : EMPTY;
1803
+ if (state.collectionId !== collectionId) setState({ collectionId, widths: EMPTY });
1822
1804
  const update = useCallback(
1823
- (change) => setState((current) => {
1824
- const base = current.collectionId === collectionId ? current.widths : read(collectionId);
1805
+ (change) => setState((previous) => {
1806
+ const base = previous.collectionId === collectionId ? previous.widths : EMPTY;
1825
1807
  const next = change(base);
1826
- if (next === base && current.collectionId === collectionId) return current;
1827
- write(collectionId, next);
1808
+ if (next === base && previous.collectionId === collectionId) return previous;
1828
1809
  return { collectionId, widths: next };
1829
1810
  }),
1830
1811
  [collectionId]
@@ -1834,7 +1815,7 @@ function useTemporaryWidths(collectionId, itemIds) {
1834
1815
  [update]
1835
1816
  );
1836
1817
  const clear = useCallback(() => update((widths2) => widths2.size ? EMPTY : widths2), [update]);
1837
- const widths = useMemo(() => presentTemporaryWidths(stored, itemIds), [stored, itemIds]);
1818
+ const widths = useMemo(() => presentTemporaryWidths(current, itemIds), [current, itemIds]);
1838
1819
  return { widths, set, clear };
1839
1820
  }
1840
1821
  var NOTICE_MS = 6e3;
@@ -3380,6 +3361,7 @@ function storyTitleFromId(storyId) {
3380
3361
  return { short: `${title} / ${name}`, full: `${title} \u203A ${name}` };
3381
3362
  }
3382
3363
  var STORY_FRAME_CONTAINER = "story-frame";
3364
+ var NARROW_STORY_WIDTH = 400;
3383
3365
  var Root2 = styled.article(({ theme }) => ({
3384
3366
  display: "flex",
3385
3367
  flexDirection: "column",
@@ -3533,6 +3515,7 @@ function StoryFrameView({
3533
3515
  "data-story-frame": storyId,
3534
3516
  "data-story-frame-status": status.kind,
3535
3517
  "data-story-frame-live": live ? "" : void 0,
3518
+ "data-story-frame-narrow": width < NARROW_STORY_WIDTH ? "" : void 0,
3536
3519
  "aria-label": fullTitle,
3537
3520
  style: { width: bodyWidth + 2 }
3538
3521
  },
@@ -4441,17 +4424,15 @@ function ThreadSidebar({
4441
4424
  ))
4442
4425
  );
4443
4426
  }
4444
- var NARROW_FRAME_WIDTH = 400;
4445
4427
  var MenuTrigger = styled(Button)(({ theme }) => ({
4446
4428
  maxWidth: 180,
4447
4429
  // A story on its own viewport in the collection (not the toolbar's): the trigger is in the accent.
4448
4430
  "&[data-colab-viewport-own]": { color: theme.color.secondary },
4449
4431
  "& > span": { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
4450
- // A story's own viewport menu in a narrow story frame (the frame is a `story-frame` container):
4451
- // only its icon, so the story's title keeps room. The name stays in its tooltip and accessible name.
4452
- [`@container ${STORY_FRAME_CONTAINER} (max-width: ${NARROW_FRAME_WIDTH - 1}px)`]: {
4453
- '&[data-colab-viewport-menu="item"] > span': { display: "none" }
4454
- }
4432
+ // A story's own viewport menu in the frame of a narrow story (`NARROW_STORY_WIDTH`, its real
4433
+ // width, so a Grid card scaled down from a wide story keeps the name): only its icon, so the story's
4434
+ // title keeps room. The name stays in its tooltip and accessible name.
4435
+ '[data-story-frame-narrow] &[data-colab-viewport-menu="item"] > span': { display: "none" }
4455
4436
  }));
4456
4437
  var MenuOnlyTrigger = forwardRef(
4457
4438
  function MenuOnlyTrigger2(props, ref) {
@@ -4749,7 +4730,7 @@ function temporaryText(count) {
4749
4730
  return `${storiesText(count)} ${count === 1 ? "has a temporary width" : "have a temporary width"} on the canvas, in this tab only. Choosing a viewport here resets ${count === 1 ? "it" : "them"}.`;
4750
4731
  }
4751
4732
  function storyFileText(count) {
4752
- return `${storiesText(count)} ${count === 1 ? "sets a viewport in its" : "set a viewport in their"} story file and ${count === 1 ? "keeps it" : "keep it"}.`;
4733
+ return `${storiesText(count)} ${count === 1 ? "sets a viewport in its" : "set a viewport in their"} story file and ${count === 1 ? "keeps" : "keep"}\xA0it.`;
4753
4734
  }
4754
4735
  function ownText(label) {
4755
4736
  return `Its own viewport in this collection: ${label}. The next choice in the toolbar clears it.`;
@@ -4763,7 +4744,8 @@ var Others = styled.div(({ theme }) => ({
4763
4744
  color: theme.textMutedColor,
4764
4745
  fontSize: theme.typography.size.s1,
4765
4746
  lineHeight: "16px",
4766
- "& p": { margin: 0 }
4747
+ // `pretty`: no word left alone on a note's last line.
4748
+ "& p": { margin: 0, textWrap: "pretty" }
4767
4749
  }));
4768
4750
  var Divider = styled.hr(({ theme }) => ({
4769
4751
  width: "100%",
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { preview_default } from './chunk-T3VJLPBO.js';
1
+ import { preview_default } from './chunk-K6X5UDOT.js';
2
2
  import { definePreviewAddon } from 'storybook/internal/csf';
3
3
 
4
4
  var index_default = () => definePreviewAddon(preview_default);
package/dist/preset.js CHANGED
@@ -1418,7 +1418,7 @@ function collectionEntryPresets(dirFor) {
1418
1418
 
1419
1419
  // package.json
1420
1420
  var package_default = {
1421
- version: "0.2.0"};
1421
+ version: "0.2.1"};
1422
1422
 
1423
1423
  // src/server/mcp/format.ts
1424
1424
  function storiesFromIndex(entries) {
package/dist/preview.js CHANGED
@@ -1 +1 @@
1
- export { preview_default as default } from './chunk-T3VJLPBO.js';
1
+ export { preview_default as default } from './chunk-K6X5UDOT.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-colab",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CoLab: collect stories in a collection, view them as a grid, rows, columns or a canvas at any viewport, discuss them in threads pinned to elements, and let a coding agent build collections and work through feedback over MCP",
5
5
  "keywords": [
6
6
  "storybook-addon",