diff --git a/web/package-lock.json b/web/package-lock.json index 81f20f5..c9fee21 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -13,6 +13,7 @@ "@sveltejs/vite-plugin-svelte": "^3.0.0", "svelte": "^4.2.7", "svelte-check": "^3.6.0", + "svelte-time": "^0.9.0", "tslib": "^2.4.1", "typescript": "^5.0.0", "vite": "^5.0.3" @@ -963,6 +964,12 @@ "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" } }, + "node_modules/dayjs": { + "version": "1.11.11", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.11.tgz", + "integrity": "sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg==", + "dev": true + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -1826,6 +1833,15 @@ } } }, + "node_modules/svelte-time": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/svelte-time/-/svelte-time-0.9.0.tgz", + "integrity": "sha512-XLEflTNZCjJM2ltCJL0NTpN9J2KBZXxupfl9S2sRFx+utSuQXbs3YIM14DIuENsjG1Qn5NtzRb0gviIB7lCMxQ==", + "dev": true, + "dependencies": { + "dayjs": "^1.11.10" + } + }, "node_modules/tiny-glob": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz", diff --git a/web/package.json b/web/package.json index b9d8d52..e88dcda 100644 --- a/web/package.json +++ b/web/package.json @@ -15,6 +15,7 @@ "@sveltejs/vite-plugin-svelte": "^3.0.0", "svelte": "^4.2.7", "svelte-check": "^3.6.0", + "svelte-time": "^0.9.0", "tslib": "^2.4.1", "typescript": "^5.0.0", "vite": "^5.0.3" diff --git a/web/src/app.html b/web/src/app.html index 77a5ff5..5595332 100644 --- a/web/src/app.html +++ b/web/src/app.html @@ -1,12 +1,26 @@ - - - - - %sveltekit.head% - - -
%sveltekit.body%
- - + + + + + + + %sveltekit.head% + + + +
%sveltekit.body%
+ + + + \ No newline at end of file diff --git a/web/src/lib/posts/card.svelte b/web/src/lib/posts/card.svelte new file mode 100644 index 0000000..22c5165 --- /dev/null +++ b/web/src/lib/posts/card.svelte @@ -0,0 +1,57 @@ + + +
+
+ {post.feed.title} + {post.feed.title} | +
+ +

{post.title}

+

{post.content}

+
+ +
+ + diff --git a/web/src/lib/posts/list.svelte b/web/src/lib/posts/list.svelte new file mode 100644 index 0000000..800dc73 --- /dev/null +++ b/web/src/lib/posts/list.svelte @@ -0,0 +1,26 @@ + + +

Posts

+ + + + diff --git a/web/src/lib/posts/tag-list.svelte b/web/src/lib/posts/tag-list.svelte new file mode 100644 index 0000000..78f6212 --- /dev/null +++ b/web/src/lib/posts/tag-list.svelte @@ -0,0 +1,37 @@ + + +
+ {#each tagsToDisplay as tag} + {tag} + {/each} + {#if tags.length > nbNonExpandedTags} + + {/if} +
+ + diff --git a/web/src/lib/stores/post.store.ts b/web/src/lib/stores/post.store.ts new file mode 100644 index 0000000..f10afec --- /dev/null +++ b/web/src/lib/stores/post.store.ts @@ -0,0 +1,24 @@ +// /home/cbihan/Documents/front_stuff/vex/web/src/lib/stores/post.store.js +import type { Post } from "$lib/types"; +import { writable } from 'svelte/store'; + +// Initial state +const initialState: Post[] = []; + +// Create the writable store +export const postStore = writable(initialState); + +// Actions +export const addPost = (post: Post) => { + postStore.update((posts) => [...posts, post]); +}; + +export const removePost = (postId: string) => { + postStore.update((posts) => posts.filter((post) => post.id !== postId)); +}; + +export const updatePost = (postId: string, updatedPost: Post) => { + postStore.update((posts) => + posts.map((post) => (post.id === postId ? updatedPost : post)) + ); +}; \ No newline at end of file diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts new file mode 100644 index 0000000..6e1d619 --- /dev/null +++ b/web/src/lib/types.ts @@ -0,0 +1,2 @@ +export type { Feed } from "./types/feed.type"; +export type { Post } from "./types/post.type"; \ No newline at end of file diff --git a/web/src/lib/types/feed.type.ts b/web/src/lib/types/feed.type.ts new file mode 100644 index 0000000..f9b48de --- /dev/null +++ b/web/src/lib/types/feed.type.ts @@ -0,0 +1,7 @@ +export type Feed = { + id: string; + title: string; + url: string; + faviconUrl: string; + tags: string[]; +} \ No newline at end of file diff --git a/web/src/lib/types/post.type.ts b/web/src/lib/types/post.type.ts new file mode 100644 index 0000000..95a2d49 --- /dev/null +++ b/web/src/lib/types/post.type.ts @@ -0,0 +1,16 @@ +import type { Feed } from "./feed.type"; + +export type Post = { + id: string; + title: string; + content: string; + link: string; + date: Date; + + author?: string; + isRead: boolean; + isBookmarked: boolean; + isIgnored: boolean; + isReadLater: boolean; + feed: Feed; +} \ No newline at end of file diff --git a/web/src/routes/+page.server.ts b/web/src/routes/+page.server.ts new file mode 100644 index 0000000..1c62402 --- /dev/null +++ b/web/src/routes/+page.server.ts @@ -0,0 +1,52 @@ +import type { Post } from "$lib/types"; + +const data: Post[] = [ + { + id: "1", + title: "The first post", + content: "This is the", + link: "https://example.com", + date: new Date(), + isRead: false, + isBookmarked: false, + isIgnored: false, + isReadLater: false, + author: "John Doe", + feed: { + id: "1", + title: "The first feed", + url: "https://example.com/feed", + faviconUrl: "https://kit.svelte.dev/favicon.png", + tags: ["tag1", "tag2"], + }, + }, + { + id: "2", + title: "Wine 9.8 Fixes Nearly 20 Year Old Bug For Installing Microsoft Office 97", + content: "Wine 9.8 is out today as the newest bi-weekly development release of this open-source software for enjoying Windows games/applications on Linux / Chrome OS, macOS, and other platforms...", + link: "https://example.com", + date: new Date(), + isRead: false, + isBookmarked: true, + isIgnored: false, + isReadLater: false, + feed: { + id: "2", + title: "Phoronix", + url: "https://www.phoronix.com", + faviconUrl: "https://www.phoronix.com/favicon.ico", + // put 50 tags in the array linked with linux world + tags: [ + "linux", "kernel", "gnu", "gnu/linux", "gnu+linux", "gnu linux", + "wine", "winehq", "wine-staging", "wine-devel", "winehq-devel", "winehq-staging", + "mesa", "mesa3d", "mesa 3d", "mesa-3d", "mesa3d-devel", "mesa3d-staging", + "NVK" + ], + }, + } +]; + +export function load() { + return { data }; +} + diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte index 5982b0a..0e06ca3 100644 --- a/web/src/routes/+page.svelte +++ b/web/src/routes/+page.svelte @@ -1,2 +1,19 @@ -

Welcome to SvelteKit

-

Visit kit.svelte.dev to read the documentation

+ + +
+

Welcome to SvelteKit

+

+ Visit kit.svelte.dev to read the documentation +

+ + +
+ +