@lightdash/cli 2.411.0 → 2.412.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.
@@ -103,6 +103,8 @@ shadcn, charting, theming, floating surfaces, screenshots) still applies.
103
103
  NOT `height: 100%` — that collapses to a 0-height invisible box unless every ancestor also
104
104
  sets a height, leaving auto-sizing charts like recharts `<ResponsiveContainer>` nothing to
105
105
  measure. Confirm the chart actually renders and isn't a blank box.
106
+ - **Fit the frame.** The viewport is an iframe exactly the size of the chart's tile, and
107
+ the tile never resizes to its content. See "Fitting the frame" below.
106
108
  - **Placeholder.** Show a clearly visible placeholder (readable, good contrast — never
107
109
  near-white on white) while `!ready`, when a required field is unmapped, or when there are
108
110
  no rows.
@@ -114,6 +116,24 @@ shadcn, charting, theming, floating surfaces, screenshots) still applies.
114
116
  `getFieldLabel(context, fieldId)`. Never show the query id (`orders_total_revenue`)
115
117
  or a name derived from it (humanized, or with the table prefix stripped).
116
118
 
119
+ ### Fitting the frame
120
+
121
+ A tile can be anything from about 300px wide and 300px tall (a phone, where a dashboard
122
+ stacks its tiles in one column) to a full-width desktop tile. The template already makes
123
+ the frame the container: it scrolls vertically when the content is taller than the tile,
124
+ and its base font size shrinks in a narrow tile. What is left to the chart:
125
+
126
+ - Size type, padding and gaps in `rem` or Tailwind classes, never `px`, so they shrink
127
+ with the frame.
128
+ - A row of items wraps onto more rows as the frame narrows (auto-fit grid columns or
129
+ `flex-wrap`). The minimum item width is what one item needs to keep its values on one
130
+ line, capped just under half the frame so two still fit on a phone:
131
+ `min(<that width in rem>, 45%)`.
132
+ - A value stays on one line and is never truncated. A long label wraps between words.
133
+ A table is `width: 100%` with wrapping header cells.
134
+ - Add no scroll region of your own. A title or table header row that should stay visible
135
+ while the frame scrolls is `position: sticky; top: 0` with an opaque background.
136
+
117
137
  ## Series colours
118
138
 
119
139
  Use the query SDK's host-resolved colour helpers for every series or group:
@@ -607,6 +627,10 @@ Then check both directions: every key you read from `options` is declared, and e
607
627
  you declared is read somewhere. `colorPalette` is declared when you use either resolved-
608
628
  colour helper or colour from `colorPalette` — it is never read from `options`.
609
629
 
630
+ Then resize the frame mentally, to a 320px by 320px phone tile and to a wide desktop
631
+ tile: nothing is wider than the frame, rows of items wrap, and a title or table header
632
+ stays in view if the frame scrolls.
633
+
610
634
  Before returning the declaration, add a `description` to each slot whose role
611
635
  could be ambiguous to a viewer, and add `inputGuidance` whenever row shape or ordering
612
636
  matters. Keep that help reusable across queries: describe the chart contract rather than a
@@ -33,6 +33,7 @@ Users describe features by what they see in the Lightdash editor. Translate:
33
33
  | Lightdash-owned "View underlying data" dialog (viz only) | `viz-host-underlying-data` | app code opt-in |
34
34
  | light/dark mode, "matches my Lightdash theme" | `follow-host-theme` | CSS tokens — see below |
35
35
  | "executive summary", "what changed", anomaly callouts, "AI insight", "Analyse this view" | `ai-insights` | app code opt-in |
36
+ | "Adapts to small tiles", responsive, works on a phone, readable in a narrow or short tile (viz only) | `viz-responsive-layout` | layout — see below |
36
37
 
37
38
  ## Automatic (zero wiring — active on any current-SDK bundle)
38
39
 
@@ -89,6 +90,45 @@ For colours CSS can't reach (a chart library's theme object, a logo swap), read
89
90
  the mode: `const colorScheme = useColorScheme();` — `'light' | 'dark'`,
90
91
  re-rendering on every host toggle.
91
92
 
