Sanitize height, border and padding of gr-autocomplete

Remove --gr-autocomplete. Always put border, border-radius, padding
on gr-autocomplete, unless it is classified as "borderless".

Add a border-radius also to the gr-autocomplete-dropdown. Makes it
look nicer.

Adjust the vertical offset of where the dropdown is shown in
gr-autocomplete to 31px, which matches the default styles. Only needs
a different value in gr-account-entry, where no border and no padding
is used.

Drop height:2em from gr-autocomplete usages, which makes it fall back
to height being calculated from border, padding, line-height as usual.

Also drop height:2em from input,select,textarea form styles, and
align their padding to 4px as used everywhere else.

Align also the standard border-radius and padding of input with that
of gr-autocomplete.

Change-Id: If3e1434f206f50577b926b3f35b624636534926b
This commit is contained in:
Ben Rohlfs
2019-11-19 23:52:00 +01:00
parent ee93acbd18
commit 285e40e1d9
13 changed files with 45 additions and 68 deletions

View File

@@ -43,11 +43,6 @@ limitations under the License.
.value { .value {
width: 32em; width: 32em;
} }
gr-autocomplete {
--gr-autocomplete: {
padding: 0 var(--spacing-xs);
}
}
.hide { .hide {
display: none; display: none;
} }

View File

@@ -40,15 +40,8 @@ limitations under the License.
width: 20em; width: 20em;
} }
gr-autocomplete { gr-autocomplete {
border: none;
--gr-autocomplete: {
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
height: 2em;
padding: 0 var(--spacing-xs);
width: 20em; width: 20em;
} }
}
</style> </style>
<div class="gr-form-styles"> <div class="gr-form-styles">

View File

@@ -48,10 +48,6 @@ limitations under the License.
} }
gr-autocomplete { gr-autocomplete {
width: 20em; width: 20em;
--gr-autocomplete: {
height: 2em;
width: 20em;
}
} }
a { a {
color: var(--primary-text-color); color: var(--primary-text-color);

View File

@@ -29,11 +29,9 @@ limitations under the License.
} }
gr-autocomplete { gr-autocomplete {
background-color: var(--view-background-color); background-color: var(--view-background-color);
border: 1px solid var(--border-color);
border-radius: var(--border-radius); border-radius: var(--border-radius);
flex: 1; flex: 1;
outline: none; outline: none;
padding: var(--spacing-xs);
} }
</style> </style>
<form> <form>
@@ -45,7 +43,6 @@ limitations under the License.
on-commit="_handleInputCommit" on-commit="_handleInputCommit"
allow-non-suggested-values allow-non-suggested-values
multi multi
borderless
threshold="[[_threshold]]" threshold="[[_threshold]]"
tab-complete tab-complete
vertical-offset="30"></gr-autocomplete> vertical-offset="30"></gr-autocomplete>

View File

@@ -55,21 +55,13 @@ limitations under the License.
gr-dialog .main > iron-input{ gr-dialog .main > iron-input{
width: 100%; width: 100%;
} }
gr-autocomplete {
--gr-autocomplete: {
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
height: 2em;
padding: 0 var(--spacing-xs);
}
}
input { input {
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
border-radius: var(--border-radius); border-radius: var(--border-radius);
height: 2em;
margin: var(--spacing-m) 0; margin: var(--spacing-m) 0;
padding: 0 var(--spacing-xs); padding: var(--spacing-s);
width: 100%; width: 100%;
box-sizing: content-box;
} }
@media screen and (max-width: 50em) { @media screen and (max-width: 50em) {
gr-dialog { gr-dialog {

View File

@@ -40,7 +40,8 @@ limitations under the License.
on-commit="_handleInputCommit" on-commit="_handleInputCommit"
clear-on-commit clear-on-commit
warn-uncommitted warn-uncommitted
text="{{_inputText}}"> text="{{_inputText}}"
vertical-offset="24">
</gr-autocomplete> </gr-autocomplete>
</template> </template>
<script src="gr-account-entry.js"></script> <script src="gr-account-entry.js"></script>

View File

@@ -60,6 +60,7 @@ limitations under the License.
.dropdown-content { .dropdown-content {
background: var(--dropdown-background-color); background: var(--dropdown-background-color);
box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px; box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px;
border-radius: var(--border-radius);
max-height: 50vh; max-height: 50vh;
overflow: auto; overflow: auto;
} }

View File

@@ -36,13 +36,14 @@ limitations under the License.
margin: 0 var(--spacing-xs); margin: 0 var(--spacing-xs);
vertical-align: top; vertical-align: top;
} }
paper-input:not(.borderless) { paper-input.borderless {
border: 1px solid var(--border-color); border: none;
padding: 0;
} }
paper-input { paper-input {
height: var(--line-height-normal); border: 1px solid var(--border-color);
width: 100%; border-radius: var(--border-radius);
@apply --gr-autocomplete; padding: var(--spacing-s);
--paper-input-container: { --paper-input-container: {
padding: 0; padding: 0;
}; };
@@ -50,13 +51,25 @@ limitations under the License.
font-size: var(--font-size-normal); font-size: var(--font-size-normal);
line-height: var(--line-height-normal); line-height: var(--line-height-normal);
}; };
/* This is a hack for not being able to set height:0 on the underline
of a paper-input 2.2.3 element. All the underline fixes below only
actually work in 3.x.x, so the height must be adjusted directly as
a workaround until we are on Polymer 3. */
height: var(--line-height-normal);
--paper-input-container-underline-height: 0;
--paper-input-container-underline-wrapper-height: 0;
--paper-input-container-underline-focus-height: 0;
--paper-input-container-underline-legacy-height: 0;
--paper-input-container-underline: { --paper-input-container-underline: {
height: 0;
display: none; display: none;
}; };
--paper-input-container-underline-focus: { --paper-input-container-underline-focus: {
height: 0;
display: none; display: none;
}; };
--paper-input-container-underline-disabled: { --paper-input-container-underline-disabled: {
height: 0;
display: none; display: none;
}; };
} }

