Skip to content

Commit

Permalink
Merge branch 'v2' into sun/fix/navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
NhongSun committed Jan 15, 2025
2 parents 294008d + 6c67f9a commit 365e24c
Show file tree
Hide file tree
Showing 21 changed files with 934 additions and 786 deletions.
4 changes: 2 additions & 2 deletions apps/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"dependencies": {
"@repo/database": "workspace:*",
"dotenv-cli": "^8.0.0",
"drizzle-orm": "^0.38.1",
"drizzle-orm": "^0.38.3",
"postgres": "^3.4.5",
"tsx": "^4.19.2"
},
"devDependencies": {
"typescript": "^5.7.2"
"typescript": "^5.7.3"
}
}
10 changes: 5 additions & 5 deletions apps/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"@sveltejs/vite-plugin-svelte": "^5.0.3",
"@tsconfig/svelte": "^5.0.4",
"eslint": "^9.17.0",
"sass-embedded": "^1.83.0",
"sass-embedded": "^1.83.1",
"storybook": "^8.4.7",
"svelte": "^5.15.0",
"svelte-check": "^4.1.1",
"svelte": "^5.17.1",
"svelte-check": "^4.1.3",
"tailwindcss": "^3.4.17",
"tslib": "^2.8.1",
"typescript": "^5.7.2",
"vite": "^6.0.5"
"typescript": "^5.7.3",
"vite": "^6.0.7"
}
}
16 changes: 8 additions & 8 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@
"@playwright/test": "^1.49.1",
"@repo/config": "workspace:^",
"@sveltejs/adapter-node": "^5.2.11",
"@sveltejs/kit": "^2.15.0",
"@sveltejs/kit": "^2.15.2",
"@sveltejs/vite-plugin-svelte": "^5.0.3",
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "^8.18.2",
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "^8.19.1",
"autoprefixer": "^10.4.20",
"drizzle-orm": "^0.38.1",
"drizzle-orm": "^0.38.3",
"eslint": "^9.17.0",
"postcss": "^8.4.49",
"postgres": "^3.4.5",
"prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.3.2",
"svelte": "^5.15.0",
"svelte-check": "^4.1.1",
"svelte": "^5.17.1",
"svelte-check": "^4.1.3",
"tailwindcss": "^3.4.17",
"tslib": "^2.8.1",
"typescript": "^5.7.2",
"vite": "^6.0.5",
"typescript": "^5.7.3",
"vite": "^6.0.7",
"vitest": "^2.1.8"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dev": "turbo run dev",
"lint": "turbo run --continue lint",
"format": "turbo run --continue format",
"test": "turbo run --continue test",
"storybook:dev": "turbo run --filter=@app/storybook dev",
"web:dev": "turbo run --filter=@app/web dev"
},
Expand All @@ -18,5 +19,5 @@
"prettier": "^3.4.2",
"turbo": "^2.3.3"
},
"packageManager": "[email protected].1"
"packageManager": "[email protected].3"
}
8 changes: 4 additions & 4 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"format": "eslint . --fix"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "^8.18.2",
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "^8.19.1",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^2.3.3",
"eslint-plugin-prettier": "^5.2.1",
Expand All @@ -23,7 +23,7 @@
"@eslint/js": "^9.17.0",
"eslint": "^9.17.0",
"globals": "^15.14.0",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.2"
"typescript": "^5.7.3",
"typescript-eslint": "^8.19.1"
}
}
6 changes: 3 additions & 3 deletions packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
},
"dependencies": {
"@paralleldrive/cuid2": "^2.2.2",
"drizzle-orm": "^0.38.1",
"drizzle-orm": "^0.38.3",
"postgres": "^3.4.5"
},
"devDependencies": {
"@types/cli-progress": "^3.11.6",
"@types/node": "^22.10.2",
"@types/node": "^22.10.5",
"cli-progress": "^3.12.0",
"dotenv-cli": "^8.0.0",
"drizzle-kit": "^0.30.0",
"tsx": "^4.19.2",
"typescript": "^5.7.2"
"typescript": "^5.7.3"
}
}
4 changes: 2 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"@storybook/addon-svelte-csf": "^5.0.0-next.21",
"@storybook/svelte": "^8.4.7",
"@sveltejs/adapter-node": "^5.2.11",
"@sveltejs/kit": "^2.15.0",
"@sveltejs/kit": "^2.15.2",
"@sveltejs/vite-plugin-svelte": "^5.0.3",
"svelte": "^5.15.0",
"svelte": "^5.17.1",
"vitest": "^2.1.8"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/atom/rating-star/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as RatingStar } from './rating-star.svelte'
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script module lang="ts">
import { defineMeta } from '@storybook/addon-svelte-csf'
import { RatingStar } from './index.js'
const { Story } = defineMeta<typeof RatingStar>({
title: 'Atom/Rating Star',
component: RatingStar,
tags: ['autodocs'],
argTypes: {
rating: {
control: {
type: 'range',
min: 0,
max: 5,
step: 0.5,
},
},
},
})
</script>

