mirror of
https://github.com/SigNoz/signoz.git
synced 2026-11-23 08:40:42 +00:00
Compare commits
6 Commits
docs/css-m
...
ci/storybo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e810c0541 | ||
|
|
b49b9a45a1 | ||
|
|
aa8fe8ef5d | ||
|
|
367c6c970c | ||
|
|
0d8c2c9cd3 | ||
|
|
b92d061a2c |
@@ -88,7 +88,7 @@ Say the numbers plainly: how many screens changed, how many are new, how many ar
|
||||
- A full capture is hundreds of shots. Scope with `--title "Pages/Alerts"` or `--stories "a,b,c"` (substring match on id or Title/Name, repeatable).
|
||||
- **On macOS a capture can pin itself to one story at a time.** sbshot picks how many to shoot at once by sampling free memory, and off Linux it reads `os.freemem()`, which counts only truly free pages. macOS parks almost everything in "inactive" instead, which is reclaimable on demand, so the sampler can read ~100 MB on a 25 GB machine and shrink to one forever. `--jobs` does not help: it is only an upper cap. Check `parallelism` in `<run>/events.ndjson`; if it sits at 1 while `vm_stat` shows gigabytes inactive, that is this. A 124-shot run takes about 90 minutes pinned and about 6 minutes at four at a time, so it is worth spotting before a long capture.
|
||||
- A fresh worktree cannot build Storybook: `i18n-translations-hash.json` is gitignored and generated. Run `node ./i18-generate-hash.cjs` in `<worktree>/frontend`, and symlink `node_modules` from the main checkout.
|
||||
- `pnpm test:storybook` starts its own server on 6006 and hangs silently if something already holds that port. Free it first.
|
||||
- `pnpm test:storybook` builds Storybook and serves the build on 6006, and refuses to start if something already holds that port. Free it first.
|
||||
- ImageMagick on macOS may have no default font, so `--mode green-parallel` fails with ``unable to read font `' ``. Map Helvetica to a real file in `~/.config/ImageMagick/type.xml`.
|
||||
- `sbshot link <dir> <name>` adds a run from elsewhere into the workspace, but it symlinks. Keep the source directory alive until you have exported.
|
||||
- The export directory is build output. Delete it when done, or gitignore it.
|
||||
|
||||
72
.github/workflows/jsci.yaml
vendored
72
.github/workflows/jsci.yaml
vendored
@@ -79,19 +79,74 @@ jobs:
|
||||
run: |
|
||||
cd frontend && pnpm generate:api
|
||||
git diff --compact-summary --exit-code || (echo; echo "Unexpected difference in generated api clients. Run pnpm generate:api in frontend/ locally and commit."; exit 1)
|
||||
storybook:
|
||||
storybook-build:
|
||||
if: |
|
||||
github.event_name == 'merge_group' ||
|
||||
(github.event_name == 'pull_request' && ! github.event.pull_request.head.repo.fork && github.event.pull_request.user.login != 'dependabot[bot]' && ! contains(github.event.pull_request.labels.*.name, 'safe-to-test')) ||
|
||||
(github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe-to-test'))
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
outputs:
|
||||
shards: ${{ steps.select-stories.outputs.shards }}
|
||||
steps:
|
||||
- name: self-checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# The pull_request merge commit and its first parent, the base branch.
|
||||
fetch-depth: 2
|
||||
- name: install-pnpm
|
||||
uses: pnpm/action-setup@v6
|
||||
with:
|
||||
version: 10
|
||||
- name: node-install
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: pnpm
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
- name: install-frontend
|
||||
run: cd frontend && pnpm install
|
||||
- name: build-storybook
|
||||
run: |
|
||||
cd frontend
|
||||
mkdir -p storybook-stats
|
||||
pnpm storybook:build --quiet --stats-json storybook-stats
|
||||
- name: select-stories
|
||||
id: select-stories
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
run: |
|
||||
cd frontend
|
||||
if [ "$EVENT_NAME" = pull_request ]; then
|
||||
git diff --name-only HEAD^1 HEAD | node scripts/select-stories.mjs storybook-stats/preview-stats.json > storybook-stories.txt
|
||||
else
|
||||
node scripts/select-stories.mjs --all storybook-stats/preview-stats.json > storybook-stories.txt
|
||||
fi
|
||||
count=$(grep -c . storybook-stories.txt || true)
|
||||
shard_count=$(( count > 80 ? 4 : (count + 19) / 20 ))
|
||||
echo "Testing $count story files on $shard_count shards"
|
||||
cat storybook-stories.txt
|
||||
echo "shards=[$(seq -s, 1 "$shard_count")]" >> "$GITHUB_OUTPUT"
|
||||
- name: upload-storybook
|
||||
if: steps.select-stories.outputs.shards != '[]'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: storybook-static
|
||||
retention-days: 1
|
||||
path: |
|
||||
frontend/storybook-static
|
||||
frontend/storybook-stories.txt
|
||||
storybook:
|
||||
needs: storybook-build
|
||||
if: needs.storybook-build.outputs.shards != '[]'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
container:
|
||||
image: mcr.microsoft.com/playwright:v1.57.0-noble
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shard: [1, 2, 3, 4]
|
||||
shard: ${{ fromJSON(needs.storybook-build.outputs.shards) }}
|
||||
steps:
|
||||
- name: self-checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -107,8 +162,19 @@ jobs:
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
- name: install-frontend
|
||||
run: cd frontend && pnpm install
|
||||
- name: download-storybook
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: storybook-static
|
||||
path: frontend
|
||||
- name: test-storybook
|
||||
run: cd frontend && pnpm test:storybook --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
||||
shell: bash
|
||||
env:
|
||||
STORYBOOK_STATIC_DIR: storybook-static
|
||||
run: |
|
||||
cd frontend
|
||||
mapfile -t stories < storybook-stories.txt
|
||||
pnpm test:storybook --shard=${{ matrix.shard }}/${{ strategy.job-total }} "${stories[@]}"
|
||||
web-settings:
|
||||
if: |
|
||||
github.event_name == 'merge_group' ||
|
||||
|
||||
2
frontend/.gitignore
vendored
2
frontend/.gitignore
vendored
@@ -32,6 +32,8 @@ e2e/test-plan/user-preferences/
|
||||
|
||||
# Storybook
|
||||
/storybook-static/
|
||||
/storybook-stats/
|
||||
/storybook-stories.txt
|
||||
debug-storybook.log
|
||||
|
||||
# Storybook screenshots (sbshot)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getStoryContext } from '@storybook/test-runner';
|
||||
import type { TestRunnerConfig } from '@storybook/test-runner';
|
||||
import type { Page } from 'playwright';
|
||||
import type { Page, Request } from 'playwright';
|
||||
|
||||
const IGNORED_MESSAGES = [
|
||||
// `preview-head.html` swaps a local stylesheet in for Google Fonts, but the
|
||||
@@ -41,6 +41,31 @@ const PREPARE_TIMEOUT_MS = 180_000;
|
||||
|
||||
const messagesByPage = new WeakMap<Page, CapturedMessage[]>();
|
||||
|
||||
const SETTLE_TIMEOUT_MS = 1_000;
|
||||
|
||||
const requestsByPage = new WeakMap<Page, Set<Request>>();
|
||||
|
||||
/**
|
||||
* The runner opens the next story in this page as soon as the previous one has
|
||||
* rendered, so what that one still has in flight answers into state both share:
|
||||
* the Noz store holds a single thread id. Requests held open on purpose never
|
||||
* end, so the wait gives up and forgets them.
|
||||
*/
|
||||
const settleRequests = async (page: Page): Promise<void> => {
|
||||
const pending = requestsByPage.get(page);
|
||||
if (!pending) {
|
||||
return;
|
||||
}
|
||||
|
||||
const deadline = Date.now() + SETTLE_TIMEOUT_MS;
|
||||
while (pending.size > 0 && Date.now() < deadline) {
|
||||
await new Promise((resolve) => {
|
||||
setTimeout(resolve, 25);
|
||||
});
|
||||
}
|
||||
pending.clear();
|
||||
};
|
||||
|
||||
/**
|
||||
* When the story under test started rendering, stamped by the preview's
|
||||
* `beforeEach`. Messages captured before it belong to the previous story: the
|
||||
@@ -71,6 +96,8 @@ const config: TestRunnerConfig = {
|
||||
});
|
||||
},
|
||||
async preVisit(page): Promise<void> {
|
||||
await settleRequests(page);
|
||||
|
||||
const existing = messagesByPage.get(page);
|
||||
if (existing) {
|
||||
existing.length = 0;
|
||||
@@ -79,6 +106,11 @@ const config: TestRunnerConfig = {
|
||||
|
||||
const messages: CapturedMessage[] = [];
|
||||
messagesByPage.set(page, messages);
|
||||
const pending = new Set<Request>();
|
||||
requestsByPage.set(page, pending);
|
||||
page.on('request', (request) => pending.add(request));
|
||||
page.on('requestfinished', (request) => pending.delete(request));
|
||||
page.on('requestfailed', (request) => pending.delete(request));
|
||||
page.on('console', (message) => {
|
||||
if (
|
||||
message.type() === 'error' &&
|
||||
|
||||
@@ -28,7 +28,7 @@ You are operating within a constrained context window and strict system prompts.
|
||||
- UI primitives come from `@signozhq/ui` (subpath imports) and icons from `@signozhq/icons`. No new `antd` component or direct icon library (`lucide-react`) where `@signozhq/ui` has an equivalent; `signoz/no-antd-components` enforces part of this list.
|
||||
- Exception: a control added beside `antd` siblings of the same kind (a tab in an `antd` tab strip) matches them until that surface migrates. Say so in the PR.
|
||||
- When `@signozhq/ui` or `@signozhq/icons` lacks what you need, say so in the PR before reaching for another library.
|
||||
- Never override a `@signozhq/ui` component's styles: no `--<component>-*` CSS variables, no `:global` class or `data-*` selectors, no restyling through `className`/`style`. Use its props, and put layout on a wrapper you own. When it can't do what the design needs, file a UI suggestion in `SigNoz/uforge-pod` (`ui-suggestion.yml` template) and link it in the PR.
|
||||
- Before styling a `@signozhq/ui` component, check its props in `node_modules/@signozhq/ui/dist/<component>/*.d.ts` for `className`/`style` support; some omit them. Avoid overriding the component's CSS vars unless explicitly needed.
|
||||
- When writing code that could need authorization checks, read ./src/lib/authz/README.md
|
||||
- A flow that gains a request also gates on that request's permission: a rename that now reads the view first needs `read` as well as `update`.
|
||||
- Identity keys (legend groups, color groups, CSV headers, React keys) come from structured values, never from joined display text: `['us, east', 'prod']` and `['us', 'east, prod']` both join to `us, east, prod`.
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
- [ ] No deep class nesting (max 3 class levels; pseudo-classes/elements and parent-reference selectors like `&.active`, `&#bar` are not counted)
|
||||
- [ ] No hardcoded colors - use `--l1/l2/l3-*` semantic tokens (not `--bg-*` primitives)
|
||||
- [ ] No magic numbers - use `--spacing-*` tokens
|
||||
- [ ] Typography uses `--{variant}-{size}-{weight}-*` text style tokens (see Typography)
|
||||
- [ ] No overrides of `@signozhq/ui` components (see below)
|
||||
- [ ] Global escapes only for third-party overrides (`@signozhq/ui` is not third-party)
|
||||
- [ ] Typography uses `--periscope-font-size-*` or `--font-size-*` tokens
|
||||
- [ ] @signozhq/ui overrides use CSS variables, not direct class overrides
|
||||
- [ ] Global escapes only for third-party overrides
|
||||
- [ ] No ID selectors
|
||||
- [ ] No bare element selectors
|
||||
- [ ] Keyframes are declared in the module with plain `@keyframes name` (already local)
|
||||
- [ ] Keyframes use `:local(@keyframes name)` to avoid global collisions
|
||||
|
||||
## Config (vite.config.ts)
|
||||
|
||||
@@ -77,7 +77,7 @@ css: {
|
||||
|
||||
// BAD: Nesting creates separate classes you might not expect
|
||||
.button {
|
||||
.icon { } // -> styles.icon, but the rule is `.button .icon`: it only matches inside .button
|
||||
.icon { } // -> styles.icon (separate class, not scoped under .button)
|
||||
}
|
||||
|
||||
// GOOD: Flat structure
|
||||
@@ -289,32 +289,88 @@ Use L1/L2/L3 semantic tokens - they handle light/dark theme automatically.
|
||||
- L2 = elevated surfaces (cards, panels)
|
||||
- L3 = nested/inset elements
|
||||
|
||||
## @signozhq/ui Components
|
||||
## Overriding @signozhq/ui Components
|
||||
|
||||
Don't override them. That covers setting a component's `--<component>-*` CSS variables, targeting its classes or `data-*` attributes through `:global(...)`, and restyling it with `className` or `style`. An override keeps working until the component changes, then breaks with no type error or lint warning, and the screen drifts from every other one using that component.
|
||||
Components expose CSS variables for customization.
|
||||
|
||||
- Use the component's props (`variant`, `color`, `size`, ...) for how it looks.
|
||||
- Put layout (position, margin, width inside a flex or grid parent) on a wrapper element you own.
|
||||
- If the component can't do what the design needs, file a [UI suggestion](https://github.com/SigNoz/uforge-pod/issues/new?template=ui-suggestion.yml) in `SigNoz/uforge-pod` and ship with the component as it renders until the suggestion is decided. Link the issue in the PR.
|
||||
You can ensure they exist by looking at ./node_modules/@signozhq/ui/dist.
|
||||
Never write a override without confirm it exists.
|
||||
|
||||
Override via:
|
||||
|
||||
### Method 1: CSS Variables (Preferred)
|
||||
|
||||
Each component exposes `--<component>-<property>` variables:
|
||||
|
||||
```scss
|
||||
// BAD: Restyling the component
|
||||
.saveButton {
|
||||
--button-primary-background-color: var(--success-background);
|
||||
// Override Button
|
||||
.customButton {
|
||||
--button-background: var(--success-background);
|
||||
--button-border-radius: var(--radius-2);
|
||||
--button-padding: var(--spacing-4) var(--spacing-8);
|
||||
--button-font-size: var(--label-base-400-font-size);
|
||||
}
|
||||
|
||||
.toolbar :global([data-variant="outlined"]) {
|
||||
--button-variant-outlined-border: 1px solid var(--accent-primary);
|
||||
// Override Input
|
||||
.customInput {
|
||||
--input-height: 2.5rem;
|
||||
--input-border-color: var(--l2-border);
|
||||
--input-padding: var(--spacing-2) var(--spacing-6);
|
||||
--input-placeholder-color: var(--l3-foreground);
|
||||
}
|
||||
|
||||
// GOOD: Layout on your own wrapper, looks from props
|
||||
.toolbarActions {
|
||||
display: flex;
|
||||
gap: var(--spacing-4);
|
||||
margin-left: auto;
|
||||
// Override nested parts
|
||||
.customInput {
|
||||
--input-prefix-padding: 0 var(--spacing-4) 0 var(--spacing-6);
|
||||
--input-suffix-color: var(--accent-primary);
|
||||
}
|
||||
```
|
||||
|
||||
### Method 2: Data Attributes
|
||||
|
||||
Components use data attributes for variants/states. Target them for state-specific overrides:
|
||||
|
||||
```scss
|
||||
// Target variant
|
||||
.wrapper :global([data-variant="outlined"]) {
|
||||
--button-border-color: var(--accent-primary);
|
||||
}
|
||||
|
||||
// Target size
|
||||
.wrapper :global([data-size="sm"]) {
|
||||
--button-font-size: var(--label-small-400-font-size);
|
||||
}
|
||||
|
||||
// Target color
|
||||
.wrapper :global([data-color="destructive"]) {
|
||||
--button-background: var(--danger-background);
|
||||
}
|
||||
|
||||
// Target state (Radix patterns)
|
||||
.popover :global([data-state="open"]) {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.tooltip :global([data-side="top"]) {
|
||||
margin-bottom: var(--spacing-2);
|
||||
}
|
||||
```
|
||||
|
||||
### Common Component CSS Variables
|
||||
|
||||
**Button:**
|
||||
- `--button-background`, `--button-border-radius`, `--button-padding`
|
||||
- `--button-font-size`, `--button-height`, `--button-gap`
|
||||
- `--button-hover-background`, `--button-disabled-opacity`
|
||||
|
||||
**Input:**
|
||||
- `--input-height`, `--input-border-color`, `--input-background`
|
||||
- `--input-padding`, `--input-font-size`, `--input-placeholder-color`
|
||||
- `--input-focus-outline-color`, `--input-hover-border-color`
|
||||
- `--input-prefix-*`, `--input-suffix-*` for adornments
|
||||
|
||||
**General pattern:** `--<component>-<property>` or `--<component>-<state>-<property>`
|
||||
|
||||
## Good Patterns
|
||||
|
||||
### Structure
|
||||
@@ -378,21 +434,24 @@ Don't override them. That covers setting a component's `--<component>-*` CSS var
|
||||
|
||||
### Keyframes (Local Scoping)
|
||||
|
||||
CSS Modules scope `@keyframes` like classes: the build renames `fadeIn` to `_fadeIn_<hash>` and rewrites every `animation` in the same module that names it. Don't wrap it in `:local(...)`; Sass rejects `:local(@keyframes fadeIn)` with `expected selector`.
|
||||
Without `:local()`, keyframe names are global and can clash across modules:
|
||||
|
||||
```scss
|
||||
// GOOD: Local to this module
|
||||
// BAD: Global keyframe - can conflict with other modules
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
// GOOD: Locally scoped keyframe
|
||||
:local(@keyframes fadeIn) {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.modal {
|
||||
animation: fadeIn 200ms ease;
|
||||
}
|
||||
|
||||
// BAD: Doesn't compile
|
||||
:local(@keyframes fadeIn) { }
|
||||
```
|
||||
|
||||
## JS Import Patterns
|
||||
|
||||
116
frontend/scripts/select-stories.mjs
Normal file
116
frontend/scripts/select-stories.mjs
Normal file
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Prints the story files a change can affect, one per line, relative to
|
||||
* `frontend/`. Reads changed paths (relative to the repo root) on stdin and the
|
||||
* module graph `storybook build --stats-json` writes.
|
||||
*
|
||||
* git diff --name-only main...HEAD | node scripts/select-stories.mjs <preview-stats.json>
|
||||
* node scripts/select-stories.mjs --all <preview-stats.json>
|
||||
*
|
||||
* A story is selected when it imports a changed file, directly or through other
|
||||
* modules. Every story is selected when a changed file reaches
|
||||
* `.storybook/` (it renders around every story) or the graph cannot see it.
|
||||
*/
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const FULL_RUN_PATHS = [
|
||||
/^\.github\/workflows\/jsci\.yaml$/,
|
||||
/^frontend\/\.storybook\//,
|
||||
/^frontend\/public\//,
|
||||
/^frontend\/(package\.json|pnpm-lock\.yaml|tsconfig\.json)$/,
|
||||
/^frontend\/scripts\/(test-storybook\.sh|select-stories\.mjs)$/,
|
||||
];
|
||||
// Sass partials are compiled inside the `.scss` that uses them, so the graph
|
||||
// never lists them.
|
||||
const STYLE_FILE = /\.(scss|sass|css)$/;
|
||||
const STORY_FILE = /\.stories\.tsx?$/;
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const selectAllFlag = args.includes('--all');
|
||||
const statsPath = args.find((arg) => arg !== '--all');
|
||||
if (!statsPath) {
|
||||
console.error('Usage: select-stories.mjs [--all] <preview-stats.json>');
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const { modules } = JSON.parse(readFileSync(statsPath, 'utf8'));
|
||||
const importersById = new Map(
|
||||
modules.map((module) => [
|
||||
module.id,
|
||||
module.reasons.map((reason) => reason.moduleName),
|
||||
]),
|
||||
);
|
||||
const allStories = [...importersById.keys()].filter((id) =>
|
||||
STORY_FILE.test(id),
|
||||
);
|
||||
|
||||
function selectAll(reason) {
|
||||
console.error(`Selecting every story: ${reason}`);
|
||||
return allStories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks importers up from `id`. Returns the stories reached, or the module
|
||||
* under `.storybook/` that imports it, which means every story is affected.
|
||||
*/
|
||||
function findImportingStories(id) {
|
||||
const stories = [];
|
||||
const pending = [id];
|
||||
const seen = new Set(pending);
|
||||
while (pending.length > 0) {
|
||||
const current = pending.pop();
|
||||
if (current.startsWith('./.storybook/')) {
|
||||
return { storybookModule: current, stories };
|
||||
}
|
||||
if (STORY_FILE.test(current)) {
|
||||
stories.push(current);
|
||||
}
|
||||
const importers = (importersById.get(current) ?? []).filter(
|
||||
(importer) => !seen.has(importer) && !importer.startsWith('/virtual:'),
|
||||
);
|
||||
importers.forEach((importer) => seen.add(importer));
|
||||
pending.push(...importers);
|
||||
}
|
||||
return { stories };
|
||||
}
|
||||
|
||||
function select(changedFiles) {
|
||||
const fullRunFile = changedFiles.find((file) =>
|
||||
FULL_RUN_PATHS.some((pattern) => pattern.test(file)),
|
||||
);
|
||||
if (fullRunFile) {
|
||||
return selectAll(`${fullRunFile} changed`);
|
||||
}
|
||||
|
||||
const selected = new Set();
|
||||
const ids = changedFiles
|
||||
.filter((file) => file.startsWith('frontend/'))
|
||||
.map((file) => `./${file.slice('frontend/'.length)}`);
|
||||
for (const id of ids) {
|
||||
if (!importersById.has(id)) {
|
||||
if (STYLE_FILE.test(id)) {
|
||||
return selectAll(`${id} is not in the module graph`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const { storybookModule, stories } = findImportingStories(id);
|
||||
if (storybookModule) {
|
||||
return selectAll(`${id} is imported by ${storybookModule}`);
|
||||
}
|
||||
stories.forEach((story) => selected.add(story));
|
||||
}
|
||||
return [...selected];
|
||||
}
|
||||
|
||||
const changedFiles = selectAllFlag
|
||||
? []
|
||||
: readFileSync(0, 'utf8')
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.filter(Boolean);
|
||||
const stories = selectAllFlag ? selectAll('--all') : select(changedFiles);
|
||||
|
||||
const lines = [...stories]
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.map((story) => `${story.slice('./'.length)}\n`);
|
||||
process.stdout.write(lines.join(''));
|
||||
@@ -1,31 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tests the static Storybook build. Arguments go to test-storybook: runner flags
|
||||
# and, optionally, the story files to test (all of them when none are given).
|
||||
# STORYBOOK_STATIC_DIR points at an existing build; without it the script builds
|
||||
# one into storybook-static/.
|
||||
set -euo pipefail
|
||||
|
||||
story_count=$(find src -name '*.stories.tsx' | wc -l)
|
||||
if [ "$story_count" -eq 0 ]; then
|
||||
echo "No *.stories.tsx found under src/" >&2
|
||||
port=6006
|
||||
static_dir=${STORYBOOK_STATIC_DIR:-}
|
||||
if [ -z "$static_dir" ]; then
|
||||
static_dir=storybook-static
|
||||
pnpm storybook:build --quiet
|
||||
fi
|
||||
if [ ! -f "$static_dir/index.json" ]; then
|
||||
echo "No Storybook build in $static_dir/" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# jest splits the sorted story files into contiguous shards and exits 1 when a
|
||||
# shard is empty, which happens on every shard above the file count. The runner
|
||||
# rejects jest's own `--passWithNoTests`, so skip those shards here.
|
||||
for arg in "$@"; do
|
||||
if [[ $arg == --shard=* ]]; then
|
||||
shard_index=${arg#--shard=}
|
||||
if [ "${shard_index%%/*}" -gt "$story_count" ]; then
|
||||
echo "Skipping ${arg#--shard=}: only ${story_count} story files"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if curl -s -o /dev/null "http://127.0.0.1:$port/"; then
|
||||
echo "Port $port is taken; stop whatever serves it first." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pnpm storybook --ci --quiet &
|
||||
SB_PID=$!
|
||||
trap 'kill "$SB_PID" 2>/dev/null || true' EXIT
|
||||
node_modules/.bin/vite preview --outDir "$static_dir" --host 127.0.0.1 --port "$port" --strictPort >/dev/null &
|
||||
SERVER_PID=$!
|
||||
trap 'kill "$SERVER_PID" 2>/dev/null || true' EXIT
|
||||
|
||||
until curl -sf http://127.0.0.1:6006/index.json >/dev/null 2>&1; do
|
||||
until curl -sf "http://127.0.0.1:$port/index.json" >/dev/null 2>&1; do
|
||||
kill -0 "$SERVER_PID" 2>/dev/null || {
|
||||
echo "Static server exited" >&2
|
||||
exit 1
|
||||
}
|
||||
sleep 1
|
||||
done
|
||||
|
||||
pnpm exec test-storybook --ci --maxWorkers=2 --testTimeout 30000 "$@"
|
||||
# Index-json mode names its tests after story titles, so story file arguments
|
||||
# would match nothing.
|
||||
pnpm exec test-storybook --ci --no-index-json --url "http://127.0.0.1:$port" --maxWorkers=2 --testTimeout 30000 "$@"
|
||||
|
||||
@@ -3,6 +3,7 @@ import { screen, userEvent } from 'storybook/test';
|
||||
|
||||
import { withCanvas } from '@/storybook/decorators/withCanvas';
|
||||
import type { GlobalMockArgs } from '@/storybook/globals';
|
||||
import { hoverTruncated } from '@/storybook/play/hoverTruncated';
|
||||
|
||||
import { CustomMultiSelect, CustomSelect } from '../index';
|
||||
|
||||
@@ -142,7 +143,7 @@ export const TruncatedOption: Story = {
|
||||
await userEvent.click(
|
||||
await screen.findByRole('combobox', { name: 'Service' }),
|
||||
);
|
||||
await userEvent.hover(
|
||||
await hoverTruncated(
|
||||
await screen.findByRole('option', { name: LONG_LABEL_OPTION.label }),
|
||||
);
|
||||
await screen.findByRole('tooltip', { name: LONG_LABEL_OPTION.label });
|
||||
@@ -156,7 +157,7 @@ export const TruncatedValue: Story = {
|
||||
value: LONG_LABEL_OPTION.value,
|
||||
},
|
||||
play: async (): Promise<void> => {
|
||||
await userEvent.hover(await screen.findByText(LONG_LABEL_OPTION.label));
|
||||
await hoverTruncated(await screen.findByText(LONG_LABEL_OPTION.label));
|
||||
await screen.findByRole('tooltip', { name: LONG_LABEL_OPTION.label });
|
||||
},
|
||||
};
|
||||
@@ -173,7 +174,7 @@ export const MultiTruncatedOption: Story = {
|
||||
await userEvent.click(
|
||||
await screen.findByRole('combobox', { name: 'Services' }),
|
||||
);
|
||||
await userEvent.hover(
|
||||
await hoverTruncated(
|
||||
await screen.findByRole('option', { name: LONG_LABEL_OPTION.label }),
|
||||
);
|
||||
await screen.findByRole('tooltip', { name: LONG_LABEL_OPTION.label });
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { expect, waitFor } from 'storybook/test';
|
||||
|
||||
import { withCanvas } from '@/storybook/decorators/withCanvas';
|
||||
|
||||
@@ -9,15 +8,18 @@ import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import { QueryBuilderV2 } from '../QueryBuilderV2';
|
||||
import {
|
||||
addOnToggles,
|
||||
appendToAggregation,
|
||||
expectGaugeDefaults,
|
||||
expectHistogramDefaults,
|
||||
expectSingleAggregation,
|
||||
expectTablePanelAddOns,
|
||||
expectTimeSeriesAddOns,
|
||||
expectValuePanelAddOns,
|
||||
} from './__story_mockdata__/queryBuilder.play';
|
||||
import {
|
||||
DEFAULT_ARGS,
|
||||
expectFirstQuery,
|
||||
PANEL_EDITOR_ARGS,
|
||||
PANEL_EDITOR_PATH,
|
||||
payloadIn,
|
||||
routeWith,
|
||||
selectMetric,
|
||||
} from './QueryBuilderV2.stories.mocks';
|
||||
import QueryProbe from './QueryProbe';
|
||||
|
||||
@@ -60,11 +62,7 @@ export const LogsOnValuePanel: Story = {
|
||||
parameters: {
|
||||
signoz: { route: routeWith(PANEL_EDITOR_PATH, initialQueriesMap.logs) },
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
await waitFor(() =>
|
||||
expect(addOnToggles(canvasElement)).toStrictEqual(['legend_format']),
|
||||
);
|
||||
},
|
||||
play: expectValuePanelAddOns,
|
||||
};
|
||||
|
||||
/** Metrics on a Table: reduce-to is offered; group by lives in the aggregation row. */
|
||||
@@ -73,17 +71,7 @@ export const MetricsOnTablePanel: Story = {
|
||||
parameters: {
|
||||
signoz: { route: routeWith(PANEL_EDITOR_PATH, initialQueriesMap.metrics) },
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
await waitFor(() =>
|
||||
expect(addOnToggles(canvasElement)).toStrictEqual([
|
||||
'having',
|
||||
'order_by',
|
||||
'limit',
|
||||
'legend_format',
|
||||
'reduce_to',
|
||||
]),
|
||||
);
|
||||
},
|
||||
play: expectTablePanelAddOns,
|
||||
};
|
||||
|
||||
/** Traces on a time series: every add-on, with group by as a toggle. */
|
||||
@@ -92,54 +80,21 @@ export const TracesOnTimeSeriesPanel: Story = {
|
||||
parameters: {
|
||||
signoz: { route: routeWith(PANEL_EDITOR_PATH, initialQueriesMap.traces) },
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
await waitFor(() =>
|
||||
expect(addOnToggles(canvasElement)).toStrictEqual([
|
||||
'group_by',
|
||||
'having',
|
||||
'order_by',
|
||||
'limit',
|
||||
'legend_format',
|
||||
]),
|
||||
);
|
||||
},
|
||||
play: expectTimeSeriesAddOns,
|
||||
};
|
||||
|
||||
/** Picking a gauge defaults to avg over time and avg across series. */
|
||||
export const GaugeMetricDefaults: Story = {
|
||||
args: METRICS_EXPLORER_ARGS,
|
||||
parameters: { signoz: { route: metricsExplorerRoute } },
|
||||
play: async ({ canvasElement }) => {
|
||||
await selectMetric(canvasElement, 'container_cpu_utilization');
|
||||
|
||||
await expectFirstQuery(canvasElement, {
|
||||
aggregations: [
|
||||
expect.objectContaining({
|
||||
metricName: 'container_cpu_utilization',
|
||||
timeAggregation: 'avg',
|
||||
spaceAggregation: 'avg',
|
||||
}),
|
||||
],
|
||||
});
|
||||
},
|
||||
play: expectGaugeDefaults,
|
||||
};
|
||||
|
||||
/** Picking a histogram defaults to the p90 across series. */
|
||||
export const HistogramMetricDefaults: Story = {
|
||||
args: METRICS_EXPLORER_ARGS,
|
||||
parameters: { signoz: { route: metricsExplorerRoute } },
|
||||
play: async ({ canvasElement }) => {
|
||||
await selectMetric(canvasElement, 'signoz_latency_bucket');
|
||||
|
||||
await expectFirstQuery(canvasElement, {
|
||||
aggregations: [
|
||||
expect.objectContaining({
|
||||
metricName: 'signoz_latency_bucket',
|
||||
spaceAggregation: 'p90',
|
||||
}),
|
||||
],
|
||||
});
|
||||
},
|
||||
play: expectHistogramDefaults,
|
||||
};
|
||||
|
||||
/** A Value panel takes a single aggregation: a second one is not accepted. */
|
||||
@@ -148,22 +103,5 @@ export const ValuePanelTakesOneAggregation: Story = {
|
||||
parameters: {
|
||||
signoz: { route: routeWith(PANEL_EDITOR_PATH, initialQueriesMap.logs) },
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
await expectFirstQuery(canvasElement, {
|
||||
aggregations: [{ expression: 'count()' }],
|
||||
});
|
||||
|
||||
const { before, after } = appendToAggregation(
|
||||
canvasElement,
|
||||
', count_distinct(service.name)',
|
||||
);
|
||||
await expect(after).toBe(before);
|
||||
|
||||
await expectFirstQuery(canvasElement, {
|
||||
aggregations: [{ expression: 'count()' }],
|
||||
});
|
||||
await expect(
|
||||
payloadIn(canvasElement).queries[0].spec.aggregations,
|
||||
).toHaveLength(1);
|
||||
},
|
||||
play: expectSingleAggregation,
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Do not hand-edit: regenerate instead.
|
||||
*/
|
||||
|
||||
import type { TransactionSpec } from '@codemirror/state';
|
||||
import { EditorView } from '@codemirror/view';
|
||||
import { expect, screen, userEvent, waitFor, within } from 'storybook/test';
|
||||
|
||||
@@ -134,6 +135,40 @@ export const selectMetric = async (
|
||||
await waitFor(() => expect(screen.queryByRole('listbox')).toBeNull());
|
||||
};
|
||||
|
||||
const aggregationEditor = (canvasElement: HTMLElement): EditorView => {
|
||||
const content = within(canvasElement)
|
||||
.getByTestId('query-aggregation-editor')
|
||||
.querySelector<HTMLElement>('.cm-content');
|
||||
const view = content ? EditorView.findFromDOM(content) : null;
|
||||
if (!view) {
|
||||
throw new Error('aggregation editor not mounted');
|
||||
}
|
||||
return view;
|
||||
};
|
||||
|
||||
const appendTo = (view: EditorView, text: string): TransactionSpec => ({
|
||||
changes: { from: view.state.doc.length, insert: text },
|
||||
selection: { anchor: view.state.doc.length + text.length },
|
||||
userEvent: 'input.type',
|
||||
});
|
||||
|
||||
/**
|
||||
* Waits until query `A`'s aggregation editor refuses `text`. The builder
|
||||
* applies a panel's limits one commit after mounting, which a fast static
|
||||
* build can beat. `state.update` runs the editor's filters without changing
|
||||
* the document.
|
||||
*/
|
||||
export const waitForAggregationLimit = async (
|
||||
canvasElement: HTMLElement,
|
||||
text: string,
|
||||
): Promise<void> => {
|
||||
await waitFor(() => {
|
||||
const view = aggregationEditor(canvasElement);
|
||||
const attempt = view.state.update(appendTo(view, text));
|
||||
return expect(attempt.newDoc.toString()).toBe(view.state.doc.toString());
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Appends `text` to query `A`'s aggregation editor and returns its document
|
||||
* before and after. Dispatched as a CodeMirror transaction: `userEvent.type`
|
||||
@@ -144,19 +179,9 @@ export const appendToAggregation = (
|
||||
canvasElement: HTMLElement,
|
||||
text: string,
|
||||
): { before: string; after: string } => {
|
||||
const content = within(canvasElement)
|
||||
.getByTestId('query-aggregation-editor')
|
||||
.querySelector<HTMLElement>('.cm-content');
|
||||
const view = content ? EditorView.findFromDOM(content) : null;
|
||||
if (!view) {
|
||||
throw new Error('aggregation editor not mounted');
|
||||
}
|
||||
const view = aggregationEditor(canvasElement);
|
||||
const before = view.state.doc.toString();
|
||||
view.dispatch({
|
||||
changes: { from: before.length, insert: text },
|
||||
selection: { anchor: before.length + text.length },
|
||||
userEvent: 'input.type',
|
||||
});
|
||||
view.dispatch(appendTo(view, text));
|
||||
// Read synchronously: the document is the editor's own verdict, before
|
||||
// React state catches up.
|
||||
return { before, after: view.state.doc.toString() };
|
||||
|
||||
@@ -15,7 +15,14 @@ import {
|
||||
ResolvedQueryBuilderField,
|
||||
resolveQueryBuilderField,
|
||||
} from '../../queryBuilderFields.utils';
|
||||
import { expectFirstQuery, payloadIn } from '../QueryBuilderV2.stories.mocks';
|
||||
import {
|
||||
addOnToggles,
|
||||
appendToAggregation,
|
||||
expectFirstQuery,
|
||||
payloadIn,
|
||||
selectMetric,
|
||||
waitForAggregationLimit,
|
||||
} from '../QueryBuilderV2.stories.mocks';
|
||||
|
||||
interface PlayContext {
|
||||
canvasElement: HTMLElement;
|
||||
@@ -197,3 +204,95 @@ export const hoverAddFunction = async ({
|
||||
|
||||
await hoverForLearnMore(button, 'Add new function');
|
||||
};
|
||||
|
||||
export const expectValuePanelAddOns = async ({
|
||||
canvasElement,
|
||||
}: PlayContext): Promise<void> => {
|
||||
await waitFor(() =>
|
||||
expect(addOnToggles(canvasElement)).toStrictEqual(['legend_format']),
|
||||
);
|
||||
};
|
||||
|
||||
export const expectTablePanelAddOns = async ({
|
||||
canvasElement,
|
||||
}: PlayContext): Promise<void> => {
|
||||
await waitFor(() =>
|
||||
expect(addOnToggles(canvasElement)).toStrictEqual([
|
||||
'having',
|
||||
'order_by',
|
||||
'limit',
|
||||
'legend_format',
|
||||
'reduce_to',
|
||||
]),
|
||||
);
|
||||
};
|
||||
|
||||
export const expectTimeSeriesAddOns = async ({
|
||||
canvasElement,
|
||||
}: PlayContext): Promise<void> => {
|
||||
await waitFor(() =>
|
||||
expect(addOnToggles(canvasElement)).toStrictEqual([
|
||||
'group_by',
|
||||
'having',
|
||||
'order_by',
|
||||
'limit',
|
||||
'legend_format',
|
||||
]),
|
||||
);
|
||||
};
|
||||
|
||||
export const expectGaugeDefaults = async ({
|
||||
canvasElement,
|
||||
}: PlayContext): Promise<void> => {
|
||||
await selectMetric(canvasElement, 'container_cpu_utilization');
|
||||
|
||||
await expectFirstQuery(canvasElement, {
|
||||
aggregations: [
|
||||
expect.objectContaining({
|
||||
metricName: 'container_cpu_utilization',
|
||||
timeAggregation: 'avg',
|
||||
spaceAggregation: 'avg',
|
||||
}),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
export const expectHistogramDefaults = async ({
|
||||
canvasElement,
|
||||
}: PlayContext): Promise<void> => {
|
||||
await selectMetric(canvasElement, 'signoz_latency_bucket');
|
||||
|
||||
await expectFirstQuery(canvasElement, {
|
||||
aggregations: [
|
||||
expect.objectContaining({
|
||||
metricName: 'signoz_latency_bucket',
|
||||
spaceAggregation: 'p90',
|
||||
}),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
const SECOND_AGGREGATION = ', count_distinct(service.name)';
|
||||
|
||||
export const expectSingleAggregation = async ({
|
||||
canvasElement,
|
||||
}: PlayContext): Promise<void> => {
|
||||
await expectFirstQuery(canvasElement, {
|
||||
aggregations: [{ expression: 'count()' }],
|
||||
});
|
||||
|
||||
await waitForAggregationLimit(canvasElement, SECOND_AGGREGATION);
|
||||
|
||||
const { before, after } = appendToAggregation(
|
||||
canvasElement,
|
||||
SECOND_AGGREGATION,
|
||||
);
|
||||
await expect(after).toBe(before);
|
||||
|
||||
await expectFirstQuery(canvasElement, {
|
||||
aggregations: [{ expression: 'count()' }],
|
||||
});
|
||||
await expect(
|
||||
payloadIn(canvasElement).queries[0].spec.aggregations,
|
||||
).toHaveLength(1);
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
--input-focus-background: transparent;
|
||||
--input-focus-outline-width: 0;
|
||||
--input-box-shadow: none;
|
||||
--input-font-size: var(--label-base-400-font-size);
|
||||
--input-font-size: var(--periscope-font-size-base);
|
||||
--input-line-height: 20px;
|
||||
--input-placeholder-color: color-mix(
|
||||
in srgb,
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
}
|
||||
|
||||
.heading {
|
||||
font-size: var(--label-small-500-font-size);
|
||||
font-weight: var(--label-small-500-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: 1;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
@@ -34,9 +34,9 @@
|
||||
--button-height: auto;
|
||||
--button-padding: var(--spacing-4) var(--spacing-6);
|
||||
--button-border-radius: var(--radius-3);
|
||||
--button-font-size: var(--label-base-400-font-size);
|
||||
--button-font-size: var(--periscope-font-size-base);
|
||||
--button-size-line-height: var(--line-height-20);
|
||||
--button-font-weight: var(--label-base-400-font-weight);
|
||||
--button-font-weight: var(--font-weight-normal);
|
||||
--button-variant-outlined-background-color: var(--l3-background-60);
|
||||
--button-variant-outlined-border: none;
|
||||
--button-variant-outlined-color: var(--l2-foreground);
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: var(--label-small-500-font-size);
|
||||
font-weight: var(--label-small-500-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: 18px;
|
||||
letter-spacing: -0.005em;
|
||||
}
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
.soloThought {
|
||||
margin: 0;
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: var(--line-height-20);
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--l2-foreground);
|
||||
@@ -64,8 +64,8 @@
|
||||
|
||||
// While Noz works, the row names the step it's on.
|
||||
.live .activitySummary {
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-weight: var(--paragraph-base-400-font-weight);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
font-weight: var(--font-weight-normal);
|
||||
line-height: var(--line-height-20);
|
||||
@include shimmer-text(var(--l3-foreground), var(--l1-foreground));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
border: none;
|
||||
background: none;
|
||||
font: inherit;
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: var(--line-height-20);
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--l1-foreground);
|
||||
@@ -90,7 +90,7 @@ button.title {
|
||||
}
|
||||
|
||||
.detail {
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: var(--line-height-20);
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--l2-foreground);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
}
|
||||
|
||||
.headerLabel {
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--font-size-sm);
|
||||
line-height: var(--line-height-20);
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--l1-foreground);
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
.summary {
|
||||
margin: 0;
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: var(--line-height-20);
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
|
||||
@@ -134,8 +134,8 @@
|
||||
--button-padding: 7px #{$padding-inline};
|
||||
--button-border-radius: 0;
|
||||
--button-justify-content: flex-start;
|
||||
--button-font-size: var(--label-base-400-font-size);
|
||||
--button-font-weight: var(--label-base-400-font-weight);
|
||||
--button-font-size: var(--periscope-font-size-base);
|
||||
--button-font-weight: var(--font-weight-normal);
|
||||
--button-variant-ghost-color: var(--l2-foreground);
|
||||
--button-variant-ghost-hover-color: var(--l1-foreground);
|
||||
--button-variant-ghost-hover-background-color: var(--l3-background);
|
||||
@@ -180,8 +180,8 @@
|
||||
height: 44px;
|
||||
padding: 0 var(--spacing-7);
|
||||
border-bottom: 1px solid var(--l2-border);
|
||||
font-size: var(--label-small-600-font-size);
|
||||
font-weight: var(--label-small-600-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
line-height: 1;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
border-radius: var(--radius-2);
|
||||
background: var(--l3-background-60);
|
||||
color: var(--l2-foreground);
|
||||
font-size: var(--label-small-500-font-size);
|
||||
font-weight: var(--label-small-500-font-weight);
|
||||
font-size: var(--font-size-xs);
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: 15px;
|
||||
transition:
|
||||
background-color 0.12s,
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
}
|
||||
|
||||
.headerLabel {
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--font-size-sm);
|
||||
line-height: var(--line-height-20);
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--l1-foreground);
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
.message {
|
||||
margin: 0;
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: var(--line-height-20);
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: 20px;
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--text-vanilla-400);
|
||||
@@ -73,7 +73,7 @@
|
||||
// Wide enough to hold the action buttons that replace it.
|
||||
min-width: 16px;
|
||||
text-align: right;
|
||||
font-size: var(--paragraph-small-400-font-size);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
line-height: 18px;
|
||||
color: var(--l3-foreground);
|
||||
opacity: calc(1 - var(--actions-opacity, 0));
|
||||
@@ -87,7 +87,7 @@
|
||||
width: 100%;
|
||||
border-bottom: 1px solid var(--accent-primary);
|
||||
--input-padding: 1px 0;
|
||||
--input-font-size: var(--label-base-400-font-size);
|
||||
--input-font-size: var(--periscope-font-size-base);
|
||||
--input-hover-border-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
--button-border-radius: 3px;
|
||||
--button-justify-content: flex-start;
|
||||
--button-gap: var(--spacing-4);
|
||||
--button-font-weight: var(--label-base-400-font-weight);
|
||||
--button-font-weight: var(--font-weight-normal);
|
||||
--button-variant-outlined-background-color: var(--l2-background);
|
||||
--button-variant-outlined-border: 1px solid var(--l1-border);
|
||||
--button-variant-outlined-color: var(--l2-foreground);
|
||||
@@ -144,8 +144,8 @@
|
||||
.groupLabel {
|
||||
display: block;
|
||||
padding: 0 0 7px;
|
||||
font-size: var(--label-small-600-font-size);
|
||||
font-weight: var(--label-small-600-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
line-height: 1;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
}
|
||||
|
||||
.note {
|
||||
font-size: var(--label-small-500-font-size);
|
||||
font-weight: var(--label-small-500-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: 1;
|
||||
font-feature-settings:
|
||||
'tnum' on,
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
align-items: flex-start;
|
||||
background: var(--l2-background);
|
||||
color: var(--l1-foreground);
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
border-bottom-left-radius: var(--radius-2);
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@
|
||||
width: max-content;
|
||||
min-width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
font-variant-numeric: tabular-nums;
|
||||
word-break: normal;
|
||||
|
||||
@@ -286,8 +286,8 @@
|
||||
|
||||
th {
|
||||
padding-block: 13px;
|
||||
font-size: var(--label-small-500-font-size);
|
||||
font-weight: var(--label-small-500-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: 1;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
--button-height: 32px;
|
||||
--button-padding: 0 var(--spacing-6);
|
||||
--button-border-radius: var(--radius-round);
|
||||
--button-font-size: var(--label-base-400-font-size);
|
||||
--button-font-weight: var(--label-base-400-font-weight);
|
||||
--button-font-size: var(--periscope-font-size-base);
|
||||
--button-font-weight: var(--font-weight-normal);
|
||||
--button-secondary-background-color: var(--l3-background);
|
||||
--button-secondary-hover-background-color: var(--l3-background-hover);
|
||||
--button-secondary-solid-foreground: var(--l1-foreground);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--spacing-6);
|
||||
font-size: var(--label-base-500-font-size);
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
.subtitle {
|
||||
padding-left: calc(12px + var(--spacing-3));
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--paragraph-small-400-font-size);
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
.code {
|
||||
flex-shrink: 0;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--paragraph-small-400-font-size);
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
align-items: center;
|
||||
gap: var(--spacing-2);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--paragraph-small-400-font-size);
|
||||
font-size: var(--font-size-xs);
|
||||
letter-spacing: -0.01em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
.sizerValue {
|
||||
font-size: 12px;
|
||||
font-weight: var(--label-base-500-font-weight);
|
||||
font-weight: var(--font-weight-medium);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
}
|
||||
|
||||
.tooltipName {
|
||||
font-weight: var(--label-base-500-font-weight);
|
||||
font-weight: var(--font-weight-medium);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
.value {
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
font-weight: var(--label-base-500-font-weight);
|
||||
font-weight: var(--font-weight-medium);
|
||||
color: var(--l1-foreground);
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -510,6 +510,11 @@ Wait on a `danger` toast with `findToastText` (or `getToastText` inside
|
||||
announced through a visually hidden copy of its text, so a bare query finds two
|
||||
elements.
|
||||
|
||||
Hover a label that only shows a tooltip when it is cut off with `hoverTruncated`
|
||||
from `play/hoverTruncated`, never a bare `userEvent.hover`. The tooltip is
|
||||
switched on by the hover that measures it, and the static build, which has no
|
||||
`act`, opens nothing during that first hover.
|
||||
|
||||
The play is a named function in `stories/__story_mockdata__/<page>.play.ts`,
|
||||
collapsed for review with the other AI-owned files, and the story file only names
|
||||
it. Branch each check on the args it reads, so every control value the page
|
||||
|
||||
13
frontend/src/storybook/play/hoverTruncated.ts
Normal file
13
frontend/src/storybook/play/hoverTruncated.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { userEvent } from 'storybook/test';
|
||||
|
||||
/**
|
||||
* Hovers an element whose tooltip is switched on by the hover that finds it
|
||||
* cut off. `userEvent` dispatches the whole hover before React renders, and a
|
||||
* production build, which has no `act` to render between its events, leaves the
|
||||
* tooltip off for all of it. A second pass finds it on.
|
||||
*/
|
||||
export const hoverTruncated = async (element: HTMLElement): Promise<void> => {
|
||||
await userEvent.hover(element);
|
||||
await userEvent.unhover(element);
|
||||
await userEvent.hover(element);
|
||||
};
|
||||
Reference in New Issue
Block a user