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
f0e9ef93
Commit
f0e9ef93
authored
Nov 15, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Nov 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert `Tutorial` to TS
parent
2d0fd21d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
22 deletions
+18
-22
Tutorial.tsx
src/sidebar/components/Tutorial.tsx
+18
-22
No files found.
src/sidebar/components/Tutorial.
js
→
src/sidebar/components/Tutorial.
tsx
View file @
f0e9ef93
...
...
@@ -4,25 +4,21 @@ import {
HighlightIcon
,
ReplyIcon
,
}
from
'@hypothesis/frontend-shared/lib/next'
;
import
type
{
IconComponent
}
from
'@hypothesis/frontend-shared/lib/types'
;
import
classnames
from
'classnames'
;
import
type
{
SidebarSettings
}
from
'../../types/config'
;
import
{
isThirdPartyService
}
from
'../helpers/is-third-party-service'
;
import
{
withServices
}
from
'../service-context'
;
/**
* @typedef {import('@hypothesis/frontend-shared/lib/types').IconComponent} IconComponent
*/
type
LabeledIconProps
=
{
/** Name of the "command" the instruction represents */
commandName
:
string
;
icon
:
IconComponent
;
};
/**
* Subcomponent: an "instruction" within the tutorial step that includes an
* icon and a "command" associated with that icon. Encapsulating these together
* allows for styling to keep them from having a line break between them.
*
* @param {object} props
* @param {string} props.commandName - Name of the "command" the instruction represents
* @param {IconComponent} props.icon icon to display
*/
function
TutorialInstruction
({
commandName
,
icon
:
Icon
})
{
function
LabeledIcon
({
commandName
,
icon
:
Icon
}:
LabeledIconProps
)
{
return
(
<
span
className=
"whitespace-nowrap"
data
-
testid=
"instruction"
>
<
Icon
...
...
@@ -37,20 +33,21 @@ function TutorialInstruction({ commandName, icon: Icon }) {
);
}
export
type
TutorialProps
=
{
// injected
settings
:
SidebarSettings
;
};
/**
* Tutorial for using the sidebar app
*
* @param {object} props
* @param {import('../../types/config').SidebarSettings} props.settings
*/
function
Tutorial
({
settings
})
{
function
Tutorial
({
settings
}
:
TutorialProps
)
{
const
canCreatePrivateGroups
=
!
isThirdPartyService
(
settings
);
return
(
<
ol
className=
"list-decimal pl-10 space-y-2"
>
<
li
>
To create an annotation, select text and then select the
{
' '
}
<
TutorialInstruction
icon
=
{
AnnotateIcon
}
commandName
=
"Annotate"
/>
{
' '
}
button
.
<
LabeledIcon
icon=
{
AnnotateIcon
}
commandName=
"Annotate"
/>
button.
</
li
>
<
li
>
To create a highlight (
...
...
@@ -62,8 +59,7 @@ function Tutorial({ settings }) {
visible only to you
</
Link
>
), select text and then select the
{
' '
}
<
TutorialInstruction
icon
=
{
HighlightIcon
}
commandName
=
"Highlight"
/>
{
' '
}
button
.
<
LabeledIcon
icon=
{
HighlightIcon
}
commandName=
"Highlight"
/>
button.
</
li
>
{
canCreatePrivateGroups
&&
(
<
li
>
...
...
@@ -81,7 +77,7 @@ function Tutorial({ settings }) {
)
}
<
li
>
To reply to an annotation, select the
{
' '
}
<
TutorialInstructi
on
icon
=
{
ReplyIcon
}
commandName
=
"Reply"
/>
button
.
<
LabeledIc
on
icon=
{
ReplyIcon
}
commandName=
"Reply"
/>
button.
</
li
>
</
ol
>
);
...
...
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