Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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.
42 changes: 42 additions & 0 deletions apps/website/src/components/workshop/AppsHalf.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { defineAsyncComponent } from 'vue'

import type { Locale } from '@/i18n/translations'
import type { CatalogueApp } from '@/lib/workshop/catalogue-apps'
import {
loadAppCatalogue,
loadHubAppCatalogue
} from '@/lib/workshop/catalogue-components'
import { HUB_HOME_FLAG } from '@/lib/workshop/hub-section'
import { useWorkshopFlag } from '@/scripts/posthog'

const { apps, locale = 'en' } = defineProps<{
apps: readonly CatalogueApp[]
locale?: Locale
}>()
const browseAll = defineModel<boolean>('browseAll')
const emit = defineEmits<{ section: [inSection: boolean] }>()

const AppCatalogue = defineAsyncComponent(loadAppCatalogue)
const HubAppCatalogue = defineAsyncComponent(loadHubAppCatalogue)
const hubOpen = useWorkshopFlag(HUB_HOME_FLAG)
</script>

<template>
<HubAppCatalogue v-if="hubOpen" :apps :locale>
<template #tabs>
<slot name="tabs" />
</template>
</HubAppCatalogue>
<AppCatalogue
v-else
v-model:browse-all="browseAll"
:apps
:locale
@section="emit('section', $event)"
>
<template #tabs>
<slot name="tabs" />
</template>
</AppCatalogue>
</template>
42 changes: 42 additions & 0 deletions apps/website/src/components/workshop/CatalogueShowMore.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { ChevronDown } from '@lucide/vue'

import type { Locale } from '@/i18n/translations'
import { translationsFor } from '@/i18n/translations'

const {
shown,
total,
locale = 'en'
} = defineProps<{
shown: number
total: number
locale?: Locale
}>()
const { t } = translationsFor(locale)

defineEmits<{ more: [] }>()
</script>

<template>
<div class="mt-10 flex flex-col items-center gap-4 max-sm:mt-8">
<p
class="text-sm text-primary-warm-gray tabular-nums"
data-testid="catalogue-show-more-count"
>
{{ t('workshop.hub.showingOf', { shown, total }) }}
</p>
<button
type="button"
class="group flex w-full cursor-pointer items-center justify-center gap-2 rounded-2xl border border-transparency-white-t8 px-8 py-4 text-sm font-medium text-primary-comfy-canvas transition-colors outline-none hover:border-primary-comfy-yellow hover:text-primary-comfy-yellow focus-visible:ring-3 focus-visible:ring-primary-comfy-yellow/50"
data-testid="catalogue-show-more"
@click="$emit('more')"
>
{{ t('workshop.hub.showMore') }}
<ChevronDown
class="size-4 transition-transform group-hover:translate-y-0.5"
aria-hidden="true"
/>
</button>
</div>
</template>
62 changes: 62 additions & 0 deletions apps/website/src/components/workshop/DetailTrail.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<script setup lang="ts">
import { ChevronLeft } from '@lucide/vue'
import { computed, onMounted, ref } from 'vue'

import { getRoutes } from '@/config/routes'
import { t } from '@/i18n/translations'
import type { ListReturn } from '@/lib/workshop/hub-list-memory'
import { lastList } from '@/lib/workshop/hub-list-memory'
import HubBreadcrumb from './HubBreadcrumb.vue'

const { section, name } = defineProps<{
section: 'models' | 'workflows'
name: string
}>()

const routes = getRoutes()
const sectionList = {
models: { href: routes.workshop, label: t('workshop.model.breadcrumb') },
workflows: { href: routes.hubWorkflows, label: t('workshop.hub.workflows') }
}[section]
const hub = { href: routes.hubExplore, label: t('workshop.catalogue.eyebrow') }

const remembered = ref<ListReturn>()

// Most visitors reach a page from a list, and the way back they want is that

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: same repo rule. This comment is new code. A name like restoreListVisitorCameFrom on the mount callback, or a test title, can carry the "new tab / shared link falls back to the section" rationale instead.

// list as they left it. Opened in a new tab, or from a shared link, there is
// no list to return to and the section answers.
onMounted(() => {
remembered.value = lastList(location.pathname)
})

const back = computed(() => {
const list = remembered.value
if (!list) return sectionList
if (list.href === hub.href) return hub
return { href: list.href, label: list.label ?? sectionList.label }
})

const crumbs = computed(() => [
{ ...hub, testId: 'detail-hub' },
{
...(back.value === hub ? sectionList : back.value),
testId: 'detail-list'
},
{ label: name }
])
</script>

