Skip to content

Commit 5422ed6

Browse files
Merge pull request #653 from mbaldessari/add-per-pattern-logo
Support per-pattern logos
2 parents 3b9036d + f92b363 commit 5422ed6

4 files changed

Lines changed: 28 additions & 2 deletions

File tree

console/src/api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ export async function fetchAllPatterns(): Promise<{
5858
const patterns = await Promise.all(
5959
catalog.patterns.map(async (key) => {
6060
const pattern = await fetchPattern(key);
61-
return { ...pattern, catalogKey: key };
61+
const logo = pattern.logo
62+
? /^https?:\/\//.test(pattern.logo)
63+
? pattern.logo
64+
: `${PATTERN_UI_CATALOG_BASE_URL}/${key}/${pattern.logo}`
65+
: undefined;
66+
return { ...pattern, catalogKey: key, logo };
6267
}),
6368
);
6469
return {

console/src/components/PatternCatalogPage.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
object-fit: contain;
1010
}
1111

12+
.patterns-operator__pattern-logo {
13+
max-height: 32px;
14+
object-fit: contain;
15+
}
16+
1217
.patterns-operator__card-field {
1318
margin-bottom: 4px;
1419
}

console/src/components/PatternCatalogPage.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,22 @@ export default function PatternCatalogPage() {
342342
isDisabled ? ' patterns-operator__card--disabled' : ''
343343
}`}
344344
>
345-
<CardHeader>
345+
<CardHeader
346+
actions={
347+
pattern.logo
348+
? {
349+
actions: (
350+
<img
351+
src={pattern.logo}
352+
alt={`${pattern.display_name} logo`}
353+
className="patterns-operator__pattern-logo"
354+
/>
355+
),
356+
hasNoOffset: true,
357+
}
358+
: undefined
359+
}
360+
>
346361
<Tooltip content={TIER_DESCRIPTIONS[pattern.tier] || pattern.tier}>
347362
<Label
348363
color={TIER_COLORS[pattern.tier] || 'grey'}

console/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface Pattern {
4848
requirements?: PatternRequirements;
4949
extra_features?: ExtraFeatures;
5050
external_requirements?: ExternalRequirements;
51+
logo?: string;
5152
/** The catalog directory key used to fetch this pattern. */
5253
catalogKey?: string;
5354
}

0 commit comments

Comments
 (0)