Skip to content

Commit 77ddfb7

Browse files
committed
fix(ListInput): the empty state reads right with any noun
The empty state built its own grammar around the record noun: a plural "s" after it and "a" before it. With "email address" it read "No email addresss yet" and "Add a email address to get started.", and with the default noun "Add a item". The messages now use the noun as given: "No {itemName} added yet" and "Each {itemName} you add appears here." Both keep their placeholder, so every translation keeps its contract.
1 parent b1fa382 commit 77ddfb7

3 files changed

Lines changed: 35 additions & 7 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[fix] ListInput's empty state reads right with any noun. Its title is "No {itemName} added yet", not "No {itemName}s yet", and its text is "Each {itemName} you add appears here.", not "Add a {itemName} to get started.": with "email address" it read "No email addresss yet" and "Add a email address". Both messages keep their `{itemName}` placeholder.
6+
7+
@ernestt

‎packages/core/locales/en.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,12 @@
676676
"description": "The noun for one record in a lab ListInput when the app gives no noun of its own. The other ListInput messages put it in their `{itemName}` placeholder, as in \"Add item\" and \"Remove item 2\". Give the form of the noun that fits there."
677677
},
678678
"@astryx.listInput.emptyTitle": {
679-
"defaultMessage": "No {itemName}s yet",
680-
"description": "EmptyState title shown inside a lab ListInput when its collection has no records. `{itemName}` is the consumer's singular noun for one record (e.g. \"guest\"); the source appends a literal \"s\" to pluralize it, which only works for regular English plurals. If your language cannot pluralize an interpolated noun this way, rephrase around `{itemName}` instead (e.g. \"No {itemName} added yet\")."
679+
"defaultMessage": "No {itemName} added yet",
680+
"description": "EmptyState title shown inside a lab ListInput when its collection has no records. `{itemName}` is the singular noun for one record, from the app or the catalog (e.g. \"guest\" or \"email address\"). The noun can be any word, so the message uses it as given, with no plural ending or article. Write your translation so that it also needs none (e.g. \"No guest added yet\")."
681681
},
682682
"@astryx.listInput.emptyDescription": {
683-
"defaultMessage": "Add a {itemName} to get started.",
684-
"description": "EmptyState supporting text shown inside a lab ListInput when its collection has no records. `{itemName}` is the consumer's singular noun for one record (e.g. \"guest\")."
683+
"defaultMessage": "Each {itemName} you add appears here.",
684+
"description": "EmptyState supporting text shown inside a lab ListInput when its collection has no records, above the button that adds one. `{itemName}` is the singular noun for one record, from the app or the catalog (e.g. \"guest\" or \"email address\"). Use it as given, with no plural ending or article (e.g. \"Each guest you add appears here.\")."
685685
},
686686
"@astryx.listInput.addItem": {
687687
"defaultMessage": "Add {itemName}",

‎packages/lab/src/ListInput/ListInput.test.tsx‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,33 @@ describe('ListInput', () => {
397397
expect(getComputedStyle(emptyState!).justifyContent).toBe('center');
398398
expect(getComputedStyle(emptyState!).textAlign).toBe('center');
399399
expect(
400-
screen.getByRole('heading', {name: 'No guests yet'}),
400+
screen.getByRole('heading', {name: 'No guest added yet'}),
401+
).toBeInTheDocument();
402+
expect(
403+
screen.getByText('Each guest you add appears here.'),
401404
).toBeInTheDocument();
402-
expect(screen.getByText('Add a guest to get started.')).toBeInTheDocument();
403405
expect(screen.getByRole('button', {name: 'Add guest'})).toBeEnabled();
404406
});
405407

408+
it('words the empty state with any noun as given, with no plural ending or article', () => {
409+
const {unmount} = renderListInput({value: [], itemName: 'email address'});
410+
expect(
411+
screen.getByRole('heading', {name: 'No email address added yet'}),
412+
).toBeInTheDocument();
413+
expect(
414+
screen.getByText('Each email address you add appears here.'),
415+
).toBeInTheDocument();
416+
unmount();
417+
418+
renderListInput({value: [], itemName: undefined});
419+
expect(
420+
screen.getByRole('heading', {name: 'No item added yet'}),
421+
).toBeInTheDocument();
422+
expect(
423+
screen.getByText('Each item you add appears here.'),
424+
).toBeInTheDocument();
425+
});
426+
406427
it('names records with the translated catalog noun when itemName is absent', () => {
407428
const {unmount} = renderListInput({itemName: undefined});
408429
expect(screen.getByRole('button', {name: 'Add item'})).toBeInTheDocument();
@@ -807,7 +828,7 @@ describe('ListInput', () => {
807828
Array.from(document.querySelectorAll('[aria-live="polite"]')).some(
808829
node =>
809830
node.textContent ===
810-
'Removed guest 1. No guests yet Add a guest to get started.',
831+
'Removed guest 1. No guest added yet Each guest you add appears here.',
811832
),
812833
).toBe(true);
813834
});

0 commit comments

Comments
 (0)