Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): versions now show as a dropdown #557

Merged
merged 2 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-drinks-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eventcatalog/core": patch
---

feat(core): versions now show as a dropdown
26 changes: 16 additions & 10 deletions src/components/Lists/VersionList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@ interface Props {

const { versions, collectionItem } = Astro.props;
const currentPath = Astro.url.pathname;

---

<div class="space-y-2 my-2 mb-8">
<span class="font-light text-black group-data-[hover]:text-black/80 capitalize">Versions ({collectionItem.data.versions?.length})</span>
<ul class="space-x-2 flex">
{versions.map((version) => {
const isCurrent = currentPath.includes(version);
return <li>
<a href={`/docs/${collectionItem.collection}/${collectionItem.data.id}/${version}`} class={`inline-flex items-center rounded-md px-2 py-1 text-xs font-medium text-indigo-700 ring-1 ring-inset ring-indigo-700/10 hover:bg-purple-100 hover:underline ${isCurrent ? 'bg-purple-100 text-purple-500 underline ' : 'bg-white'}`}>
<select id="version" class="block bg-gray-50 rounded-md border border-gray-200 px-1 py-0.5 text-xs">
{versions.map((version) => {
const isCurrent = currentPath.includes(version);
return <option selected={isCurrent} value={`/docs/${collectionItem.collection}/${collectionItem.data.id}/${version}`} class={`inline-flex items-center rounded-md px-2 py-1 text-xs text-indigo-700 ring-1 ring-inset ring-indigo-700/10 hover:bg-purple-100 hover:underline ${isCurrent ? 'bg-purple-100 text-purple-500 underline ' : 'bg-white'}`}>
<span>
v{version}
{version === collectionItem.data.latestVersion && <span>(latest)</span>}
</span>
</a>
</li>
})}
</ul>
</div>
</option>
})}
</select>
</div>

<script>
document.getElementById('version')?.addEventListener('change', (e: any) => {
if (!e.target) return
window.location.href = e.target.value;
})
</script>