Socket
Socket
Sign inDemoInstall

@samvera/nectar-iiif

Package Overview
Dependencies
Maintainers
4
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@samvera/nectar-iiif

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


Version published
Maintainers
4
Created
Source

Nectar IIIF

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

Demo | Code


Documentation


Installation

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

Basic Usage

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
as span, 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
as ol, ulul--
partOfpartOf--Yes
import { PartOf } from "@samvera/nectar-iiif";
return <PartOf partOf={manifest.partOf} as="li" />;

SeeAlso

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

Summary

Reference
PropTypeDefaultRequired
as span, 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.

image
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.

Keywords

FAQs

Package last updated on 06 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc