Skip to content

Commit 43f4962

Browse files
ericyangpanclaude
andcommitted
refactor(components): refactor product components
Update product components and refactor scripts for improved functionality. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 38168c9 commit 43f4962

File tree

7 files changed

+36
-43
lines changed

7 files changed

+36
-43
lines changed

scripts/refactor/export-vendors.ts

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ const VENDORS_DIR = path.join(MANIFESTS_DIR, 'vendors')
1919
interface VendorData {
2020
name: string
2121
websiteUrl: string | null
22-
docsUrl: string | null
2322
verified: boolean
2423
communityUrls: CommunityUrls | null
25-
i18n: Record<string, { description?: string }> | null
24+
translations: Record<string, { description?: string }> | null
2625
}
2726

2827
interface CommunityUrls {
@@ -39,10 +38,9 @@ interface VendorObject {
3938
id: string
4039
name: string
4140
description: string
42-
i18n: Record<string, { description?: string }>
43-
websiteUrl: string | null
44-
docsUrl: string | null
41+
translations: Record<string, { description?: string }>
4542
verified: boolean
43+
websiteUrl: string | null
4644
communityUrls: CommunityUrls
4745
}
4846

@@ -164,29 +162,25 @@ function mergeVendorData(existing: VendorData, newData: VendorData): VendorData
164162
merged.websiteUrl = newData.websiteUrl
165163
}
166164

167-
if (!merged.docsUrl && newData.docsUrl) {
168-
merged.docsUrl = newData.docsUrl
169-
}
170-
171165
if (merged.verified === undefined && newData.verified !== undefined) {
172166
merged.verified = newData.verified
173167
}
174168

175169
// Merge communityUrls
176170
merged.communityUrls = mergeCommunityUrls(merged.communityUrls, newData.communityUrls)
177171

