diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 799ae3a..9804189 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: Install dependencies run: npm install - name: Run formatting - run: npm run format + run: npm run format:check lint: runs-on: ubuntu-latest diff --git a/package.json b/package.json index 1c5cd29..055036d 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "lint": "eslint .", "lint:fix": "eslint . --fix", "format": "prettier --write .", + "format:check": "prettier --check .", "test": "vitest --watch=false", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build", diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx index dff78be..d32f056 100644 --- a/src/components/Button/index.tsx +++ b/src/components/Button/index.tsx @@ -6,7 +6,7 @@ export interface ButtonProps extends React.ButtonHTMLAttributes = ({ content, role }) {expanded ? "Annotation" : "Show more"} - {expanded && ( -
- )} + {expanded &&
}
); }; diff --git a/src/icons/Export.tsx b/src/icons/Export.tsx index bb59eb6..a6fe2c7 100644 --- a/src/icons/Export.tsx +++ b/src/icons/Export.tsx @@ -15,4 +15,4 @@ export const Export: React.FC> = () => { > ); -}; \ No newline at end of file +}; diff --git a/src/plugin/Panel/ChatInput/index.tsx b/src/plugin/Panel/ChatInput/index.tsx index ffeae20..b533825 100644 --- a/src/plugin/Panel/ChatInput/index.tsx +++ b/src/plugin/Panel/ChatInput/index.tsx @@ -172,13 +172,16 @@ export const ChatInput: FC = () => { })}
- {PromptInputButtons && } + {PromptInputButtons && ( + + )} diff --git a/src/plugin/Panel/MediaDialog/index.tsx b/src/plugin/Panel/MediaDialog/index.tsx index a1eb49e..3cb6f5c 100644 --- a/src/plugin/Panel/MediaDialog/index.tsx +++ b/src/plugin/Panel/MediaDialog/index.tsx @@ -2,10 +2,10 @@ import { Button, Dialog, Heading, ImageSelect } from "@components"; import { usePlugin } from "@context"; import { serializeConfigPresentation3, Traverse } from "@iiif/parser"; import type { - Annotation as IIIFAnnotation, Canvas, ContentResource, EmbeddedResource, + Annotation as IIIFAnnotation, SpecificResource, } from "@iiif/presentation-3"; import { Annotation, Media, SelectedContent } from "@types"; @@ -13,14 +13,22 @@ import { getLabelByUserLanguage, updateIIIFImageRequestURI } from "@utils"; import { FC, useEffect, useRef, useState } from "react"; import style from "./style.module.css"; -function isEmbeddedResource( - body: unknown, -): body is EmbeddedResource { - return typeof body === "object" && body !== null && "type" in body && (body as EmbeddedResource).type === "TextualBody"; +function isEmbeddedResource(body: unknown): body is EmbeddedResource { + return ( + typeof body === "object" && + body !== null && + "type" in body && + (body as EmbeddedResource).type === "TextualBody" + ); } function isSpecificResource(body: unknown): body is SpecificResource { - return typeof body === "object" && body !== null && "type" in body && (body as SpecificResource).type === "SpecificResource"; + return ( + typeof body === "object" && + body !== null && + "type" in body && + (body as SpecificResource).type === "SpecificResource" + ); } function getTextualBodyValue(body: unknown): string | undefined { @@ -46,7 +54,11 @@ function getTextualBodyValue(body: unknown): string | undefined { return getTextualBodyValue(body.source); } - if (typeof body === "object" && "value" in body && typeof (body as { value: unknown }).value === "string") { + if ( + typeof body === "object" && + "value" in body && + typeof (body as { value: unknown }).value === "string" + ) { return (body as { value: string }).value; } @@ -69,7 +81,9 @@ function isAnnotationInSelectedContent( annotation: Annotation, selectedContent: SelectedContent[], ): boolean { - return selectedContent.some((item) => item.type === "annotation" && item.content.id === annotation.id); + return selectedContent.some( + (item) => item.type === "annotation" && item.content.id === annotation.id, + ); } function handleSelectedMedia( @@ -172,7 +186,9 @@ const CurrentView = () => { imgObjectFit="contain" src={fragmentMedia.src} initialState={ - isMediaInSelectedContent(fragmentMedia, state.selectedContent) ? "selected" : "unselected" + isMediaInSelectedContent(fragmentMedia, state.selectedContent) + ? "selected" + : "unselected" } onSelectionChange={(selected) => handleAddMedia(selected, fragmentMedia)} /> @@ -237,9 +253,11 @@ const Paintings: FC<{ canvas: Canvas }> = ({ canvas }) => { handleAddMedia(selected, m)} /> ))} @@ -295,9 +313,11 @@ const Placeholder: FC<{ placeholder: NonNullable }> handleAddMedia(selected, m)} /> ))} @@ -383,7 +403,9 @@ const Annotations: FC<{ canvas: Canvas }> = ({ canvas }) => { function handleAddAnnotation(selected: boolean, annotation: Annotation) { const resources: SelectedContent[] = selected ? [...state.selectedContent, { type: "annotation", content: annotation }] - : state.selectedContent.filter((item) => !(item.type === "annotation" && item.content.id === annotation.id)); + : state.selectedContent.filter( + (item) => !(item.type === "annotation" && item.content.id === annotation.id), + ); dispatch({ type: "setSelectedContent", selectedContent: resources }); } diff --git a/src/plugin/base_provider.tsx b/src/plugin/base_provider.tsx index 913e957..78d272f 100644 --- a/src/plugin/base_provider.tsx +++ b/src/plugin/base_provider.tsx @@ -136,7 +136,9 @@ export abstract class BaseProvider { /** * A component that providers can implement to add buttons to the Prompt Input area, extending functionality. */ - PromptInputButtons(_props: { disabled?: boolean }): JSX.Element & { props: { children: (typeof Button)[] } } { + PromptInputButtons(_props: { + disabled?: boolean; + }): JSX.Element & { props: { children: (typeof Button)[] } } { return <>; } diff --git a/src/plugin/context/plugin-context.test.tsx b/src/plugin/context/plugin-context.test.tsx index 1161709..dc6888e 100644 --- a/src/plugin/context/plugin-context.test.tsx +++ b/src/plugin/context/plugin-context.test.tsx @@ -162,7 +162,10 @@ describe("pluginReducer", () => { it("should handle setSelectedContent", () => { const selectedContent: SelectedContent[] = [ - { type: "media", content: { type: "image" as const, id: "media-1", src: "http://example.com/img.png" } }, + { + type: "media", + content: { type: "image" as const, id: "media-1", src: "http://example.com/img.png" }, + }, { type: "annotation", content: { id: "annotation-1", content: "

Test annotation

" } }, ]; const action: PluginContextActions = { type: "setSelectedContent", selectedContent }; diff --git a/src/providers/userTokenProvider/index.tsx b/src/providers/userTokenProvider/index.tsx index ef8b3da..97e01ca 100644 --- a/src/providers/userTokenProvider/index.tsx +++ b/src/providers/userTokenProvider/index.tsx @@ -429,6 +429,7 @@ export class UserTokenProvider extends BaseProvider { size="small" title="Tasks" type="button" + variant="ghost" onClick={openDialog} > diff --git a/stories/components/Button.stories.ts b/stories/components/Button.stories.ts index 5777f9b..141f3a0 100644 --- a/stories/components/Button.stories.ts +++ b/stories/components/Button.stories.ts @@ -34,6 +34,14 @@ export const Primary: Story = { }, }; +export const Accent: Story = { + name: "Variant / Accent", + args: { + variant: "accent", + children: "Click me", + }, +}; + export const Secondary: Story = { name: "Variant / Secondary", args: {