Skip to content

Commit

Permalink
Add icons for subjects
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlurak committed Jun 5, 2024
1 parent 1e2fd4c commit 0676530
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@
import { Icon, Clock } from 'svelte-hero-icons';
import Store from '../../utils/Store.svelte';
import { i } from '$lib/i18n/store';
import { getSubjectIcon } from '$lib/utils/icons/subjectIcons';
export let assignment: Assignment;
$: icon = getSubjectIcon(assignment.subject)
</script>

<h3>{assignment.subject}</h3>
<div class="flex items-center gap-2">
{#if icon}
<Icon src={icon} class="h-6 w-6" mini />
{/if}

<h3>{assignment.subject}</h3>
</div>

<p>{assignment.description}</p>

Expand Down
93 changes: 93 additions & 0 deletions src/lib/utils/icons/subjectIcons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {
Banknotes,
Beaker,
Bolt,
BugAnt,
BuildingLibrary,
Calculator,
ComputerDesktop,
HomeModern,
Language,
LightBulb,
MusicalNote,
PaintBrush,
type IconSource
} from 'svelte-hero-icons';

type IconObj = {
subjects: string[];
icon: IconSource;
};

const iconObjs: IconObj[] = [
{
subjects: ['informatik', 'info', 'computer science', 'programming'],
icon: ComputerDesktop
},
{
subjects: ['biologie', 'bio', 'biology'],
icon: BugAnt
},
{
subjects: ['biologie', 'bio', 'biology'],
icon: Beaker
},
{
subjects: ['biologie', 'bio', 'biology'],
icon: Beaker
},
{
subjects: [
'deutsch',
'englisch',
'spanisch',
'german',
'english',
'spanish',
'latin',
'latein',
'klingon',
'japanese',
'japanisch'
],
icon: Language
},
{
subjects: ['geschichte', 'history'],
icon: BuildingLibrary
},
{
subjects: ['art', 'kunst', 'malen', 'drawing', 'draw'],
icon: PaintBrush
},
{
subjects: ['mathe', 'mathematik', 'math', 'mathemathics', 'rechnen', 'calculus', 'algebra'],
icon: Calculator
},
{
subjects: ['musik', 'music'],
icon: MusicalNote
},
{
subjects: ['physik', 'physics'],
icon: Bolt
},
{
subjects: ['reli', 'religion'],
icon: LightBulb
},
{
subjects: ['sport', 'pe'],
icon: HomeModern
},
{
subjects: ['powi', 'politik', 'wirtschaft', 'economy'],
icon: Banknotes
}
];

export function getSubjectIcon(subject: string) {
const subj = subject.trim().toLowerCase();

return iconObjs.find(({ subjects }) => subjects.includes(subj))?.icon ?? null;
}

0 comments on commit 0676530

Please sign in to comment.