0.0.20 • Published 1 year ago

@samvera/nectar-iiif v0.0.20

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Nectar IIIF

React.js UI component library of IIIF Presentation API 3.0 property fluent primitives.

Demo | Code


Documentation


Install the component from your command line using npm install,

npm install @samvera/nectar-iiif

OR if you prefer Yarn, use yarn add.

yarn add @samvera/nectar-iiif

Add the Nectar component(s) to your jsx or tsx code.

import { Label, Summary } from "@samvera/nectar-iiif";
/**
 * Some logic may be required to retrieve the IIIF Manifest.
 */
const manifest = {...};

return (
  <>
    <Label label={manifest.label} as="h1" />
    <Summary summary={manifest.summary} as="p" />
  </>
);

Primitives

Primitives aim to cover most of the noted Descriptive and Linking properties noted in the IIIF Presentation API 3.0 specification. Some of these, specifically Provider may have a more complex component structure.

Completed (initial release) and proposed primitives include:

Descriptive Properties

  • Label
  • Metadata
  • Summary
  • RequiredStatement
  • Rights
  • Provider
  • Thumbnail

Linking Properties

  • Homepage
  • Logo
  • Rendering
  • SeeAlso
  • PartOf

Label

Reference

PropTypeDefaultRequired
asspan, h1, h2, h3, h4, h5, h6, p, label, dt, ddspan--
labellabel--Yes

Usage

import { Label } from "@samvera/nectar-iiif";
return <Label label={manifest.label} as="h1" lang="en" />;

Homepage

import { Homepage } from "@samvera/nectar-iiif";

Wrap resource label with homepage id.

return <Homepage homepage={manifest.homepage} />;

Wrap React children with homepage id.

return (
  <Homepage homepage={manifest.homepage}>
    <figure>...</figure>
  </Homepage>
);

Metadata

Metadata is rendered am HTML dl with corresponding dt and dd elements for they respective label and value pairs. By default value entries are rendered as a string, with , interspersed to seperate multiple entries. A consuming application using can optionally update the value output for each entry.

Reference

PropTypeDefaultRequired
asdldl
metadatametadata--Yes
customValueContentNectarCustomValueContent[]----
customValueDelimiterstring?,--
import { Metadata } from "@samvera/nectar-iiif";
return <Metadata metadata={manifest.metadata} />;

Custom Value Content

If a consumign application required rendering specific metadata item values in a custom pattern, the customValueContent prop can be set for the <Metadata> component. The pattern requires matchingLabel as following https://iiif.io/api/presentation/3.0/#label and Content asa ReactElement carrying props. The element set for Content must map props.value to the appropriate code in the custom pattern.

In the example below, the value of Pantaloon with a matching label of { none: ["Subject"] } would be rendered as <dd><a href="https://example.org/?subject=Pantaloon">Pantaloon</a><dd>, while the value entry of comic masks would render simply as <dd>comic masks</dd>.

const metadata = [
  {
    label: { none: ["Genre"] },
    value: { none: ["comic masks"] },
  },
  {
    label: { none: ["Subject"] },
    value: { none: ["Pantaloon"] },
  },
];

const CustomValueSubject = (props) => (
  <a href={encodeURI(`https://example.org/?subject=${props.value}`)}>
    {props.value}
  </a>
);

const customValueContent = [
  {
    matchingLabel: { none: ["Subject"] },
    Content: <CustomValueSubject />,
  },
];

return <Metadata metadata={metadata} customValueContent={customValueContent} />;

RequiredStatement

import { RequiredStatement } from "@samvera/nectar-iiif";
return <RequiredStatement requiredStatement={manifest.requiredStatement} />;

Reference

PropTypeDefaultRequired
requiredStatementrequiredStatement--Yes
customValueDelimiterstring?,--

PartOf

Reference

PropTypeDefaultRequired
asol, ulul--
partOfpartOf--Yes
import { PartOf } from "@samvera/nectar-iiif";
return <PartOf partOf={manifest.partOf} as="li" />;

SeeAlso

Reference

PropTypeDefaultRequired
asol, ulul--
seeAlsoseeAlso--Yes
import { SeeAlso } from "@samvera/nectar-iiif";
return <SeeAlso seeAlso={manifest.seeAlso} as="li" />;

Summary

Reference

PropTypeDefaultRequired
asspan, h1, h2, h3, h4, h5, h6, pspan--
summarysummary--Yes
customValueDelimiterstring?,--

Usage

import { Summary } from "@samvera/nectar-iiif";
return <Summary summary={manifest.summary} as="p" />;

Thumbnail

Thumbnails are rendered to a relative HTML <img> or <video> element dependendent on the type of the resource in the thumbnail entry. Currently, only type Image and Video are supported.

Reference

PropTypeDefaultRequired
thumbnailthumbnail--Yes
altAsLabellabel----
import { Thumbnail } from "@samvera/nectar-iiif";
return <Thumbnail thumbnail={manifest.thumbnail} altAsLabel={manifest.label} />;

Attributes

All primitives accept common HTMLElement attributes.

PropTypeDefault
classNamestring, undefinedundefined
styleCSSProperties, undefinedundefined
langstring, undefinedundefined
titlestring, undefinedundefined
data-*string, undefinedundefined
aria-*AriaAttributes, undefinedundefined

Language (Internationalization)

The value of lang will couple with InternationalString props to output the denoted label, value, summary entries. If lang is undefined, entries will default to the first entry in the array index.

0.0.20

1 year ago

0.0.19

1 year ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.14

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.9

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.6-alpha.7

2 years ago

0.0.6-alpha.6

2 years ago

0.0.6-alpha.5

2 years ago

0.0.6-alpha.4

2 years ago

0.0.6-alpha.3

2 years ago

0.0.6-alpha.2

2 years ago

0.0.6-alpha.1

2 years ago

0.0.6-alpha.0

2 years ago

0.0.5

2 years ago

0.0.5-alpha.5

2 years ago

0.0.5-alpha.3

2 years ago

0.0.5-alpha.2

2 years ago

0.0.5-alpha.1

2 years ago

0.0.5-alpha.0

2 years ago

0.0.4

2 years ago

0.0.4-alpha.2

2 years ago

0.0.4-alpha.1

2 years ago

0.0.4-alpha.0

2 years ago

0.0.3-alpha.0

2 years ago

0.0.2-alpha.0

2 years ago

0.0.1

2 years ago