Skip to content

Conversation

@kennethsn
Copy link
Owner

  • Also renames award & id badge moments to awards and id badges moments to be consistent with other [Plural]Moment naming conventions
  • Adds some cleanup to awards+id badge interfaces and integrations

@kennethsn kennethsn added this to the Version 1 milestone Nov 1, 2025
@kennethsn kennethsn self-assigned this Nov 1, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements several significant features and refactoring improvements to the Stories API:

  • Adds template string interpolation with dot-notation support for accessing nested object properties
  • Renames and restructures "Award" and "IdBadge" moment types to their plural forms ("Awards", "IdBadges") for consistency
  • Introduces a new "Mirador" moment type for displaying IIIF content
  • Enhances the CardsBrowser component with multiple layout options (minimal, standard, tool)
  • Updates various type definitions from enums to union types and adjusts property naming conventions

Reviewed Changes

Copilot reviewed 65 out of 66 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/utils/string.ts Updated formatString to support nested object access via dot-notation and iterative replacement
src/utils/object.ts Added getValue helper function for accessing nested properties with array index support
src/constants.ts Updated FORMATTER_TEMPLATE_REGEX to support dot-notation in template strings
src/types.ts Renamed Award/IdBadge moment types to plural forms, updated property naming to snake_case, converted StatType enum to union type
src/state/storyStore.ts Added typographyFormatter getter for template string interpolation
src/state/momentStore.ts Added muiTheme property, typographyFormatter getter, and refactored getField to use getValue utility
src/state/moments/*.ts Created new MiradorMomentStore, renamed AwardMomentStore to AwardsMomentStore, IdBadgeMomentStore to IdBadgesMomentStore
src/state/collectionStore.ts Added layout property, typographyFormatter getter, and story key management
src/components/UI/EditableTypography/* Added formatter support for template string interpolation in typography
src/components/UI/CardsBrowser/* Enhanced with multiple layout options (minimal, standard, tool)
src/components/UI/Cards/* Updated Swiper configurations for carousel and row layouts, removed redundant imports
src/components/UI/IdBadge/* Updated to accept idBadge as nested prop instead of spread props
src/components/Moments/AwardsMoment/* Renamed from AwardMoment to AwardsMoment with corresponding file and variable updates
src/components/Moments/IdBadgesMoment/* Renamed from IdBadgeMoment to IdBadgesMoment with updated structure
src/components/Moments/MiradorMoment/* New component for displaying Mirador IIIF viewer in an iframe
src/components/Moments/IFrameMoment/* Added postMessage support for sending configuration to iframes
package.json Updated version to 1.0.0-dev-51 and react-resizable-panels dependency
Comments suppressed due to low confidence (1)

src/components/UI/Cards/CardsRowLayout.tsx:1

  • The 'loop' prop was removed from the Swiper configuration without corresponding removal from the module imports. Additionally, if looping was previously enabled by default, removing it changes the carousel behavior. Consider making this configurable through layoutOptions.loop like in CardsCarouselLayout.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to +18
// @ts-expect-error TS2345 - Need to fix type issue later.
items={shelf.items}
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A @ts-expect-error directive is used to suppress a type error rather than fixing the underlying type mismatch. This creates technical debt and masks potential runtime issues. Consider updating the type definitions in Bookshelf.types.ts to match the LibraryShelf item structure, or add proper type transformation.

Suggested change
// @ts-expect-error TS2345 - Need to fix type issue later.
items={shelf.items}
items={shelf.items as any} {/* TODO: Replace 'any' with the correct type transformation */}

Copilot uses AI. Check for mistakes.
{badges.map((idBadge, index) => (
<IdBadge
key={idBadge.content?.id || idBadge.logo?.url || `badge-${index}`}
// @ts-expect-error -- caption is passed through for the zigzag card layout
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using @ts-expect-error to bypass type checking for the caption prop indicates that the IdBadge component types don't match the actual usage pattern. The IdBadgeProps type should be updated to include the optional caption property if it's a valid prop used by the zigzag layout.

Suggested change
// @ts-expect-error -- caption is passed through for the zigzag card layout

Copilot uses AI. Check for mistakes.
slidesPerView={slidesPerView}
slidesOffsetAfter={24}
slidesOffsetBefore={24}
slidesPerView="auto"
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slidesPerView property is now hardcoded to 'auto', completely ignoring the layoutOptions?.slides_per_view configuration that was removed from line 24. This breaks the API contract where users could configure the number of slides per view through layoutOptions. Consider restoring this configuration option.

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +31
const slidesPerView = layoutOptions?.slides_per_view ?? 'auto';
const slideGap = layoutOptions?.slide_gap;
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default for slidesPerView changed from 3 to 'auto', and slideGap no longer has a default value (was 16). These breaking changes to default behavior should be documented or reconsidered to maintain backward compatibility.

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +19
iframeWindow.postMessage(
JSON.parse(JSON.stringify(moment.message)),
'*',
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using '*' as the targetOrigin in postMessage allows any origin to receive the message, creating a potential security vulnerability. Consider restricting the targetOrigin to specific domains or extracting it from the iframe URL to prevent unintended message interception.

Suggested change
iframeWindow.postMessage(
JSON.parse(JSON.stringify(moment.message)),
'*',
// Extract the origin from the iframe URL to use as targetOrigin
let targetOrigin = '*';
try {
targetOrigin = new URL(moment.url).origin;
} catch (e) {
// If parsing fails, default to '*' (not recommended, but prevents crash)
}
iframeWindow.postMessage(
JSON.parse(JSON.stringify(moment.message)),
targetOrigin,

Copilot uses AI. Check for mistakes.
current = current[Number(field)];
} else if (
typeof current === 'object'
&& current !== null
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable 'current' is of type date, object or regular expression, but it is compared to an expression of type null.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@emulatingkat emulatingkat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants