Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
feat: replace focus ring mixin and added new mixin where needed
Browse files Browse the repository at this point in the history
* Removed older focus ring mixin. Added mixin to match calcite-components. Replaced older mixin. Added new mixin where it was needed. (#945)

* use var for animation speed
  • Loading branch information
asangma committed Apr 28, 2020
1 parent d4c9c7a commit f4429d4
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/components/calcite-action/calcite-action.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
transition: color 125ms ease-in-out, fill 125ms ease-in-out, background-color 125ms ease-in-out;
text-align: unset;
position: relative;

@include focus-style-base();
&:hover,
&:focus {
background-color: var(--calcite-app-background-hover);
color: var(--calcite-app-foreground-hover);
fill: var(--calcite-app-foreground-hover);
}

@include focusRingInset();
&:focus {
@include focus-style-inset();
}

.icon-container {
min-width: var(--calcite-app-icon-size);
Expand Down
5 changes: 4 additions & 1 deletion src/components/calcite-block/calcite-block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
font-size: var(--calcite-app-font-size-0);
text-align: unset;
color: var(--calcite-app-foreground);
@include focusRingInset();
@include focus-style-base();
&:focus {
@include focus-style-inset();
}
}

.header,
Expand Down
10 changes: 5 additions & 5 deletions src/components/calcite-handle/calcite-handle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
color: var(--calcite-app-border);
line-height: 0;
cursor: move;
@include focusRingInset();
&:focus {
outline-offset: var(--calcite-app-outline-inset);
color: var(--calcite-app-foreground);
}
&:hover {
background-color: var(--calcite-app-background-hover);
color: var(--calcite-app-foreground);
}
@include focus-style-base();
&:focus {
color: var(--calcite-app-foreground);
@include focus-style-inset();
}
&--activated {
background-color: var(--calcite-app-background-active);
color: var(--calcite-app-foreground-active);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
padding: var(--calcite-app-cap-spacing-half) var(--calcite-app-side-spacing-quarter);
align-items: center;
cursor: pointer;

@include focusRingInset();
@include focus-style-base();
&:focus {
@include focus-style-inset();
}
}

.text-container {
Expand Down
8 changes: 8 additions & 0 deletions src/components/calcite-tip-manager/calcite-tip-manager.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ $tip-max-width: 540px;
position: relative;
padding: var(--calcite-app-cap-spacing-half) var(--calcite-app-side-spacing-half) 0;
min-height: 150px;
@include focus-style-base();
&:focus {
@include focus-style-outset();
}
}

.tip-container {
Expand All @@ -57,6 +61,10 @@ $tip-max-width: 540px;
display: flex;
justify-content: center;
align-items: flex-start;
@include focus-style-base();
&:focus {
@include focus-style-inset();
}
}

::slotted(calcite-tip-group) {
Expand Down
5 changes: 5 additions & 0 deletions src/components/calcite-tip/calcite-tip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ $tip-image-max-width: 100% !default;

::slotted(a) {
color: var(--calcite-app-foreground-link);
@include focus-style-base();
}

::slotted(a:focus) {
@include focus-style-outset();
}

.image-frame {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ calcite-pick-list-item {
color: var(--calcite-app-border);
line-height: 0;
cursor: move;
@include focusRingInset();
@include focus-style-base();
&:hover,
&:focus {
background-color: var(--calcite-app-background-hover);
outline-offset: var(--calcite-app-outline-inset);
color: var(--calcite-app-foreground);
}
&:focus {
@include focus-style-inset();
}
&--activated {
background-color: var(--calcite-app-background-active);
color: var(--calcite-app-foreground-active);
Expand Down
6 changes: 3 additions & 3 deletions src/demos/tip/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h2>With thumbnail</h2>
<p>
This is another paragraph in a subsequent "info" slot.
</p>
<a href="http://www.esri.com">This is the "link" slot.</a>
<a href="http://www.esri.com">This is a link.</a>
</calcite-tip>
</div>
<hr />
Expand All @@ -52,7 +52,7 @@ <h2>Without heading</h2>
<p>
This is another paragraph in a subsequent "info" slot.
</p>
<a href="http://www.esri.com">This is the "link" slot.</a>
<a href="http://www.esri.com">This is a link.</a>
</calcite-tip>
</div>
<h2>Without header</h2>
Expand All @@ -65,7 +65,7 @@ <h2>Without header</h2>
<p>
This is another paragraph in a subsequent "info" slot.
</p>
<a href="http://www.esri.com">This is the "link" slot.</a>
<a href="http://www.esri.com">This is a link.</a>
</calcite-tip>
</div>
<hr />
Expand Down
21 changes: 17 additions & 4 deletions src/scss/mixins/_utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,21 @@
-webkit-box-orient: vertical;
}

@mixin focusRingInset() {
&:focus {
outline-offset: var(--calcite-app-outline-inset);
}
// place on the element that receives focus style, not in focus
@mixin focus-style-base() {
outline-offset: 0;
outline-color: transparent;
transition: outline-offset var(--calcite-app-animation-time-fast) ease-in-out,
outline-color var(--calcite-app-animation-time-fast) ease-in-out;
}

// place on the element that receives focus style, while in focus
@mixin focus-style-outset() {
outline: 2px solid var(--calcite-ui-blue-1);
outline-offset: 2px;
}

@mixin focus-style-inset() {
outline: 2px solid var(--calcite-ui-blue-1);
outline-offset: -2px;
}

0 comments on commit f4429d4

Please sign in to comment.