From fb735f0c58d8f299e260c1a3ab7573b819bdc779 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Tue, 19 Jan 2021 11:44:14 -0500 Subject: [PATCH 1/2] feat(Dropdown): add hideTitleText prop --- .all-contributorsrc | 9 +++++++++ README.md | 1 + packages/react/src/components/Dropdown/Dropdown-story.js | 1 + packages/react/src/components/Dropdown/Dropdown.js | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 120a3bf13b05..dbca2e54ae1e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -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" diff --git a/README.md b/README.md index 49d72eaf5a85..3aa8af37f05d 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
DavidSCChen

💻 +
molyholy

💻 diff --git a/packages/react/src/components/Dropdown/Dropdown-story.js b/packages/react/src/components/Dropdown/Dropdown-story.js index 351c66447651..ad12e5cdc81d 100644 --- a/packages/react/src/components/Dropdown/Dropdown-story.js +++ b/packages/react/src/components/Dropdown/Dropdown-story.js @@ -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( diff --git a/packages/react/src/components/Dropdown/Dropdown.js b/packages/react/src/components/Dropdown/Dropdown.js index 6547e6b9b91c..c8b3bb57395c 100644 --- a/packages/react/src/components/Dropdown/Dropdown.js +++ b/packages/react/src/components/Dropdown/Dropdown.js @@ -45,6 +45,7 @@ const Dropdown = React.forwardRef(function Dropdown( onChange, id, titleText, + hideTitleText, helperText, translateWithId, light, @@ -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`, { @@ -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` */ From f366ddad80d6057958b344bc4409d05d4b38902c Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Wed, 20 Jan 2021 11:31:35 -0500 Subject: [PATCH 2/2] refactor(Dropdown): change hideTitleText to hideLabel --- .../react/__tests__/__snapshots__/PublicAPI-test.js.snap | 3 +++ packages/react/src/components/Dropdown/Dropdown-story.js | 2 +- packages/react/src/components/Dropdown/Dropdown.js | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index 33016a52039a..a00da41370a7 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -2306,6 +2306,9 @@ Map { ], "type": "oneOfType", }, + "hideLabel": Object { + "type": "bool", + }, "id": Object { "isRequired": true, "type": "string", diff --git a/packages/react/src/components/Dropdown/Dropdown-story.js b/packages/react/src/components/Dropdown/Dropdown-story.js index ad12e5cdc81d..bf55f87e8ca8 100644 --- a/packages/react/src/components/Dropdown/Dropdown-story.js +++ b/packages/react/src/components/Dropdown/Dropdown-story.js @@ -60,7 +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), + 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( diff --git a/packages/react/src/components/Dropdown/Dropdown.js b/packages/react/src/components/Dropdown/Dropdown.js index c8b3bb57395c..ad3828dcfc2d 100644 --- a/packages/react/src/components/Dropdown/Dropdown.js +++ b/packages/react/src/components/Dropdown/Dropdown.js @@ -45,7 +45,7 @@ const Dropdown = React.forwardRef(function Dropdown( onChange, id, titleText, - hideTitleText, + hideLabel, helperText, translateWithId, light, @@ -99,7 +99,7 @@ const Dropdown = React.forwardRef(function Dropdown( const titleClasses = cx(`${prefix}--label`, { [`${prefix}--label--disabled`]: disabled, - [`${prefix}--visually-hidden`]: hideTitleText, + [`${prefix}--visually-hidden`]: hideLabel, }); const helperClasses = cx(`${prefix}--form__helper-text`, { @@ -237,7 +237,7 @@ Dropdown.propTypes = { /** * Specify whether the title text should be hidden or not */ - hideTitleText: PropTypes.bool, + hideLabel: PropTypes.bool, /** * Specify a custom `id`