Skip to content

Commit

Permalink
fixup! fixup! fixup! Create InputGroup component (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
dacerondrej committed Feb 27, 2023
1 parent a12a16d commit 3d19d62
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 35 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions src/lib/components/InputGroup/InputGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const InputGroup = ({
);

return (
<label
<div
className={classNames(
styles.root,
resolveContextOrProp(formLayoutContext && formLayoutContext.layout, layout) === 'horizontal'
Expand Down Expand Up @@ -71,9 +71,7 @@ export const InputGroup = ({
</InputGroupContext.Provider>
</div>
{validationTexts && (
<div
className={styles.validationTexts}
>
<div className={styles.validationTexts}>
{validationTexts.map((validationText) => (
<Text blockLevel key={validationText}>
{validationText}
Expand All @@ -82,7 +80,7 @@ export const InputGroup = ({
</div>
)}
</div>
</label>
</div>
);
};

Expand Down
18 changes: 4 additions & 14 deletions src/lib/components/SelectField/SelectField.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@
@include box-field-layout.in-form-layout();
}

.isRootGrouped {
@include box-field-layout.in-group-layout();
}

// Sizes
.isRootSizeSmall {
@include box-field-sizes.size(small);
Expand All @@ -102,17 +106,3 @@
.isRootSizeLarge {
@include box-field-sizes.size(large);
}

// Groups
.isRootGrouped {
&:not(:first-child) .input {
margin-left: var(--rui-local-gap);
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}

&:not(:last-child) .input {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
}
18 changes: 4 additions & 14 deletions src/lib/components/TextField/TextField.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
@include box-field-layout.horizontal-with-small-input();
}

.isRootGrouped {
@include box-field-layout.in-group-layout();
}

// Sizes
.isRootSizeSmall {
@include box-field-sizes.size(small);
Expand All @@ -100,17 +104,3 @@
.isRootSizeLarge {
@include box-field-sizes.size(large);
}

// Groups
.isRootGrouped {
&:not(:first-child) .input {
margin-left: var(--rui-local-gap);
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}

&:not(:last-child) .input {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
}
16 changes: 16 additions & 0 deletions src/lib/styles/tools/form-fields/_box-field-layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
//
// 13. Label and field are vertically aligned to top (start) by default (see 10.). Vertical
// alignment of each block can be changed by theme configuration.
//
// 14. Inner corners of TextField and SelectField components inside the InputGroup component are sharp
// (their radius is set to 0).

@use "../../settings/forms";
@use "../../settings/form-fields" as settings;
Expand Down Expand Up @@ -227,3 +230,16 @@
}
}
}

@mixin in-group-layout() {
&:not(:first-child) .input {
margin-left: var(--rui-local-gap);
border-top-left-radius: 0; // 14.
border-bottom-left-radius: 0; // 14.
}

&:not(:last-child) .input {
border-top-right-radius: 0; // 14.
border-bottom-right-radius: 0; // 14.
}
}
2 changes: 1 addition & 1 deletion src/lib/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@
// InputGroup
// =======

--rui-InputGroup__gap: var(--rui-spacing-1);
--rui-InputGroup__gap: var(--rui-dimension-space-1);

//
// Modal
Expand Down

0 comments on commit 3d19d62

Please sign in to comment.