|
1 | 1 | import { useArea } from "~/i18n/content" |
2 | 2 | import { appsSource } from "~/i18n/content/areas/apps" |
3 | 3 | import { useI18n } from "~/context/i18n" |
| 4 | +import { useLanguage } from "~/context/language" |
4 | 5 | import "./companions.css" |
5 | | -import { For } from "solid-js" |
| 6 | +import { For, Show } from "solid-js" |
6 | 7 | import { NewTab } from "./icons" |
7 | | -import { anomalyApps } from "./links" |
8 | | -import type { PageSlug } from "./product-data" |
| 8 | +import { anomalyApps, appLink } from "./links" |
| 9 | +import { SectionHeading } from "./on-this-page" |
9 | 10 | import { siteSettings } from "./settings" |
10 | 11 |
|
11 | | -const [hex, opentunnel] = anomalyApps |
12 | | - |
13 | | -export const companions: Record<PageSlug, (typeof anomalyApps)[number][]> = { |
14 | | - desktop: [hex, opentunnel], |
15 | | - terminal: [opentunnel, hex], |
16 | | - mobile: [hex, opentunnel], |
17 | | - sdk: [opentunnel, hex], |
18 | | - ide: [opentunnel, hex], |
19 | | - mini: [opentunnel, hex], |
20 | | -} |
21 | | - |
22 | 12 | /** |
23 | | - * "More open source products": the apps in one row, like an app store shelf (icon, |
24 | | - * name, category, Free button). On phones the row scrolls sideways. The `companionStyle` setting |
25 | | - * swaps the grey tiles for a ruled grid or a ruled list. |
| 13 | + * "Works great with OpenCode": Anomaly's apps in one row, like an app store shelf (icon, name, |
| 14 | + * category, Free button), the same on every product page. On phones the row scrolls sideways. The |
| 15 | + * `companionStyle` setting swaps the ruled grid for grey tiles or a ruled list. |
26 | 16 | */ |
27 | | -export function Companions(props: { product: PageSlug }) { |
| 17 | +export function Companions() { |
28 | 18 | const i18n = useI18n() |
| 19 | + const language = useLanguage() |
29 | 20 | const appCopy = useArea("apps", appsSource) |
30 | 21 | return ( |
31 | | - <section |
32 | | - data-component="companions" |
33 | | - data-section="companions" |
34 | | - data-design="companionStyle" |
35 | | - data-style={siteSettings.companionStyle} |
36 | | - aria-label={i18n.t("site.companions")} |
37 | | - > |
38 | | - <ul data-slot="track"> |
39 | | - <For each={companions[props.product]}> |
40 | | - {(app) => ( |
41 | | - <li data-component="companion"> |
42 | | - <span data-slot="icon" aria-hidden="true" /> |
43 | | - <span data-slot="text"> |
44 | | - <a data-slot="name" href={app.href} target="_blank" rel="noopener"> |
45 | | - {app.name} |
46 | | - <NewTab /> |
47 | | - </a> |
48 | | - <span data-slot="body">{appCopy()[app.id].category}</span> |
49 | | - </span> |
50 | | - <span data-slot="action"> |
51 | | - {/* The same link as the name, so screen readers and the tab order skip it. */} |
52 | | - <a data-slot="get" href={app.href} target="_blank" rel="noopener" tabindex="-1" aria-hidden="true"> |
53 | | - {i18n.t("site.companions.free")} |
54 | | - </a> |
55 | | - </span> |
56 | | - </li> |
57 | | - )} |
58 | | - </For> |
59 | | - </ul> |
| 22 | + <section data-component="block" data-slot="product-companions" data-section="companions"> |
| 23 | + <SectionHeading id="works-with-opencode" title={i18n.t("site.companions")} label /> |
| 24 | + <div data-component="companions" data-design="companionStyle" data-style={siteSettings.companionStyle}> |
| 25 | + <ul data-slot="track"> |
| 26 | + <For each={anomalyApps}> |
| 27 | + {(app) => { |
| 28 | + const link = appLink(app, language.route) |
| 29 | + const target = link.external ? "_blank" : undefined |
| 30 | + const rel = link.external ? "noopener" : undefined |
| 31 | + return ( |
| 32 | + <li data-component="companion"> |
| 33 | + {/* The icon and name are one link, the row's only stop; the row is its target. */} |
| 34 | + <a data-slot="link" href={link.href} target={target} rel={rel}> |
| 35 | + <span data-slot="icon" aria-hidden="true"> |
| 36 | + <img src={app.icon} width="56" height="56" alt="" loading="lazy" /> |
| 37 | + </span> |
| 38 | + <span data-slot="name"> |
| 39 | + {app.name} |
| 40 | + <Show when={link.external}> |
| 41 | + <NewTab /> |
| 42 | + </Show> |
| 43 | + </span> |
| 44 | + </a> |
| 45 | + <span data-slot="body">{appCopy()[app.id].category}</span> |
| 46 | + {/* The same link again, so screen readers and the tab order skip it. */} |
| 47 | + <a |
| 48 | + data-slot="get" |
| 49 | + href={link.href} |
| 50 | + target={target} |
| 51 | + rel={rel} |
| 52 | + tabindex="-1" |
| 53 | + aria-hidden="true" |
| 54 | + > |
| 55 | + {i18n.t("site.companions.free")} |
| 56 | + </a> |
| 57 | + </li> |
| 58 | + ) |
| 59 | + }} |
| 60 | + </For> |
| 61 | + </ul> |
| 62 | + </div> |
60 | 63 | </section> |
61 | 64 | ) |
62 | 65 | } |
0 commit comments