From bce557cc2dc767628bed6aac87301a1be7c5431b Mon Sep 17 00:00:00 2001 From: rxliuli Date: Tue, 4 Nov 2025 05:03:50 +0800 Subject: init commit --- src/components/jet/today-card/TodayCard.svelte | 401 +++++++++++++++++++++ .../jet/today-card/TodayCardMedia.svelte | 49 +++ .../jet/today-card/TodayCardOverlay.svelte | 48 +++ .../jet/today-card/background-color-utils.ts | 54 +++ .../today-card/media/TodayCardMediaAppEvent.svelte | 78 ++++ .../today-card/media/TodayCardMediaAppIcon.svelte | 62 ++++ .../media/TodayCardMediaBrandedSingleApp.svelte | 41 +++ .../jet/today-card/media/TodayCardMediaList.svelte | 86 +++++ .../today-card/media/TodayCardMediaRiver.svelte | 78 ++++ .../today-card/media/TodayCardMediaVideo.svelte | 72 ++++ .../media/TodayCardMediaWithArtwork.svelte | 100 +++++ .../overlay/TodayCardLockupListOverlay.svelte | 42 +++ 12 files changed, 1111 insertions(+) create mode 100644 src/components/jet/today-card/TodayCard.svelte create mode 100644 src/components/jet/today-card/TodayCardMedia.svelte create mode 100644 src/components/jet/today-card/TodayCardOverlay.svelte create mode 100644 src/components/jet/today-card/background-color-utils.ts create mode 100644 src/components/jet/today-card/media/TodayCardMediaAppEvent.svelte create mode 100644 src/components/jet/today-card/media/TodayCardMediaAppIcon.svelte create mode 100644 src/components/jet/today-card/media/TodayCardMediaBrandedSingleApp.svelte create mode 100644 src/components/jet/today-card/media/TodayCardMediaList.svelte create mode 100644 src/components/jet/today-card/media/TodayCardMediaRiver.svelte create mode 100644 src/components/jet/today-card/media/TodayCardMediaVideo.svelte create mode 100644 src/components/jet/today-card/media/TodayCardMediaWithArtwork.svelte create mode 100644 src/components/jet/today-card/overlay/TodayCardLockupListOverlay.svelte (limited to 'src/components/jet/today-card') diff --git a/src/components/jet/today-card/TodayCard.svelte b/src/components/jet/today-card/TodayCard.svelte new file mode 100644 index 0000000..84d760f --- /dev/null +++ b/src/components/jet/today-card/TodayCard.svelte @@ -0,0 +1,401 @@ + + + + +
+ {#if media && !useListStyle} + + {/if} + +
+
+ +
+ {#if useBlurryProtectionLayer} +
+ {/if} + +
+ {#if heading && !titleArtwork} +

+ + {heading} + +

+ {/if} + + {#if titleArtwork} +
+ +
+ {/if} + + {#if title && !titleArtwork} +

+ + {@html sanitizeHtml(title)} + +

+ {/if} + + {#if inlineDescription} + +

+ {@html sanitizeHtml(inlineDescription)} +

+
+ {/if} +
+
+ + + {#if overlay} +
+ +
+ {/if} +
+
+ + {#if media && useListStyle} + + {/if} +
+ + + diff --git a/src/components/jet/today-card/TodayCardMedia.svelte b/src/components/jet/today-card/TodayCardMedia.svelte new file mode 100644 index 0000000..99f444f --- /dev/null +++ b/src/components/jet/today-card/TodayCardMedia.svelte @@ -0,0 +1,49 @@ + + +{#if isTodayCardMediaAppEvent(media)} + +{:else if isTodayCardMediAppIcon(media)} + +{:else if isTodayCardMediaBrandedSingleApp(media)} + +{:else if isTodayCardMediaList(media)} + +{:else if isTodayCardMediaWithArtwork(media)} + +{:else if isTodayCardMediaRiver(media)} + +{:else if isTodayCardMediaVideo(media)} + +{/if} diff --git a/src/components/jet/today-card/TodayCardOverlay.svelte b/src/components/jet/today-card/TodayCardOverlay.svelte new file mode 100644 index 0000000..4e3c405 --- /dev/null +++ b/src/components/jet/today-card/TodayCardOverlay.svelte @@ -0,0 +1,48 @@ + + + + +{#if isLockupOverlay(overlay)} +
+ +
+{:else if isLockupListOverlay(overlay)} + +{/if} + + diff --git a/src/components/jet/today-card/background-color-utils.ts b/src/components/jet/today-card/background-color-utils.ts new file mode 100644 index 0000000..c2c0fe6 --- /dev/null +++ b/src/components/jet/today-card/background-color-utils.ts @@ -0,0 +1,54 @@ +import { type Optional, isSome } from '@jet/environment/types/optional'; +import type { + Color, + TodayCardMedia, + TodayCardMediaWithArtwork, +} from '@jet-app/app-store/api/models'; + +import { isTodayCardMediaBrandedSingleApp } from './media/TodayCardMediaBrandedSingleApp.svelte'; +import { isTodayCardMediaAppEvent } from './media/TodayCardMediaAppEvent.svelte'; +import { isTodayCardMediaWithArtwork } from './media/TodayCardMediaWithArtwork.svelte'; + +const DEFAULT_COLOR: Color = { + type: 'named', + name: 'defaultBackground', +}; + +function getBackgroundFromMediaWithArtwork( + media: TodayCardMediaWithArtwork, +): Optional { + return ( + media.videos[0]?.preview.backgroundColor ?? + media.artworks[0]?.backgroundColor + ); +} + +/** + * Onyx App Store alternative to the `bestBackgroundColor` method that exists on + * the {@linkcode TodayCardMedia} type + * + * This is necessary because the functions on those class instances are not + * carried over to the client when serializing the view-model, making them + * impossible to call in a consistent way from our codebase + */ +export function bestBackgroundColor(media: Optional): Color { + if (isSome(media)) { + if (isTodayCardMediaAppEvent(media)) { + return media.tintColor; + } + + if (isTodayCardMediaBrandedSingleApp(media)) { + return ( + getBackgroundFromMediaWithArtwork(media) ?? + media.icon.backgroundColor ?? + DEFAULT_COLOR + ); + } + + if (isTodayCardMediaWithArtwork(media)) { + return getBackgroundFromMediaWithArtwork(media) ?? DEFAULT_COLOR; + } + } + + return DEFAULT_COLOR; +} diff --git a/src/components/jet/today-card/media/TodayCardMediaAppEvent.svelte b/src/components/jet/today-card/media/TodayCardMediaAppEvent.svelte new file mode 100644 index 0000000..1faa933 --- /dev/null +++ b/src/components/jet/today-card/media/TodayCardMediaAppEvent.svelte @@ -0,0 +1,78 @@ + + + + +
+ + + + +
+ {#if media.videos.length > 0} + + {:else if media.artworks.length > 0} + + {/if} +
+
+ + diff --git a/src/components/jet/today-card/media/TodayCardMediaAppIcon.svelte b/src/components/jet/today-card/media/TodayCardMediaAppIcon.svelte new file mode 100644 index 0000000..a6db985 --- /dev/null +++ b/src/components/jet/today-card/media/TodayCardMediaAppIcon.svelte @@ -0,0 +1,62 @@ + + + + +
+
+ +
+
+ + diff --git a/src/components/jet/today-card/media/TodayCardMediaBrandedSingleApp.svelte b/src/components/jet/today-card/media/TodayCardMediaBrandedSingleApp.svelte new file mode 100644 index 0000000..dfdaa0f --- /dev/null +++ b/src/components/jet/today-card/media/TodayCardMediaBrandedSingleApp.svelte @@ -0,0 +1,41 @@ + + + + +{#if media.videos.length > 0} + +{:else if media.artworks.length > 0} + +{/if} diff --git a/src/components/jet/today-card/media/TodayCardMediaList.svelte b/src/components/jet/today-card/media/TodayCardMediaList.svelte new file mode 100644 index 0000000..00f8688 --- /dev/null +++ b/src/components/jet/today-card/media/TodayCardMediaList.svelte @@ -0,0 +1,86 @@ + + + + +
+
    + {#each media.lockups as item} +
  • + +
  • + {/each} +
+
+ + diff --git a/src/components/jet/today-card/media/TodayCardMediaRiver.svelte b/src/components/jet/today-card/media/TodayCardMediaRiver.svelte new file mode 100644 index 0000000..d3f9666 --- /dev/null +++ b/src/components/jet/today-card/media/TodayCardMediaRiver.svelte @@ -0,0 +1,78 @@ + + + + +
+ {#if icons.length} + + {/if} +
+ + diff --git a/src/components/jet/today-card/media/TodayCardMediaVideo.svelte b/src/components/jet/today-card/media/TodayCardMediaVideo.svelte new file mode 100644 index 0000000..f2524c6 --- /dev/null +++ b/src/components/jet/today-card/media/TodayCardMediaVideo.svelte @@ -0,0 +1,72 @@ + + + + +{#if videoToDisplay} +
+
+{/if} + + diff --git a/src/components/jet/today-card/media/TodayCardMediaWithArtwork.svelte b/src/components/jet/today-card/media/TodayCardMediaWithArtwork.svelte new file mode 100644 index 0000000..e604708 --- /dev/null +++ b/src/components/jet/today-card/media/TodayCardMediaWithArtwork.svelte @@ -0,0 +1,100 @@ + + + + +{#if artworkProfile} + +{:else} +
+
+ +
+ +
+ +
+
+{/if} + + diff --git a/src/components/jet/today-card/overlay/TodayCardLockupListOverlay.svelte b/src/components/jet/today-card/overlay/TodayCardLockupListOverlay.svelte new file mode 100644 index 0000000..1e7d297 --- /dev/null +++ b/src/components/jet/today-card/overlay/TodayCardLockupListOverlay.svelte @@ -0,0 +1,42 @@ + + + + +
+ {#each overlay.lockups as lockup} + + + + {/each} +
+ + -- cgit v1.2.3