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

Convert `AnnotationBody` to TS

parent 5ce4ac3b
...@@ -6,6 +6,9 @@ import { ...@@ -6,6 +6,9 @@ import {
import classnames from 'classnames'; import classnames from 'classnames';
import { useMemo, useState } from 'preact/hooks'; import { useMemo, useState } from 'preact/hooks';
import type { Annotation } from '../../../types/api';
import type { SidebarSettings } from '../../../types/config';
import { useSidebarStore } from '../../store'; import { useSidebarStore } from '../../store';
import { isThirdPartyUser } from '../../helpers/account-id'; import { isThirdPartyUser } from '../../helpers/account-id';
import { isHidden } from '../../helpers/annotation-metadata'; import { isHidden } from '../../helpers/annotation-metadata';
...@@ -17,20 +20,20 @@ import MarkdownView from '../MarkdownView'; ...@@ -17,20 +20,20 @@ import MarkdownView from '../MarkdownView';
import TagList from '../TagList'; import TagList from '../TagList';
import TagListItem from '../TagListItem'; import TagListItem from '../TagListItem';
/** type ToggleExcerptButtonProps = {
* @typedef {import("../../../types/api").Annotation} Annotation classes?: string;
* @typedef {import("../../../types/config").SidebarSettings} SidebarSettings setCollapsed: (collapse: boolean) => void;
*/ collapsed: boolean;
};
/** /**
* Button to expand or collapse the annotation excerpt (content) * Button to expand or collapse the annotation excerpt (content)
*
* @param {object} props
* @param {string} [props.classes]
* @param {(collapse:boolean) => void} props.setCollapsed
* @param {boolean} props.collapsed
*/ */
function ToggleExcerptButton({ classes, setCollapsed, collapsed }) { function ToggleExcerptButton({
classes,
setCollapsed,
collapsed,
}: ToggleExcerptButtonProps) {
const toggleText = collapsed ? 'More' : 'Less'; const toggleText = collapsed ? 'More' : 'Less';
return ( return (
<Button <Button
...@@ -51,18 +54,17 @@ function ToggleExcerptButton({ classes, setCollapsed, collapsed }) { ...@@ -51,18 +54,17 @@ function ToggleExcerptButton({ classes, setCollapsed, collapsed }) {
); );
} }
/** export type AnnotationBodyProps = {
* @typedef AnnotationBodyProps annotation: Annotation;
* @prop {Annotation} annotation - The annotation in question
* @prop {SidebarSettings} settings // injected
*/ settings: SidebarSettings;
};
/** /**
* Display the rendered content of an annotation. * Display the rendered content of an annotation.
*
* @param {AnnotationBodyProps} props
*/ */
function AnnotationBody({ annotation, settings }) { function AnnotationBody({ annotation, settings }: AnnotationBodyProps) {
// Should the text content of `Excerpt` be rendered in a collapsed state, // Should the text content of `Excerpt` be rendered in a collapsed state,
// assuming it is collapsible (exceeds allotted collapsed space)? // assuming it is collapsible (exceeds allotted collapsed space)?
const [collapsed, setCollapsed] = useState(true); const [collapsed, setCollapsed] = useState(true);
...@@ -88,10 +90,7 @@ function AnnotationBody({ annotation, settings }) { ...@@ -88,10 +90,7 @@ function AnnotationBody({ annotation, settings }) {
[annotation, defaultAuthority] [annotation, defaultAuthority]
); );
/** const createTagSearchURL = (tag: string) => {
* @param {string} tag
*/
const createTagSearchURL = tag => {
return store.getLink('search.tag', { tag }); return store.getLink('search.tag', { tag });
}; };
......
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