93
+ ### `viz-responsive-layout` — a chart type that adapts to small tiles
94
+
95
+ There is no API to call: this is a layout rework. The chart renders in an iframe
96
+ exactly the size of its tile, and the tile never resizes to its content, so the
97
+ chart adapts to the tile.
98
+
99
+ The template makes the frame the container, but a chart type built on an older
100
+ template carries its own copies of `src/main.jsx` and `src/index.css` without
101
+ that. Add both pieces first if they are missing:
102
+
103
+ ```jsx
104
+ // src/main.jsx — import useVizContext from '@lightdash/query-sdk', define this,
105
+ // and render <VizFrame /> just before <App /> inside <VizContextProvider>.
106
+ function VizFrame() {
107
+ const { ready } = useVizContext();
108
+ React.useEffect(() => {
109
+ document.documentElement.toggleAttribute('data-viz-frame', ready);
110
+ }, [ready]);
111
+ return null;
112
+ }
113
+ ```
114
+
115
+ ```css
116
+ /* src/index.css — inside the `@layer base` block that holds the `#root` rules. */
117
+ html[data-viz-frame] {
118
+ font-size: clamp(12px, calc(4px + 2.5vw), 16px);
119
+ }
120
+ html[data-viz-frame] #root {
121
+ height: 100vh;
122
+ overflow-y: auto;
123
+ }
124
+ ```
125
+
126
+ Then follow the "Fitting the frame" section of the `reusable-visualization`
127
+ skill. An older chart type usually needs its fixed column counts and pixel sizes
128
+ replaced with wrapping, `rem`-sized ones and its own scroll regions removed; a
129
+ chart drawn by a library that measures its container often needs nothing more.
130
+ Keep the declaration (fields, config options, palette) unchanged.
131
+
92
132
  ### `viz-pivoted-results` — reusable visualization pivots
93
133
 
94
134
  Read `pivotDetails` from `useVizContext()`. When it is non-null, match
@@ -98,6 +98,16 @@
98
98
  z-index: -1;
99
99
  background: inherit;
100
100
  }
101
+ /* Chart types (see VizFrame in main.jsx): the frame is the container. It
102
+ scrolls when the content is taller than the tile, and rem sizes shrink in
103
+ a narrow tile. */
104
+ html[data-viz-frame] {
105
+ font-size: clamp(12px, calc(4px + 2.5vw), 16px);
106
+ }
107
+ html[data-viz-frame] #root {
108
+ height: 100vh;
109
+ overflow-y: auto;
110
+ }
101
111
  /* `dark` on the shell re-points the theme variables but not the color already
102
112
  inherited from <body>, which would leave bare text in light-theme ink. */
103
113
  :where(#root > .dark:first-child) {
@@ -6,6 +6,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
6
6
  import {
7
7
  createClient,
8
8
  LightdashProvider,
9
+ useVizContext,
9
10
  VizContextProvider,
10
11
  } from '@lightdash/query-sdk';
11
12
  import { FilterProvider } from '@/lib/filters';
@@ -33,6 +34,16 @@ const lightdash = createClient();
33
34
 
34
35
  initScreenshotHandler();
35
36
 
37
+ // A chart type renders in a frame the size of its tile; a page app grows.
38
+ // Only a chart type receives a viz context, so mark the document for index.css.
39
+ function VizFrame() {
40
+ const { ready } = useVizContext();
41
+ React.useEffect(() => {
42
+ document.documentElement.toggleAttribute('data-viz-frame', ready);
43
+ }, [ready]);
44
+ return null;
45
+ }
46
+
36
47
  ReactDOM.createRoot(document.getElementById('root')).render(
37
48
  <React.StrictMode>
38
49
  <QueryClientProvider client={queryClient}>
@@ -40,6 +51,7 @@ ReactDOM.createRoot(document.getElementById('root')).render(
40
51
  <FilterProvider>
41
52
  <ErrorBoundary>
42
53
  <VizContextProvider>
54
+ <VizFrame />
43
55
  <App />
44
56
  </VizContextProvider>
45
57
  </ErrorBoundary>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/cli",
3
- "version": "2.411.0",
3
+ "version": "2.412.1",
4
4
  "description": "Lightdash CLI tool",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,8 +22,8 @@
22
22
  "@actions/core": "1.11.1",
23
23
  "@aws-sdk/credential-providers": "3.995.0",
24
24
  "@casl/ability": "6.8.0",
25
- "@lightdash/common": "2.411.0",
26
- "@lightdash/warehouses": "2.411.0",
25
+ "@lightdash/common": "2.412.1",
26
+ "@lightdash/warehouses": "2.412.1",
27
27
  "@sidvind/better-ajv-errors": "7.0.0",
28
28
  "@types/columnify": "1.5.1",
29
29
  "ajv": "8.18.0",