178-
// Merge i18n if both exist
179-
if (newData.i18n) {
180-
if (!merged.i18n) {
181-
merged.i18n = {}
172+
// Merge translations if both exist
173+
if (newData.translations) {
174+
if (!merged.translations) {
175+
merged.translations = {}
182176
}
183-
// Merge i18n descriptions for each locale
184-
for (const locale of Object.keys(newData.i18n)) {
185-
if (!merged.i18n[locale]) {
186-
merged.i18n[locale] = {}
177+
// Merge translations descriptions for each locale
178+
for (const locale of Object.keys(newData.translations)) {
179+
if (!merged.translations[locale]) {
180+
merged.translations[locale] = {}
187181
}
188-
if (!merged.i18n[locale].description && newData.i18n[locale]?.description) {
189-
merged.i18n[locale].description = newData.i18n[locale].description
182+
if (!merged.translations[locale].description && newData.translations[locale]?.description) {
183+
merged.translations[locale].description = newData.translations[locale].description
190184
}
191185
}
192186
}
@@ -207,13 +201,13 @@ function extractVendorData(manifest: Record<string, unknown>): VendorData | null
207201
const vendorData: VendorData = {
208202
name: manifest.vendor as string,
209203
websiteUrl: (manifest.websiteUrl as string | null) || null,
210-
docsUrl: (manifest.docsUrl as string | null) || null,
211204
verified:
212205
(manifest.verified as boolean | undefined) !== undefined
213206
? (manifest.verified as boolean)
214207
: false,
215208
communityUrls: (manifest.communityUrls as CommunityUrls | null) || null,
216-
i18n: (manifest.i18n as Record<string, { description?: string }> | null) || null,
209+
translations:
210+
(manifest.translations as Record<string, { description?: string }> | null) || null,
217211
}
218212

219213
return vendorData
@@ -233,10 +227,9 @@ function createVendorObject(vendorId: string, vendorData: VendorData): VendorObj
233227
id: vendorId,
234228
name: vendorData.name,
235229
description: (vendorData as { description?: string }).description || defaultDescription,
236-
i18n: vendorData.i18n || {},
237-
websiteUrl: vendorData.websiteUrl || null,
238-
docsUrl: vendorData.docsUrl || null,
230+
translations: vendorData.translations || {},
239231
verified: vendorData.verified !== undefined ? vendorData.verified : false,
232+
websiteUrl: vendorData.websiteUrl || null,
240233
communityUrls: mergeCommunityUrls(null, vendorData.communityUrls),
241234
}
242235

scripts/refactor/sort-locales-fields.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22

33
/**
4-
* Sort fields in all locales JSON files alphabetically
5-
* This script recursively processes all JSON files in the locales directory
4+
* Sort fields in all translation JSON files alphabetically
5+
* This script recursively processes all JSON files in the translations directory
66
* and sorts their object keys alphabetically (including nested objects).
77
*/
88

@@ -13,7 +13,7 @@ import { fileURLToPath } from 'node:url'
1313
const __filename = fileURLToPath(import.meta.url)
1414
const __dirname = path.dirname(__filename)
1515
const ROOT_DIR = path.resolve(__dirname, '../..')
16-
const LOCALES_DIR = path.join(ROOT_DIR, 'locales')
16+
const LOCALES_DIR = path.join(ROOT_DIR, 'translations')
1717

1818
interface JsonFile {
1919
fullPath: string
@@ -98,13 +98,13 @@ async function findJsonFiles(dirPath: string, basePath = dirPath): Promise<JsonF
9898
* Main function
9999
*/
100100
async function main(): Promise<void> {
101-
console.log('🔄 Sorting locales JSON files alphabetically...\n')
101+
console.log('🔄 Sorting translations JSON files alphabetically...\n')
102102

103-
// Find all JSON files in locales directory
103+
// Find all JSON files in translations directory
104104
const jsonFiles = await findJsonFiles(LOCALES_DIR)
105105

106106
if (jsonFiles.length === 0) {
107-
console.log('⚠️ No JSON files found in locales directory')
107+
console.log('⚠️ No JSON files found in translations directory')
108108
return
109109
}
110110

src/components/product/LinkCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ export function LinkCardGrid<K extends string>({
9393
gridCols = 'grid-cols-1 md:grid-cols-3',
9494
}: LinkCardGridProps<K>) {
9595
return (
96-
<section className="my-[var(--spacing-lg)] border-b border-[var(--color-border)]">
96+
<section className="py-[var(--spacing-xl)] border-b border-[var(--color-border)]">
9797
<div className="max-w-8xl mx-auto px-[var(--spacing-md)]">
98-
<h2 className="text-2xl font-semibold tracking-[-0.02em] mb-[var(--spacing-sm)]">
98+
<h2 className="text-2xl font-semibold tracking-[-0.02em] mb-[var(--spacing-md)]">
9999
{title}
100100
</h2>
101101

102-
<div className={`grid ${gridCols} gap-[var(--spacing-md)] mt-[var(--spacing-lg)]`}>
102+
<div className={`grid ${gridCols} gap-[var(--spacing-md)] mt-[var(--spacing-xl)]`}>
103103
{links.map(link => (
104104
<LinkCard
105105
key={link.key}

src/components/product/ProductCommands.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ function CommandSectionItem({ value, label }: Omit<CommandSection, 'labelKey'>)
1919
if (!value) return null
2020

2121
return (
22-
<section className="py-[var(--spacing-lg)] border-b border-[var(--color-border)]">
22+
<section className="py-[var(--spacing-xl)] border-b border-[var(--color-border)]">
2323
<div className="max-w-8xl mx-auto px-[var(--spacing-md)]">
24-
<h2 className="text-2xl font-semibold tracking-[-0.02em] mb-[var(--spacing-sm)]">
24+
<h2 className="text-2xl font-semibold tracking-[-0.02em] mb-[var(--spacing-md)]">
2525
{label}
2626
</h2>
2727

28-
<div className="border border-[var(--color-border)] overflow-hidden mt-[var(--spacing-md)]">
28+
<div className="border border-[var(--color-border)] overflow-hidden mt-[var(--spacing-lg)]">
2929
<pre className="p-[var(--spacing-md)] text-sm leading-relaxed overflow-x-auto bg-[var(--color-bg)]">
3030
$ {value}
3131
</pre>

src/components/product/ProductHero.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ export function ProductHero({
105105
</div>
106106

107107
{/* Description */}
108-
<p className="text-lg text-[var(--color-text-secondary)] font-light leading-relaxed mb-[var(--spacing-lg)]">
108+
<p className="text-lg text-[var(--color-text-secondary)] font-light leading-relaxed mb-[var(--spacing-xl)]">
109109
{description}
110110
</p>
111111
</div>
112112

113113
{/* Metadata Bar - Content-based width */}
114114
{(vendor || latestVersion || license || (additionalInfo && additionalInfo.length > 0)) && (
115115
<div className="flex justify-center mb-[var(--spacing-lg)] px-[var(--spacing-md)]">
116-
<div className="inline-flex items-center gap-[var(--spacing-sm)] flex-wrap px-[var(--spacing-md)] py-[var(--spacing-md)] border border-[var(--color-border)] text-sm">
116+
<div className="inline-flex items-center gap-[var(--spacing-md)] flex-wrap px-[var(--spacing-md)] py-[var(--spacing-sm)] border border-[var(--color-border)] text-sm">
117117
{vendor && (
118118
<div className="flex gap-1">
119119
<span className="text-[var(--color-text-muted)]">

src/components/product/ProductPricing.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ export function ProductPricing({ pricing, pricingUrl }: ProductPricingProps) {
1414
}
1515

1616
return (
17-
<section className="py-[var(--spacing-lg)] border-b border-[var(--color-border)]">
17+
<section className="py-[var(--spacing-xl)] border-b border-[var(--color-border)]">
1818
<div className="max-w-8xl mx-auto px-[var(--spacing-md)]">
19-
<h2 className="text-2xl font-semibold tracking-[-0.02em] mb-[var(--spacing-sm)]">
19+
<h2 className="text-2xl font-semibold tracking-[-0.02em] mb-[var(--spacing-md)]">
2020
{tShared('terms.pricing')}
2121
</h2>
2222

23-
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-[var(--spacing-md)] mt-[var(--spacing-lg)]">
23+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-[var(--spacing-md)] mt-[var(--spacing-xl)]">
2424
{pricing.map(tier => (
2525
<div
2626
key={tier.name}

src/components/product/RelatedProducts.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ export function RelatedProducts({ products = [] }: RelatedProductsProps) {
7171
}
7272

7373
return (
74-
<section className="py-[var(--spacing-lg)] border-b border-[var(--color-border)]">
74+
<section className="py-[var(--spacing-xl)] border-b border-[var(--color-border)]">
7575
<div className="max-w-8xl mx-auto px-[var(--spacing-md)]">
76-
<h2 className="text-xl font-semibold tracking-tight mb-[var(--spacing-md)]">
76+
<h2 className="text-xl font-semibold tracking-tight mb-[var(--spacing-lg)]">
7777
{tComponent('relatedProducts.title')}
7878
</h2>
7979

0 commit comments

Comments
 (0)