From 1c1856fff8751ffdd22814636e7fe56d4355314f Mon Sep 17 00:00:00 2001 From: Jong <95050610+JongSinister@users.noreply.github.com> Date: Thu, 26 Dec 2024 21:08:42 +0700 Subject: [PATCH] Feat/UI/course card (#724) * add course-card and recommended-tag * format course card code * add mobile course-card & stories * add recommended-tag storybook * fix: course-card responsive style * fix: course-card type declaration * chore: format * update dot size * clear coursecard default prop value --------- Co-authored-by: Patthapol Kittikun Co-authored-by: Nutthapat Pongtanyavichai --- apps/web/src/routes/+page.svelte | 15 ++++- .../course-card/course-card.stories.svelte | 43 +++++++++++++- .../molecule/course-card/course-card.svelte | 56 +++++++++---------- .../components/molecule/course-card/index.ts | 15 +++++ 4 files changed, 95 insertions(+), 34 deletions(-) diff --git a/apps/web/src/routes/+page.svelte b/apps/web/src/routes/+page.svelte index 6d2083eec..31c7ab225 100644 --- a/apps/web/src/routes/+page.svelte +++ b/apps/web/src/routes/+page.svelte @@ -40,7 +40,20 @@

Testtsetst

- +

RecommendedTag

diff --git a/packages/ui/src/components/molecule/course-card/course-card.stories.svelte b/packages/ui/src/components/molecule/course-card/course-card.stories.svelte index bb98df617..11969fcbd 100644 --- a/packages/ui/src/components/molecule/course-card/course-card.stories.svelte +++ b/packages/ui/src/components/molecule/course-card/course-card.stories.svelte @@ -22,6 +22,16 @@ }, course: { control: false, + defaultValue: { + code: '0123101', + name: 'PARAGRAPH WRITING', + credit: 3, + gened: ['HU'], + seat: 24, + maxseat: 305, + review: 14, + days: ['MO', 'TU', 'WE'], + }, }, }, }) @@ -29,6 +39,35 @@ - + - + diff --git a/packages/ui/src/components/molecule/course-card/course-card.svelte b/packages/ui/src/components/molecule/course-card/course-card.svelte index 78c4afaa4..d64d71ebe 100644 --- a/packages/ui/src/components/molecule/course-card/course-card.svelte +++ b/packages/ui/src/components/molecule/course-card/course-card.svelte @@ -7,19 +7,11 @@ import { DayChip } from '../../atom/day-chip/index.js' import { GenedChip } from '../../atom/gened-chip/index.js' import { RecommendedTag } from '../../atom/recommended-tag/index.js' + import type { Course } from './index.js' interface Props { class?: string | undefined | null - course?: { - code: string - name: string - credit: number - gened: ('HU' | 'SC' | 'SO' | 'IN')[] - seat: number - maxseat: number - review: number - days: ('MO' | 'TU' | 'WE' | 'TH' | 'FR' | 'SA' | 'SU')[] - } + course?: Course selected?: boolean recommended?: boolean [key: string]: unknown @@ -27,16 +19,7 @@ let { class: className = undefined, - course = { - code: '0123101', - name: 'PARAGRAPH WRITING', - credit: 3, - gened: ['HU'], - seat: 24, - maxseat: 305, - review: 14, - days: ['MO', 'TU', 'WE'], - }, + course, selected = $bindable(false), recommended = false, ...rest @@ -49,7 +32,7 @@
{course.code}
-
{course.name}
+
+ {course.name} +
{#each course.gened as gened} @@ -72,11 +57,11 @@
- {course.credit} āļŦāļ™āđˆāļ§āļĒāļāļīāļ• āļ—āļĩāđˆāļ™āļąāđˆāļ‡ GenEd {course.seat} - / - {course.maxseat} - - {course.review} āļĢāļĩāļ§āļīāļ§ + {course.credit} āļŦāļ™āđˆāļ§āļĒāļāļīāļ• + + āļ—āļĩāđˆāļ™āļąāđˆāļ‡ GenEd {course.seat} / {course.maxseat} + + {course.review} āļĢāļĩāļ§āļīāļ§
{#each course.days as day} @@ -85,20 +70,29 @@
- + āđ€āļĨāļ·āļ­āļāđ€āļ‹āļ„āļŠāļąāļ™ + {#if !selected} {:else} - {/if} diff --git a/packages/ui/src/components/molecule/course-card/index.ts b/packages/ui/src/components/molecule/course-card/index.ts index c47077c4d..07dfbe35f 100644 --- a/packages/ui/src/components/molecule/course-card/index.ts +++ b/packages/ui/src/components/molecule/course-card/index.ts @@ -1 +1,16 @@ export { default as CourseCard } from './course-card.svelte' +import type { Day } from '../day-chip' +import type { Type } from '../gened-chip' + +type Course = { + code: string + name: string + credit: number + gened: Type[] + seat: number + maxseat: number + review: number + days: Day[] +} + +export type { Course }