From 9a434aed5e83d3f33e1b3684b60c4711c767fec2 Mon Sep 17 00:00:00 2001 From: George Marshall Date: Tue, 29 Nov 2022 13:01:05 -0800 Subject: [PATCH] Label house keeping updates (#16680) --- .../component-library/label/README.mdx | 30 ++++++++++--------- .../label/__snapshots__/label.test.js.snap | 11 +++++++ .../component-library/label/label.js | 6 ++-- .../component-library/label/label.stories.js | 9 +++--- .../component-library/label/label.test.js | 12 ++++---- 5 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 ui/components/component-library/label/__snapshots__/label.test.js.snap diff --git a/ui/components/component-library/label/README.mdx b/ui/components/component-library/label/README.mdx index 5f83c96d5..a05500c28 100644 --- a/ui/components/component-library/label/README.mdx +++ b/ui/components/component-library/label/README.mdx @@ -1,10 +1,12 @@ import { Story, Canvas, ArgsTable } from '@storybook/addon-docs'; +import { Text } from '..'; + import { Label } from './label'; # Label -The `Label` is a component used to label form inputs. +The `Label` is a component used to label form inputs @@ -12,13 +14,17 @@ The `Label` is a component used to label form inputs. ## Props -The `Label` accepts all props below as well as all [Text](/docs/ui-components-component-library-text-text-stories-js--default-story#props) and [Box](/docs/ui-components-ui-box-box-stories-js--default-story#props) component props. +The `Label` accepts all props below as well as all [Box](/docs/ui-components-ui-box-box-stories-js--default-story#props) component props +`Label` accepts all [Text](/docs/ui-components-component-library-text-text-stories-js--default-story#props) component props + + + ### Children -The `children` of the label can be text or a react node. +The `children` of the label can be text or a react node @@ -26,9 +32,7 @@ The `children` of the label can be text or a react node. ```jsx import { DISPLAY, ALIGN_ITEMS, FLEX_DIRECTION, SIZES, COLORS } from '../../../helpers/constants/design-system'; -import { Icon, ICON_NAMES } from '../../ui/components/component-library'; -import { Label } from '../../ui/components/component-library'; -import { TextFieldBase } from '../../ui/components/component-library'; +import { Label, TextField, Icon, ICON_NAMES } from '../../component-library'; ``` ### Html For -Use the `htmlFor` prop to allow the `Label` to focus on an input with the same id when clicked. The cursor will also change to a `pointer` when the `htmlFor` has a value +Use the `htmlFor` prop to allow the `Label` to focus on an input with the same id when clicked. The cursor will also change to a `pointer` when the `htmlFor` has a value. ```jsx -import { TextFieldBase } from '../../ui/components/component-library'; -import { Label } from '../../ui/components/component-library'; +import { Label, TextFieldBase } from '../../component-library'; - + ``` ### Required @@ -75,7 +77,7 @@ Use the `required` prop to add a required red asterisk next to the `children` of ```jsx -import { Label } from '../../ui/components/component-library'; +import { Label } from '../../component-library'; ; ``` @@ -89,7 +91,7 @@ Use the `disabled` prop to set the `Label` in disabled state ```jsx -import { Label } from '../../ui/components/component-library'; +import { Label } from '../../component-library'; ; ``` diff --git a/ui/components/component-library/label/__snapshots__/label.test.js.snap b/ui/components/component-library/label/__snapshots__/label.test.js.snap new file mode 100644 index 000000000..f21bba761 --- /dev/null +++ b/ui/components/component-library/label/__snapshots__/label.test.js.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`label should render text inside the label 1`] = ` +
+ +
+`; diff --git a/ui/components/component-library/label/label.js b/ui/components/component-library/label/label.js index aece4d958..121c3ba22 100644 --- a/ui/components/component-library/label/label.js +++ b/ui/components/component-library/label/label.js @@ -20,15 +20,15 @@ export const Label = ({ ...props }) => ( ( alignItems={ALIGN_ITEMS.FLEX_START} > Label that wraps an input - {/* TODO: replace with TextField component */} - + ); @@ -87,7 +86,7 @@ export const HtmlFor = (args) => { return (