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
Show 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
classnames
from
'classnames'
;
import
{
useCallback
,
useMemo
}
from
'preact/hooks'
;
import
{
useCallback
,
useMemo
}
from
'preact/hooks'
;
...
@@ -23,7 +28,7 @@ import ModerationBanner from './ModerationBanner';
...
@@ -23,7 +28,7 @@ import ModerationBanner from './ModerationBanner';
* @param {() => void} props.onToggleReplies
* @param {() => void} props.onToggleReplies
*/
*/
function
ThreadCollapseControl
({
threadIsCollapsed
,
onToggleReplies
})
{
function
ThreadCollapseControl
({
threadIsCollapsed
,
onToggleReplies
})
{
const
toggleIcon
=
threadIsCollapsed
?
'collapsed'
:
'expand-menu'
;
const
ToggleIcon
=
threadIsCollapsed
?
CaretRightIcon
:
MenuExpandIcon
;
const
toggleTitle
=
threadIsCollapsed
?
'Expand replies'
:
'Collapse replies'
;
const
toggleTitle
=
threadIsCollapsed
?
'Expand replies'
:
'Collapse replies'
;
return
(
return
(
<
div
<
div
...
@@ -45,20 +50,20 @@ function ThreadCollapseControl({ threadIsCollapsed, onToggleReplies }) {
...
@@ -45,20 +50,20 @@ function ThreadCollapseControl({ threadIsCollapsed, onToggleReplies }) {
'bg-white'
'bg-white'
)}
)}
>
>
<
IconButton
<
ButtonBase
classes
=
{
classnames
(
classes
=
{
classnames
(
// Pull the button up a little to align horizontally with the
// Pull the button up a little to align horizontally with the
// thread/annotation's header. Override large touch targets for
// thread/annotation's header. Override large touch targets for
// touch interfaces; we need to conserve space here
// 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
}
expanded
=
{
!
threadIsCollapsed
}
icon
=
{
toggleIcon
}
title
=
{
toggleTitle
}
title
=
{
toggleTitle
}
onClick
=
{
onToggleReplies
}
onClick
=
{
onToggleReplies
}
size
=
"medium"
>
variant
=
"light"
<
ToggleIcon
className
=
"w-em h-em"
/>
/
>
<
/ButtonBase
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
);
);
...
@@ -186,11 +191,12 @@ function Thread({ thread, threadsService }) {
...
@@ -186,11 +191,12 @@ function Thread({ thread, threadsService }) {
/
>
/
>
)}
)}
<
div
>
<
div
>
<
LabeledButton
<
Button
data
-
testid
=
"show-hidden-button"
onClick
=
{()
=>
threadsService
.
forceVisible
(
thread
)}
onClick
=
{()
=>
threadsService
.
forceVisible
(
thread
)}
>
>
Show
{
countHidden
(
thread
)}
more
in
conversation
Show
{
countHidden
(
thread
)}
more
in
conversation
<
/
Labeled
Button
>
<
/Button
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
)}
)}
...
...
src/sidebar/components/test/Thread-test.js
View file @
d11a78eb
...
@@ -115,7 +115,7 @@ describe('Thread', () => {
...
@@ -115,7 +115,7 @@ describe('Thread', () => {
// Retrieve the (caret) button for showing and hiding replies
// Retrieve the (caret) button for showing and hiding replies
const
getToggleButton
=
wrapper
=>
{
const
getToggleButton
=
wrapper
=>
{
return
wrapper
.
find
(
'
IconButton
'
);
return
wrapper
.
find
(
'
button[data-testid="toggle-button"]
'
);
};
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -209,9 +209,7 @@ describe('Thread', () => {
...
@@ -209,9 +209,7 @@ describe('Thread', () => {
collapsedThread
.
parent
=
'1'
;
collapsedThread
.
parent
=
'1'
;
const
wrapper
=
createComponent
({
thread
:
collapsedThread
});
const
wrapper
=
createComponent
({
thread
:
collapsedThread
});
assert
.
isTrue
(
assert
.
isTrue
(
wrapper
.
find
(
'button[title="Expand replies"]'
).
exists
());
wrapper
.
find
(
'IconButton[title="Expand replies"]'
).
exists
()
);
});
});
it
(
'does not render child threads'
,
()
=>
{
it
(
'does not render child threads'
,
()
=>
{
...
@@ -264,7 +262,10 @@ describe('Thread', () => {
...
@@ -264,7 +262,10 @@ describe('Thread', () => {
const
wrapper
=
createComponent
({
thread
});
const
wrapper
=
createComponent
({
thread
});
act
(()
=>
{
act
(()
=>
{
wrapper
.
find
(
'LabeledButton'
).
props
().
onClick
();
wrapper
.
find
(
'button[data-testid="show-hidden-button"]'
)
.
props
()
.
onClick
();
});
});
assert
.
calledOnce
(
fakeThreadsService
.
forceVisible
);
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