Repository navigation
fix(models): a category-aware back control, and the rest of the UI review #17569
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
Changes from all commits
4395c3a
28a29e3
d270cfb
78bc593
f55f0c0
7034a24
d6d6656
957bdf1
6383157
bacc6f9
f2040fc
dfd9e77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // @vitest-environment happy-dom | ||
| import { render, screen, waitFor } from '@testing-library/vue' | ||
| import { afterEach, describe, expect, it } from 'vitest' | ||
|
|
||
| import { rememberShelf } from '../../lib/workshop/shelf-memory' | ||
| import CatalogueBackLink from './CatalogueBackLink.vue' | ||
|
|
||
| afterEach(() => { | ||
| sessionStorage.clear() | ||
| }) | ||
|
|
||
| describe('CatalogueBackLink', () => { | ||
| it('offers the whole catalogue when no shelf was left behind', () => { | ||
| render(CatalogueBackLink) | ||
|
|
||
| const link = screen.getByTestId('model-back') | ||
| expect(link.textContent.trim()).toBe('Back to all models') | ||
| expect(link.getAttribute('href')).toBe('/models') | ||
| }) | ||
|
|
||
| it('offers the shelf the visitor came from', async () => { | ||
| rememberShelf('generate-videos') | ||
| render(CatalogueBackLink) | ||
|
|
||
| await waitFor(() => { | ||
| const link = screen.getByTestId('model-back') | ||
| expect(link.textContent.trim()).toBe('Back to Generate videos') | ||
| expect(link.getAttribute('href')).toBe('/models?useCase=generate-videos') | ||
| }) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <script setup lang="ts"> | ||
| import { ChevronLeft } from '@lucide/vue' | ||
| import { onMounted, ref } from 'vue' | ||
|
|
||
| import { catalogSearch } from '../../config/models-catalogue' | ||
| import { getRoutes } from '../../config/routes' | ||
| import type { Locale } from '../../i18n/translations' | ||
| import { t } from '../../i18n/translations' | ||
| import { lastShelf } from '../../lib/workshop/shelf-memory' | ||
| import { useCaseLabelKey } from '../../lib/workshop/use-case-label' | ||
|
|
||
| const { locale = 'en' } = defineProps<{ locale?: Locale }>() | ||
|
|
||
| const routes = getRoutes(locale) | ||
| const href = ref(routes.workshop) | ||
| const category = ref<string>() | ||
|
|
||
| // Most visitors reach a model from a shelf, and the way back they want is that | ||
| // shelf, not the whole catalogue. Opened in a new tab, or reached from a link | ||
| // somebody shared, there is no shelf to return to and the catalogue answers. | ||
| onMounted(() => { | ||
| const shelf = lastShelf() | ||
| if (!shelf || shelf === 'all') return | ||
| href.value = `${routes.workshop}${catalogSearch({ useCase: shelf })}` | ||
| category.value = t(useCaseLabelKey[shelf], locale) | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <a | ||
| :href | ||
| class="hover:text-primary-comfy-yellow focus-visible:ring-primary-comfy-yellow/50 -ml-1 inline-flex items-center gap-1 rounded-lg px-1 text-sm font-medium text-primary-warm-gray opacity-60 transition hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-3" | ||
| data-testid="model-back" | ||
| > | ||
| <ChevronLeft class="size-4" aria-hidden="true" /> | ||
| {{ | ||
| category | ||
| ? t('workshop.model.backTo', locale).replace('{category}', category) | ||
| : t('workshop.model.back', locale) | ||
| }} | ||
| </a> | ||
| </template> | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -43,7 +43,7 @@ | |||||
| <div class="flex flex-col gap-1"> | ||||||
| <h2 class="text-sm font-bold text-primary-warm-white"> | ||||||
| {{ | ||||||
| t( | ||||||
|
Check failure on line 46 in apps/website/src/components/workshop/ExamplesTab.vue
|
||||||
| samplesOnly | ||||||
| ? 'workshop.examples.samples' | ||||||
| : 'workshop.examples.start', | ||||||
|
|
@@ -73,7 +73,7 @@ | |||||
| they fit in a row of their own. --> | ||||||
| <ul | ||||||
| v-else | ||||||
| class="flex scrollbar-hide snap-x gap-3 overflow-x-auto max-sm:-mx-6 max-sm:-my-1 max-sm:scroll-px-6 max-sm:px-6 max-sm:py-1 sm:grid sm:max-w-2xl sm:grid-cols-3 sm:overflow-visible" | ||||||
| class="flex scrollbar-hide snap-x gap-3 overflow-x-auto max-sm:-mx-6 max-sm:-my-1 max-sm:scroll-px-6 max-sm:px-6 max-sm:py-1 sm:grid sm:max-w-5xl sm:grid-cols-[repeat(auto-fit,minmax(14rem,1fr))] sm:overflow-visible" | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SHOULD FIX:
Suggested change
|
||||||
| > | ||||||
| <li | ||||||
| v-for="example in examples" | ||||||
|
|
@@ -82,15 +82,18 @@ | |||||
| > | ||||||
| <button | ||||||
| type="button" | ||||||
| :aria-label=" | ||||||
| :aria-label="`${example.title}: ${ | ||||||
| example.sampleOnly | ||||||
| ? actionFor(example) | ||||||
| : t('workshop.examples.open', locale) | ||||||
| " | ||||||
| }`" | ||||||
| :aria-current="example.id === activeId ? 'true' : undefined" | ||||||
| class="group flex w-full cursor-pointer flex-col gap-2 text-left outline-none" | ||||||
| data-testid="example-card" | ||||||
| :title="actionFor(example, example.id === activeId)" | ||||||
| :title="`${example.title} · ${actionFor( | ||||||
| example, | ||||||
| example.id === activeId | ||||||
| )}`" | ||||||
| @click="emit('open', example)" | ||||||
| > | ||||||
| <span | ||||||
|
|
@@ -147,7 +150,7 @@ | |||||
| <span | ||||||
| :class=" | ||||||
| cn( | ||||||
| 'line-clamp-2 text-xs transition-colors', | ||||||
| 'line-clamp-1 text-xs transition-colors', | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||||||
| example.id === activeId | ||||||
| ? 'text-primary-warm-white' | ||||||
| : 'text-primary-comfy-canvas group-hover:text-primary-warm-white' | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Low — Nothing invalidates the stored shelf except
WorkshopModelsGridwriting a new one, so a model page reached without passing back through the catalogue — a related-model card on this very page, or a shared link opened in the same tab — still offers "Back to Generate videos" for a shelf the visitor never came from and that may not even contain the model. Stamping the stored value with the slug it was captured for, or clearing it once consumed, would keep the link honest.Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).