Skip to content
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
33 changes: 21 additions & 12 deletions src/components/Chip.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@
handle_click?: () => void
children: Snippet
size?: 'small' | 'medium'
selected?: boolean
link?: string
}

let { handle_click, children, size = 'medium' }: Props = $props()
let {
handle_click,
children,
size = 'medium',
selected = false,
link
}: Props = $props()
</script>

{#if handle_click !== undefined}
<button class="chip {size}" onclick={handle_click}>
{#if link}
<a href={link} class="chip {size}" onclick={handle_click} aria-current={selected}>
{@render children()}
</button>
{:else}
<div class="chip {size}">
</a>
{:else if handle_click}
<button class="chip {size}" onclick={handle_click} aria-current={selected}>
{@render children()}
</div>
</button>
{/if}

<style>
Expand All @@ -26,6 +34,7 @@
border-radius: 100vw;
background-color: var(--secondary-bg-color);
outline: 1px solid var(--secondary-outline-color);
transition: outline-color 150ms;
}

.chip.medium {
Expand All @@ -38,12 +47,12 @@
padding: 0.15rem 0.85rem;
}

button.chip {
transition: outline-color 150ms;
.chip:hover,
.chip:focus-visible {
outline-color: var(--outline-color);
}

button.chip:hover,
button.chip:focus-visible {
outline-color: var(--outline-color);
a.chip {
text-decoration: none;
}
</style>
16 changes: 6 additions & 10 deletions src/components/TagList.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts">
import { goto } from '$app/navigation'
import type { StructureType } from '$lib/commons/types'
import Fa from 'svelte-fa'
import Chip from './Chip.svelte'
Expand All @@ -13,19 +12,16 @@
}

let { type, tags, sort }: Props = $props()

function filter_by_tag(tag: string) {
if (sort === 'structure') {
goto(`/${type}-list/${tag}`)
} else {
goto(`/${type}-properties/${tag}`)
}
}
</script>

<ChipGroup>
{#each tags as tag}
<Chip size="small" handle_click={() => filter_by_tag(tag)}>
<Chip
size="small"
link={sort === 'structure'
? `/${type}-list/${tag}`
: `/${type}-properties/${tag}`}
>
<Fa icon={faTag} color="var(--secondary-text-color)" />
&nbsp;{tag}
</Chip>
Expand Down
57 changes: 14 additions & 43 deletions src/routes/settings/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,13 @@
<ChipGroup>
{#each THEMES as option}
{@const selected = theme.value === option}
<label class:selected>
<input
class="visually-hidden"
type="radio"
name="color"
value={option}
bind:group={theme.value}
/>
<Chip>
{option}
{#if selected}
&nbsp;
<Fa icon={faCheckCircle} />
{/if}
</Chip>
</label>
<Chip handle_click={() => (theme.value = option)} {selected}>
{option}
{#if selected}
&nbsp;
<Fa icon={faCheckCircle} />
{/if}
</Chip>
{/each}
</ChipGroup>
</section>
Expand All @@ -53,34 +44,14 @@
<ChipGroup>
{#each [true, false] as allow}
{@const selected = tracking.allow === allow}
<label class:selected>
<input
class="visually-hidden"
type="radio"
name="tracking"
value={allow}
bind:group={tracking.allow}
/>

<Chip>
{allow ? 'On' : 'Off'}
{#if selected}
&nbsp;
<Fa icon={faCheckCircle} />
{/if}
</Chip>
</label>
<Chip handle_click={() => (tracking.allow = allow)} {selected}>
{allow ? 'On' : 'Off'}
{#if selected}
&nbsp;
<Fa icon={faCheckCircle} />
{/if}
</Chip>
{/each}
</ChipGroup>
</section>

<style>
label {
cursor: pointer;
}

label:has(:focus-visible) {
outline: 2px solid var(--outline-color);
outline-offset: 2px;
}
</style>
4 changes: 2 additions & 2 deletions tests/categories.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test("user can navigate to categories tagged with 'analysis' from the category l
await page.goto('/category-list', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'analysis',
exact: true
})
Expand All @@ -72,7 +72,7 @@ test("user can navigate to categories tagged with 'algebra' from the category de
await page.goto('/category/Grp', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'algebra',
exact: true
})
Expand Down
4 changes: 2 additions & 2 deletions tests/category-properties.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ test("user can navigate to properties tagged with 'colimits' from the property l
await page.goto('/category-properties', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'colimits',
exact: true
})
Expand Down Expand Up @@ -183,7 +183,7 @@ test("user can navigate to properties tagged with 'topos theory' from the proper
await page.goto('/category-property/cartesian_closed', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'topos theory',
exact: true
})
Expand Down
4 changes: 2 additions & 2 deletions tests/functor-properties.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ test("user can navigate to properties tagged with 'adjunctions' from the propert
await page.goto('/functor-properties', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'adjunctions',
exact: true
})
Expand Down Expand Up @@ -171,7 +171,7 @@ test("user can navigate to properties tagged with 'colimit preservation' from th
await page.goto('/functor-property/finitary', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'colimit preservation',
exact: true
})
Expand Down
4 changes: 2 additions & 2 deletions tests/functors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test("user can navigate to functors tagged with 'topology' from the functor list
await page.goto('/functor-list', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'topology',
exact: true
})
Expand All @@ -70,7 +70,7 @@ test("user can navigate to functors tagged with 'algebra' from the functor detai
await page.goto('/functor/abelianization', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'algebra',
exact: true
})
Expand Down
4 changes: 2 additions & 2 deletions tests/morphism-properties.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ test("user can navigate to properties tagged with 'types of epimorphism' from th
await page.goto('/morphism-properties', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'types of epimorphisms',
exact: true
})
Expand Down Expand Up @@ -183,7 +183,7 @@ test("user can navigate to properties tagged with 'types of monomorphisms' from
})

await page
.getByRole('button', {
.getByRole('link', {
name: 'types of monomorphisms',
exact: true
})
Expand Down
4 changes: 2 additions & 2 deletions tests/morphisms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test("user can navigate to morphisms tagged with 'algebra' from the morphism lis
await page.goto('/morphism-list', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'algebra',
exact: true
})
Expand All @@ -70,7 +70,7 @@ test("user can navigate to morphisms tagged with 'set theory' from the morphism
await page.goto('/morphism/id_X', { waitUntil: 'networkidle' })

await page
.getByRole('button', {
.getByRole('link', {
name: 'set theory',
exact: true
})
Expand Down