From 8a1863e155cf47d80577f191ae5a4c97d0681e7c Mon Sep 17 00:00:00 2001 From: tunny17 Date: Wed, 4 Dec 2024 15:02:07 +0100 Subject: [PATCH 1/3] feat: add marquee --- src/lib/pages/home/author-display.svelte | 15 +++++ src/lib/pages/home/hero.svelte | 36 +++++++++++ src/lib/pages/home/marquee-card.svelte | 30 +++++++++ src/lib/pages/home/marquee.svelte | 34 +++++++++++ src/lib/pages/home/page.svelte | 49 ++++++++------- src/lib/pages/home/table.svelte | 77 +++++++++--------------- tailwind.config.js | 44 ++++++++------ 7 files changed, 196 insertions(+), 89 deletions(-) create mode 100644 src/lib/pages/home/author-display.svelte create mode 100644 src/lib/pages/home/hero.svelte create mode 100644 src/lib/pages/home/marquee-card.svelte create mode 100644 src/lib/pages/home/marquee.svelte diff --git a/src/lib/pages/home/author-display.svelte b/src/lib/pages/home/author-display.svelte new file mode 100644 index 0000000..f9989ec --- /dev/null +++ b/src/lib/pages/home/author-display.svelte @@ -0,0 +1,15 @@ + + +
+ + + + + {data.author} +
diff --git a/src/lib/pages/home/hero.svelte b/src/lib/pages/home/hero.svelte new file mode 100644 index 0000000..6bee652 --- /dev/null +++ b/src/lib/pages/home/hero.svelte @@ -0,0 +1,36 @@ + + +
+

+ Open 10 source projects in Nigeria +

