-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): added ability to filter by badges (#1004)
* feat(core): added ability to filter by badges * Create sharp-timers-agree.md
- Loading branch information
Showing
11 changed files
with
92 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@eventcatalog/core": patch | ||
--- | ||
|
||
feat(core): added ability to filter by badges |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
eventcatalog/src/components/Tables/columns/SharedColumns.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { createColumnHelper } from '@tanstack/react-table'; | ||
import { Tag } from 'lucide-react'; | ||
import { filterByBadge } from '../filters/custom-filters'; | ||
export const createBadgesColumn = <T extends { data: { badges?: any[] } }>( | ||
columnHelper: ReturnType<typeof createColumnHelper<T>> | ||
) => { | ||
return columnHelper.accessor((row) => row.data.badges, { | ||
id: 'badges', | ||
header: () => <span>Badges</span>, | ||
cell: (info) => { | ||
const item = info.row.original; | ||
const badges = item.data.badges || []; | ||
|
||
if (badges?.length === 0 || !badges) | ||
return <div className="font-light text-sm text-gray-400/60 text-left italic">No badges documented</div>; | ||
|
||
return ( | ||
<ul> | ||
{badges.map((badge: any, index: number) => { | ||
return ( | ||
<li key={`${badge.id}-${index}`} className="py-1 group font-light "> | ||
<div className="group-hover:text-primary flex space-x-1 items-center "> | ||
<div className="flex items-center border border-gray-300 shadow-sm rounded-md"> | ||
<span className="flex items-center"> | ||
<span className={`bg-${badge.backgroundColor}-500 h-full rounded-tl rounded-bl p-1`}> | ||
{badge.icon && <badge.icon className="h-4 w-4 text-white" />} | ||
{!badge.icon && <Tag className="h-4 w-4 text-white" />} | ||
</span> | ||
<span className="leading-none px-2 group-hover:underline ">{badge.content}</span> | ||
</span> | ||
</div> | ||
</div> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
); | ||
}, | ||
meta: { | ||
filterVariant: 'badges', | ||
}, | ||
filterFn: filterByBadge, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.