Skip to content

Commit

Permalink
fix(ListBoxTrigger): support title on ListBoxTrigger (#8094)
Browse files Browse the repository at this point in the history
* fix(ListBoxTrigger): support title on ListBoxTrigger

* docs(ListBox): add translateWithId knob in ComboBox and dropdown

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
emyarod and kodiakhq[bot] authored Mar 17, 2021
1 parent 322ca4d commit 8d39b78
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
32 changes: 22 additions & 10 deletions packages/react/src/components/ComboBox/ComboBox-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';
import { action } from '@storybook/addon-actions';
import { boolean, select, text } from '@storybook/addon-knobs';
import { boolean, object, select, text } from '@storybook/addon-knobs';
import ComboBox from '../ComboBox';
import mdx from './ComboBox.mdx';

Expand Down Expand Up @@ -91,17 +91,29 @@ const props = () => ({
'Warning state text (warnText)',
'This mode may perform worse on older machines'
),
listBoxMenuIconTranslationIds: object(
'Listbox menu icon translation IDs (for translateWithId callback)',
{
'close.menu': 'Close menu',
'open.menu': 'Open menu',
'clear.selection': 'Clear selection',
}
),
});

export const Playground = () => (
<div style={{ width: 300 }}>
<ComboBox
items={items}
itemToString={(item) => (item ? item.text : '')}
{...props()}
/>
</div>
);
export const Playground = () => {
const { listBoxMenuIconTranslationIds, ...comboBoxProps } = props();
return (
<div style={{ width: 300 }}>
<ComboBox
{...comboBoxProps}
items={items}
itemToString={(item) => (item ? item.text : '')}
translateWithId={(id) => listBoxMenuIconTranslationIds[id]}
/>
</div>
);
};

export const disabled = () => (
<div style={{ width: 300 }}>
Expand Down
19 changes: 17 additions & 2 deletions packages/react/src/components/Dropdown/Dropdown-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

import React from 'react';
import { action } from '@storybook/addon-actions';
import { withKnobs, boolean, select, text } from '@storybook/addon-knobs';
import {
withKnobs,
boolean,
object,
select,
text,
} from '@storybook/addon-knobs';
import Dropdown from '../Dropdown';
import DropdownSkeleton from './Dropdown.Skeleton';
import mdx from './Dropdown.mdx';
Expand Down Expand Up @@ -78,6 +84,13 @@ const props = () => ({
'Warning state text (warnText)',
'This mode may perform worse on older machines'
),
listBoxMenuIconTranslationIds: object(
'Listbox menu icon translation IDs (for translateWithId callback)',
{
'close.menu': 'Close menu',
'open.menu': 'Open menu',
}
),
});

export default {
Expand Down Expand Up @@ -125,12 +138,14 @@ export const Inline = () => (
);

export const Playground = () => {
const { listBoxMenuIconTranslationIds, ...dropdownProps } = props();
return (
<div style={{ width: 300 }}>
<Dropdown
{...props()}
{...dropdownProps}
items={items}
itemToString={(item) => (item ? item.text : '')}
translateWithId={(id) => listBoxMenuIconTranslationIds[id]}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const ListBoxTrigger = ({ isOpen, translateWithId: t, ...rest }) => {
<button
{...rest}
aria-label={description}
title={description}
className={className}
type="button"
tabIndex="-1">
Expand Down

0 comments on commit 8d39b78

Please sign in to comment.