refactor: dedupe embed core across platform wrappers - #22
Merged
Conversation
- Share CarouselSharedProps in types.ts; components extend it instead of redeclaring the ten forwarding props per file - Extract pure per-platform embed URL builders into utils/embeds with unit tests (keyless thumbnails + Instagram tracker stripping preserved) - Add CarouselCaption/CarouselActiveCaption to replace the triplicated caption template and CSS - Introduce useYouTubeMedia to own the YouTube facade/player-api lifecycle - Drop dead useInstagramEmbed/useTikTokEmbed auto-imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
De-duplicates the shared presentation and embed lifecycle across
YouTubeCarousel,TikTokCarousel, andInstagramCarouselper the repo instructions (compound shared props, stateless reusable helpers/composables).Changes
CarouselSharedPropsintypes.ts— the wrappers andBaseCarouselextend it instead of redeclaring the ten presentation props in each file.utils/embeds.ts— pure, unit-tested URL builders (YouTube embed/watch/thumb, TikTok embembed, Instagram captioned embed with tracker stripping).CarouselCaption/CarouselActiveCaption— replaces the triplicated caption block + scoped CSS + fade transition in all three wrappers.useYouTubeMediacomposable — owns facade activation, thumbnail fallbacks, iframe handshake, player-api registration, and control dispatch (was four near-identical*ByVideofunctions).useInstagramEmbed/useTikTokEmbed— dead code (never imported by any component), so their auto-imports are gone.Public API
Prop/slot/event names, DOM classes, and embed URLs are unchanged. The two removed auto-imports are the only breaking change.
Verification
pnpm test— 54 tests (was 39; 15 new URL tests), SSR fixture suite still greenpnpm lint,pnpm test:types,pnpm prepack— all pass