Skip to content

Commit e6eb44d

Browse files
authored
feat(field-label): add tone (#1147)
* feat(field-label): add tone to be passed to label * feat(label-field): add tone to story * fix(field-label): typo Co-Authored-By: Abel Almeida <[email protected]> * docs(readme/field-label) to have other non default indicator Co-Authored-By: Abel Almeida <[email protected]> * feat(label-field): forward tone * feat(label-field): add to vrt * fix(label-field): to properly vrt things * fix(label-field): make canada happy * fix(label-field): swap wrap and detail
1 parent 06aac62 commit e6eb44d

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

src/components/field-label/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The `hintIcon` also accepts a custom `color` while defaulting to `warning` in th
5555
| `hint` | `string` or `node` | - | - | - | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`. |
5656
| `description` | `string` or `node` | - | - | - | Provides a description for the title. |
5757
| `onInfoButtonClick` | `function` | - | - | - | Function called when info button is pressed. Info button will only be visible when this prop is passed. |
58+
| `tone` | `string` | - | `['primary', 'inverted']` | _ | Indicates the tone to be applied to the label |
5859
| `hintIcon` | `node` | - | - | - | Icon to be displayed beside the hint text. Will only get rendered when `hint` is passed as well. |
5960
| `badge` | `node` | - | - | - | Badge to be displayed beside the label. Might be used to display additional information about the content of the field (E.g verified email) |
6061
| `hasRequiredIndicator` | `bool` | - | - | `false` | Indicates if the labeled field is required in a form |

src/components/field-label/field-label.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const FieldLabel = props => {
2626
isBold={true}
2727
isRequiredIndicatorVisible={props.hasRequiredIndicator}
2828
htmlFor={props.htmlFor}
29+
tone={props.tone}
2930
>
3031
{props.title}
3132
</Label>
@@ -51,13 +52,15 @@ export const FieldLabel = props => {
5152
})}
5253
</Spacings.Inline>
5354
)}
54-
{props.hint && <Text.Detail>{props.hint}</Text.Detail>}
55+
{props.hint && (
56+
<Text.Detail tone={props.tone}>{props.hint}</Text.Detail>
57+
)}
5558
</Spacings.Inline>
5659
)}
5760
{props.description && (
58-
<Text.Detail>
59-
<Text.Wrap>{props.description}</Text.Wrap>
60-
</Text.Detail>
61+
<Text.Wrap>
62+
<Text.Detail tone={props.tone}>{props.description}</Text.Detail>
63+
</Text.Wrap>
6164
)}
6265

6366
{props.badge && (
@@ -85,6 +88,7 @@ FieldLabel.propTypes = {
8588
),
8689
description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
8790
onInfoButtonClick: PropTypes.func,
91+
tone: PropTypes.oneOf(['primary', 'inverted']),
8892
hintIcon: PropTypes.node,
8993
badge: PropTypes.node,
9094
hasRequiredIndicator: PropTypes.bool,

src/components/field-label/field-label.story.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ storiesOf('Components|FieldLabel', module)
3333
)}
3434
title={text('title', 'Sort Order')}
3535
hasRequiredIndicator={boolean('hasRequiredIndicator', false)}
36+
tone={select('tone', ['', 'inverted'])}
3637
onInfoButtonClick={
3738
boolean('show info button', true)
3839
? action('onInfoButtonClick')

src/components/field-label/field-label.visualroute.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from 'react';
2-
import { FieldLabel, WarningIcon, FlatButton } from 'ui-kit';
2+
import { ThemeProvider } from 'emotion-theming';
3+
import { FieldLabel, WarningIcon, FlatButton, customProperties } from 'ui-kit';
34
import { Suite, Spec } from '../../../test/percy';
45

56
export const routePath = '/field-label';
67

7-
export const component = () => (
8+
export const component = ({ themes }) => (
89
<Suite>
910
<Spec label="minimal">
1011
<FieldLabel title="Hello" horizontalConstraint="m" />
@@ -58,5 +59,17 @@ export const component = () => (
5859
horizontalConstraint="m"
5960
/>
6061
</Spec>
62+
<ThemeProvider theme={themes.darkTheme}>
63+
<Spec label="with inverted tone" omitPropsList>
64+
<ThemeProvider theme={customProperties}>
65+
<FieldLabel
66+
title="Hello"
67+
description="description"
68+
hasRequiredIndicator={true}
69+
tone="inverted"
70+
/>
71+
</ThemeProvider>
72+
</Spec>
73+
</ThemeProvider>
6174
</Suite>
6275
);

0 commit comments

Comments
 (0)