-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cdk-input): move input autofill and autosize utils into cdk (#9831)
* move autofill to cdk * move textarea autosize into cdk * fix bazel build * rename input to text-field * set resize back to none for autosize in input css * fix tsconfig
- Loading branch information
Showing
37 changed files
with
563 additions
and
403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package(default_visibility=["//visibility:public"]) | ||
load("@angular//:index.bzl", "ng_module") | ||
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library", "sass_binary") | ||
|
||
ng_module( | ||
name = "text-field", | ||
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]), | ||
module_name = "@angular/cdk/text-field", | ||
deps = [ | ||
"@rxjs", | ||
"//src/cdk/platform", | ||
], | ||
tsconfig = ":tsconfig-build.json", | ||
) | ||
|
||
sass_library( | ||
name = "text_field_scss_lib", | ||
srcs = glob(["**/_*.scss"]), | ||
) | ||
|
||
sass_binary( | ||
name = "text_field_prebuilt_scss", | ||
src = "text-field-prebuilt.scss", | ||
deps = [":text_field_scss_lib"], | ||
) | ||
|
||
# TODO(jelbourn): remove this when sass_binary supports specifying an output filename and dir. | ||
# Copy the output of the sass_binary such that the filename and path match what we expect. | ||
genrule( | ||
name = "text_field_prebuilt_css", | ||
srcs = [":text_field_prebuilt_scss"], | ||
outs = ["text-field-prebuilt.css"], | ||
cmd = "cat $(locations :text_field_prebuilt_scss) > $@", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Core styles that enable monitoring autofill state of text fields. | ||
@mixin cdk-text-field { | ||
// Keyframes that apply no styles, but allow us to monitor when an text field becomes autofilled | ||
// by watching for the animation events that are fired when they start. | ||
// Based on: https://medium.com/@brunn/detecting-autofilled-fields-in-javascript-aed598d25da7 | ||
@keyframes cdk-text-field-autofill-start {} | ||
@keyframes cdk-text-field-autofill-end {} | ||
|
||
.cdk-text-field-autofill-monitored:-webkit-autofill { | ||
animation-name: cdk-text-field-autofill-start; | ||
} | ||
|
||
.cdk-text-field-autofill-monitored:not(:-webkit-autofill) { | ||
animation-name: cdk-text-field-autofill-end; | ||
} | ||
|
||
// Remove the resize handle on autosizing textareas, because whatever height | ||
// the user resized to will be overwritten once they start typing again. | ||
textarea.cdk-textarea-autosize { | ||
resize: none; | ||
} | ||
} | ||
|
||
// Used to generate UIDs for keyframes used to change the text field autofill styles. | ||
$cdk-text-field-autofill-color-frame-count: 0; | ||
|
||
// Mixin used to apply custom background and foreground colors to an autofilled text field. | ||
// Based on: https://stackoverflow.com/questions/2781549/ | ||
// removing-input-background-colour-for-chrome-autocomplete#answer-37432260 | ||
@mixin cdk-text-field-autofill-color($background, $foreground:'') { | ||
@keyframes cdk-text-field-autofill-color-#{$cdk-text-field-autofill-color-frame-count} { | ||
to { | ||
background: $background; | ||
@if $foreground != '' { color: $foreground; } | ||
} | ||
} | ||
|
||
&:-webkit-autofill { | ||
animation-name: cdk-text-field-autofill-color-#{$cdk-text-field-autofill-color-frame-count}; | ||
animation-fill-mode: both; | ||
} | ||
|
||
&.cdk-text-field-autofill-monitored:-webkit-autofill { | ||
animation-name: cdk-text-field-autofill-start, | ||
cdk-text-field-autofill-color-#{$cdk-text-field-autofill-color-frame-count}; | ||
} | ||
|
||
$cdk-text-field-autofill-color-frame-count: | ||
$cdk-text-field-autofill-color-frame-count + 1 !global; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.