Unverified Commit 552407de authored by Lyza Gardner's avatar Lyza Gardner Committed by GitHub

Merge pull request #2119 from hypothesis/improve-document-outline

Improve document outline and stucture
parents f09715c1 c2349d68
...@@ -39,7 +39,7 @@ export default function AnnotationBody({ ...@@ -39,7 +39,7 @@ export default function AnnotationBody({
const showTagList = !isEditing && tags.length > 0; const showTagList = !isEditing && tags.length > 0;
return ( return (
<section className="annotation-body"> <div className="annotation-body">
{showExcerpt && ( {showExcerpt && (
<Excerpt <Excerpt
collapse={isCollapsed} collapse={isCollapsed}
...@@ -78,7 +78,7 @@ export default function AnnotationBody({ ...@@ -78,7 +78,7 @@ export default function AnnotationBody({
)} )}
{showTagList && <TagList annotation={annotation} tags={tags} />} {showTagList && <TagList annotation={annotation} tags={tags} />}
{isEditing && <TagEditor onEditTags={onEditTags} tagList={tags} />} {isEditing && <TagEditor onEditTags={onEditTags} tagList={tags} />}
</section> </div>
); );
} }
......
...@@ -23,7 +23,7 @@ function AnnotationQuote({ annotation, isFocused, settings = {} }) { ...@@ -23,7 +23,7 @@ function AnnotationQuote({ annotation, isFocused, settings = {} }) {
const documentLanguage = ''; const documentLanguage = '';
return ( return (
<section <div
className={classnames('annotation-quote', { className={classnames('annotation-quote', {
'is-orphan': isOrphan(annotation), 'is-orphan': isOrphan(annotation),
'is-focused': isFocused, 'is-focused': isFocused,
...@@ -43,7 +43,7 @@ function AnnotationQuote({ annotation, isFocused, settings = {} }) { ...@@ -43,7 +43,7 @@ function AnnotationQuote({ annotation, isFocused, settings = {} }) {
{quote(annotation)} {quote(annotation)}
</blockquote> </blockquote>
</Excerpt> </Excerpt>
</section> </div>
); );
} }
......
...@@ -39,7 +39,7 @@ function AnnotationUser({ annotation, features, serviceUrl, settings }) { ...@@ -39,7 +39,7 @@ function AnnotationUser({ annotation, features, serviceUrl, settings }) {
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
> >
<span className="annotation-user__user-name">{displayName}</span> <h3 className="annotation-user__user-name">{displayName}</h3>
</a> </a>
</div> </div>
); );
...@@ -47,7 +47,7 @@ function AnnotationUser({ annotation, features, serviceUrl, settings }) { ...@@ -47,7 +47,7 @@ function AnnotationUser({ annotation, features, serviceUrl, settings }) {
return ( return (
<div className="annotation-user"> <div className="annotation-user">
<span className="annotation-user__user-name">{displayName}</span> <h3 className="annotation-user__user-name">{displayName}</h3>
</div> </div>
); );
} }
......
...@@ -127,6 +127,7 @@ function SidebarContent({ ...@@ -127,6 +127,7 @@ function SidebarContent({
return ( return (
<div> <div>
<h2 className="u-screen-reader-only">Annotations</h2>
{isFocusedMode && <FocusedModeHeader />} {isFocusedMode && <FocusedModeHeader />}
<LoginPromptPanel onLogin={onLogin} onSignUp={onSignUp} /> <LoginPromptPanel onLogin={onLogin} onSignUp={onSignUp} />
{hasDirectLinkedAnnotationError && ( {hasDirectLinkedAnnotationError && (
......
...@@ -55,7 +55,7 @@ export default function SidebarPanel({ ...@@ -55,7 +55,7 @@ export default function SidebarPanel({
<SvgIcon name={icon} title={title} /> <SvgIcon name={icon} title={title} />
</div> </div>
)} )}
<div className="sidebar-panel__title u-stretch">{title}</div> <h2 className="sidebar-panel__title u-stretch">{title}</h2>
<div> <div>
<Button <Button
icon="cancel" icon="cancel"
......
...@@ -214,13 +214,13 @@ describe('ThreadList', () => { ...@@ -214,13 +214,13 @@ describe('ThreadList', () => {
* Get the blank spacer `<div>` that reserves space for non-rendered threads * Get the blank spacer `<div>` that reserves space for non-rendered threads
* above the viewport. * above the viewport.
*/ */
const getUpperSpacer = wrapper => wrapper.find('div').first(); const getUpperSpacer = wrapper => wrapper.find('div > div').first();
/** /**
* Get the blank spacer `<div>` that reserves space for non-rendered threads * Get the blank spacer `<div>` that reserves space for non-rendered threads
* below the viewport. * below the viewport.
*/ */
const getLowerSpacer = wrapper => wrapper.find('div').last(); const getLowerSpacer = wrapper => wrapper.find('div > div').last();
it('renders dimensional elements above and below visible threads', () => { it('renders dimensional elements above and below visible threads', () => {
const wrapper = createComponent(); const wrapper = createComponent();
......
...@@ -174,7 +174,7 @@ function ThreadList({ thread, $rootScope }) { ...@@ -174,7 +174,7 @@ function ThreadList({ thread, $rootScope }) {
}, [visibleThreads]); }, [visibleThreads]);
return ( return (
<section> <div>
<div style={{ height: offscreenUpperHeight }} /> <div style={{ height: offscreenUpperHeight }} />
{visibleThreads.map(child => ( {visibleThreads.map(child => (
<div className="thread-list__card" id={child.id} key={child.id}> <div className="thread-list__card" id={child.id} key={child.id}>
...@@ -182,7 +182,7 @@ function ThreadList({ thread, $rootScope }) { ...@@ -182,7 +182,7 @@ function ThreadList({ thread, $rootScope }) {
</div> </div>
))} ))}
<div style={{ height: offscreenLowerHeight }} /> <div style={{ height: offscreenLowerHeight }} />
</section> </div>
); );
} }
......
@use '../variables' as var; @use '../variables' as var;
@use "../mixins/a11y";
// 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
@mixin screen-reader-only {
// Take the content out of the normal layout flow.
position: absolute;
// 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 {
...@@ -47,14 +31,14 @@ ...@@ -47,14 +31,14 @@
// 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 screen-reader-only; @include a11y.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 assisitve technologies from the content before/after it. // as separate words by assisitve technologies from the content before/after it.
content: ' annotation start '; content: ' annotation start ';
} }
&::after { &::after {
@include screen-reader-only; @include a11y.screen-reader-only;
content: ' annotation end '; content: ' annotation end ';
} }
......
// 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
@mixin screen-reader-only {
// Take the content out of the normal layout flow.
position: absolute;
// 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;
}
...@@ -94,6 +94,22 @@ blockquote { ...@@ -94,6 +94,22 @@ blockquote {
margin: 0; margin: 0;
} }
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
font-weight: normal;
font-style: normal;
vertical-align: baseline;
}
// Custom elements // Custom elements
markdown { markdown {
display: block; display: block;
......
@use "./mixins/a11y";
// Utility classes for layout // Utility classes for layout
.u-stretch { .u-stretch {
flex-grow: 1; flex-grow: 1;
...@@ -11,3 +13,7 @@ ...@@ -11,3 +13,7 @@
.u-strong { .u-strong {
font-weight: bold; font-weight: bold;
} }
.u-screen-reader-only {
@include a11y.screen-reader-only;
}
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