budibase/packages/standard-components/node_modules/@spectrum-css/textfield/index.css

329 lines
10 KiB
CSS

/*
Copyright 2019 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
@import "../vars/css/components/spectrum-textfield.css";
@import "../vars/css/components/spectrum-textarea.css";
.spectrum-Textfield {
@remapvars {
find: /--spectrum-textfield-m(.*)/;
filter: color;
replace: --spectrum-textfield$1;
}
/* pull in quiet vars with incorrect property ordering */
@remapvars {
find: /--spectrum-textfield-quiet-m(.*)/;
filter: color;
replace: --spectrum-textfield-quiet$1;
}
@remapvars {
find: /--spectrum-textarea-m(.*)/;
filter: color;
replace: --spectrum-textarea$1;
}
/* pull in quiet vars with incorrect property ordering */
@remapvars {
find: /--spectrum-textarea-quiet-m(.*)/;
filter: color;
replace: --spectrum-textarea-quiet$1;
}
/* todo: unclear how to use --spectrum-textfield-m-text-padding-top and friends */
--spectrum-textfield-padding-top: 3px;
--spectrum-textfield-padding-bottom: 5px;
/* todo: DNA uses incorrect font family "Adobe Clean" */
--spectrum-textfield-text-font-family: var(--spectrum-alias-body-text-font-family);
/* todo: add to DNA */
--spectrum-textfield-icon-gap: var(--spectrum-global-dimension-size-65);
--spectrum-textfield-quiet-icon-gap: var(--spectrum-global-dimension-size-75);
/* height is incorrectly named in DNA, should be min-height */
--spectrum-textarea-min-height: var(--spectrum-textarea-height);
--spectrum-textarea-height-adjusted: auto;
/* padding is incorrectly named in DNA, should drop text */
--spectrum-textarea-padding-top: var(--spectrum-textarea-text-padding-top);
--spectrum-textarea-padding-bottom: var(--spectrum-textarea-text-padding-bottom);
}
.spectrum-Textfield {
display: inline-flex;
position: relative;
min-inline-size: var(--spectrum-textfield-min-width);
inline-size: var(--spectrum-alias-single-line-width);
&.spectrum-Textfield--quiet.spectrum-Textfield--multiline
.spectrum-Textfield-input {
block-size: var(--spectrum-textfield-height);
min-block-size: var(--spectrum-textfield-height);
}
}
.spectrum-Textfield-input {
/* box */
box-sizing: border-box;
border: var(--spectrum-textfield-border-size) solid;
border-radius: var(--spectrum-textfield-border-radius);
/* Apply padding by default to center text, giving consistency between input and textfield */
padding: var(--spectrum-textfield-padding-top)
var(--spectrum-textfield-padding-right) var(--spectrum-textfield-padding-bottom)
calc(var(--spectrum-textfield-padding-left) - 1px);
/* Use padding instead of text-indent because text-indent does not left align the text in Edge browser */
text-indent: 0;
inline-size: 100%;
block-size: var(--spectrum-textfield-height);
vertical-align: top; /* used to align them correctly in forms. */
/* Remove the margin for input in Firefox and Safari. */
margin: 0;
/* Show the overflow for input in Edge. */
overflow: visible;
/* Change the input font styles in all browsers */
font-family: var(--spectrum-textfield-text-font-family);
font-size: var(--spectrum-textfield-text-size);
line-height: var(--spectrum-textfield-text-line-height);
text-overflow: ellipsis;
transition: border-color var(--spectrum-global-animation-duration-100)
ease-in-out,
box-shadow var(--spectrum-global-animation-duration-100) ease-in-out;
outline: none;
-webkit-appearance: none;
/*
Removes the native spin buttons in Firefox; -moz-appearance: none results in spinners.
This has to come after -webkit-appearance or it gets overridden (#214)
Details: http://stackoverflow.com/questions/23372903/hide-spinner-in-input-number-firefox-29
Sets the opacity to 1 as normalize.css sets an opacity to placeholders
Details: https://github.com/csstools/normalize.css/blob/main/normalize.css#L297
*/
-moz-appearance: textfield;
&::placeholder {
font-weight: var(--spectrum-textfield-placeholder-text-font-weight);
font-style: var(--spectrum-textfield-placeholder-text-font-style);
transition: color var(--spectrum-global-animation-duration-100) ease-in-out;
opacity: 1;
}
/* added to work with Edge, note, it needs double ::
* not single : which is what autoprefixer will add
*/
&::-ms-input-placeholder {
font-weight: var(--spectrum-textfield-placeholder-text-font-weight);
font-style: var(--spectrum-textfield-placeholder-text-font-style);
transition: color var(--spectrum-global-animation-duration-100) ease-in-out;
opacity: 1;
}
&:lang(ja),
&:lang(zh),
&:lang(ko) {
&::placeholder {
font-style: normal;
}
&::-ms-input-placeholder {
/* added to work with Edge, same as above */
font-style: normal;
}
}
&:hover {
&::placeholder {
font-weight: var(--spectrum-textfield-placeholder-text-font-weight);
}
}
&:disabled {
/* Disable the resize functionality when disabled */
resize: none;
/* The opacity must be set to 1 */
opacity: 1;
&::placeholder {
font-weight: var(--spectrum-textfield-placeholder-text-font-weight);
}
}
/* Remove the native clear button in IE */
/* http://stackoverflow.com/questions/14007655/remove-ie10s-clear-field-x-button-on-certain-inputs */
&::-ms-clear {
inline-size: 0;
block-size: 0;
}
/* removes the native spin buttons */
/* http://stackoverflow.com/questions/23372903/hide-spinner-in-input-number-firefox-29 */
&::-webkit-inner-spin-button,
&::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* removes the red border that appears in Firefox */
&:-moz-ui-invalid {
box-shadow: none;
}
.spectrum-Textfield.is-valid & {
padding-inline-end: calc(
var(--spectrum-textfield-padding-right) +
var(--spectrum-icon-checkmark-medium-width) +
var(--spectrum-textfield-success-icon-margin-left)
);
}
.spectrum-Textfield.is-invalid & {
padding-inline-end: calc(
var(--spectrum-textfield-padding-right) +
var(--spectrum-icon-alert-medium-width) +
var(--spectrum-textfield-error-icon-margin-left)
);
}
.spectrum-Textfield--multiline & {
block-size: var(--spectrum-textarea-height-adjusted);
min-block-size: var(--spectrum-textarea-min-height);
padding: var(--spectrum-textarea-padding-top)
var(--spectrum-textarea-padding-right)
var(--spectrum-textarea-padding-bottom)
calc(var(--spectrum-textarea-padding-left) - 1px);
/* Remove the default vertical scrollbar for textarea in IE. */
overflow: auto;
}
.spectrum-Textfield--quiet & {
border-radius: var(--spectrum-textfield-quiet-border-radius);
border-block-start-width: 0;
border-block-end-width: var(--spectrum-textfield-quiet-border-size);
border-inline-width: 0;
/* removes the side padding to align the text properly */
padding-inline-start: var(--spectrum-textfield-quiet-padding-left);
padding-inline-end: var(--spectrum-textfield-quiet-padding-right);
/* Treat all quiet inputs and textareas the same */
resize: none;
overflow-y: hidden;
.is-invalid& {
padding-inline-end: calc(
var(--spectrum-icon-alert-medium-width) +
var(--spectrum-textfield-quiet-error-icon-margin-left)
);
}
.is-valid& {
padding-inline-end: calc(
var(--spectrum-icon-checkmark-medium-width) +
var(--spectrum-textfield-quiet-success-icon-margin-left)
);
}
}
}
.spectrum-Textfield-validationIcon {
position: absolute;
pointer-events: all;
.spectrum-Textfield--quiet & {
padding-inline-end: 0;
}
.spectrum-Textfield.is-invalid & {
inline-size: var(--spectrum-textfield-error-icon-width);
block-size: var(--spectrum-textfield-error-icon-height);
inset-block-end: calc(
calc(var(--spectrum-textfield-height) / 2) -
calc(var(--spectrum-textfield-error-icon-height) / 2)
);
inset-inline-end: var(--spectrum-textfield-error-icon-margin-left);
.spectrum-Textfield--quiet& {
inset-inline-end: 0;
}
}
.spectrum-Textfield.is-valid & {
inline-size: var(--spectrum-textfield-success-icon-width);
block-size: var(--spectrum-textfield-success-icon-height);
inset-block-end: calc(
calc(var(--spectrum-textfield-height) / 2) -
calc(var(--spectrum-textfield-success-icon-height) / 2)
);
inset-inline-end: var(--spectrum-textfield-success-icon-margin-left);
.spectrum-Textfield--quiet& {
inset-inline-end: 0;
}
}
}
/* styles the left icon for textfield, assumes usage of workflow icon sizing (18px by 18px) */
.spectrum-Textfield-icon {
display: block;
position: absolute;
block-size: var(--spectrum-alias-workflow-icon-size-m);
inline-size: var(--spectrum-alias-workflow-icon-size-m);
/* todo what token is this? */
inset-inline-start: var(--spectrum-textfield-error-icon-margin-left);
inset-block-start: calc(
var(--spectrum-textfield-height) / 2 -
var(--spectrum-alias-workflow-icon-size-m) / 2
);
.spectrum-Textfield--quiet & {
/* Since quiet button has no left padding, push the icon all the way to the left */
inset-inline-start: 0;
& ~ .spectrum-Textfield-input {
padding-inline-start: calc(
var(--spectrum-alias-workflow-icon-size-m) +
var(--spectrum-textfield-quiet-icon-gap)
);
}
}
/* styles the textfield properly if the left icon is provided */
& + .spectrum-Textfield-input {
/* Use padding instead of text-indent so long strings don't overlap the icon */
/* todo what token is this? */
padding-inline-start: calc(
var(--spectrum-textfield-error-icon-margin-left) +
var(--spectrum-alias-workflow-icon-size-m) +
var(--spectrum-textfield-icon-gap)
);
}
}
.spectrum-Textfield--multiline {
.spectrum-Textfield-icon {
& ~ .spectrum-Textfield-input {
block-size: var(--spectrum-textfield-height);
min-block-size: var(--spectrum-textfield-height);
}
}
}