- update client and server dependencies within their ranges, keeping all playwright packages aligned at 1.63 - fix code flagged by react-hooks 7.1: refs written during render and synchronous setState in effects - add stories for the ui components that had none, with interaction tests, and cover all DescriptionList layouts - drop the unused mdx stories pattern - run the storybook tests as part of the pre-commit checks - bump version to 1.20.1
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import React, { useState } from 'react';
|
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
import { CodeEditor, type CodeEditorProps } from '../../src/ui/CodeEditor/CodeEditor';
|
|
|
|
// Monaco is loaded from a CDN at runtime, so these stories only check that the
|
|
// editor mounts; they have no interaction tests.
|
|
function ControlledEditor(
|
|
props: Omit<CodeEditorProps, 'value' | 'onChange'> & { initial: string },
|
|
) {
|
|
const { initial, ...rest } = props;
|
|
const [value, setValue] = useState(initial);
|
|
return <CodeEditor {...rest} value={value} onChange={setValue} />;
|
|
}
|
|
|
|
const meta: Meta<typeof ControlledEditor> = {
|
|
title: 'UI/CodeEditor',
|
|
component: ControlledEditor,
|
|
parameters: { layout: 'padded' },
|
|
tags: ['autodocs'],
|
|
};
|
|
export default meta;
|
|
type Story = StoryObj<typeof ControlledEditor>;
|
|
|
|
export const JavaScript: Story = {
|
|
args: {
|
|
language: 'javascript',
|
|
rows: 8,
|
|
initial:
|
|
"await context.page.goto(context.getEnv('BASE_URL'));\nreturn await context.page.title();",
|
|
},
|
|
};
|
|
|
|
export const WithError: Story = {
|
|
args: { language: 'javascript', rows: 4, error: true, initial: 'await context.page.goto(' },
|
|
};
|