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
d23de12f
Commit
d23de12f
authored
May 09, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
May 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract MenuArrow component for reuse
parent
fd80c4ff
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
37 deletions
+66
-37
AnnotationShareControl.js
src/sidebar/components/Annotation/AnnotationShareControl.js
+5
-19
AutocompleteList.js
src/sidebar/components/AutocompleteList.js
+4
-18
MenuArrow.js
src/sidebar/components/MenuArrow.js
+27
-0
MenuArrow-test.js
src/sidebar/components/test/MenuArrow-test.js
+30
-0
No files found.
src/sidebar/components/Annotation/AnnotationShareControl.js
View file @
d23de12f
import
{
Card
,
Icon
,
IconButton
,
TextInput
,
TextInputWithButton
,
...
...
@@ -15,6 +14,7 @@ import { isPrivate } from '../../helpers/permissions';
import
{
withServices
}
from
'../../service-context'
;
import
{
isIOS
}
from
'../../../shared/user-agent'
;
import
MenuArrow
from
'../MenuArrow'
;
import
ShareLinks
from
'../ShareLinks'
;
/**
...
...
@@ -39,23 +39,6 @@ function selectionOverflowsInputElement() {
return
isIOS
();
}
/**
*
* @param {object} props
* @param {string} [props.classes] - Optional additional CSS classes
*/
function
MenuArrowDown
({
classes
})
{
return
(
<
Icon
name
=
"pointer"
classes
=
{
classnames
(
'absolute inline z-2 text-grey-3 fill-white rotate-180'
,
classes
)}
/
>
);
}
/**
* "Popup"-style component for sharing a single annotation.
*
...
...
@@ -203,7 +186,10 @@ function AnnotationShareControl({
)}
<
/div
>
{
showShareLinks
&&
<
ShareLinks
shareURI
=
{
shareUri
}
/>
}
<
MenuArrowDown
classes
=
"bottom-[-12px] right-1 touch:right-[9px]"
/>
<
MenuArrow
direction
=
"down"
classes
=
"bottom-[-12px] right-1 touch:right-[9px]"
/>
<
/Card
>
)}
<
/div
>
...
...
src/sidebar/components/AutocompleteList.js
View file @
d23de12f
import
{
Card
,
Icon
}
from
'@hypothesis/frontend-shared'
;
import
{
Card
}
from
'@hypothesis/frontend-shared'
;
import
classnames
from
'classnames'
;
import
{
useMemo
}
from
'preact/hooks'
;
import
MenuArrow
from
'./MenuArrow'
;
/**
* @template T
* @param {T} item
*/
const
defaultListFormatter
=
item
=>
item
;
/**
* @param {object} props
* @param {string} [props.classes] - Optional additional CSS classes
*/
function
MenuArrowUp
({
classes
})
{
return
(
<
Icon
name
=
"pointer"
classes
=
{
classnames
(
'absolute inline z-2 text-grey-3 fill-white'
,
classes
)}
/
>
);
}
/**
* @template T
* @typedef AutocompleteListProps
...
...
@@ -111,7 +97,7 @@ export default function AutocompleteList({
<
ul
tabIndex
=
{
-
1
}
aria
-
label
=
"Suggestions"
role
=
"listbox"
{...
props
}
>
{
items
}
<
/ul
>
<
MenuArrow
Up
classes
=
"top-[-10px] left-[3px]"
/>
<
MenuArrow
direction
=
"up"
classes
=
"top-[-10px] left-[3px]"
/>
<
/Card
>
<
/div
>
);
...
...
src/sidebar/components/MenuArrow.js
0 → 100644
View file @
d23de12f
import
{
Icon
}
from
'@hypothesis/frontend-shared'
;
import
classnames
from
'classnames'
;
/**
* @typedef MenuArrowProps
* @prop {string} [classes]
* @prop {'up'|'down'} [direction]
*/
/**
* Render a white-filled "pointer" arrow for use in menus and menu-like
* elements
*
* @param {MenuArrowProps} props
*/
export
default
function
MenuArrow
({
classes
,
direction
=
'up'
})
{
return
(
<
Icon
name
=
"pointer"
classes
=
{
classnames
(
'absolute inline z-2 text-grey-3 fill-white'
,
{
'rotate-180'
:
direction
===
'down'
},
classes
)}
/
>
);
}
src/sidebar/components/test/MenuArrow-test.js
0 → 100644
View file @
d23de12f
import
{
mount
}
from
'enzyme'
;
import
{
mockImportedComponents
}
from
'../../../test-util/mock-imported-components'
;
import
MenuArrow
,
{
$imports
}
from
'../MenuArrow'
;
describe
(
'MenuArrow'
,
()
=>
{
const
createComponent
=
(
props
=
{})
=>
mount
(
<
MenuArrow
{...
props
}
/>
)
;
beforeEach
(()
=>
{
$imports
.
$mock
(
mockImportedComponents
());
});
afterEach
(()
=>
{
$imports
.
$restore
();
});
it
(
'should render an arrow pointing up by default'
,
()
=>
{
const
wrapper
=
createComponent
();
const
arrowClasses
=
wrapper
.
find
(
'Icon'
).
props
().
classes
;
assert
.
notInclude
(
arrowClasses
,
'rotate-180'
);
});
it
(
'should render an arrow pointing down if direction is `down`'
,
()
=>
{
const
wrapper
=
createComponent
({
direction
:
'down'
});
const
arrowClasses
=
wrapper
.
find
(
'Icon'
).
props
().
classes
;
assert
.
include
(
arrowClasses
,
'rotate-180'
);
});
});
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