Repository navigation
refactor(website): render split headings as complete messages #21034
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
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 |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| <script setup lang="ts"> | ||
| import type { Locale } from '@/i18n/translations' | ||
| import type { Locale, TranslationKey } from '@/i18n/translations' | ||
|
|
||
| import { I18nT } from 'vue-i18n' | ||
|
|
||
| import { translationsFor } from '@/i18n/translations' | ||
| import NodeBadge from '@/components/common/NodeBadge.vue' | ||
|
|
@@ -8,8 +10,6 @@ import SectionLabel from '@/components/common/SectionLabel.vue' | |
| const { locale = 'en' } = defineProps<{ locale?: Locale }>() | ||
| const { t } = translationsFor(locale) | ||
|
|
||
| type TranslationKey = Parameters<typeof t>[0] | ||
|
|
||
| const values: { | ||
| segments: Array<{ text: string }> | ||
| bodyKey: TranslationKey | ||
|
|
@@ -39,15 +39,18 @@ const values: { | |
| <SectionLabel> | ||
| {{ t('about.values.label') }} | ||
| </SectionLabel> | ||
| <h2 | ||
| <I18nT | ||
| keypath="about.values.heading" | ||
|
Comment on lines
+42
to
+43
Contributor
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. P2: three of the five converted headings have no test. One table covering every heading component catches all three. Each row would be
Member
Author
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. Added |
||
| tag="h2" | ||
| :i18n="translationsFor(locale)" | ||
| class="mt-6 text-3xl font-light text-primary-comfy-canvas lg:text-5xl" | ||
| > | ||
| {{ t('about.values.headingBefore') | ||
| }}<span class="text-primary-comfy-yellow">{{ | ||
| t('about.values.headingHighlight') | ||
| }}</span | ||
| >{{ t('about.values.headingAfter') }} | ||
| </h2> | ||
| <template #highlight> | ||
| <span class="text-primary-comfy-yellow">{{ | ||
| t('about.values.headingHighlight') | ||
| }}</span> | ||
| </template> | ||
| </I18nT> | ||
| </div> | ||
|
|
||
| <div class="mx-auto mt-16 max-w-5xl"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import type { Component } from 'vue' | ||
|
|
||
| import type { Locale } from '@/i18n/translations' | ||
|
|
||
| import { render, screen, within } from '@testing-library/vue' | ||
| import { describe, expect, it } from 'vitest' | ||
|
|
||
| import OurValuesSection from './about/OurValuesSection.vue' | ||
| import StorySection from './about/StorySection.vue' | ||
| import WireNodeLayout from './common/WireNodeLayout.vue' | ||
| import AudienceSection from './product/cloud/AudienceSection.vue' | ||
|
|
||
| type HighlightedHeadingCase = { | ||
| name: string | ||
| component: Component | ||
| locale: Locale | ||
| heading: string | ||
| highlight: string | ||
| } | ||
|
|
||
| const highlightedHeadings: HighlightedHeadingCase[] = [ | ||
| { | ||
| name: 'OurValuesSection', | ||
| component: OurValuesSection, | ||
| locale: 'en', | ||
| heading: | ||
| 'We believe everyone deserves to design exactly what they dream, own their process, and never compromise because of their software.', | ||
| highlight: 'everyone deserves to design exactly what they dream' | ||
| }, | ||
| { | ||
| name: 'OurValuesSection', | ||
| component: OurValuesSection, | ||
| locale: 'zh-CN', | ||
| heading: | ||
| '我们相信每个人都值得设计出自己梦想中的作品,掌握自己的流程,永远不因软件而妥协。', | ||
| highlight: '每个人都值得设计出自己梦想中的作品' | ||
| }, | ||
| { | ||
| name: 'StorySection', | ||
| component: StorySection, | ||
| locale: 'en', | ||
| heading: | ||
| 'An open-source project that became the professional standard for visual AI.', | ||
| highlight: 'professional standard' | ||
| }, | ||
| { | ||
| name: 'StorySection', | ||
| component: StorySection, | ||
| locale: 'zh-CN', | ||
| heading: '一个开源项目成为了视觉 AI 的行业标准。', | ||
| highlight: '行业标准' | ||
| }, | ||
| { | ||
| name: 'AudienceSection', | ||
| component: AudienceSection, | ||
| locale: 'en', | ||
| heading: 'Built for creators who need quality, control, and simplicity.', | ||
| highlight: 'creators' | ||
| }, | ||
| { | ||
| name: 'AudienceSection', | ||
| component: AudienceSection, | ||
| locale: 'zh-CN', | ||
| heading: '为追求质量、控制与简约的创作者而生。', | ||
| highlight: '创作者' | ||
| } | ||
| ] | ||
|
|
||
| describe('interpolated headings', () => { | ||
| it.for(highlightedHeadings)( | ||
| '$name keeps the highlight inside the $locale heading', | ||
| ({ component, locale, heading, highlight }) => { | ||
| render(component, { props: { locale } }) | ||
|
|
||
| const title = screen.getByRole('heading', { level: 2 }) | ||
| expect(title.textContent).toBe(heading) | ||
| expect(within(title).getByText(highlight)).toBeInTheDocument() | ||
| } | ||
| ) | ||
|
|
||
| it.for([ | ||
| { locale: 'en', title: 'Why join?' }, | ||
| { locale: 'zh-CN', title: '为什么加入?' } | ||
| ] as const)( | ||
| 'WireNodeLayout renders the $locale title card as one message', | ||
| ({ locale, title }) => { | ||
| render(WireNodeLayout, { props: { locale, reasons: [] } }) | ||
|
|
||
| const cards = screen.getAllByText(title) | ||
| expect(cards.map((card) => card.textContent)).toEqual([title, title]) | ||
| } | ||
| ) | ||
|
Comment on lines
+81
to
+92
Contributor
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. P2: this case passes when the card loses its logo or its line break. The logo span and the The logo has no accessible name either (same as main), so screen readers already read this card as "Why join?" with the brand missing. That is also why no semantic query can reach it. Giving the span |
||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,8 @@ import ModelsHeroSection from './ModelsHeroSection.vue' | |
| describe('ModelsHeroSection', () => { | ||
| it.for([ | ||
| { locale: 'en', title: 'Flux in ComfyUI' }, | ||
| { locale: 'zh-CN', title: 'ComfyUI 中的 Flux' } | ||
| { locale: 'zh-CN', title: 'ComfyUI 中的 Flux' }, | ||
| { locale: 'ja', title: 'ComfyUIのFlux' } | ||
| ] as const)( | ||
| 'places the brand where the $locale title puts it', | ||
|
Contributor
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. P3: the title says "places the brand", but the body only checks the heading text. I removed the yellow span from the expect(screen.getByText('ComfyUI')).toBeInTheDocument()No other element in the section has the exact text "ComfyUI", so
Member
Author
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. Added; removing the span now fails all three rows. |
||
| ({ locale, title }) => { | ||
|
|
@@ -23,6 +24,7 @@ describe('ModelsHeroSection', () => { | |
| new RegExp(`^${title}$`), | ||
| { normalizeWhitespace: false } | ||
| ) | ||
| expect(screen.getByText('ComfyUI')).toBeInTheDocument() | ||
| } | ||
| ) | ||
| }) | ||
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.
P3 Nit: the convention covers styled words, but not the rule that fixed the careers title: an inline image or a line break is its own placeholder too, never part of another slot. Without it, the next author can bake a
<br>into a slot again and lock the break for every locale. One clause and thewhyJoinTitleexample cover it.