<template>
<div class="min-w-0" data-testid="detail-trail">
<HubBreadcrumb :crumbs class="max-sm:hidden" />
<a
:href="back.href"
:aria-label="t('workshop.model.backTo', { category: back.label })"
class="-ml-1 inline-flex max-w-full min-w-0 items-center gap-1 rounded-lg px-1 text-sm font-medium text-primary-warm-gray transition-colors outline-none hover:text-primary-comfy-canvas focus-visible:ring-3 focus-visible:ring-primary-comfy-yellow/50 sm:hidden"
data-testid="detail-back"
>
<ChevronLeft class="size-4 shrink-0" aria-hidden="true" />
<span class="truncate">{{ back.label }}</span>
</a>
</div>
</template>
106 changes: 106 additions & 0 deletions apps/website/src/components/workshop/ExampleCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<script setup lang="ts">
import { Check } from '@lucide/vue'
import { computed } from 'vue'

import { cn } from '@comfyorg/tailwind-utils'

import type { PlaygroundExample } from '@/config/workshop-playground'
import type { Locale } from '@/i18n/translations'
import { translationsFor } from '@/i18n/translations'
import ExampleMedia from './ExampleMedia.vue'

const {
example,
locale = 'en',
disabled = false
} = defineProps<{
example: PlaygroundExample
active: boolean
alt: string
videoPreload: 'metadata' | 'none'
locale?: Locale
disabled?: boolean
}>()
const { t } = translationsFor(locale)

const emit = defineEmits<{ open: [] }>()

const specs = computed(() => example.specs.join(' · '))

function actionFor(active = false) {
if (example.sampleOnly)
return t(active ? 'workshop.examples.viewing' : 'workshop.examples.view')
return t(active ? 'workshop.examples.using' : 'workshop.examples.use')
}

const openLabel = computed(() =>
example.sampleOnly ? actionFor() : t('workshop.examples.open')
)
</script>

<template>
<figure class="flex flex-col gap-2">
<button
type="button"
:aria-label="`${example.title}: ${openLabel}`"
:aria-current="active ? 'true' : undefined"
:disabled
class="group flex w-full cursor-pointer flex-col gap-2 text-left outline-none disabled:cursor-not-allowed disabled:opacity-50"
data-testid="example-card"
:title="`${example.title} · ${actionFor(active)}`"
@click="emit('open')"
>
<span
:class="
cn(
'relative block aspect-video overflow-hidden rounded-lg bg-primary-comfy-ink-light ring-1 transition-all',
active
? 'ring-2 ring-primary-comfy-yellow group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-primary-warm-white'
: 'ring-transparency-white-t8 group-hover:-translate-y-0.5 group-hover:ring-transparency-white-t20 group-hover:brightness-110 group-focus-visible:ring-primary-comfy-yellow'
)
"
data-testid="example-thumbnail"
>
<ExampleMedia :example :alt :video-preload />

<span
v-if="active"
class="absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-primary-comfy-yellow text-primary-comfy-ink"
data-testid="example-chosen"
>
<Check class="size-3" :stroke-width="3" aria-hidden="true" />
</span>
<span
v-else
class="absolute top-1.5 left-1.5 rounded-full bg-black/70 px-2 py-0.5 text-[11px] font-medium text-primary-warm-white opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"
aria-hidden="true"
>
{{ actionFor() }}
</span>

<span
class="absolute inset-x-0 bottom-0 flex flex-col gap-0.5 bg-linear-to-t from-black/85 to-transparent px-2 pt-6 pb-1.5"
>
<span class="line-clamp-1 text-xs text-primary-warm-white">
{{ example.title }}
</span>
<span
v-if="specs"
class="line-clamp-1 text-[11px] text-primary-comfy-canvas/70"
data-testid="example-specs"
>
{{ specs }}
</span>
</span>
</span>
</button>
<audio
v-if="example.mediaKind === 'audio'"
:src="example.outputUrl"
:aria-label="alt"
controls
preload="metadata"
class="w-full"
/>
</figure>
</template>
38 changes: 38 additions & 0 deletions apps/website/src/components/workshop/ExampleMedia.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<script setup lang="ts">
import { Music2 } from '@lucide/vue'

import type { PlaygroundExample } from '@/config/workshop-playground'
import { isVideoUrl, videoPosterUrl } from '@/config/workshop-playground'

defineProps<{
example: PlaygroundExample
alt: string
videoPreload: 'metadata' | 'none'
}>()
</script>

<template>
<video
v-if="example.mediaKind === 'video' || isVideoUrl(example.outputUrl)"
:src="videoPosterUrl(example.outputUrl)"
:aria-label="alt"
class="size-full object-cover"
muted
playsinline
:preload="videoPreload"
data-testid="example-video"
/>
<Music2
v-else-if="example.mediaKind === 'audio'"
class="size-full px-3"
aria-hidden="true"
/>
<img
v-else-if="example.outputUrl"
:src="example.outputUrl"
:alt
class="size-full object-cover"
loading="lazy"
decoding="async"
/>
</template>
Loading
Loading