-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
176 additions
and
46 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
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,54 @@ | ||
<script lang="ts"> | ||
import Chips from '$lib/components/filter/Chips.svelte'; | ||
import Store from '$lib/components/utils/Store.svelte'; | ||
import { i } from '$lib/i18n/store'; | ||
import type { OrderKey, SortOrder } from '$lib/types/sorting'; | ||
import { objectEntries } from '$lib/utils/objects/entries'; | ||
import { createEventDispatcher } from 'svelte'; | ||
import { ArrowDownRight, ArrowUpRight } from 'svelte-hero-icons'; | ||
const ORDER_KEYS = [ | ||
'due', | ||
'from', | ||
'subject', | ||
'description', | ||
'versionsCount' | ||
] as const satisfies OrderKey[]; | ||
export let direction: SortOrder = 'desc'; | ||
export let orderKey: OrderKey = 'due'; | ||
const orderings = { | ||
asc: ArrowUpRight, | ||
desc: ArrowDownRight | ||
}; | ||
const dispatch = createEventDispatcher<{ | ||
change: { | ||
direction: SortOrder; | ||
orderKey: OrderKey; | ||
}; | ||
}>(); | ||
</script> | ||
|
||
<h3><Store store={i('sorting')} /></h3> | ||
<div class="flex gap-2"> | ||
<Chips | ||
bind:value={direction} | ||
options={objectEntries(orderings).map(([value, icon]) => ({ | ||
icon, | ||
value, | ||
label: i(`sorting.${value}`) | ||
}))} | ||
on:change={({ detail: direction }) => dispatch('change', { direction, orderKey })} | ||
/> | ||
|
||
<Chips | ||
bind:value={orderKey} | ||
options={ORDER_KEYS.map((value) => ({ | ||
value, | ||
label: i(`sorting.assignments.${value}`) | ||
}))} | ||
on:change={({ detail: orderKey }) => dispatch('change', { direction, orderKey })} | ||
/> | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import type { Readable } from 'svelte/motion'; | ||
import type { IconSource } from 'svelte-hero-icons'; | ||
|
||
export type Option<T> = { | ||
value: T; | ||
label: Readable<string>; | ||
|
||
icon?: IconSource; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { AssignmentProps } from '$lib/dlool/assignments/list'; | ||
import type { RemoveOneValue } from '$lib/types/utils'; | ||
|
||
export type OrderKey = RemoveOneValue<AssignmentProps['orderKey'], undefined>; | ||
export type SortOrder = 'asc' | 'desc'; |
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 @@ | ||
export type RemoveOneValue<T, R> = T extends R ? never : T; |
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