Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
2896e15e
Unverified
Commit
2896e15e
authored
Feb 13, 2020
by
Kyle Keating
Committed by
GitHub
Feb 13, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1785 from hypothesis/excerpt-a11y
Fix a11y for Excerpt
parents
e8a82607
67e728b6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
13 deletions
+29
-13
excerpt.js
src/sidebar/components/excerpt.js
+6
-11
excerpt-test.js
src/sidebar/components/test/excerpt-test.js
+17
-2
excerpt.scss
src/styles/sidebar/components/excerpt.scss
+6
-0
No files found.
src/sidebar/components/excerpt.js
View file @
2896e15e
...
...
@@ -12,24 +12,20 @@ import { applyTheme } from '../util/theme';
* it is expanded or collapsed.
*/
function
InlineControls
({
isCollapsed
,
setCollapsed
,
linkStyle
=
{}
})
{
const
toggleTitle
=
isCollapsed
?
'Show the full excerpt'
:
'Show the first few lines only'
;
const
toggleLabel
=
isCollapsed
?
'More'
:
'Less'
;
return
(
<
div
className
=
"excerpt__inline-controls"
>
<
span
className
=
"excerpt__toggle-link"
>
{
/* FIXME-A11Y */
}
{
/* eslint-disable-next-line jsx-a11y/anchor-is-valid */
}
<
a
href
=
"#"
<
button
className
=
"excerpt__toggle-button"
onClick
=
{()
=>
setCollapsed
(
!
isCollapsed
)}
title
=
{
toggleTitle
}
aria
-
label
=
"Toggle to show the full excerpt or first few lines only"
aria
-
pressed
=
{(
!
isCollapsed
).
toString
()}
style
=
{
linkStyle
}
>
{
toggleLabel
}
<
/
a
>
<
/
button
>
<
/span
>
<
/div
>
);
...
...
@@ -113,9 +109,8 @@ function Excerpt({
<
div
className
=
"excerpt__content"
ref
=
{
contentElement
}
>
{
children
}
<
/div
>
{
/* FIXME-A11Y */
}
{
/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
}
<
div
role
=
"presentation"
onClick
=
{()
=>
setCollapsed
(
false
)}
className
=
{
classnames
({
excerpt__shadow
:
true
,
...
...
src/sidebar/components/test/excerpt-test.js
View file @
2896e15e
...
...
@@ -128,11 +128,26 @@ describe('Excerpt', () => {
it
(
'toggles the expanded state when clicked'
,
()
=>
{
const
wrapper
=
createExcerpt
({
inlineControls
:
true
},
TALL_DIV
);
const
control
=
wrapper
.
find
(
'.excerpt__inline-controls a
'
);
const
button
=
wrapper
.
find
(
'.excerpt__toggle-button
'
);
assert
.
equal
(
getExcerptHeight
(
wrapper
),
40
);
control
.
simulate
(
'click'
);
button
.
simulate
(
'click'
);
assert
.
equal
(
getExcerptHeight
(
wrapper
),
200
);
});
it
(
"sets button's default state to unpressed"
,
()
=>
{
const
wrapper
=
createExcerpt
({
inlineControls
:
true
},
TALL_DIV
);
const
button
=
wrapper
.
find
(
'.excerpt__toggle-button'
);
assert
.
equal
(
button
.
prop
(
'aria-pressed'
),
'false'
);
assert
.
equal
(
button
.
text
(),
'More'
);
});
it
(
"changes button's state to pressed when clicked"
,
()
=>
{
const
wrapper
=
createExcerpt
({
inlineControls
:
true
},
TALL_DIV
);
wrapper
.
find
(
'.excerpt__toggle-button'
).
simulate
(
'click'
);
const
button
=
wrapper
.
find
(
'.excerpt__toggle-button'
);
assert
.
equal
(
button
.
prop
(
'aria-pressed'
),
'true'
);
assert
.
equal
(
button
.
text
(),
'Less'
);
});
});
it
(
...
...
src/styles/sidebar/components/excerpt.scss
View file @
2896e15e
@use
"../../mixins/buttons"
;
@use
"../../variables"
as
var
;
// FIXME - Remove the `@at-root` here when SASS modules are used, as local
...
...
@@ -37,6 +38,11 @@
line-height
:
var
.
$normal-line-height
;
}
.excerpt__toggle-button
{
@include
buttons
.
reset-native-btn-styles
;
font-style
:
italic
;
}
.excerpt__toggle-link
>
a
{
color
:
var
.
$text-color
;
font-style
:
italic
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment