Skip to content

Commit

Permalink
feat: add border-width/border-color tokens for textbox hover/focus-vi…
Browse files Browse the repository at this point in the history
…sible/invalid
  • Loading branch information
Robbert committed Sep 18, 2024
1 parent d9a5161 commit c3c679e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-pigs-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@utrecht/textbox-css": minor
---

Add `hover`, `focus-visible` and `invalid` tokens for `border-width` and `border-color` for Textbox.
31 changes: 31 additions & 0 deletions components/textbox/src/_mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ $utrecht-support-prince-xml: false !default;
var(--utrecht-textbox-background-color, var(--utrecht-form-control-background-color))
)
);
box-shadow: inset 0 0 0
calc(var(--utrecht-textbox-invalid-border-width, 0px) - var(--utrecht-textbox-border-width, 0px))
var(--utrecht-textbox-invalid-border-color, var(--utrecht-textbox-border-color));
border-width: var(--_utrecht-textbox-border-width);
border-block-end-width: var(
--utrecht-textbox-invalid-border-bottom-width,
Expand Down Expand Up @@ -148,6 +151,19 @@ $utrecht-support-prince-xml: false !default;
cursor: var(--utrecht-action-disabled-cursor, not-allowed);
}

@mixin utrecht-textbox--hover {
border-color: var(
--utrecht-textbox-hover-border-color,
var(
--utrecht-form-control-hover-border-color,
var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color))
)
);
box-shadow: inset 0 0 0
calc(var(--utrecht-textbox-hover-border-width, 0px) - var(--utrecht-textbox-border-width, 0px))
var(--utrecht-textbox-hover-border-color, var(--utrecht-textbox-border-color));
}

@mixin utrecht-textbox--focus {
@include utrecht-focus;

Expand All @@ -173,6 +189,18 @@ $utrecht-support-prince-xml: false !default;

@mixin utrecht-textbox--focus-visible {
@include utrecht-focus-visible;

border-color: var(
--utrecht-textbox-focus-visible-border-color,
var(
--utrecht-form-control-focus-visible-border-color,
var(--utrecht-textbox-border-color, var(--utrecht-form-control-border-color))
)
);
box-shadow: inset 0 0 0
calc(var(--utrecht-textbox-focus-visible-border-width, 0px) - var(--utrecht-textbox-border-width, 0px))
var(--utrecht-textbox-focus-visible-border-color, var(--utrecht-textbox-border-color)),
var(--_utrecht-focus-ring-box-shadow);
}

@mixin utrecht-textbox--read-only {
Expand Down Expand Up @@ -240,6 +268,9 @@ $utrecht-support-prince-xml: false !default;
@mixin utrecht-textbox--html-input {
// The workaround for missing `:focus-visible` support makes the code quite complex,
// keep the ideal version around to restore it easily when browser support improves.
&:hover {
@include utrecht-textbox--hover;
}

@if $utrecht-focus-visible-fallback {
&:focus {
Expand Down

0 comments on commit c3c679e

Please sign in to comment.