From 2be09fa262cb45e849730f2325147603a49ebd6e Mon Sep 17 00:00:00 2001 From: emyarod Date: Mon, 11 Feb 2019 14:26:43 -0600 Subject: [PATCH] fix(text-input): position experimental password visibility toggle (#1735) * fix(text-input): style experimental password toggle * fix(text-input): add prefix to password visibility toggle SVGs * refactor(text-input): avoid data attribute selector --- src/components/text-input/_text-input.scss | 42 ++++++++++++++++++++++ src/components/text-input/text-input.hbs | 14 ++++---- src/components/text-input/text-input.js | 4 +-- tests/spec/text-input_spec.js | 4 +-- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/components/text-input/_text-input.scss b/src/components/text-input/_text-input.scss index 88b3963d3974..d0494f098d5d 100644 --- a/src/components/text-input/_text-input.scss +++ b/src/components/text-input/_text-input.scss @@ -143,6 +143,36 @@ &:active { @include focus-outline('outline'); } + + &-wrapper svg[hidden] { + display: none; + } + + &[type='text'] + .#{$prefix}--text-input--password__visibility, + &[type='password'] + .#{$prefix}--text-input--password__visibility { + top: rem(-28px); + right: rem(12px); + display: flex; + justify-content: center; + align-self: flex-end; + align-items: center; + height: rem(16px); + width: rem(16px); + padding: 0; + margin-bottom: -1rem; + border: 0; + background: none; + cursor: pointer; + outline: inherit; + + svg { + fill: $brand-01; + + &:hover { + fill: $hover-primary; + } + } + } } .#{$prefix}--text-input::-webkit-input-placeholder { @@ -161,6 +191,18 @@ background-position: right 8px bottom 50%; } + .#{$prefix}--text-input:disabled + .#{$prefix}--text-input--password__visibility svg { + opacity: 0.5; + cursor: not-allowed; + } + + .#{$prefix}--text-input:disabled + .#{$prefix}--text-input--password__visibility, + .#{$prefix}--text-input[data-invalid] + .#{$prefix}--text-input--password__visibility, + .#{$prefix}--text-input:invalid + .#{$prefix}--text-input--password__visibility, + .#{$prefix}--text-input[data-loading] + .#{$prefix}--text-input--password__visibility { + right: rem(32px); + } + //----------------------------- // Disabled //----------------------------- diff --git a/src/components/text-input/text-input.hbs b/src/components/text-input/text-input.hbs index b0b694782d21..e5e48b609bf1 100644 --- a/src/components/text-input/text-input.hbs +++ b/src/components/text-input/text-input.hbs @@ -14,13 +14,13 @@ placeholder="Placeholder text" data-toggle-password-visibility>