View File

@@ -89,11 +89,15 @@
type: Boolean, type: Boolean,
value: false, value: false,
}, },
// Vertical offset needed for a 1em font-size with no vertical padding. /**
// Inputs with additional padding will need to increase vertical offset. * Vertical offset needed for an element with 20px line-height, 4px
* padding and 1px border (30px height total). Plus 1px spacing between
* input and dropdown. Inputs with different line-height or padding will
* need to tweak vertical offset.
*/
verticalOffset: { verticalOffset: {
type: Number, type: Number,
value: 20, value: 31,
}, },
text: { text: {

View File

@@ -335,7 +335,7 @@ limitations under the License.
}); });
test('vertical offset overridden by param if it exists', () => { test('vertical offset overridden by param if it exists', () => {
assert.equal(element.$.suggestions.verticalOffset, 20); assert.equal(element.$.suggestions.verticalOffset, 31);
element.verticalOffset = 30; element.verticalOffset = 30;
assert.equal(element.$.suggestions.verticalOffset, 30); assert.equal(element.$.suggestions.verticalOffset, 30);
}); });

View File

@@ -38,14 +38,7 @@ limitations under the License.
#body { #body {
display: flex; display: flex;
} }
gr-autocomplete {
height: 1.5em;
--gr-autocomplete: {
border: none;
}
}
#trigger { #trigger {
border-left: 1px solid var(--deemphasized-text-color);
color: var(--deemphasized-text-color); color: var(--deemphasized-text-color);
cursor: pointer; cursor: pointer;
padding-left: var(--spacing-s); padding-left: var(--spacing-s);

View File

@@ -61,7 +61,6 @@ limitations under the License.
} }
.gr-form-styles td, .gr-form-styles td,
.gr-form-styles tfoot th { .gr-form-styles tfoot th {
height: 2em;
padding: var(--spacing-s) 0; padding: var(--spacing-s) 0;
vertical-align: middle; vertical-align: middle;
} }
@@ -84,8 +83,7 @@ limitations under the License.
.gr-form-styles textarea { .gr-form-styles textarea {
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
border-radius: var(--border-radius); border-radius: var(--border-radius);
height: 2em; padding: var(--spacing-s);
padding: 0 var(--spacing-xs);
} }
.gr-form-styles td:last-child { .gr-form-styles td:last-child {
width: 5em; width: 5em;
@@ -97,24 +95,17 @@ limitations under the License.
.gr-form-styles iron-autogrow-textarea { .gr-form-styles iron-autogrow-textarea {
border: none; border: none;
height: auto; height: auto;
min-height: 2em; min-height: 4em;
--iron-autogrow-textarea: { --iron-autogrow-textarea: {
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
border-radius: var(--border-radius); border-radius: var(--border-radius);
box-sizing: border-box; box-sizing: border-box;
padding: var(--spacing-s) var(--spacing-xs) 0 var(--spacing-xs); padding: var(--spacing-s);
} }
} }
.gr-form-styles gr-autocomplete { .gr-form-styles gr-autocomplete {
border: none;
--gr-autocomplete: {
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
height: 2em;
padding: 0 var(--spacing-xs);
width: 14em; width: 14em;
} }
}
@media only screen and (max-width: 40em) { @media only screen and (max-width: 40em) {
.gr-form-styles section { .gr-form-styles section {
margin-bottom: var(--spacing-l); margin-bottom: var(--spacing-l);

View File

@@ -42,10 +42,11 @@ limitations under the License.
input { input {
background-color: inherit; background-color: inherit;
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
border-radius: var(--border-radius);
box-sizing: border-box; box-sizing: border-box;
color: var(--primary-text-color); color: var(--primary-text-color);
margin: 0; margin: 0;
padding: 0; padding: var(--spacing-s);
} }
iron-autogrow-textarea { iron-autogrow-textarea {
background-color: inherit; background-color: inherit;