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(Dropdown): add hideTitleText prop #7594

Merged
merged 9 commits into from
Jan 27, 2021
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,15 @@
"contributions": [
"code"
]
},
{
"login": "molyholy",
"name": "molyholy",
"avatar_url": "https://avatars2.githubusercontent.com/u/77503726?v=4",
"profile": "https://github.com/molyholy",
"contributions": [
"code"
]
}
],
"commitConvention": "none"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
</tr>
<tr>
<td align="center"><a href="https://github.com/DavidSCChen"><img src="https://avatars1.githubusercontent.com/u/54974983?v=4?s=100" width="100px;" alt=""/><br /><sub><b>DavidSCChen</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=DavidSCChen" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/molyholy"><img src="https://avatars2.githubusercontent.com/u/77503726?v=4?s=100" width="100px;" alt=""/><br /><sub><b>molyholy</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=molyholy" title="Code">💻</a></td>
</tr>
</table>

Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/Dropdown/Dropdown-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const props = () => ({
disabled: boolean('Disabled (disabled)', false),
light: boolean('Light variant (light)', false),
titleText: text('Title (titleText)', 'Dropdown label'),
hideTitleText: boolean('No title text shown (hideTitleText)', false),
helperText: text('Helper text (helperText)', 'This is some helper text.'),
invalid: boolean('Show form validation UI (invalid)', false),
invalidText: text(
Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/components/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const Dropdown = React.forwardRef(function Dropdown(
onChange,
id,
titleText,
hideTitleText,
helperText,
translateWithId,
light,
Expand Down Expand Up @@ -98,6 +99,7 @@ const Dropdown = React.forwardRef(function Dropdown(

const titleClasses = cx(`${prefix}--label`, {
[`${prefix}--label--disabled`]: disabled,
[`${prefix}--visually-hidden`]: hideTitleText,
});

const helperClasses = cx(`${prefix}--form__helper-text`, {
Expand Down Expand Up @@ -232,6 +234,11 @@ Dropdown.propTypes = {
*/
helperText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),

/**
* Specify whether the title text should be hidden or not
*/
hideTitleText: PropTypes.bool,

/**
* Specify a custom `id`
*/
Expand Down