Commit 35b000bf authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Consolidate some styling in `Excerpt`

parent 84cbc9db
@use "../../mixins/buttons"; @use "../../mixins/buttons";
@use "../../variables" as var; @use "../../variables" as var;
// FIXME - Remove the `@at-root` here when SASS modules are used, as local // the distance by which the shadow indicating a collapsed
// variables will no longer be exposed to other modules. // annotation expands beyond the left/right edges of the card.
@at-root { // This value is chosen such that the shadow expands to the full width of
$expand-duration: 0.15s; // the card
$shadow-h-offset: -12px;
$expand-duration: 0.15s;
.excerpt { .excerpt {
transition: max-height $expand-duration ease-in; transition: max-height $expand-duration ease-in;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
} }
.excerpt__content { .excerpt__content {
// Create a new block-formatting context. This prevents any margins on // Create a new block-formatting context. This prevents any margins on
// elements inside the excerpt from "leaking out" due to margin-collapsing, // elements inside the excerpt from "leaking out" due to margin-collapsing,
// which would push this container element away from the top of the excerpt. // which would push this container element away from the top of the excerpt.
...@@ -21,65 +23,57 @@ ...@@ -21,65 +23,57 @@
// and https://github.com/hypothesis/client/issues/1518. // and https://github.com/hypothesis/client/issues/1518.
display: inline-block; display: inline-block;
width: 100%; width: 100%;
} }
// inline controls for expanding and collapsing // inline controls for expanding and collapsing
// the <excerpt> // the excerpt
// ------------- .excerpt__inline-controls {
.excerpt__inline-controls {
display: block; display: block;
position: absolute; position: absolute;
right: 0; right: 0;
bottom: 0; bottom: 0;
} }
.excerpt__toggle-link { .excerpt__toggle-link {
padding-left: 15px; padding-left: var.$layout-space;
background-image: linear-gradient(to right, transparent 0px, white 12px); // See https://stackoverflow.com/a/56548711/9788954 regarding
} // rgba(255, 255, 255, 0) used here instead of `transparent` (for Safari)
background-image: linear-gradient(
to right,
rgba(255, 255, 255, 0) 0px,
var.$color-background var.$layout-space
);
}
.excerpt__toggle-button { // TODO the tap target here is quite small
.excerpt__toggle-button {
@include buttons.reset-native-btn-styles; @include buttons.reset-native-btn-styles;
background: transparent;
font-style: italic; font-style: italic;
} }
.excerpt__toggle-link > a {
color: var.$color-text;
font-style: italic;
font-weight: normal;
}
// a shadow displayed at the bottom of an <excerpt>s with inline controls
// disabled, which provides a hint that the excerpt is collapsed
// -------------
// the distance by which the shadow indicating a collapsed
// annotation expands beyond the left/right edges of the card.
// This value is chosen such that the shadow expands to the full width of
// the card
$shadow-h-offset: -12px;
.excerpt__shadow { // a shadow displayed at the bottom of an <excerpt>s with inline controls
// disabled, which provides a hint that the excerpt is collapsed
.excerpt__shadow {
position: absolute; position: absolute;
left: $shadow-h-offset; left: $shadow-h-offset;
right: $shadow-h-offset; right: $shadow-h-offset;
bottom: 0; bottom: 0;
height: 40px; height: var.$touch-target-size;
background-image: linear-gradient( background-image: linear-gradient(
to bottom, to bottom,
transparent 50%, rgba(255, 255, 255, 0) 50%,
rgba(0, 0, 0, 0.08) 95%, rgba(0, 0, 0, 0.08) 95%,
rgba(0, 0, 0, 0.13) 100% rgba(0, 0, 0, 0.13) 100%
); );
transition: opacity $expand-duration linear; transition: opacity $expand-duration linear;
} }
.excerpt__shadow--transparent { .excerpt__shadow--transparent {
background-image: none; background-image: none;
} }
.excerpt__shadow.is-hidden { .excerpt__shadow.is-hidden {
opacity: 0; opacity: 0;
pointer-events: none; pointer-events: none;
}
} }
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