Commit f0e9ef93 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Convert `Tutorial` to TS

parent 2d0fd21d
...@@ -4,25 +4,21 @@ import { ...@@ -4,25 +4,21 @@ import {
HighlightIcon, HighlightIcon,
ReplyIcon, ReplyIcon,
} from '@hypothesis/frontend-shared/lib/next'; } from '@hypothesis/frontend-shared/lib/next';
import type { IconComponent } from '@hypothesis/frontend-shared/lib/types';
import classnames from 'classnames'; import classnames from 'classnames';
import type { SidebarSettings } from '../../types/config';
import { isThirdPartyService } from '../helpers/is-third-party-service'; import { isThirdPartyService } from '../helpers/is-third-party-service';
import { withServices } from '../service-context'; import { withServices } from '../service-context';
/** type LabeledIconProps = {
* @typedef {import('@hypothesis/frontend-shared/lib/types').IconComponent} IconComponent /** Name of the "command" the instruction represents */
*/ commandName: string;
icon: IconComponent;
};
/** function LabeledIcon({ commandName, icon: Icon }: LabeledIconProps) {
* 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 }) {
return ( return (
<span className="whitespace-nowrap" data-testid="instruction"> <span className="whitespace-nowrap" data-testid="instruction">
<Icon <Icon
...@@ -37,20 +33,21 @@ function TutorialInstruction({ commandName, icon: Icon }) { ...@@ -37,20 +33,21 @@ function TutorialInstruction({ commandName, icon: Icon }) {
); );
} }
export type TutorialProps = {
// injected
settings: SidebarSettings;
};
/** /**
* Tutorial for using the sidebar app * 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); const canCreatePrivateGroups = !isThirdPartyService(settings);
return ( return (
<ol className="list-decimal pl-10 space-y-2"> <ol className="list-decimal pl-10 space-y-2">
<li> <li>
To create an annotation, select text and then select the{' '} To create an annotation, select text and then select the{' '}
<TutorialInstruction icon={AnnotateIcon} commandName="Annotate" />{' '} <LabeledIcon icon={AnnotateIcon} commandName="Annotate" /> button.
button.
</li> </li>
<li> <li>
To create a highlight ( To create a highlight (
...@@ -62,8 +59,7 @@ function Tutorial({ settings }) { ...@@ -62,8 +59,7 @@ function Tutorial({ settings }) {
visible only to you visible only to you
</Link> </Link>
), select text and then select the{' '} ), select text and then select the{' '}
<TutorialInstruction icon={HighlightIcon} commandName="Highlight" />{' '} <LabeledIcon icon={HighlightIcon} commandName="Highlight" /> button.
button.
</li> </li>
{canCreatePrivateGroups && ( {canCreatePrivateGroups && (
<li> <li>
...@@ -81,7 +77,7 @@ function Tutorial({ settings }) { ...@@ -81,7 +77,7 @@ function Tutorial({ settings }) {
)} )}
<li> <li>
To reply to an annotation, select the{' '} To reply to an annotation, select the{' '}
<TutorialInstruction icon={ReplyIcon} commandName="Reply" /> button. <LabeledIcon icon={ReplyIcon} commandName="Reply" /> button.
</li> </li>
</ol> </ol>
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment