Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Text): add text to Accordion, Button, Checkbox, Combobox, Contentswitcher #9493

Merged

Conversation

dakahn
Copy link
Contributor

@dakahn dakahn commented Aug 17, 2021

Closes #9462

@dakahn dakahn requested a review from a team as a code owner August 17, 2021 19:11
@netlify
Copy link

netlify bot commented Aug 17, 2021

✔️ Deploy Preview for carbon-react-next ready!

🔨 Explore the source changes: acc7ec5

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-react-next/deploys/6148ab9a4b33ad0008384b2b

😎 Browse the preview: https://deploy-preview-9493--carbon-react-next.netlify.app

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Copy link
Contributor

@joshblack joshblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Just a couple of usage notes/questions

packages/react/src/components/Accordion/AccordionItem.js Outdated Show resolved Hide resolved
packages/react/src/components/Button/Button.js Outdated Show resolved Hide resolved
@joshblack
Copy link
Contributor

I think a big thing for the conversion will be any text that we accept as props that the user cannot control rendering of will need to be wrapped in a Text component. If they can supply children or configure the nod already, then we don't need to convert that part of a component. Curious what you all think after going through these five components 🤔

@netlify
Copy link

netlify bot commented Aug 17, 2021

✔️ Deploy Preview for carbon-elements ready!

🔨 Explore the source changes: acc7ec5

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/6148ab9a4548e10007d1a511

😎 Browse the preview: https://deploy-preview-9493--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Aug 17, 2021

✔️ Deploy Preview for carbon-components-react ready!
Built without sensitive environment variables

🔨 Explore the source changes: acc7ec5

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/6148ab9a09147300080d7f01

😎 Browse the preview: https://deploy-preview-9493--carbon-components-react.netlify.app

@dakahn dakahn requested a review from joshblack August 19, 2021 22:51
@dakahn
Copy link
Contributor Author

dakahn commented Aug 19, 2021

@joshblack that makes sense to me!

@andreancardona andreancardona removed their request for review August 25, 2021 16:59
Copy link
Contributor

@joshblack joshblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you're still looking for a review from me, but I think the change left is in AccordionItem to wrap the title in a Text and to not wrap the content in a Text

@joshblack
Copy link
Contributor

@dakahn saw the re-review request, I think my last review comment is here: #9493 (review)

@tay1orjones
Copy link
Member

@joshblack fixed the accordion item 👍

@kodiakhq kodiakhq bot merged commit b5c1f82 into carbon-design-system:main Sep 20, 2021
@wajnberg
Copy link

wajnberg commented Sep 30, 2021

Hi all
I just tested Button with TextDirection
I added this story (in Button-story.js)

export const WithTextDir = () => {
  return <TextDirection dir="auto"><Button kind="ghost">שלום!!</Button></TextDirection>;	
};

But I get:
image

It should be !!שלום
Am I missing anything ?

@wajnberg
Copy link

Ok I checked all the 5 components:
This is what I found:

  • Button is not working (see above)
  • Accordion is OK
  • Checkbox is OK
  • Combobox is partially OK. It is working for title and helper text. But what about the options themselves ?
    image
  • Contentsswitcher is not working
    image

I further looked at the code you committed and I can actually see that no code has been changed for Button (apart from a cosmetic change ) and ContentSwitcher.

Thank you for your feedback

@tay1orjones
Copy link
Member

Thanks for taking a look at this! I think you’ve highlighted a few gaps in documentation that we should address.

Button

It’s my understanding that for any component accepting children as a prop that is not explicitly a string, we’ll be recommending the use of the Text composed within the component. For instance, Button accepts children as a prop, but this prop can be things other than text (icons, etc). Based on this, the following updated snippet returns the text in RTL as you expect:

export const ButtonExample = () => {
  const buttonText = 'שלום!!';
  return (
    <Button kind="ghost">
      <Text>{buttonText}</Text>
    </Button>
  );
};

Listbox - ComboBox

For any component using the ListBox (Dropdown, ComboBox, MultiSelect, FilterableMultiSelect), you'll need to use the itemToElement function prop to render text in the proper direction through the downshift library these components use under the hood. The following updated snippet returns the option-1 text in RTL as you expect:

export const DropdownExample = () => {
  const items = [
    {
      id: 'option-0',
      text: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit.',
    },
    {
      id: 'option-1',
      text: 'שלום!!',
    },
  ];
  return (
    <div style={{ width: 400 }}>
      <Dropdown
        id="default"
        titleText="Dropdown label"
        helperText="This is some helper text"
        label="Dropdown menu options"
        items={items}
        itemToElement={(item) => <Text>{item.text}</Text>}
      />
    </div>
  );
};

ContentSwitcher

The same general idea applies to ContentSwitcher.

export const ContentSwitcherExample = () => {
  const switchText = 'שלום!!';
  return (
    <ContentSwitcher onChange={() => {}}>
      <Switch name="one" text={<Text>{switchText}</Text>} />
      <Switch name="two" text="Second section" />
      <Switch name="three" text="Third section" />
    </ContentSwitcher>
  );
};

The above works, but it throws a prop-type warning. The text prop-type definition is configured to accept a string only. This will need to be updated to accept a node or similar to avoid the proptype warning.

@wajnberg
Copy link

Hello @tay1orjones ,

Thank you for your explanations.
It's much clearer now :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update 5 components to use Text
5 participants