Skip to content

Commit

Permalink
feat(Dropdown): add hideTitleText prop (#7594)
Browse files Browse the repository at this point in the history
* feat(Dropdown): add hideTitleText prop

* refactor(Dropdown): change hideTitleText to hideLabel

Co-authored-by: Tony Wu <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 27, 2021
1 parent 5a2ec5d commit 0dc1626
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
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
3 changes: 3 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2309,6 +2309,9 @@ Map {
],
"type": "oneOfType",
},
"hideLabel": Object {
"type": "bool",
},
"id": Object {
"isRequired": true,
"type": "string",
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'),
hideLabel: boolean('No title text shown (hideLabel)', 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,
hideLabel,
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`]: hideLabel,
});

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
*/
hideLabel: PropTypes.bool,

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

0 comments on commit 0dc1626

Please sign in to comment.