|
| 1 | +import type { Meta, StoryObj } from 'storybook' |
| 2 | + |
| 3 | +import DiffString from 'components/diff/DiffString' |
| 4 | + |
| 5 | +const meta: Meta<typeof DiffString> = { |
| 6 | + component: DiffString, |
| 7 | + parameters: { |
| 8 | + docs: { |
| 9 | + description: { |
| 10 | + component: |
| 11 | + 'The diff view for flag values (react-diff-viewer + Prism for JSON). ' + |
| 12 | + 'Uses the same code colour tokens as the Highlight component, so it ' + |
| 13 | + 'follows light/dark mode. Toggle the theme in the toolbar to QA.', |
| 14 | + }, |
| 15 | + }, |
| 16 | + layout: 'padded', |
| 17 | + }, |
| 18 | + title: 'Components/Diff/DiffString', |
| 19 | +} |
| 20 | + |
| 21 | +export default meta |
| 22 | + |
| 23 | +type Story = StoryObj<typeof DiffString> |
| 24 | + |
| 25 | +const oldJson = `{ |
| 26 | + "id": "london-js", |
| 27 | + "title": "Hello London.js!", |
| 28 | + "description": "Join us at London.js and get insights on best practices!", |
| 29 | + "buttonText": "Register on Meetup", |
| 30 | + "isClosable": false |
| 31 | +}` |
| 32 | + |
| 33 | +const newJson = `{ |
| 34 | + "id": "london-js", |
| 35 | + "title": "Hello London.js!", |
| 36 | + "description": "Join us at London.js!", |
| 37 | + "buttonText": "Register now", |
| 38 | + "isClosable": true |
| 39 | +}` |
| 40 | + |
| 41 | +export const ChangedJson: Story = { |
| 42 | + args: { newValue: newJson, oldValue: oldJson }, |
| 43 | +} |
| 44 | + |
| 45 | +export const ChangedString: Story = { |
| 46 | + args: { newValue: 'banner_size: large', oldValue: 'banner_size: small' }, |
| 47 | +} |
| 48 | + |
| 49 | +export const SameJson: Story = { |
| 50 | + args: { newValue: oldJson, oldValue: oldJson }, |
| 51 | +} |
| 52 | + |
| 53 | +// An empty old value renders as `""`, not a blank row. |
| 54 | +export const FromEmpty: Story = { |
| 55 | + args: { newValue: 'banner_size: large', oldValue: '' }, |
| 56 | +} |
0 commit comments