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
4 changes: 4 additions & 0 deletions apps/website/src/components/common/HeaderMain/HeaderMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import {
useWorkshopAppsEnabled,
useWorkshopAuthFlag,
useWorkshopEnabled,
useWorkshopFlag,
useWorkshopWorkflowsEnabled
} from '@/scripts/posthog.ts'
import { HUB_HOME_FLAG } from '@/lib/workshop/hub-section.ts'
import { isWorkshopModelShown } from '@/scripts/workshop-model-flags.ts'
import type { HubApp, HubSections } from '@/data/mainNavigation.ts'
import GitHubStarBadge from '@/components/common/GitHubStarBadge.vue'
Expand Down Expand Up @@ -57,9 +59,11 @@ const showWorkshop = computed(
)
const workflowsEnabled = useWorkshopWorkflowsEnabled()
const appsEnabled = useWorkshopAppsEnabled()
const hubHomeEnabled = useWorkshopFlag(HUB_HOME_FLAG)
const hubSections = computed<HubSections>(() => ({
workflows: showWorkshop.value && workflowsEnabled.value,
apps: showWorkshop.value && appsEnabled.value,
explore: mounted.value && hubHomeEnabled.value,
reshoot:
showWorkshop.value &&
appsEnabled.value &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import HeaderMainDesktop from './HeaderMainDesktop.vue'
const ALL_SECTIONS: HubSections = {
workflows: true,
apps: true,
reshoot: true
reshoot: true,
explore: true
}

async function openHub(hubSections: HubSections = ALL_SECTIONS) {
Expand Down Expand Up @@ -111,7 +112,8 @@ describe('HeaderMainDesktop', () => {
const menu = await openHub({
workflows: false,
apps: false,
reshoot: false
reshoot: false,
explore: false
})

expect(menu.queryByRole('list', { name: 'Workflows' })).toBeNull()
Expand Down Expand Up @@ -152,3 +154,25 @@ describe('HeaderMainDesktop', () => {
}
)
})

describe('Hub menu: the way into the Hub home', () => {
it('offers the way in once the flag opens the Hub home', async () => {
const menu = await openHub()

expect(menu.getByTestId('nav-explore-row')).toBeTruthy()
expect(menu.getByTestId('nav-explore-link').getAttribute('href')).toBe(
'/hub/'
)
})

it('leaves the way in out while the flag is closed', async () => {
const menu = await openHub({
workflows: true,
apps: true,
reshoot: true,
explore: false
})

expect(menu.queryByTestId('nav-explore-row')).toBeNull()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import type { HubSections, NavItem } from '@/data/mainNavigation'
import type { Locale } from '@/i18n/translations'
import NavColumn from './NavColumn.vue'
import NavExploreRow from './NavExploreRow.vue'
import NavFeaturedCard from './NavFeaturedCard.vue'
import NewBadge from './NewBadge.vue'

Expand Down Expand Up @@ -58,7 +59,10 @@
</script>

<template>
<NavigationMenu data-testid="desktop-nav-links">
<NavigationMenu
:viewport-align="hubSections.explore ? 'start' : 'center'"

Check failure on line 63 in apps/website/src/components/common/HeaderMain/HeaderMainDesktop.vue

View workflow job for this annotation

GitHub Actions / fallow / fallow

High cognitive complexity (high)

Function '<template>' is hard to understand (cognitive: 29, threshold: 15). • Severity: high • Cyclomatic: 14 • Cognitive: 29 • Lines: 135 High cognitive complexity means deeply nested or interleaved logic. Consider flattening control flow or extracting helper functions.
data-testid="desktop-nav-links"
>
<NavigationMenuList>
<NavigationMenuItem
v-for="navItem in mainNavigation"
Expand All @@ -77,6 +81,10 @@
</NavigationMenuTrigger>
<NavigationMenuContent class="w-auto" data-testid="nav-dropdown">
<div class="w-max">
<NavExploreRow
v-if="navItem.exploreLink"
:link="navItem.exploreLink"
/>
<ul :class="cn('flex', columnGap(navItem))">
<NavFeaturedCard
v-if="navItem.featured"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { describe, expect, it } from 'vitest'

import HeaderMainMobile from './HeaderMainMobile.vue'

async function openMenu() {
async function openMenu(explore = false) {
const user = userEvent.setup()
render(HeaderMainMobile, {
props: { hubSections: { workflows: true, apps: true, reshoot: true } }
props: {
hubSections: { workflows: true, apps: true, reshoot: true, explore }
}
})
await user.click(screen.getByRole('button', { name: 'Toggle menu' }))
return user
Expand Down Expand Up @@ -111,3 +113,21 @@ describe('HeaderMainMobile', () => {
).toEqual(enterpriseLinks)
})
})

describe('HeaderMainMobile: the way into the Hub home', () => {
it('offers the way in once the flag opens the Hub home', async () => {
const user = await openMenu(true)
await user.click(screen.getByRole('button', { name: /^Hub\b/ }))

expect(screen.getByTestId('nav-explore-link').getAttribute('href')).toBe(
'/hub/'
)
})

it('leaves the way in out while the flag is closed', async () => {
const user = await openMenu()
await user.click(screen.getByRole('button', { name: /^Hub\b/ }))

expect(screen.queryByTestId('nav-explore-link')).toBeNull()
})
})
17 changes: 17 additions & 0 deletions apps/website/src/components/common/HeaderMain/HeaderMainMobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,23 @@ onUnmounted(() => {
</Button>

<div v-if="activeItem" class="mt-6 flex flex-col">
<div
v-if="activeItem.exploreLink"
class="flex flex-col gap-y-2"
>
<p class="text-sm text-primary-comfy-canvas">
{{ activeItem.exploreLink.intro }}
</p>
<Button
:href="activeItem.exploreLink.href"
variant="link"
as="a"
class="text-primary-warm-white transition-colors hover:text-primary-comfy-yellow"
data-testid="nav-explore-link"
>
{{ activeItem.exploreLink.label }}
</Button>
</div>
<div
v-for="(column, columnIndex) in activeItem.columns"
:key="column.header ?? columnIndex"
Expand Down
34 changes: 34 additions & 0 deletions apps/website/src/components/common/HeaderMain/NavExploreRow.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script setup lang="ts">
import { ArrowRight } from '@lucide/vue'

import Button from '@/components/ui/button/Button.vue'
import type { NavItem } from '@/data/mainNavigation'

defineProps<{
link: NonNullable<NavItem['exploreLink']>
}>()
</script>

<template>
<div
class="mb-6 flex items-center justify-between gap-8 border-b border-transparency-white-t8 pb-4"
data-testid="nav-explore-row"
>
<p class="pl-2 text-sm text-primary-comfy-canvas">
{{ link.intro }}
</p>
<Button
as="a"
variant="link"
size="sm"
:href="link.href"
class="shrink-0 text-primary-warm-white transition-colors hover:text-primary-comfy-yellow"
data-testid="nav-explore-link"
>
{{ link.label }}
<template #append>
<ArrowRight class="size-4" aria-hidden="true" />
</template>
</Button>
</div>
</template>
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<script setup lang="ts">
import type { NavigationMenuRootEmits, NavigationMenuRootProps } from 'reka-ui'
import type {
NavigationMenuRootEmits,
NavigationMenuRootProps,
NavigationMenuViewportProps
} from 'reka-ui'
import { NavigationMenuRoot, useForwardPropsEmits } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import { computed } from 'vue'
Expand All @@ -10,12 +14,14 @@ import NavigationMenuViewport from './NavigationMenuViewport.vue'

const {
viewport = true,
viewportAlign = 'center',
class: className,
...restProps
} = defineProps<
NavigationMenuRootProps & {
class?: HTMLAttributes['class']
viewport?: boolean
viewportAlign?: NavigationMenuViewportProps['align']
}
>()
const emits = defineEmits<NavigationMenuRootEmits>()
Expand All @@ -40,6 +46,6 @@ const forwarded = useForwardPropsEmits(
"
>
<slot v-bind="slotProps" />
<NavigationMenuViewport v-if="viewport" />
<NavigationMenuViewport v-if="viewport" :align="viewportAlign" />
</NavigationMenuRoot>
</template>
82 changes: 82 additions & 0 deletions apps/website/src/components/workshop/ExploreDoors.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { render, screen, within } from '@testing-library/vue'
import { describe, expect, it } from 'vitest'

import ExploreDoors from './ExploreDoors.vue'

const ALL = { models: 3, workflows: 2, apps: 1 }

describe('ExploreDoors', () => {
it('says who each door is for', () => {
render(ExploreDoors, { props: { counts: ALL } })

expect(
screen
.getAllByRole('link')
.map((door) => [
within(door).getByTestId('explore-door-intent').textContent.trim(),
within(door).getByTestId('explore-door-hint').textContent.trim()
])
).toEqual([
[
'Run or call any model',
'Call the latest models from your code. Try them here first.'
],
['Download and remix', 'Open the graph and change any step.'],
['Make it in one click', 'Upload, click, done. No nodes, no setup.']
])
})

it.for([
{
door: 'models',
copy: ['Alpine lake at blue hour', 'Nano Banana Pro', 'Run']
},
{
door: 'workflows',
copy: ['Relight', 'light', '45°', 'strength', '0.80', 'Save Image']
},
{
door: 'apps',
copy: ['Focal length', '35mm', 'Generate']
}
] as const)('shows the $door interface over its image', ({ door, copy }) => {
render(ExploreDoors, {
props: {
counts: ALL,
art: {
models: {
src: '/lake.png',
name: 'Nano Banana Pro',
provider: 'Google',
usd: 0.03,
credits: 6,
prompt: 'workshop.explore.doorModelPromptLake'
},
workflows: { src: '/bottle.webp' },
apps: {
src: '/studio.jpg',
control: 'workshop.explore.doorAppControlFocal',
value: '35mm'
}
}
}
})

const art = within(
within(screen.getByTestId(`explore-door-${door}`)).getByTestId(
'explore-door-art'
)
)
for (const text of copy) expect(art.getByText(text)).toBeInTheDocument()
})

it('keeps a door without art to its words', () => {
render(ExploreDoors, { props: { counts: ALL } })

expect(screen.queryByTestId('explore-door-art')).not.toBeInTheDocument()
expect(screen.getByRole('link', { name: /Models/ })).toHaveAttribute(
'href',
'/hub/models/'
)
})
})
Loading
Loading