Skip to content

Commit

Permalink
fix(Label): consistent gutter spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
zettca authored and francisco-guilherme committed Dec 12, 2024
1 parent 75efe8d commit 1623164
Show file tree
Hide file tree
Showing 31 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/CheckBoxGroup/CheckBoxGroup.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const { staticClasses, useClasses } = createClasses("HvCheckBoxGroup", {
overflowClipMargin: 4,
verticalAlign: "top",
},
label: { marginBottom: theme.space.xs },
label: {},
group: { display: "flex" },
vertical: {
flexDirection: "column",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/CheckBoxGroup/CheckBoxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ export const HvCheckBoxGroup = forwardRef<HTMLDivElement, HvCheckBoxGroupProps>(
>
{label && (
<HvLabel
showGutter
id={setId(elementId, "label")}
label={label}
className={classes.label}
Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/ColorPicker/ColorPicker.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ export const { staticClasses, useClasses } = createClasses("HvColorPicker", {
display: "flex",
alignItems: "flex-start",
},
label: {
paddingBottom: "6px",
display: "block",
cursor: "pointer",
},
label: {},
description: {},
headerColorValue: {
textTransform: "uppercase",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/ColorPicker/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export const HvColorPicker = forwardRef<HTMLDivElement, HvColorPickerProps>(
<div className={classes.labelContainer}>
{hasLabel && (
<HvLabel
showGutter
id={setId(elementId, "label")}
label={label}
className={classes.label}
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/DatePicker/DatePicker.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ export const { staticClasses, useClasses } = createClasses("HvDatePicker", {
display: "flex",
alignItems: "flex-start",
},
label: {
paddingBottom: "6px",
display: "block",
},
label: {},
description: {},
error: {},

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ export const HvDatePicker = forwardRef<HTMLDivElement, HvDatePickerProps>(
<div className={classes.labelContainer}>
{hasLabel && (
<HvLabel
showGutter
id={setId(elementId, "label")}
label={label}
className={classes.label}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Dropdown/Dropdown.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const { staticClasses, useClasses } = createClasses("HvDropdown", {
display: "inline-block",
},
labelContainer: { display: "flex", alignItems: "flex-start" },
label: { paddingBottom: "6px", display: "block" },
label: {},
description: {},
error: {},
placeholder: {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export const HvDropdown = fixedForwardRef(function HvDropdown<
<div className={classes.labelContainer}>
{hasLabel && (
<HvLabel
showGutter
id={setId(elementId, "label")}
label={label}
className={classes.label}
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/FileUploader/DropZone/DropZone.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ export const { staticClasses, useClasses } = createClasses("HvDropZone", {
margin: "auto",
marginRight: theme.space.xs,
},
dropZoneLabel: {
paddingBottom: 6,
},
dropZoneLabel: {},
dragText: {
...(theme.typography.body as React.CSSProperties),
},
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/FileUploader/DropZone/DropZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export const HvDropZone = (props: HvDropZoneProps) => {
{!hideLabels && (
<div id={id} className={classes.dropZoneLabelsGroup}>
<HvLabel
showGutter
id={setId(id, "input-file-label")}
htmlFor={setId(id, "input-file")}
label={labels?.dropzone}
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/FilterGroup/FilterGroup.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { createClasses } from "@hitachivantara/uikit-react-utils";

export const { staticClasses, useClasses } = createClasses("HvFilterGroup", {
root: {},
label: {
display: "flex",
alignItems: "flex-start",
},
label: {},
labelContainer: { display: "flex", alignItems: "flex-start" },
description: {},
error: {},
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/FilterGroup/FilterGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export const HvFilterGroup = forwardRef<HTMLDivElement, HvFilterGroupProps>(
<div className={classes.labelContainer}>
{hasLabel && (
<HvLabel
showGutter
id={setId(elementId, "label")}
htmlFor={setId(elementId, "input")}
label={label}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/FormElement/Label/Label.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { theme } from "@hitachivantara/uikit-styles";
export const { staticClasses, useClasses } = createClasses("HvLabel", {
root: { fontWeight: theme.fontWeights.normal, display: "inline-block" },
labelDisabled: { color: theme.colors.secondary_60 },
childGutter: { paddingBottom: "6px" },
childGutter: { paddingBottom: 4 },
});
7 changes: 5 additions & 2 deletions packages/core/src/FormElement/Label/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface HvLabelProps extends HvTypographyProps<"label"> {
id?: string;
/** The text to be shown by the label. */
label?: React.ReactNode;
/** Whether to give label gutter spacing */
showGutter?: boolean;
/** The id of the form element the label is bound to. */
htmlFor?: string;
/** If `true` the label is displayed with a disabled style. */
Expand All @@ -39,6 +41,7 @@ export const HvLabel = (props: HvLabelProps) => {
className,
children,
label,
showGutter,
disabled: disabledProp,
required: requiredProp,
htmlFor: htmlForProp,
Expand All @@ -62,8 +65,8 @@ export const HvLabel = (props: HvLabelProps) => {
className={cx(
classes.root,
{
[classes.labelDisabled]: !!disabled,
[classes.childGutter]: !!(children && label),
[classes.labelDisabled]: disabled,
[classes.childGutter]: showGutter || (children && label),
},
className,
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Input/Input.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { suggestionsClasses } from "../FormElement/Suggestions";
export const { staticClasses, useClasses } = createClasses("HvInput", {
root: { display: "block" },
labelContainer: { display: "flex", alignItems: "flex-start" },
label: { paddingBottom: "6px", display: "block" },
label: {},
description: {},
adornmentsBox: {
display: "flex",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ export const HvInput = fixedForwardRef(function HvInput<
<div className={classes.labelContainer}>
{hasLabel && (
<HvLabel
showGutter
id={setId(elementId, "label")}
className={classes.label}
htmlFor={setId(elementId, "input")}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/RadioGroup/RadioGroup.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const { staticClasses, useClasses } = createClasses("HvRadioGroup", {
overflowClipMargin: 4,
verticalAlign: "top",
},
label: { marginBottom: theme.space.xs },
label: {},
group: { display: "flex" },
vertical: {
flexDirection: "column",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/RadioGroup/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export const HvRadioGroup = forwardRef<HTMLDivElement, HvRadioGroupProps>(
>
{label && (
<HvLabel
showGutter
id={setId(elementId, "label")}
label={label}
className={classes.label}
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/Select/Select.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export const { staticClasses, useClasses } = createClasses("HvSelect", {
display: "flex",
alignItems: "flex-start",
},
label: {
display: "block",
paddingBottom: 6,
},
label: {},
description: {},
select: {},
popper: {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export const HvSelect = fixedForwardRef(function HvSelect<
<div className={classes.labelContainer}>
{label && (
<HvLabel
showGutter
id={labelId}
htmlFor={id}
label={label}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/SelectionList/SelectionList.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const { staticClasses, useClasses } = createClasses("HvSelectionList", {
width: "100%",
paddingBottom: theme.space.xs,
},
label: { marginBottom: theme.space.xs, float: "left" },
label: {},
description: { float: "left" },
horizontal: {
flexDirection: "row",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/SelectionList/SelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export const HvSelectionList = forwardRef<
>
{label && (
<HvLabel
showGutter
id={setId(elementId, "label")}
label={label}
className={classes.label}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Switch/Switch.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const { staticClasses, useClasses } = createClasses("HvSwitch", {
flexDirection: "column",
alignItems: "flex-start",
},
label: { marginBottom: theme.space.xs },
label: {},
error: {},
switchContainer: {
height: "32px",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export const HvSwitch = forwardRef<HTMLButtonElement, HvSwitchProps>(
>
{label && (
<HvLabel
showGutter
id={setId(elementId, "label")}
htmlFor={setId(elementId, "input")}
label={label}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/TagsInput/TagsInput.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const { staticClasses, useClasses } = createClasses("HvTagsInput", {
resizable: { width: "auto", resize: "both", overflow: "auto" },
invalid: {},
labelContainer: { float: "left", display: "flex", alignItems: "flex-start" },
label: { display: "block", float: "left", paddingBottom: "6px" },
label: {},
description: { display: "block", float: "left" },
characterCounter: {
display: "block",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/TagsInput/TagsInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ export const HvTagsInput = forwardRef<HTMLUListElement, HvTagsInputProps>(
<div className={classes.labelContainer}>
{hasLabel && (
<HvLabel
showGutter
className={classes.label}
id={setId(id, "label")}
htmlFor={setId(elementId, "input")}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/TextArea/TextArea.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const { staticClasses, useClasses } = createClasses("HvTextArea", {
input: {},
inputResizable: { width: "100%", resize: "both" },
labelContainer: { float: "left", display: "flex", alignItems: "flex-start" },
label: { display: "block", float: "left", paddingBottom: "6px" },
label: {},
description: { display: "block", float: "left" },
characterCounter: {
display: "block",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ export const HvTextArea = forwardRef<
<div className={classes.labelContainer}>
{hasLabel && (
<HvLabel
showGutter
className={classes.label}
id={setId(id, "label")}
htmlFor={setId(elementId, "input")}
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/TimePicker/TimePicker.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export const { useClasses, staticClasses } = createClasses("HvTimePicker", {
display: "flex",
alignItems: "flex-start",
},
label: {
marginBottom: 6,
display: "block",
},
label: {},
description: {},

placeholder: {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/TimePicker/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export const HvTimePicker = forwardRef<HTMLDivElement, HvTimePickerProps>(
<div className={classes.labelContainer}>
{label && (
<HvLabel
showGutter
label={label}
className={classes.label}
{...labelProps}
Expand Down
1 change: 1 addition & 0 deletions packages/styles/src/themes/ds3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ const ds3 = makeTheme((theme) => ({
HvLabel: {
classes: {
root: { fontWeight: theme.fontWeights.semibold },
childGutter: { paddingBottom: 6 },
},
},
HvList: {
Expand Down

0 comments on commit 1623164

Please sign in to comment.