Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit 644269f

Browse files
TedSandernshahan
authored andcommitted
Add a compact mode to material-button
Currently all buttons in acx are 'compact' have around 8px of padding. The default should be 16px. This attribute will make transitioning easier. PiperOrigin-RevId: 187928191
1 parent 677c937 commit 644269f

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

lib/material_button/_mixins.scss

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ $button-disabled-background-dark: rgba(255, 255, 255, $mat-divider-opacity);
5555
}
5656
}
5757

58+
/// Mixin used for styling compact buttons local to a view. Private to this
59+
/// file.
60+
@mixin _button-compact {
61+
&:not([icon]) {
62+
padding: 0 $mat-grid;
63+
}
64+
}
65+
5866
/// Private mixin for styling the highlight when a button is hovered or focused.
5967
@mixin _button-hover {
6068
&:not([disabled]):not([icon]):hover::after,
@@ -100,6 +108,10 @@ $button-disabled-background-dark: rgba(255, 255, 255, $mat-divider-opacity);
100108
@include _button-dense;
101109
}
102110

111+
&[compact] {
112+
@include _button-compact;
113+
}
114+
103115
&[disabled] {
104116
@include acx-theme-dark {
105117
color: $button-disabled-color-dark;
@@ -296,11 +308,29 @@ $button-disabled-background-dark: rgba(255, 255, 255, $mat-divider-opacity);
296308
/// Example:
297309
/// ```scss
298310
/// :host {
299-
/// @include button-dense-theme('material-button.dense', $mat-blue);
311+
/// @include button-dense-theme('material-button.dense');
300312
/// }
301313
/// ```
302314
@mixin button-dense-theme($selector) {
303315
::ng-deep #{$selector} {
304316
@include _button-dense;
305317
}
306318
}
319+
320+
/// Mixin to create a compact button. Use this mixin enable compact buttons
321+
/// to all components below the given scope. Do not provide a scope if all
322+
/// all buttons or all buttons of a certain selector on the page should be
323+
/// compact.
324+
///
325+
/// Should be scopped unless all buttons on the page should be compact.
326+
/// Example:
327+
/// ```scss
328+
/// :host {
329+
/// @include button-compact-theme('material-button.compact');
330+
/// }
331+
/// ```
332+
@mixin button-compact-theme($selector) {
333+
::ng-deep #{$selector} {
334+
@include _button-compact;
335+
}
336+
}

0 commit comments

Comments
 (0)