feat: add course card context menu on course page (#118)

* feat: add context menu for course card component

* chore: add functions for context menu options

* chore: replace console.log statements with alert

* chore: revert changes to package.json

* chore: function declaration cleanup

* chore: fix package.json space formatting
This commit is contained in:
Tioluwani Kolawole
2023-12-20 20:44:00 +03:00
committed by GitHub
parent cad8817fed
commit 0f8f1c98d8
2 changed files with 38 additions and 1 deletions
@@ -1,8 +1,11 @@
<script lang="ts">
import { Tag, ImageLoader, SkeletonPlaceholder } from 'carbon-components-svelte';
import { Tag, ImageLoader, SkeletonPlaceholder, ContextMenu, ContextMenuDivider, ContextMenuOption, } from 'carbon-components-svelte';
import getCurrencyFormatter from '$lib/utils/functions/getCurrencyFormatter';
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
import CopyFile from "carbon-icons-svelte/lib/CopyFile.svelte";
import Share from "carbon-icons-svelte/lib/Share.svelte";
import UserFollow from "carbon-icons-svelte/lib/UserFollow.svelte";
export let bannerImage: string | undefined;
export let id = '';
@@ -17,12 +20,45 @@
export let isOnLandingPage = false;
export let isLMS = false;
export let progressRate = 45;
export let showContextMenu = false;
let target: any;
$: formatter = getCurrencyFormatter(currency);
function handleCloneCourse() {
// TODO: Clone course functionality
alert('WIP: Clone course');
}
function handleShareCourse() {
// TODO: Share course functionality
alert('WIP: Share course');
}
function handleInvite() {
// TODO: Invite functionality
alert('WIP: Invite people to course');
}
function handleDeleteCourse() {
// TODO: Delete course functionality
alert('WIP: Delete course');
}
</script>
{#if showContextMenu}
<ContextMenu {target}>
<ContextMenuOption indented labelText="Clone" icon={CopyFile} on:click={handleCloneCourse} />
<ContextMenuOption indented labelText="Share" icon={Share} on:click={handleShareCourse} />
<ContextMenuOption indented labelText="Invite" icon={UserFollow} on:click={handleInvite} />
<ContextMenuDivider />
<ContextMenuOption kind="danger" labelText="Delete" on:click={handleDeleteCourse} />
</ContextMenu>
{/if}
<a
rel="prefetch"
bind:this={target}
href={isOnLandingPage ? `/course/${slug}` : `/courses/${id}`}
class="text-black border border-gray rounded w-full max-w-[320px] relative hover:scale-95 transition-all ease-in-out"
>
@@ -32,6 +32,7 @@
{#each courses as courseData}
{#key courseData.id}
<Card
showContextMenu
id={courseData.id}
bannerImage={courseData.logo || '/images/classroomio-course-img-template.jpg'}
title={courseData.title}