Skip to content

Commit

Permalink
fix: few design & ux issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Mokto committed Apr 30, 2024
1 parent b8bdc50 commit d466721
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/tab/tab-head-item.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<button
class={`px-4 py-2 w-full text-lg font-bold border-b-2 ${
isSelected ? 'border-b-accent-200 text-accent-200' : 'border-b-transparent'
isSelected ? 'border-b-accent-200 ' : 'border-b-transparent'
}`}
on:click={() => selectTab(tab)}
>
Expand Down
21 changes: 21 additions & 0 deletions src/lib/menu/menu-item.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@
: 'text-stripe-100'
}`}
{href}
on:click={(event) => {
if (
(window.location.pathname === '/' || window.location.pathname.indexOf('/topics') === 0) &&
(href === '/' || href.indexOf('/topics') === 0)
) {
if (href === '/') {
const element = document.getElementById('main-container');
if (element) {
element.scrollTo(0, 0);
}
} else {
const element = document.getElementById(href.split('/topics/')[1]);
if (element) {
element.scrollIntoView();
}
}
urlStore.set(href);
window.history.pushState({}, '', window.location.origin + href);
event.preventDefault();
}
}}
>
{label}
</a>
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<div class="flex h-screen pt-16 sm:pt-0">
<div
class="border-r border-stripe-200 px-4 overflow-auto pb-6 hidden sm:block w-60 min-w-60 md:w-80 md:min-w-80"
class="border-r border-stripe-200 px-4 overflow-auto pb-6 hidden sm:block w-60 min-w-60 md:w-72 md:min-w-72"
>
{#if data.logo}
<img src={data.logo} alt="" class="w-full" />
Expand Down
15 changes: 11 additions & 4 deletions src/routes/[...page]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
});
</script>

<div class="scrolled-item grid grid-cols-1 lg:grid-cols-2 gap-12 px-12 py-12">
<div
class="scrolled-item max-w-screen-xl mx-auto grid grid-cols-1 lg:grid-cols-2 gap-12 px-12 py-12"
>
<div>
<h1 class="text-2xl font-bold mb-4">Introduction</h1>
<Markdown markdown={data.description} />
Expand All @@ -63,8 +65,11 @@
<hr />

{#if data.topics}
{#each data.topics as topic}
<div class="scrolled-item grid grid-cols-1 lg:grid-cols-2 gap-12 px-12 py-12" id={topic.id}>
{#each data.topics as topic, index}
<div
class={`scrolled-item max-w-screen-xl mx-auto grid grid-cols-1 lg:grid-cols-2 gap-12 px-12 py-12 ${index == data.topics.length - 1 ? 'h-screen' : ''}`}
id={topic.id}
>
<div class={`${!topic.example ? 'col-span-2' : ''}`}>
<h1 class="text-2xl font-bold mb-4">{topic.title}</h1>
<Markdown markdown={topic.content} />
Expand All @@ -73,6 +78,8 @@
<Markdown markdown={topic.example} />
{/if}
</div>
<hr />
{#if index < data.topics.length - 1}
<hr />
{/if}
{/each}
{/if}
21 changes: 5 additions & 16 deletions src/routes/operations/[...page]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

{#key data.operationId}
{#if data.operation}
<div class="grid grid-cols-1 lg:grid-cols-2 gap-12 px-12 py-12">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-12 px-12 py-12 max-w-screen-xl mx-auto">
<div>
<h1 class="text-2xl font-bold mb-2">{data.operation.summary}</h1>
<div class="mb-4">
Expand All @@ -29,19 +29,8 @@
</div>
<hr />

{#if data.operation.queryParameters?.length}
<div class="grid grid-cols-1 gap-12 px-12 py-12">
<div>
<h2 class="text-lg font-bold mt-4 mb-2">Query Parameters</h2>
{#each data.operation.queryParameters as parameter}
<DocumentedProperty {parameter} />
{/each}
</div>
</div>
<hr />
{/if}
{#if data.operation.pathParameters?.length || data.operation.pathParameters?.length || data.operation.cookieParameters?.length || data.operation.headerParameters?.length}
<div class="grid grid-cols-1 gap-12 px-12 py-12">
{#if data.operation.pathParameters?.length || data.operation.queryParameters?.length || data.operation.cookieParameters?.length || data.operation.headerParameters?.length}
<div class="grid grid-cols-1 gap-12 px-12 py-12 max-w-screen-xl mx-auto">
<div>
<h2 class="text-lg font-bold mt-4 mb-2">Parameters</h2>
{#each data.operation.pathParameters as parameter}
Expand All @@ -62,7 +51,7 @@
{/if}

{#if data.operation.requestBody}
<div class="grid grid-cols-1 lg:grid-cols-2 gap-12 px-12 py-12">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-12 px-12 py-12 max-w-screen-xl mx-auto">
<div>
<div class="flex items-center">
<h2 class="!my-2 text-lg font-bold mt-4 mb-2">Body</h2>
Expand All @@ -88,7 +77,7 @@
<hr />
{/if}
{#if data.operation.responses}
<div class="px-12 py-12">
<div class="px-12 py-12 max-w-screen-xl mx-auto">
<Tabs>
<TabHead>
{#each Object.keys(data.operation.responses) as statusCode}
Expand Down

0 comments on commit d466721

Please sign in to comment.