Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

feat(layouts): add @mixin for responsive support for rows #11981

Merged
merged 1 commit into from
Jul 27, 2020
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
1 change: 1 addition & 0 deletions src/components/checkbox/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function MdCheckboxDirective(inputDirective, $mdAria, $mdConstant, $mdTheming, $
tAttrs.$set('tabindex', tAttrs.tabindex || '0');
tAttrs.$set('type', 'checkbox');
tAttrs.$set('role', tAttrs.type);
tElement.addClass('md-auto-horizontal-margin');

return {
pre: function(scope, element) {
Expand Down
7 changes: 0 additions & 7 deletions src/components/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//
// ^^ defined in _variables.scss
//
$checkbox-margin-end: 16px !default;
$checkbox-text-margin-top: 10px !default;
$container-checkbox-margin: 3px !default;

Expand Down Expand Up @@ -41,13 +40,7 @@ md-checkbox {
position: relative;
min-width: $checkbox-width;
@include dense(min-height, $checkbox-min-height, $checkbox-min-height-dense);
@include rtl(margin-left, 0, $checkbox-margin-end);
@include rtl(margin-right, $checkbox-margin-end, 0);

&:last-of-type {
margin-left: 0;
margin-right: 0;
}
&.md-focused:not([disabled]) {
.md-container:before {
left: -8px;
Expand Down
13 changes: 1 addition & 12 deletions src/components/divider/divider-theme.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
md-divider.md-THEME_NAME-theme {
border-top-color: '{{foreground-4}}';
}

.layout-row,
.layout-xs-row, .layout-gt-xs-row,
.layout-sm-row, .layout-gt-sm-row,
.layout-md-row, .layout-gt-md-row,
.layout-lg-row, .layout-gt-lg-row,
.layout-xl-row {
& > md-divider.md-THEME_NAME-theme {
border-right-color: '{{foreground-4}}';
}
border-color: '{{foreground-4}}';
}
15 changes: 4 additions & 11 deletions src/components/divider/divider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,8 @@ md-divider {
}
}

.layout-row,
.layout-xs-row, .layout-gt-xs-row,
.layout-sm-row, .layout-gt-sm-row,
.layout-md-row, .layout-gt-md-row,
.layout-lg-row, .layout-gt-lg-row,
.layout-xl-row {
& > md-divider {
border-top-width: 0;
border-right-width: 1px;
border-right-style: solid;
}
@include when-layout-row(md-divider) {
border-top-width: 0;
border-right-width: 1px;
border-right-style: solid;
}
2 changes: 2 additions & 0 deletions src/components/input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ function mdInputContainerDirective($mdTheming, $parse, $$rAF) {
function ContainerCtrl($scope, $element, $attrs, $animate) {
var self = this;

$element.addClass('md-auto-horizontal-margin');

self.isErrorGetter = $attrs.mdIsError && $parse($attrs.mdIsError);

self.delegateClick = function() {
Expand Down
1 change: 1 addition & 0 deletions src/components/radioButton/radio-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ function mdRadioButtonDirective($mdAria, $mdUtil, $mdTheming) {

$mdTheming(element);
configureAria(element, scope);
element.addClass('md-auto-horizontal-margin');

// ngAria overwrites the aria-checked inside a $watch for ngValue.
// We should defer the initialization until all the watches have fired.
Expand Down
35 changes: 4 additions & 31 deletions src/components/radioButton/radio-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,6 @@ md-radio-button {
}

md-radio-group {
/** Layout adjustments for the radio group. */
&.layout-column,
&.layout-xs-column, &.layout-gt-xs-column,
&.layout-sm-column, &.layout-gt-sm-column,
&.layout-md-column, &.layout-gt-md-column,
&.layout-lg-column, &.layout-gt-lg-column,
&.layout-xl-column {
md-radio-button {
margin-bottom: $radio-margin;
}
}

&.layout-row,
&.layout-xs-row, &.layout-gt-xs-row,
&.layout-sm-row, &.layout-gt-sm-row,
&.layout-md-row, &.layout-gt-md-row,
&.layout-lg-row, &.layout-gt-lg-row,
&.layout-xl-row {
md-radio-button {
margin-top: 0;
margin-bottom: 0;
@include rtl(margin-left, 0, $radio-margin);
@include rtl(margin-right, $radio-margin, 0);

&:last-of-type {
margin-left: 0;
margin-right: 0;
}
}
}

&:focus {
outline: none;
}
Expand All @@ -171,6 +140,10 @@ md-radio-group {
}
}

@include when-layout-row(md-radio-button) {
margin-bottom: 0;
}

.md-inline-form {
md-radio-group {
margin: 18px 0 19px;
Expand Down
3 changes: 0 additions & 3 deletions src/components/select/demoBasicUsage/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
md-input-container {
margin-right: 10px;
}
2 changes: 2 additions & 0 deletions src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ function SelectDirective($mdSelect, $mdUtil, $mdConstant, $mdTheming, $mdAria, $
*/
function compile(tElement, tAttrs) {
var isMultiple = $mdUtil.parseAttributeBoolean(tAttrs.multiple);
tElement.addClass('md-auto-horizontal-margin');

// add the select value that will hold our placeholder or selected option value
var valueEl = angular.element('<md-select-value><span></span></md-select-value>');
valueEl.append('<span class="md-select-icon" aria-hidden="true"></span>');
Expand Down
53 changes: 53 additions & 0 deletions src/core/style/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,56 @@
@include rtl($prop, $ltr-dense, $rtl-dense);
}
}

// Only use when in row layout
@mixin when-layout-row($element) {
@media (max-width: $layout-breakpoint-xs - 1) {
.layout-row:not(.layout-xs-column),
.layout-xs-row {
& > #{$element} { @content; }
}
}
@media (min-width: $layout-breakpoint-xs) and (max-width: $layout-breakpoint-sm - 1) {
.layout-row:not(.layout-gt-xs-column),
.layout-gt-xs-row,
.layout-sm-row {
&:not(.layout-sm-column) > #{$element} { @content; }
}
}
@media (min-width: $layout-breakpoint-sm) and (max-width: $layout-breakpoint-md - 1) {
.layout-row:not(.layout-gt-xs-column):not(.layout-gt-sm-column),
.layout-gt-xs-row:not(.layout-gt-sm-column),
.layout-gt-sm-row,
.layout-md-row {
&:not(.layout-md-column) > #{$element} { @content; }
}
}
@media (min-width: $layout-breakpoint-md) and (max-width: $layout-breakpoint-lg - 1) {
.layout-row:not(.layout-gt-xs-column):not(.layout-gt-sm-column):not(.layout-gt-md-column),
.layout-gt-xs-row:not(.layout-gt-sm-column):not(.layout-gt-md-column),
.layout-gt-sm-row:not(.layout-gt-md-column),
.layout-gt-md-row,
.layout-lg-row {
&:not(.layout-lg-column) > #{$element} { @content; }
}
}
@media (min-width: $layout-breakpoint-lg) {
.layout-row:not(.layout-gt-xs-column):not(.layout-gt-sm-column):not(.layout-gt-md-column),
.layout-gt-xs-row:not(.layout-gt-sm-column):not(.layout-gt-md-column),
.layout-gt-sm-row:not(.layout-gt-md-column),
.layout-gt-md-row,
.layout-gt-lg-row,
.layout-xl-row {
&:not(.layout-gt-lg-column):not(.layout-xl-column) > #{$element} { @content; }
}
}
}

// Auto insert object margin
@mixin auto-horizontal-margin($selector) {
@include when-layout-row($selector) {
&:not(:first-child) {
@include rtl-prop(margin-left, margin-right, $default-horizontal-margin, 0);
}
}
}
3 changes: 3 additions & 0 deletions src/core/style/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,6 @@ $checkbox-width: 18px !default;
$checkbox-height: $checkbox-width !default;
$checkbox-border-radius: 2px !default;
$checkbox-border-width: 2px !default;

// Shared Horizontal Margin Variables
$default-horizontal-margin: 16px !default;
1 change: 1 addition & 0 deletions src/core/style/structure.scss
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,4 @@ bdo[dir=ltr] {
unicode-bidi: bidi-override;
}

@include auto-horizontal-margin('.md-auto-horizontal-margin');