Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui-library): add hover state to the icon and password icon in pas… #295

Merged
merged 8 commits into from
Aug 18, 2023
10 changes: 9 additions & 1 deletion packages/ui-library/src/components/text-input/index.css.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from 'lit';
import { css } from "lit";

export const styleCustom = css`
.blr-input {
Expand All @@ -9,4 +9,12 @@ export const styleCustom = css`
.blr-text-input:disabled {
pointer-events: none;
}

.blr-input-icon:hover {
cursor: pointer;
}

.blr-input-icon:disabled {
cursor: none;
}
`;
8 changes: 4 additions & 4 deletions packages/ui-library/src/components/text-input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,24 @@ export class BlrTextInput extends LitElement {
hasError="${this.hasError}"
/>

${this.showInputIcon && !wasInitialPasswordField
${this.showInputIcon && !wasInitialPasswordField && !this.readonly
? html`${BlrIconRenderFunction({
icon: this.hasError ? 'blrErrorFilledSm' : calculateIconName(this.inputIcon, this.size),
name: this.hasError ? 'blrErrorFilledSm' : calculateIconName(this.inputIcon, this.size),
size: this.size,
classMap: iconClasses,
hideAria: true,
disablePointerEvents: true,
disablePointerEvents: this.disabled || this.readonly,
})}`
: nothing}
${wasInitialPasswordField
${wasInitialPasswordField && !this.readonly
? html`${BlrIconRenderFunction({
icon: this.hasError ? 'blrErrorFilledSm' : getPasswordIcon(),
name: this.hasError ? 'blrErrorFilledSm' : getPasswordIcon(),
size: this.size,
classMap: iconClasses,
hideAria: true,
disablePointerEvents: false,
disablePointerEvents: this.disabled || this.readonly,
onClick: () => this.togglePassword(),
})}`
: nothing}
Expand Down
36 changes: 30 additions & 6 deletions packages/ui-library/src/foundation/semantic-tokens/form.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ import { renderThemedCssStrings } from "../_tokens-generated/index.pseudo.genera

export const { tokenizedLight: formLight, tokenizedDark: formDark } = renderThemedCssStrings(
(componentTokens, semanticTokens) => {
const { UserInput, SurfaceFill, SM, MD, LG, Input, InputBorderRadius, Placeholder, Caption, Label, LabelAppendix } =
semanticTokens.Forms;
const {
UserInput,
SurfaceFill,
SM,
MD,
LG,
Input,
InputBorderRadius,
Placeholder,
Caption,
Label,
LabelAppendix,
InputIcon,
} = semanticTokens.Forms;
const { Select, TextArea } = componentTokens.Forms;

return css`
Expand All @@ -27,7 +39,7 @@ export const { tokenizedLight: formLight, tokenizedDark: formDark } = renderThem
&:hover {
border-width: ${Input.Default.Hover.width};
border-style: ${Input.Default.Hover.style};
border-color: ${Input.Default.Rest.color};
border-color: ${Input.Default.Hover.color};
color: ${UserInput.Default.Hover};
background-color: ${SurfaceFill.Default.Hover};

Expand Down Expand Up @@ -68,6 +80,7 @@ export const { tokenizedLight: formLight, tokenizedDark: formDark } = renderThem
outline: ${Input.Default.Disabled.width} ${Input.Default.Disabled.style} ${Input.Default.Disabled.color};
color: ${UserInput.Default.Disabled};
background-color: ${SurfaceFill.Default.Disabled};
cursor: not-allowed;

&::placeholder {
color: ${Placeholder.Default.Disabled};
Expand Down Expand Up @@ -179,7 +192,7 @@ export const { tokenizedLight: formLight, tokenizedDark: formDark } = renderThem
}

&.sm {
padding-bottom: ${SM.LabelSlot.Padding};
padding: ${SM.LabelSlot.Padding};
margin: ${SM.InputSlot.Margin};

.blr-input-icon {
Expand All @@ -188,7 +201,7 @@ export const { tokenizedLight: formLight, tokenizedDark: formDark } = renderThem
}

&.md {
padding-bottom: ${MD.LabelSlot.Padding};
padding: ${MD.LabelSlot.Padding};
margin: ${MD.InputSlot.Margin};

.blr-input-icon {
Expand All @@ -197,13 +210,24 @@ export const { tokenizedLight: formLight, tokenizedDark: formDark } = renderThem
}

&.lg {
padding-bottom: ${LG.LabelSlot.Padding};
padding: ${LG.LabelSlot.Padding};
margin: ${LG.InputSlot.Margin};

.blr-input-icon {
right: ${Select.LG.IconPaddingRight};
}
}

&:hover {
& input:not(:disabled) + .blr-input-icon {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is a little messy, but we need one more condition to check that no error is present. Otherwise the hover state will be applied to when there is an error
I think this will resolve it:
& input:not(:disabled, .error) + .blr-input-icon {

color: ${InputIcon.Hover};
}

& .error-input:not(:disabled) + .blr-input-icon {
color: ${Input.Error.Rest.color};
cursor: default;
}
}
}

.hint-wrapper {
Expand Down