+ + {#each firstRow as item} + + {/each} + + + {#each secondRow as item} + + {/each} + +
+
+
diff --git a/src/lib/pages/home/marquee-card.svelte b/src/lib/pages/home/marquee-card.svelte new file mode 100644 index 0000000..3e2de0e --- /dev/null +++ b/src/lib/pages/home/marquee-card.svelte @@ -0,0 +1,30 @@ + + +
+
+ +
+ +
+ {name} +
+

{author}

+
+
+
{description}
+
diff --git a/src/lib/pages/home/marquee.svelte b/src/lib/pages/home/marquee.svelte new file mode 100644 index 0000000..e710f05 --- /dev/null +++ b/src/lib/pages/home/marquee.svelte @@ -0,0 +1,34 @@ + + +
+ {#each { length: repeat } as _, i (i)} +
+ Default +
+ {/each} +
diff --git a/src/lib/pages/home/page.svelte b/src/lib/pages/home/page.svelte index 8dc8915..4fc8dd8 100644 --- a/src/lib/pages/home/page.svelte +++ b/src/lib/pages/home/page.svelte @@ -8,6 +8,7 @@ import detectUrlChange from 'detect-url-change'; import Table from './table.svelte'; + import Hero from './hero.svelte'; let repositories: Repository[] = []; let apiMetadata: ApiMetadata = { @@ -17,12 +18,12 @@ totalItems: 250, itemsPerPage: 10, hasNextPage: false, - hasPrevPage: false, + hasPrevPage: false }, sort: { sortBy: 'stars', - order: 'desc', - }, + order: 'desc' + } }; let currentPage: number = 1; let currentOrder: string = 'desc'; @@ -57,11 +58,11 @@ repositories = result.data.map((repo: Repository, index: number) => ({ ...repo, - id: index + 1 + (page - 1) * 10, + id: index + 1 + (page - 1) * 10 })); apiMetadata = { pagination: result.pagination, - sort: result.sort, + sort: result.sort }; } catch (err: any) { console.error(err); @@ -91,11 +92,11 @@ const result = await response.json(); repositories = result.data.map((repo: Repository, index: number) => ({ ...repo, - id: index + 1, + id: index + 1 })); apiMetadata = { pagination: result.pagination, - sort: result.sort, + sort: result.sort }; } catch (err: any) { console.error(err); @@ -118,7 +119,7 @@ > -
+
{#if isFetching && !isMounted}
@@ -132,21 +133,25 @@
{:else}
-

- Open source projects in Nigeria -

+ + +
+

+ Open source projects in Nigeria +

+
+ {#key gettingFreshData} + + {/key} - {#key gettingFreshData} -
- {/key} {/if} diff --git a/src/lib/pages/home/table.svelte b/src/lib/pages/home/table.svelte index 2632cae..fc6367a 100644 --- a/src/lib/pages/home/table.svelte +++ b/src/lib/pages/home/table.svelte @@ -3,14 +3,15 @@ import { Render, Subscribe, + createRender, // createRender, - createTable, + createTable } from 'svelte-headless-table'; import { addHiddenColumns, addPagination, addSortBy, - addTableFilter, + addTableFilter } from 'svelte-headless-table/plugins'; import ArrowUpDown from 'lucide-svelte/icons/arrow-up-down'; import ArrowRight from 'lucide-svelte/icons/chevron-right'; @@ -24,6 +25,7 @@ import * as Table from '$lib/components/table'; import { Button } from '$lib/components/button'; import { BorderBeam } from '$lib/components/border-beam'; + import AuthorDisplay from './author-display.svelte'; export let data: Repository[] = []; export let apiMetadata: ApiMetadata; @@ -48,44 +50,43 @@ sort: addSortBy({ disableMultiSort: true }), page: addPagination(), filter: addTableFilter({ - fn: ({ filterValue, value }) => value.includes(filterValue), + fn: ({ filterValue, value }) => value.includes(filterValue) }), - hide: addHiddenColumns(), + hide: addHiddenColumns() }); const columns = table.createColumns([ table.column({ header: '#', - accessor: 'id', + accessor: 'id' }), table.column({ header: 'Name', - accessor: 'link', - }), - table.column({ - header: '', - accessor: 'author_avatar', - cell: ({ value }) => value.toLowerCase(), + accessor: 'link' }), table.column({ header: 'Author', - accessor: 'author', - cell: ({ value }) => value.toLowerCase(), + accessor: (data) => data, + cell: ({ value }) => { + return createRender(AuthorDisplay, { + data: value + }); + } }), table.column({ header: 'Stars', accessor: 'stars', cell: ({ value }) => { return value; - }, + } }), table.column({ header: 'Forks', accessor: 'forks', cell: ({ value }) => { return value; - }, - }), + } + }) // table.column({ // header: '', // accessor: (data) => data, @@ -95,15 +96,8 @@ // }), ]); - const { - headerRows, - pageRows, - tableAttrs, - tableBodyAttrs, - flatColumns, - pluginStates, - rows, - } = table.createViewModel(columns); + const { headerRows, pageRows, tableAttrs, tableBodyAttrs, flatColumns, pluginStates, rows } = + table.createViewModel(columns); const { hiddenColumnIds } = pluginStates.hide; const ids = flatColumns.map((c) => c.id); @@ -172,16 +166,8 @@ {#each headerRow.cells as cell (cell.id)} - - + + {#if cell.id === 'stars' || cell.id === 'forks'} diff --git a/tailwind.config.js b/tailwind.config.js index ee8a036..19cd85b 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -10,8 +10,8 @@ const config = { center: true, padding: '2rem', screens: { - '2xl': '1400px', - }, + '2xl': '1400px' + } }, extend: { colors: { @@ -22,54 +22,64 @@ const config = { foreground: 'hsl(var(--foreground) / )', primary: { DEFAULT: 'hsl(var(--primary) / )', - foreground: 'hsl(var(--primary-foreground) / )', + foreground: 'hsl(var(--primary-foreground) / )' }, secondary: { DEFAULT: 'hsl(var(--secondary) / )', - foreground: 'hsl(var(--secondary-foreground) / )', + foreground: 'hsl(var(--secondary-foreground) / )' }, destructive: { DEFAULT: 'hsl(var(--destructive) / )', - foreground: 'hsl(var(--destructive-foreground) / )', + foreground: 'hsl(var(--destructive-foreground) / )' }, muted: { DEFAULT: 'hsl(var(--muted) / )', - foreground: 'hsl(var(--muted-foreground) / )', + foreground: 'hsl(var(--muted-foreground) / )' }, accent: { DEFAULT: 'hsl(var(--accent) / )', - foreground: 'hsl(var(--accent-foreground) / )', + foreground: 'hsl(var(--accent-foreground) / )' }, popover: { DEFAULT: 'hsl(var(--popover) / )', - foreground: 'hsl(var(--popover-foreground) / )', + foreground: 'hsl(var(--popover-foreground) / )' }, card: { DEFAULT: 'hsl(var(--card) / )', - foreground: 'hsl(var(--card-foreground) / )', - }, + foreground: 'hsl(var(--card-foreground) / )' + } }, borderRadius: { lg: 'var(--radius)', md: 'calc(var(--radius) - 2px)', - sm: 'calc(var(--radius) - 4px)', + sm: 'calc(var(--radius) - 4px)' }, fontFamily: { - sans: ['Inter', ...fontFamily.sans], + sans: ['Inter', ...fontFamily.sans] }, animation: { 'border-beam': 'border-beam calc(var(--duration)*1s) infinite linear', + marquee: 'marquee var(--duration) linear infinite', + 'marquee-vertical': 'marquee-vertical var(--duration) linear infinite' }, keyframes: { 'border-beam': { '100%': { - 'offset-distance': '100%', - }, + 'offset-distance': '100%' + } }, - }, - }, - }, + marquee: { + from: { transform: 'translateX(0)' }, + to: { transform: 'translateX(calc(-100% - var(--gap)))' } + }, + 'marquee-vertical': { + from: { transform: 'translateY(0)' }, + to: { transform: 'translateY(calc(-100% - var(--gap)))' } + } + } + } + } }; export default config; From c7af0e248445156503546a3320aac1a0a68f889c Mon Sep 17 00:00:00 2001 From: tunny17 Date: Wed, 4 Dec 2024 15:55:06 +0100 Subject: [PATCH 2/3] feat: ui changes --- src/lib/assets/star.svg | 8 +++++++ src/lib/pages/home/marquee-card.svelte | 33 +++++++++++++++++--------- 2 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 src/lib/assets/star.svg diff --git a/src/lib/assets/star.svg b/src/lib/assets/star.svg new file mode 100644 index 0000000..9038ea0 --- /dev/null +++ b/src/lib/assets/star.svg @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/src/lib/pages/home/marquee-card.svelte b/src/lib/pages/home/marquee-card.svelte index 3e2de0e..a6beb03 100644 --- a/src/lib/pages/home/marquee-card.svelte +++ b/src/lib/pages/home/marquee-card.svelte @@ -1,13 +1,18 @@ -
-
- -
- -
- {name} -
-

{author}

+
+
+ +
+ +
+ {name} +
+

{author}

+
+
+
+ +

{stars}

-
{description}
-
+
{description}
+ From a4e98318da286a9931d42d44b6bd60252d035e4c Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Wed, 4 Dec 2024 16:30:46 +0100 Subject: [PATCH 3/3] feat: add top 10 in marques --- deno.json | 1 + src/lib/components/marquee/index.ts | 4 ++ .../marquee}/marquee-card.svelte | 8 ++- .../marquee}/marquee.svelte | 4 +- src/lib/pages/home/hero.svelte | 9 +-- src/lib/pages/home/page.svelte | 18 ++--- src/lib/pages/home/table.svelte | 68 ++++++++++++------- 7 files changed, 73 insertions(+), 39 deletions(-) create mode 100644 src/lib/components/marquee/index.ts rename src/lib/{pages/home => components/marquee}/marquee-card.svelte (90%) rename src/lib/{pages/home => components/marquee}/marquee.svelte (91%) diff --git a/deno.json b/deno.json index 85db2d7..5f6bca6 100644 --- a/deno.json +++ b/deno.json @@ -1,5 +1,6 @@ { "tasks": { + "dev": "deno run fe:dev & deno run be:dev", "fe:dev": "deno run -A --node-modules-dir npm:vite", "fe:build": "deno run -A --node-modules-dir npm:vite build", "fe:preview": "deno run -A --node-modules-dir npm:vite preview", diff --git a/src/lib/components/marquee/index.ts b/src/lib/components/marquee/index.ts new file mode 100644 index 0000000..ca2105d --- /dev/null +++ b/src/lib/components/marquee/index.ts @@ -0,0 +1,4 @@ +import Root from './marquee.svelte'; +import MarqueeCard from './marquee-card.svelte'; + +export { Root, Root as Marquee, MarqueeCard }; diff --git a/src/lib/pages/home/marquee-card.svelte b/src/lib/components/marquee/marquee-card.svelte similarity index 90% rename from src/lib/pages/home/marquee-card.svelte rename to src/lib/components/marquee/marquee-card.svelte index a6beb03..1b20f64 100644 --- a/src/lib/pages/home/marquee-card.svelte +++ b/src/lib/components/marquee/marquee-card.svelte @@ -23,7 +23,13 @@ >
- +
diff --git a/src/lib/pages/home/marquee.svelte b/src/lib/components/marquee/marquee.svelte similarity index 91% rename from src/lib/pages/home/marquee.svelte rename to src/lib/components/marquee/marquee.svelte index e710f05..657c9b4 100644 --- a/src/lib/pages/home/marquee.svelte +++ b/src/lib/components/marquee/marquee.svelte @@ -14,7 +14,7 @@ 'group flex overflow-hidden p-2 [--duration:2s] [--gap:1rem] [gap:var(--gap)]', { 'flex-row': !vertical, - 'flex-col': vertical + 'flex-col': vertical, }, className )} @@ -25,7 +25,7 @@ 'animate-marquee flex-row': !vertical, 'animate-marquee-vertical flex-col': vertical, 'group-hover:[animation-play-state:paused]': pauseOnHover, - '[animation-direction:reverse]': reverse + '[animation-direction:reverse]': reverse, })} > Default diff --git a/src/lib/pages/home/hero.svelte b/src/lib/pages/home/hero.svelte index 6bee652..6c5f2ab 100644 --- a/src/lib/pages/home/hero.svelte +++ b/src/lib/pages/home/hero.svelte @@ -1,7 +1,7 @@
+