<Story
name="Default"
args={{
rating: 3.5,
}}
/>
36 changes: 36 additions & 0 deletions packages/ui/src/components/atom/rating-star/rating-star.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script lang="ts">
import { Star } from 'lucide-svelte'
let { rating }: { rating: number } = $props()
// Calculate the number of filled and unfilled stars
const totalStars: number = 5
let filledStars: number = $derived(Math.floor(rating)) // Number of fully filled stars
let hasHalfStar: boolean = $derived(rating % 1 !== 0) // Determine if there's a half star
let emptyStars: number = $derived(
totalStars - filledStars - (hasHalfStar ? 1 : 0),
)
</script>

<div class="flex flex-row text-h3 text-primary gap-1.5">
{#each Array(filledStars) as _}
<Star fill="currentColor" />
{/each}

<!-- Optionally render a half star (if applicable) -->
{#if hasHalfStar}
<div class="flex gap-0">
<div class="relative inline-block w-6 h-6 overflow-hidden max-w-3">
<Star fill="currentColor" />
</div>
<div
class="relative inline-block w-6 h-6 overflow-hidden max-w-3 transform scale-x-[-1]"
>
<Star />
</div>
</div>
{/if}

<!-- Render unfilled stars -->
{#each Array(emptyStars) as _}
<Star />
{/each}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

<div
class={cn(
'inline-flex items-center justify-center relative text-neutral-white bg-tangerine-500 py-[2px] px-6 rounded-tl-xl rounded-br-xl z-30',
'inline-flex items-center justify-center relative text-neutral-white bg-tangerine-500 py-[2px] px-6 rounded-tl-xl rounded-br-xl',
className,
)}
{...rest}
>
<Sparkles class="mr-2" size="16" />
แนะนำสำหรับคุณ
<div
class="absolute right-0 top-0 translate-x-full border-b-8 border-b-tangerine-700 border-r-8 border-r-neutral-white"
class="absolute right-0 top-0 translate-x-full border-b-8 border-b-tangerine-700 border-r-8 border-r-surface"
></div>
</div>
45 changes: 45 additions & 0 deletions packages/ui/src/components/molecule/comment/comment.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<script module lang="ts">
import { defineMeta } from '@storybook/addon-svelte-csf'
import { Comment } from './index.js'
const { Story } = defineMeta<typeof Comment>({
title: 'Molecule/Comment',
component: Comment,
tags: ['autodocs'],
argTypes: {
content: {
control: 'text',
},
semester: {
control: 'text',
},
rating: {
control: 'number',
},
likesCount: {
control: 'number',
},
dislikesCount: {
control: 'number',
},
},
})
</script>

<Story
name="Default"
args={{
content: `ส่วนตัวคิดว่าค่อนข้างสบาย
มีงานสัปดาห์ละครั้ง ปกติจะมีวิดีโอให้ดู ไม่ยาวมาก แต่จะไม่ดูก็ได้ เพราะปกติเราแค่อ่านตัวอย่างที่ให้มาแล้วก็ลองเขียนเลย งานส่วนใหญ่จะให้
Topic กว้างๆมา ถ้าอาจารย์ประจำ sec ไม่ strict มาก ก็เขียนตามใจไปเลย แค่เอาเรื่องที่เรียนในสัปดาห์นั้นมาปรับๆนิดหน่อย
ปกติจะไม่อยากเสียเวลามาก ก็เขียนครั้งเดียวแล้วส่งไปเลย เลยเสียเวลาแค่ 1-2 ชม. ต่อสัปดาห์ แต่ถ้าใครจริงจังกับงานเขียนหน่อยก็อาจใช้เวลาเพิ่มขึ้น
สอบเหมือนกับงานที่ทำ จะไม่อ่านไปสอบก็ได้ถ้าจำพวกงานที่ทำส่งได้ แต่ก่อนสอบมีคลิปรีวิวให้ดูก่อน พึ่งตัวนี้เอาก็ได้
อันนี้ก็ขึ้นอยู่กับ sec ของเราอาจารย์ให้คะแนนงานค่อนข้างง่าย แต่จะให้คะแนนสอบยากหน่อย แต่เฉลี่ยๆรวมๆกันก็ได้ A
เพราะเขียนตามใจตัวเองเป็นหลัก ไม่ค่อยยึดกับเรื่องที่เรียนมาเลยรู้สึกไม่ค่อยได้อะไรใหม่ ที่ช่วยน่าจะเป็นการจัดระเบียบความคิดและสรุปให้อยู่ในย่อหน้า`,
semester: `ภาคต้น 2565`,
rating: 3.5,
likesCount: 100,
dislikesCount: 0,
}}
/>
79 changes: 79 additions & 0 deletions packages/ui/src/components/molecule/comment/comment.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<script lang="ts">
import { ThumbsDown, ThumbsUp } from 'lucide-svelte'
import { RatingStar } from '../../atom/rating-star'
let {
content,
semester,
rating,
likesCount,
dislikesCount,
}: {
content: string
semester: string
rating: number
likesCount: number
dislikesCount: number
} = $props()
let hasHalfStar: boolean = $derived(rating % 1 !== 0) // Determine if there's a half star
let isExpanded: boolean = $state(false)
</script>

<div
class="h-[320px] w-full lg:h-auto border border-surface-container px-6 py-5 lg:py-10 lg:px-12 box-border rounded-xl flex flex-col gap-y-4
lg:gap-y-8 overflow-hidden"
class:h-auto={isExpanded}
>
<div class="flex flex-row gap-x-6">
<div class="font-bold text-h3 text-primary">
{#if !hasHalfStar}
<span>{rating}.0</span>
{:else}
<span>{rating}</span>
{/if}
</div>

<RatingStar {rating} />

<div class="text-subtitle font-sans font-medium">
{semester}
</div>
</div>

<div
class="h-[200px] lg:h-auto relative overflow-hidden"
class:h-fit={isExpanded}
class:overflow-visible={isExpanded}
>
<p
class="w-full h-auto self-center text-body1 font-sarabun font-regular text-on-surface"
>
{content}
</p>

<!-- Button to toggle view -->
<button
class="absolute bottom-0 right-0 underline text-button1 text-primary lg:hidden pb-1 pt-1 pl-2 bg-surface
"
onclick={() => (isExpanded = !isExpanded)}
>
{#if isExpanded}
ดูน้อยลง
{:else}
ดูเพ่ิมเติม
{/if}
</button>
</div>

<div class="gap-6 flex flex-row text-subtitle font-sans">
<div class="flex flex-row font-medium gap-x-2">
<ThumbsUp class="text-neutral-400" />
{likesCount}
</div>
<div class="flex flex-row font-medium gap-x-2">
<ThumbsDown class="text-neutral-400" />
{dislikesCount}
</div>
</div>
</div>
1 change: 1 addition & 0 deletions packages/ui/src/components/molecule/comment/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Comment } from './comment.svelte'
1 change: 1 addition & 0 deletions packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"strict": true,
"paths": {
"$lib": ["./src"],
"$lib/*": ["./src/*"]
Expand Down
10 changes: 7 additions & 3 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
"main": "src/index.ts",
"scripts": {
"lint": "eslint .",
"format": "eslint . --fix"
"format": "eslint . --fix",
"test": "vitest run",
"test:cov": "vitest run --coverage"
},
"devDependencies": {
"typescript": "^5.7.2"
"@vitest/coverage-v8": "^2.1.8",
"typescript": "^5.7.3",
"vitest": "^2.1.8"
},
"dependencies": {
"clsx": "^2.1.1",
"svelte": "^5.15.0",
"svelte": "^5.17.1",
"tailwind-merge": "^2.6.0",
"tailwind-variants": "^0.3.0"
}
Expand Down
8 changes: 8 additions & 0 deletions packages/utils/src/name.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from 'vitest'

import { getShortenName } from './name.js'

test('getShortenName', () => {
expect(getShortenName('John Doe')).toBe('John D.')
expect(getShortenName('John Doe Jr.')).toBe('John J.')
})
6 changes: 6 additions & 0 deletions packages/utils/src/name.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function getShortenName(fullName: string) {
const names = fullName.split(' ')
const firstName = names[0]
const lastName = names[names.length - 1]
return `${firstName} ${lastName.charAt(0)}.`
}
Loading

0 comments on commit 365e24c

Please sign in to comment.