Skip to content

Commit 786db2d

Browse files
authored
chore(core): added icons to spec files in sidebar (event-catalog#1909)
* chore(core): added icons to spec files in sidebar * Create beige-nails-wonder.md * chore(core): added icons to spec files in sidebar
1 parent fd5bd40 commit 786db2d

File tree

9 files changed

+36
-6
lines changed

9 files changed

+36
-6
lines changed

.changeset/beige-nails-wonder.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@eventcatalog/core": patch
3+
---
4+
5+
chore(core): added icons to spec files in sidebar
Lines changed: 2 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

eventcatalog/src/components/SideNav/NestedSideBar/__tests__/sidebar-builder.spec.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,24 @@ describe('getNestedSideBarData', () => {
896896
const serviceNode = getNavigationConfigurationByKey('service:ShippingService:0.0.1', navigationData);
897897
const apiContractsSection = getChildNodeByTitle('API & Contracts', serviceNode.pages ?? []);
898898
expect(apiContractsSection.pages).toEqual([
899-
{ type: 'item', title: 'OpenAPI (OpenAPI)', href: '/docs/services/ShippingService/0.0.1/spec/openapi' },
900-
{ type: 'item', title: 'AsyncAPI (AsyncAPI)', href: '/docs/services/ShippingService/0.0.1/asyncapi/asyncapi' },
901-
{ type: 'item', title: 'GraphQL (GraphQL)', href: '/docs/services/ShippingService/0.0.1/graphql/graphql' },
899+
{
900+
type: 'item',
901+
title: 'OpenAPI',
902+
leftIcon: '/icons/openapi-black.svg',
903+
href: '/docs/services/ShippingService/0.0.1/spec/openapi',
904+
},
905+
{
906+
type: 'item',
907+
title: 'AsyncAPI',
908+
leftIcon: '/icons/asyncapi-black.svg',
909+
href: '/docs/services/ShippingService/0.0.1/asyncapi/asyncapi',
910+
},
911+
{
912+
type: 'item',
913+
title: 'GraphQL',
914+
leftIcon: '/icons/graphql-black.svg',
915+
href: '/docs/services/ShippingService/0.0.1/graphql/graphql',
916+
},
902917
]);
903918
});
904919
});

eventcatalog/src/components/SideNav/NestedSideBar/builders/service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,24 @@ export const buildServiceNode = (service: CollectionEntry<'services'>, owners: a
8080
pages: [
8181
...openAPISpecifications.map((specification) => ({
8282
type: 'item',
83-
title: `${specification.name} (OpenAPI)`,
83+
title: `${specification.name}`,
84+
leftIcon: '/icons/openapi-black.svg',
8485
href: buildUrl(
8586
`/docs/services/${service.data.id}/${service.data.version}/spec/${specification.filenameWithoutExtension}`
8687
),
8788
})),
8889
...asyncAPISpecifications.map((specification) => ({
8990
type: 'item',
90-
title: `${specification.name} (AsyncAPI)`,
91+
title: `${specification.name}`,
92+
leftIcon: '/icons/asyncapi-black.svg',
9193
href: buildUrl(
9294
`/docs/services/${service.data.id}/${service.data.version}/asyncapi/${specification.filenameWithoutExtension}`
9395
),
9496
})),
9597
...graphQLSpecifications.map((specification) => ({
9698
type: 'item',
97-
title: `${specification.name} (GraphQL)`,
99+
title: `${specification.name}`,
100+
leftIcon: '/icons/graphql-black.svg',
98101
href: buildUrl(
99102
`/docs/services/${service.data.id}/${service.data.version}/graphql/${specification.filenameWithoutExtension}`
100103
),

eventcatalog/src/components/SideNav/NestedSideBar/builders/shared.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type NavNode = {
1717
type: 'group' | 'item';
1818
title: string;
1919
icon?: string; // Lucide icon name
20+
leftIcon?: string; // Path to SVG icon shown on the left of the label
2021
href?: string; // URL (for leaf items)
2122
external?: boolean; // If true, the item will open in a new tab
2223
pages?: ChildRef[]; // Can mix keys and inline nodes

eventcatalog/src/components/SideNav/NestedSideBar/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ export default function NestedSideBar() {
776776
<IconComponent className="w-4 h-4" />
777777
</span>
778778
)}
779+
{item.leftIcon && <img src={item.leftIcon} alt="" className="w-4 h-4 flex-shrink-0" />}
779780
<span
780781
className={cn(
781782
'text-[13px] truncate',

examples/default/domains/E-Commerce/subdomains/Orders/services/OrdersService/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ schemaPath: openapi-v1.yml
3636
specifications:
3737
- type: asyncapi
3838
path: order-service-asyncapi.yaml
39+
name: AsyncAPI
3940
- type: openapi
4041
path: openapi-v1.yml
4142
name: v1 API

0 commit comments

Comments
 (0)