-
Notifications
You must be signed in to change notification settings - Fork 1
FEAT: Add templating support for collection, story, and moment fields #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/169_id-badge-moment
Are you sure you want to change the base?
Conversation
…eat/169_id-badge-ksn
also refactors id badge and awards moments BREAKING CHANGE: - award moment -> awards moment #169
There was a problem hiding this 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.
| // @ts-expect-error TS2345 - Need to fix type issue later. | ||
| items={shelf.items} |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
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.
| // @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 */} |
| {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 |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
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.
| // @ts-expect-error -- caption is passed through for the zigzag card layout |
| slidesPerView={slidesPerView} | ||
| slidesOffsetAfter={24} | ||
| slidesOffsetBefore={24} | ||
| slidesPerView="auto" |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
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.
| const slidesPerView = layoutOptions?.slides_per_view ?? 'auto'; | ||
| const slideGap = layoutOptions?.slide_gap; |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
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.
| iframeWindow.postMessage( | ||
| JSON.parse(JSON.stringify(moment.message)), | ||
| '*', |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
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.
| 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, |
| current = current[Number(field)]; | ||
| } else if ( | ||
| typeof current === 'object' | ||
| && current !== null |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
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.
emulatingkat
left a comment
There was a problem hiding this 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!
[Plural]Momentnaming conventions