-
-
Notifications
You must be signed in to change notification settings - Fork 400
feat: noodles #2421
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
Merged
Merged
feat: noodles #2421
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4061599
feat: configure noodles infra
alexdln 895b87b
feat: add artemis noodle
alexdln 34ac51f
feat: comment archive-noodles
alexdln c5c423a
feat: comment archive-noodles
alexdln a4e310e
chore: fix date
alexdln 565e2ab
test: update tests related to noodles
alexdln f1430a1
[autofix.ci] apply automated fixes
autofix-ci[bot] 286d648
chore: one more tests fix
alexdln d0bd08f
[autofix.ci] apply automated fixes
autofix-ci[bot] d6029b7
Merge branch 'main' into feat/noodles
alexdln File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <script setup lang="ts"> | ||
| const props = defineProps<{ | ||
| lightSrc: string | ||
| darkSrc: string | ||
| }>() | ||
| </script> | ||
|
|
||
| <template> | ||
| <img | ||
| :src="props.darkSrc" | ||
| class="color-mode-img" | ||
| :style="`--light-src: url('${props.lightSrc}')`" | ||
| /> | ||
| </template> | ||
|
|
||
| <style> | ||
| .light .color-mode-img { | ||
| content: var(--light-src); | ||
| } | ||
| </style> | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| <script setup lang="ts"> | ||
| import { ACTIVE_NOODLES, PERMANENT_NOODLES, type Noodle } from '../Noodle' | ||
|
|
||
| const { env } = useAppConfig().buildInfo | ||
|
|
||
| const activeNoodlesData = ACTIVE_NOODLES.map(noodle => ({ | ||
| key: noodle.key, | ||
| date: noodle.date, | ||
| timezone: noodle.timezone, | ||
| tagline: noodle.tagline, | ||
| })) | ||
|
|
||
| const permanentNoodlesData = PERMANENT_NOODLES.map(noodle => ({ | ||
| key: noodle.key, | ||
| tagline: noodle.tagline, | ||
| })) | ||
|
|
||
| onPrehydrate(el => { | ||
| const tagline = el.querySelector<HTMLElement>('#intro-header-tagline') | ||
| const defaultLogo = el.querySelector<HTMLElement>('#intro-header-noodle-default') | ||
|
|
||
| if (!tagline || !defaultLogo) return | ||
|
|
||
| let permanentNoodles | ||
| try { | ||
| permanentNoodles = JSON.parse(el.dataset.permanentNoodles as string) as Noodle[] | ||
| } catch { | ||
| return | ||
| } | ||
| const activePermanentNoodle = permanentNoodles?.find(noodle => | ||
| new URLSearchParams(window.location.search).has(noodle.key), | ||
| ) | ||
|
|
||
| if (activePermanentNoodle) { | ||
| const permanentNoodleLogo = el.querySelector<HTMLElement>( | ||
| `#intro-header-noodle-${activePermanentNoodle.key}`, | ||
| ) | ||
|
|
||
| if (!permanentNoodleLogo) return | ||
|
|
||
| permanentNoodleLogo.style.display = 'block' | ||
| defaultLogo.style.display = 'none' | ||
| if (activePermanentNoodle.tagline === false) { | ||
| tagline.style.display = 'none' | ||
| } | ||
| return | ||
| } | ||
|
|
||
| let activeNoodles | ||
| try { | ||
| activeNoodles = JSON.parse(el.dataset.activeNoodles as string) as Noodle[] | ||
| } catch { | ||
| return | ||
| } | ||
|
|
||
| const currentActiveNoodles = activeNoodles.filter(noodle => { | ||
| const todayDate = new Intl.DateTimeFormat('en-US', { | ||
| timeZone: noodle.timezone === 'auto' ? undefined : noodle.timezone, | ||
| month: '2-digit', | ||
| day: '2-digit', | ||
| year: 'numeric', | ||
| }).format(new Date()) | ||
|
|
||
| const noodleDate = | ||
| noodle.date && | ||
| new Intl.DateTimeFormat('en-US', { | ||
| timeZone: noodle.timezone === 'auto' ? undefined : noodle.timezone, | ||
| month: '2-digit', | ||
| day: '2-digit', | ||
| year: 'numeric', | ||
| }).format(new Date(noodle.date)) | ||
| return todayDate === noodleDate | ||
| }) | ||
|
|
||
| if (!currentActiveNoodles.length) return | ||
|
|
||
| const roll = Math.floor(Math.random() * currentActiveNoodles.length) | ||
| const selectedNoodle = currentActiveNoodles[roll] | ||
|
|
||
| if (!selectedNoodle) return | ||
|
|
||
| const noodleLogo = el.querySelector<HTMLElement>(`#intro-header-noodle-${selectedNoodle.key}`) | ||
|
|
||
| if (!defaultLogo || !noodleLogo || !tagline) return | ||
|
|
||
| defaultLogo.style.display = 'none' | ||
| noodleLogo.style.display = 'block' | ||
| if (selectedNoodle.tagline === false) { | ||
| tagline.style.display = 'none' | ||
| } | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div | ||
| :data-active-noodles="JSON.stringify(activeNoodlesData)" | ||
| :data-permanent-noodles="JSON.stringify(permanentNoodlesData)" | ||
| > | ||
| <h1 class="sr-only"> | ||
| {{ $t('alt_logo') }} | ||
| </h1> | ||
| <div | ||
| id="intro-header-noodle-default" | ||
| class="relative mb-6 w-fit mx-auto motion-safe:animate-fade-in motion-safe:animate-fill-both" | ||
| aria-hidden="true" | ||
| > | ||
| <AppLogo id="npmx-index-h1-logo-normal" class="w-42 h-auto sm:w-58 md:w-70" /> | ||
| <span | ||
| id="npmx-index-h1-logo-env" | ||
| class="text-sm sm:text-base md:text-lg transform-origin-br font-mono tracking-widest text-accent absolute -bottom-4 -inset-ie-1.5" | ||
| > | ||
| {{ env === 'release' ? 'alpha' : env }} | ||
| </span> | ||
| </div> | ||
| <component | ||
| v-for="noodle in PERMANENT_NOODLES" | ||
| :key="noodle.key" | ||
| :id="`intro-header-noodle-${noodle.key}`" | ||
| class="hidden" | ||
| aria-hidden="true" | ||
| :is="noodle.logo" | ||
| /> | ||
| <component | ||
| v-for="noodle in ACTIVE_NOODLES" | ||
| :key="noodle.key" | ||
| :id="`intro-header-noodle-${noodle.key}`" | ||
| class="hidden" | ||
| aria-hidden="true" | ||
| :is="noodle.logo" | ||
| /> | ||
| <p | ||
| id="intro-header-tagline" | ||
| class="text-fg-muted text-lg sm:text-xl max-w-xl mb-12 lg:mb-14 motion-safe:animate-slide-up motion-safe:animate-fill-both delay-100" | ||
| > | ||
| {{ $t('tagline') }} | ||
| </p> | ||
| </div> | ||
| </template> |
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <template> | ||
| <div> | ||
| <ColorSchemeImg | ||
| width="400" | ||
| class="mb-8 motion-safe:animate-fade-in motion-safe:animate-scale-in w-80 sm:w-100" | ||
| dark-src="/extra/npmx-dark-artemis.svg" | ||
| light-src="/extra/npmx-light-artemis.svg" | ||
| alt="" | ||
| /> | ||
| <ColorSchemeImg | ||
| width="1440" | ||
| height="455" | ||
| class="absolute bottom-0 inset-is-0 w-full h-auto mix-blend-lighten light:mix-blend-darken motion-safe:animate-fade-in" | ||
| dark-src="/extra/moon-dark.png" | ||
| light-src="/extra/moon-light.png" | ||
| alt="" | ||
| /> | ||
alexdln marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| </template> | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <template> | ||
| <img | ||
| width="400" | ||
| class="mb-8 motion-safe:animate-fade-in motion-safe:animate-scale-in motion-safe:hover:scale-105 motion-safe:transition w-80 sm:w-100" | ||
| src="/extra/npmx-cute.svg" | ||
| :alt="$t('alt_logo_kawaii')" | ||
| /> | ||
| </template> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import NoodleKawaiiLogo from './Kawaii/Logo.vue' | ||
| import NoodleArtemisLogo from './Artemis/Logo.vue' | ||
| // import NoodleTkawaiiLogo from './Tkawaii/Logo.vue' | ||
|
|
||
| export type Noodle = { | ||
| // Unique identifier for the noodle | ||
| key: string | ||
| // Timezone for the noodle (default is auto, i.e. user's timezone) | ||
| timezone?: string | ||
| // Date for the noodle | ||
| date?: string | ||
| // Logo for the noodle - could be any component. Relative parent - intro section | ||
| logo: Component | ||
| // Show npmx tagline or not (default is true) | ||
| tagline?: boolean | ||
| } | ||
|
|
||
| // Archive noodles - might be shown on special page | ||
| // export const ARCHIVE_NOODLES: Noodle[] = [ | ||
| // { | ||
| // key: 'tkawaii', | ||
| // date: '2026-04-08T12:00:00UTC', | ||
| // timezone: 'auto', | ||
| // logo: NoodleTkawaiiLogo, | ||
| // tagline: false, | ||
| // }, | ||
| // ] | ||
|
|
||
| // Permanent noodles - always shown on specific query param (e.g. ?kawaii) | ||
| export const PERMANENT_NOODLES: Noodle[] = [ | ||
| { | ||
| key: 'kawaii', | ||
| logo: NoodleKawaiiLogo, | ||
| tagline: false, | ||
| }, | ||
| ] | ||
|
|
||
| // Active noodles - shown based on date and timezone | ||
| export const ACTIVE_NOODLES: Noodle[] = [ | ||
| { | ||
| key: 'artemis', | ||
| logo: NoodleArtemisLogo, | ||
| date: '2026-04-08T12:00:00Z', | ||
| timezone: 'America/Los_Angeles', | ||
| tagline: true, | ||
| }, | ||
| ] |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.