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
d11a78eb
Commit
d11a78eb
authored
Oct 13, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jan 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update shared components in `Thread`
parent
83bbd271
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
15 deletions
+22
-15
Thread.js
src/sidebar/components/Thread.js
+16
-10
Thread-test.js
src/sidebar/components/test/Thread-test.js
+6
-5
No files found.
src/sidebar/components/Thread.js
View file @
d11a78eb
import
{
IconButton
,
LabeledButton
}
from
'@hypothesis/frontend-shared'
;
import
{
Button
,
ButtonBase
,
CaretRightIcon
,
MenuExpandIcon
,
}
from
'@hypothesis/frontend-shared/lib/next'
;
import
classnames
from
'classnames'
;
import
{
useCallback
,
useMemo
}
from
'preact/hooks'
;
...
...
@@ -23,7 +28,7 @@ import ModerationBanner from './ModerationBanner';
* @param {() => void} props.onToggleReplies
*/
function
ThreadCollapseControl
({
threadIsCollapsed
,
onToggleReplies
})
{
const
toggleIcon
=
threadIsCollapsed
?
'collapsed'
:
'expand-menu'
;
const
ToggleIcon
=
threadIsCollapsed
?
CaretRightIcon
:
MenuExpandIcon
;
const
toggleTitle
=
threadIsCollapsed
?
'Expand replies'
:
'Collapse replies'
;
return
(
<
div
...
...
@@ -45,20 +50,20 @@ function ThreadCollapseControl({ threadIsCollapsed, onToggleReplies }) {
'bg-white'
)}
>
<
IconButton
<
ButtonBase
classes
=
{
classnames
(
// Pull the button up a little to align horizontally with the
// thread/annotation's header. Override large touch targets for
// touch interfaces; we need to conserve space here
'-mt-1 touch:min-w-[auto] touch:min-h-[auto]'
'-mt-1 touch:min-w-[auto] touch:min-h-[auto]
p-[6.5px] text-grey-5 hover:text-grey-7
'
)}
data
-
testid
=
"toggle-button"
expanded
=
{
!
threadIsCollapsed
}
icon
=
{
toggleIcon
}
title
=
{
toggleTitle
}
onClick
=
{
onToggleReplies
}
size
=
"medium"
variant
=
"light"
/
>
>
<
ToggleIcon
className
=
"w-em h-em"
/>
<
/ButtonBase
>
<
/div
>
<
/div
>
);
...
...
@@ -186,11 +191,12 @@ function Thread({ thread, threadsService }) {
/
>
)}
<
div
>
<
LabeledButton
<
Button
data
-
testid
=
"show-hidden-button"
onClick
=
{()
=>
threadsService
.
forceVisible
(
thread
)}
>
Show
{
countHidden
(
thread
)}
more
in
conversation
<
/
Labeled
Button
>
<
/Button
>
<
/div
>
<
/div
>
)}
...
...
src/sidebar/components/test/Thread-test.js
View file @
d11a78eb
...
...
@@ -115,7 +115,7 @@ describe('Thread', () => {
// Retrieve the (caret) button for showing and hiding replies
const
getToggleButton
=
wrapper
=>
{
return
wrapper
.
find
(
'
IconButton
'
);
return
wrapper
.
find
(
'
button[data-testid="toggle-button"]
'
);
};
beforeEach
(()
=>
{
...
...
@@ -209,9 +209,7 @@ describe('Thread', () => {
collapsedThread
.
parent
=
'1'
;
const
wrapper
=
createComponent
({
thread
:
collapsedThread
});
assert
.
isTrue
(
wrapper
.
find
(
'IconButton[title="Expand replies"]'
).
exists
()
);
assert
.
isTrue
(
wrapper
.
find
(
'button[title="Expand replies"]'
).
exists
());
});
it
(
'does not render child threads'
,
()
=>
{
...
...
@@ -264,7 +262,10 @@ describe('Thread', () => {
const
wrapper
=
createComponent
({
thread
});
act
(()
=>
{
wrapper
.
find
(
'LabeledButton'
).
props
().
onClick
();
wrapper
.
find
(
'button[data-testid="show-hidden-button"]'
)
.
props
()
.
onClick
();
});
assert
.
calledOnce
(
fakeThreadsService
.
forceVisible
);
...
...
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