Commit 1eb65bfa authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Remove external dependencies from `highlights.scss`

parent 30f18b3b
@use '../variables' as var; $color-highlight: rgba(255, 255, 60, 0.4);
@use '../mixins/a11y'; $color-highlight-second: rgba(206, 206, 60, 0.4);
$color-highlight-focused: rgba(156, 230, 255, 0.5);
// Hide content from sighted users but make it visible to screen readers.
//
// Resources:
// - https://webaim.org/techniques/css/invisiblecontent/ (see "CSS clip")
// - https://cloudfour.com/thinks/see-no-evil-hidden-content-and-accessibility/#showing-additional-content-for-screen-readers
// - https://tailwindcss.com/docs/screen-readers#screen-reader-only-elements Tailwind's `sr-only` class
@mixin screen-reader-only {
// Take the content out of the normal layout flow.
position: absolute;
width: 1px;
height: 1px;
white-space: nowrap;
// Visually hide the content and prevent it from interfering with mouse/touch
// text selection by clipping it to an empty box. Compared to moving content with
// `top`/`left` this is less likely to cause the browser to scroll to a
// different part of the page when the hidden text has screen-reader focus.
clip: rect(0 0 0 0);
overflow: hidden;
}
// SVG highlights when the "Show Highlights" toggle is turned off. // SVG highlights when the "Show Highlights" toggle is turned off.
.hypothesis-svg-highlight { .hypothesis-svg-highlight {
...@@ -10,19 +32,19 @@ ...@@ -10,19 +32,19 @@
// of the annotated document when highlights are enabled/disabled. // of the annotated document when highlights are enabled/disabled.
.hypothesis-highlights-always-on { .hypothesis-highlights-always-on {
.hypothesis-svg-highlight { .hypothesis-svg-highlight {
fill: var.$color-highlight; fill: $color-highlight;
&.is-opaque { &.is-opaque {
fill: yellow; fill: yellow;
} }
&.is-focused { &.is-focused {
fill: var.$color-highlight-focused; fill: $color-highlight-focused;
} }
} }
.hypothesis-highlight { .hypothesis-highlight {
background-color: var.$color-highlight; background-color: $color-highlight;
// For PDFs, we still create highlight elements to wrap the text but the // For PDFs, we still create highlight elements to wrap the text but the
// highlight effect is created by another element. // highlight effect is created by another element.
...@@ -35,20 +57,20 @@ ...@@ -35,20 +57,20 @@
// Make highlights visible to screen readers. // Make highlights visible to screen readers.
// See also - https://developer.paciellogroup.com/blog/2017/12/short-note-on-making-your-mark-more-accessible/. // See also - https://developer.paciellogroup.com/blog/2017/12/short-note-on-making-your-mark-more-accessible/.
&::before { &::before {
@include a11y.screen-reader-only; @include screen-reader-only;
// nb. The leading/trailing spaces are intended to ensure the text is treated // nb. The leading/trailing spaces are intended to ensure the text is treated
// as separate words by assistive technologies from the content before/after it. // as separate words by assistive technologies from the content before/after it.
content: ' annotation start '; content: ' annotation start ';
} }
&::after { &::after {
@include a11y.screen-reader-only; @include screen-reader-only;
content: ' annotation end '; content: ' annotation end ';
} }
// Give a highlight inside a larger highlight a different color to stand out. // Give a highlight inside a larger highlight a different color to stand out.
& .hypothesis-highlight { & .hypothesis-highlight {
background-color: var.$color-highlight-second; background-color: $color-highlight-second;
&.is-transparent { &.is-transparent {
background-color: transparent; background-color: transparent;
} }
...@@ -69,7 +91,7 @@ ...@@ -69,7 +91,7 @@
// When an annotation card is hovered in the sidebar, the corresponding // When an annotation card is hovered in the sidebar, the corresponding
// highlights are shown with a "focused" color. // highlights are shown with a "focused" color.
&.hypothesis-highlight-focused { &.hypothesis-highlight-focused {
background-color: var.$color-highlight-focused !important; background-color: $color-highlight-focused !important;
.hypothesis-highlight { .hypothesis-highlight {
background-color: transparent !important; background-color: transparent !important;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment