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

refactor(select): support for md-inline-form, more configurable SCSS #8716

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ function SelectProvider($$interimElementProvider) {
transformOrigin = '50% 100%';
}
} else {
left = (targetRect.left + centeredRect.left - centeredRect.paddingLeft) + 2;
left = (targetRect.left + centeredRect.left - centeredRect.paddingLeft);
top = Math.floor(targetRect.top + targetRect.height / 2 - centeredRect.height / 2 -
centeredRect.top + contentNode.scrollTop) + 2;

Expand Down
69 changes: 43 additions & 26 deletions src/components/select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,23 @@ $select-option-height: 48px !default;
$select-option-padding: 16px !default;
$select-container-padding: 16px !default;
$select-container-transition-duration: 350ms !default;
$select-value-padding-top: 6px;
$select-value-padding-bottom: 4px;

$select-max-visible-options: 5 !default;

// from input.scss
$input-container-margin-top: 18px !default;
$input-container-padding-top: 2px !default;
$input-padding-top: 2px !default;
$input-padding-bottom: 1px !default;

$input-alignment: ($input-padding-top + $input-padding-bottom)
- ($select-value-padding-top + $select-value-padding-bottom);
$md-inline-alignment: ($input-container-margin-top + $input-container-padding-top)
+ ($input-padding-top + $input-padding-bottom)
- ($select-value-padding-top + $select-value-padding-bottom);

// Fixes the animations with the floating label when select is inside an input container
md-input-container {
&:not([md-no-float]) {
Expand Down Expand Up @@ -71,9 +85,18 @@ md-input-container {
}
}

md-input-container > md-select {
margin: 0;
order: 2;
.md-inline-form md-select {
margin-top: $md-inline-alignment;
}

md-input-container {
> md-select,
.md-inline-form & > md-select {
margin-top: $input-alignment;
}
> md-select {
order: 2;
}
}


Expand Down Expand Up @@ -102,7 +125,6 @@ md-input-container.md-input-invalid {

md-select {
display: flex;
margin: 2.5*$baseline-grid 0 3*$baseline-grid + 2 0;

&[required], &.ng-required {
&.ng-invalid:not(.md-no-asterisk) {
Expand All @@ -120,7 +142,12 @@ md-select {
// to create a dotted line under the input.
background-size: 4px 1px;
background-repeat: repeat-x;
margin-bottom: -1px; // Shift downward so dotted line is positioned the same as other bottom borders
// Add to padding-bottom to keep dotted line aligned with other bottom borders
// Sub from padding-top to keep height consistent
// Translate text 1px up to keep in alignment
padding-bottom: $select-value-padding-bottom + 1;
padding-top: $select-value-padding-top - 1;
transform: translate3d(0, 1px, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

translate3d generally breaks IE. Can just translate be used here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just moving this from what was Line#160, so it's unlikely to cause any major rendering changes.

You're probably right that 2D translation is probably better, but I think that would be outside the scope of the PR. It's best not to bunch too many changes at once.

}

&:focus {
Expand All @@ -135,43 +162,33 @@ md-select {
}
&.ng-invalid.ng-touched {
.md-select-value {
border-bottom-style: solid;
padding-bottom: 1px;
border-bottom: 2px solid;
}
}
&:focus {
.md-select-value {
border-bottom-width: 2px;
border-bottom-style: solid;
padding-bottom: 0;
}
&.ng-invalid.ng-touched {
.md-select-value {
padding-bottom: 0;
}
padding-bottom: $select-value-padding-bottom - 1;
}
}
}
}

// Fix value by 1px to align with standard text inputs (and spec)
md-input-container.md-input-has-value .md-select-value {
> span:not(.md-select-icon) {
transform: translate3d(0, 1px, 0);
}
}

.md-select-value {
display: flex;
align-items: center;
padding: 2px 2px 1px;
padding-top: $select-value-padding-top;
padding-bottom: $select-value-padding-bottom;
border-bottom-width: 1px;
border-bottom-style: solid;
background-color: rgba(0,0,0,0);
position: relative;
box-sizing: content-box;
min-width: 8 * $baseline-grid;
min-width: 11 * $baseline-grid;
min-height: 26px;
margin-bottom: auto;
-ms-flex-item-align: start; // workaround for margin-bottom: auto
flex-grow: 1;


Expand All @@ -192,7 +209,6 @@ md-input-container.md-input-has-value .md-select-value {
align-items: flex-end;
text-align: end;
width: 3 * $baseline-grid;
margin: 0 .5 * $baseline-grid;
transform: translate3d(0, -2px, 0);
font-size: 1.2rem;
}
Expand All @@ -202,17 +218,18 @@ md-input-container.md-input-has-value .md-select-value {
content: '\25BC';
position: relative;
top: 2px;
@include rtl(right, -4px, auto);
@include rtl(left, auto, -4px);
speak: none;
font-size: 13px;
transform: scaleY(0.5) scaleX(1);
font-size: 16px;
transform: scaleY(0.5);
}

&.md-select-placeholder {
display: flex;
order: 1;
pointer-events: none;
-webkit-font-smoothing: antialiased;
padding-left: 2px;
z-index: 1;
}
}
Expand Down