- Open 10 source projects in Nigeria + The Odogwu's

{#each firstRow as item} diff --git a/src/lib/pages/home/page.svelte b/src/lib/pages/home/page.svelte index 4fc8dd8..47d74f5 100644 --- a/src/lib/pages/home/page.svelte +++ b/src/lib/pages/home/page.svelte @@ -18,12 +18,12 @@ totalItems: 250, itemsPerPage: 10, hasNextPage: false, - hasPrevPage: false + hasPrevPage: false, }, sort: { sortBy: 'stars', - order: 'desc' - } + order: 'desc', + }, }; let currentPage: number = 1; let currentOrder: string = 'desc'; @@ -58,11 +58,11 @@ repositories = result.data.map((repo: Repository, index: number) => ({ ...repo, - id: index + 1 + (page - 1) * 10 + id: index + 1 + (page - 1) * 10, })); apiMetadata = { pagination: result.pagination, - sort: result.sort + sort: result.sort, }; } catch (err: any) { console.error(err); @@ -92,11 +92,11 @@ const result = await response.json(); repositories = result.data.map((repo: Repository, index: number) => ({ ...repo, - id: index + 1 + id: index + 1, })); apiMetadata = { pagination: result.pagination, - sort: result.sort + sort: result.sort, }; } catch (err: any) { console.error(err); @@ -137,9 +137,9 @@

- Open source projects in Nigeria + All Projects

{#key gettingFreshData} diff --git a/src/lib/pages/home/table.svelte b/src/lib/pages/home/table.svelte index fc6367a..7520997 100644 --- a/src/lib/pages/home/table.svelte +++ b/src/lib/pages/home/table.svelte @@ -5,13 +5,13 @@ Subscribe, createRender, // createRender, - createTable + createTable, } from 'svelte-headless-table'; import { addHiddenColumns, addPagination, addSortBy, - addTableFilter + addTableFilter, } from 'svelte-headless-table/plugins'; import ArrowUpDown from 'lucide-svelte/icons/arrow-up-down'; import ArrowRight from 'lucide-svelte/icons/chevron-right'; @@ -50,43 +50,43 @@ sort: addSortBy({ disableMultiSort: true }), page: addPagination(), filter: addTableFilter({ - fn: ({ filterValue, value }) => value.includes(filterValue) + fn: ({ filterValue, value }) => value.includes(filterValue), }), - hide: addHiddenColumns() + hide: addHiddenColumns(), }); const columns = table.createColumns([ table.column({ header: '#', - accessor: 'id' + accessor: 'id', }), table.column({ header: 'Name', - accessor: 'link' + accessor: 'link', }), table.column({ header: 'Author', accessor: (data) => data, cell: ({ value }) => { return createRender(AuthorDisplay, { - data: value + data: value, }); - } + }, }), table.column({ header: 'Stars', accessor: 'stars', cell: ({ value }) => { return value; - } + }, }), table.column({ header: 'Forks', accessor: 'forks', cell: ({ value }) => { return value; - } - }) + }, + }), // table.column({ // header: '', // accessor: (data) => data, @@ -96,15 +96,20 @@ // }), ]); - const { headerRows, pageRows, tableAttrs, tableBodyAttrs, flatColumns, pluginStates, rows } = - table.createViewModel(columns); + const { + headerRows, + pageRows, + tableAttrs, + tableBodyAttrs, + flatColumns, + pluginStates, + rows, + } = table.createViewModel(columns); const { hiddenColumnIds } = pluginStates.hide; const ids = flatColumns.map((c) => c.id); let hideForId = Object.fromEntries(ids.map((id) => [id, true])); - const { filterValue } = pluginStates.filter; - function goToPage(page: number) { const url = new URL(window.location.href); url.searchParams.set('page', page.toString()); @@ -166,8 +171,16 @@ {#each headerRow.cells as cell (cell.id)} - - + + {#if cell.id === 'stars' || cell.id === 'forks'}