Skip to content

feat(@clayui/css): LPD-23703 Adds btn-group-spaced for a separated button group #5812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions packages/clay-button/src/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,14 @@ const ClayButtonGroup = ({
}: IButtonGroupProps) => (
<div
{...otherProps}
className={classNames(
className,
vertical ? 'btn-group-vertical' : 'btn-group'
)}
className={classNames(className, {
'btn-group': !spaced && !vertical,
'btn-group-spaced': spaced,
'btn-group-vertical': vertical,
})}
role={role}
>
{spaced
? React.Children.map(children, (child, i) =>
React.cloneElement(
<div className="btn-group-item">{child}</div>,
{key: i}
)
)
: children}
{children}
</div>
);

Expand Down
30 changes: 11 additions & 19 deletions packages/clay-button/src/__tests__/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,21 @@ exports[`Button renders ClayButtonWithIcon without monospaced 1`] = `
exports[`Button renders a ButtonGroup with spaced 1`] = `
<div>
<div
class="btn-group"
class="btn-group-spaced"
role="group"
>
<div
class="btn-group-item"
<button
class="btn btn-primary"
type="button"
>
<button
class="btn btn-primary"
type="button"
>
Button
</button>
</div>
<div
class="btn-group-item"
Button
</button>
<button
class="btn btn-primary"
type="button"
>
<button
class="btn btn-primary"
type="button"
>
Button
</button>
</div>
Button
</button>
</div>
</div>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@
flex-wrap: wrap;
}

.btn-group-spaced {
@include clay-css($cadmin-btn-group-spaced);
}

.btn-group-nowrap {
flex-wrap: nowrap;
}

// @deprecated as of v3.113.0 replace `.btn-group` with `.btn-group-spaced`
// instead

.btn-group-item {
align-items: center;
display: inline-flex;
Expand Down
12 changes: 12 additions & 0 deletions packages/clay-css/src/scss/cadmin/variables/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,18 @@ $cadmin-btn-unstyled: map-deep-merge(

$cadmin-btn-group-item-margin-right: 16px !default;

$cadmin-btn-group-spaced: () !default;
$cadmin-btn-group-spaced: map-merge(
(
align-items: center,
column-gap: $cadmin-btn-group-item-margin-right,
display: inline-flex,
flex-wrap: wrap,
position: relative,
),
$cadmin-btn-group-spaced
);

// Button Toolbar

$cadmin-btn-toolbar-spacer-x: 8px !default; // 8px
Expand Down
7 changes: 7 additions & 0 deletions packages/clay-css/src/scss/components/_button-groups.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@
flex-wrap: wrap;
}

.btn-group-spaced {
@include clay-css($btn-group-spaced);
}

.btn-group-nowrap {
flex-wrap: nowrap;
}

/// @deprecated as of v3.113.0 replace `.btn-group` with `.btn-group-spaced`
/// instead

.btn-group-item {
align-items: center;
display: inline-flex;
Expand Down
12 changes: 12 additions & 0 deletions packages/clay-css/src/scss/variables/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,18 @@ $btn-unstyled: map-deep-merge(

$btn-group-item-margin-right: map-get($spacers, 2) !default;

$btn-group-spaced: () !default;
$btn-group-spaced: map-merge(
(
align-items: center,
column-gap: $btn-group-item-margin-right,
display: inline-flex,
flex-wrap: wrap,
position: relative,
),
$btn-group-spaced
);

// Button Toolbar

$btn-toolbar-spacer-x: 0.5rem !default; // 8px
Expand Down