Skip to content

Commit

Permalink
Create CSS variables to support the base-focus focus-visible properti…
Browse files Browse the repository at this point in the history
…es, to be injected into components not naturally on the DOM (Shopify#3503)
  • Loading branch information
joeyTedeschi committed Jun 5, 2024
1 parent 6e3f3c6 commit 8616c24
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
--alpha-button-border: 1;
--alpha-link: 0.85;
--alpha-badge-border: 0.1;
--focused-base-outline: 0.2rem solid rgba(var(--color-foreground), 0.5);
--focused-base-outline-offset: 0.3rem;
--focused-base-box-shadow: 0 0 0 0.3rem rgb(var(--color-background)), 0 0 0.5rem 0.4rem rgba(var(--color-foreground), 0.3);
}

.product-card-wrapper .card,
Expand Down Expand Up @@ -689,16 +692,16 @@ summary::-webkit-details-marker {
}

*:focus-visible {
outline: 0.2rem solid rgba(var(--color-foreground), 0.5);
outline-offset: 0.3rem;
box-shadow: 0 0 0 0.3rem rgb(var(--color-background)), 0 0 0.5rem 0.4rem rgba(var(--color-foreground), 0.3);
outline: var(--focused-base-outline);
outline-offset: var(--focused-base-outline-offset);
box-shadow: var(--focused-base-box-shadow);
}

/* Fallback - for browsers that don't support :focus-visible, a fallback is set for :focus */
.focused {
outline: 0.2rem solid rgba(var(--color-foreground), 0.5);
outline-offset: 0.3rem;
box-shadow: 0 0 0 0.3rem rgb(var(--color-background)), 0 0 0.5rem 0.4rem rgba(var(--color-foreground), 0.3);
outline: var(--focused-base-outline);
outline-offset: var(--focused-base-outline-offset);
box-shadow: var(--focused-base-box-shadow);
}

/*
Expand Down

0 comments on commit 8616c24

Please sign in to comment.