|
| 1 | +// Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | + |
| 3 | +/** |
| 4 | + * @file CommandPaletteEmpty.stories.tsx |
| 5 | + * @input Uses CommandPalette, CommandPaletteEmpty, Link, InternationalizationProvider |
| 6 | + * @output Storybook fixture for empty-state content the CommandPalette stories do not reach |
| 7 | + * @position Component-owned fixture; the CommandPalette audit matrix covers the |
| 8 | + * default built-in empty branch, this covers expanded, long, and standalone content |
| 9 | + */ |
| 10 | + |
| 11 | +import {useMemo} from 'react'; |
| 12 | +import type {Meta, StoryObj} from '@storybook/react'; |
| 13 | +import { |
| 14 | + CommandPalette, |
| 15 | + CommandPaletteEmpty, |
| 16 | +} from '@astryxdesign/core/CommandPalette'; |
| 17 | +import {Link} from '@astryxdesign/core/Link'; |
| 18 | +import {InternationalizationProvider} from '@astryxdesign/core/i18n'; |
| 19 | +import {createStaticSource} from '@astryxdesign/core/Typeahead'; |
| 20 | + |
| 21 | +const meta: Meta<typeof CommandPaletteEmpty> = { |
| 22 | + title: 'Core/CommandPaletteEmpty', |
| 23 | + component: CommandPaletteEmpty, |
| 24 | + tags: ['autodocs'], |
| 25 | +}; |
| 26 | + |
| 27 | +export default meta; |
| 28 | +type Story = StoryObj<typeof meta>; |
| 29 | + |
| 30 | +const panelStyle = {flex: '1 1 280px', minWidth: 0} as const; |
| 31 | +const headingStyle = { |
| 32 | + marginBlock: '0 8px', |
| 33 | + font: 'inherit', |
| 34 | + fontWeight: 600, |
| 35 | +} as const; |
| 36 | + |
| 37 | +/** |
| 38 | + * Empty content the built-in branch must hold without breaking layout: catalog |
| 39 | + * text expanded by translation, a long unbroken path echoed into the message, |
| 40 | + * and the standalone composition with caller-provided rich content. |
| 41 | + */ |
| 42 | +export const ContentMatrix: Story = { |
| 43 | + render: function Render() { |
| 44 | + const emptySource = useMemo(() => createStaticSource([]), []); |
| 45 | + return ( |
| 46 | + <div |
| 47 | + style={{ |
| 48 | + display: 'flex', |
| 49 | + flexWrap: 'wrap', |
| 50 | + alignItems: 'flex-start', |
| 51 | + gap: 16, |
| 52 | + width: '100%', |
| 53 | + padding: 16, |
| 54 | + boxSizing: 'border-box', |
| 55 | + }}> |
| 56 | + <section style={panelStyle}> |
| 57 | + <h2 style={headingStyle}>Translated built-in text</h2> |
| 58 | + <InternationalizationProvider |
| 59 | + locale="fr" |
| 60 | + overrides={{ |
| 61 | + fr: { |
| 62 | + '@astryx.commandPalette.emptyBootstrap': |
| 63 | + 'Commencez à saisir pour rechercher parmi les commandes disponibles', |
| 64 | + '@astryx.commandPalette.emptySearch': |
| 65 | + 'Aucune commande ne correspond à votre recherche', |
| 66 | + }, |
| 67 | + }}> |
| 68 | + <CommandPalette |
| 69 | + isOpen |
| 70 | + isInline |
| 71 | + role="region" |
| 72 | + label="Translated empty command palette" |
| 73 | + onOpenChange={() => {}} |
| 74 | + searchSource={emptySource} |
| 75 | + width="100%" |
| 76 | + maxHeight={320} |
| 77 | + /> |
| 78 | + </InternationalizationProvider> |
| 79 | + </section> |
| 80 | + <section style={panelStyle}> |
| 81 | + <h2 style={headingStyle}>Long unbroken text</h2> |
| 82 | + <CommandPalette |
| 83 | + isOpen |
| 84 | + isInline |
| 85 | + role="region" |
| 86 | + label="Long empty command palette" |
| 87 | + onOpenChange={() => {}} |
| 88 | + searchSource={emptySource} |
| 89 | + emptyBootstrapText="No files in /workspace/design-system/packages/core/src/CommandPalette/__fixtures__/empty-results/" |
| 90 | + emptySearchText="No files match /workspace/design-system/packages/core/src/CommandPalette/__fixtures__/empty-results/" |
| 91 | + width="100%" |
| 92 | + maxHeight={320} |
| 93 | + /> |
| 94 | + </section> |
| 95 | + <section style={panelStyle}> |
| 96 | + <h2 style={headingStyle}>Standalone rich content</h2> |
| 97 | + <CommandPaletteEmpty> |
| 98 | + <span> |
| 99 | + No saved searches yet.{' '} |
| 100 | + <Link href="#create-saved-search">Create a saved search</Link> |
| 101 | + </span> |
| 102 | + </CommandPaletteEmpty> |
| 103 | + </section> |
| 104 | + </div> |
| 105 | + ); |
| 106 | + }, |
| 107 | +}; |
0 commit comments