Skip to content

Commit

Permalink
feat(homepage): add latest repositories list view
Browse files Browse the repository at this point in the history
add pure ui components:
 - add repo summary card
 - add repo summary list

add data wrapper components:
 - add repo recent

add repo rent to the homepage
  • Loading branch information
DanConwayDev committed Sep 30, 2023
1 parent eb0a284 commit a17b5fb
Show file tree
Hide file tree
Showing 20 changed files with 440 additions and 18 deletions.
Binary file added __snapshots__/repo-summary-card--loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __snapshots__/repo-summary-card--long-details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __snapshots__/repo-summary-card--no-details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions __snapshots__/repo-summary-card.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Repo/Summary/Card Long Details test 1`] = `
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
Long Name that goes on and on and on and on a...
</h2>
<p class="s-LKxYhcdFgLTA">
Lorem ipsum dolor sit amet, consectetur adipi...
</p>
</div>
</div>
`;

exports[`Repo/Summary/Card Long and No Spaces test 1`] = `
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
LongNameLongNameLongNameLongNameLongNameLongN...
</h2>
<p class="s-LKxYhcdFgLTA">
LoremipsumLoremipsumLoremipsumLoremipsumLorem...
</p>
</div>
</div>
`;

exports[`Repo/Summary/Card No Details test 1`] = `
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
Untitled
</h2>
<p class="s-LKxYhcdFgLTA">
</p>
</div>
</div>
`;

exports[`Repo/Summary/Card Short Details test 1`] = `
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
Short Name
</h2>
<p class="s-LKxYhcdFgLTA">
short description
</p>
</div>
</div>
`;

exports[`Repo/Summary/Card loading test 1`] = `
<div class="card w-96 bg-neutral text-neutral-focus s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<div class="text-center s-LKxYhcdFgLTA">
<span class="loading loading-spinner loading-lg s-LKxYhcdFgLTA">
</span>
</div>
</div>
</div>
`;
Binary file added __snapshots__/repo-summary-list--default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __snapshots__/repo-summary-list--empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __snapshots__/repo-summary-list--loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __snapshots__/repo-summary-list--no-title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
151 changes: 151 additions & 0 deletions __snapshots__/repo-summary-list.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Repo/Summary/List Default test 1`] = `
<div class="space-y-5">
<div class="prose">
<h3>
Featured Repositories
</h3>
</div>
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
Short Name
</h2>
<p class="s-LKxYhcdFgLTA">
short description
</p>
</div>
</div>
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
Long Name that goes on and on and on and on a...
</h2>
<p class="s-LKxYhcdFgLTA">
Lorem ipsum dolor sit amet, consectetur adipi...
</p>
</div>
</div>
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
LongNameLongNameLongNameLongNameLongNameLongN...
</h2>
<p class="s-LKxYhcdFgLTA">
LoremipsumLoremipsumLoremipsumLoremipsumLorem...
</p>
</div>
</div>
</div>
`;

exports[`Repo/Summary/List Empty test 1`] = `
<div class="space-y-5">
<div class="prose">
<h3>
Latest
</h3>
</div>
<p class="prose">
None
</p>
</div>
`;

exports[`Repo/Summary/List Loading test 1`] = `
<div class="space-y-5">
<div class="prose">
<h3>
Latest
</h3>
</div>
<div class="card w-96 bg-neutral text-neutral-focus s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<div class="text-center s-LKxYhcdFgLTA">
<span class="loading loading-spinner loading-lg s-LKxYhcdFgLTA">
</span>
</div>
</div>
</div>
<div class="card w-96 bg-neutral text-neutral-focus s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<div class="text-center s-LKxYhcdFgLTA">
<span class="loading loading-spinner loading-lg s-LKxYhcdFgLTA">
</span>
</div>
</div>
</div>
<div class="card w-96 bg-neutral text-neutral-focus s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<div class="text-center s-LKxYhcdFgLTA">
<span class="loading loading-spinner loading-lg s-LKxYhcdFgLTA">
</span>
</div>
</div>
</div>
</div>
`;

exports[`Repo/Summary/List No Title test 1`] = `
<div class="space-y-5">
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
Short Name
</h2>
<p class="s-LKxYhcdFgLTA">
short description
</p>
</div>
</div>
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
Long Name that goes on and on and on and on a...
</h2>
<p class="s-LKxYhcdFgLTA">
Lorem ipsum dolor sit amet, consectetur adipi...
</p>
</div>
</div>
</div>
`;

exports[`Repo/Summary/List Partially Loaded test 1`] = `
<div class="space-y-5">
<div class="prose">
<h3>
Latest
</h3>
</div>
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
Short Name
</h2>
<p class="s-LKxYhcdFgLTA">
short description
</p>
</div>
</div>
<div class="card w-96 bg-primary text-primary-content s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<h2 class="card-title s-LKxYhcdFgLTA">
Long Name that goes on and on and on and on a...
</h2>
<p class="s-LKxYhcdFgLTA">
Lorem ipsum dolor sit amet, consectetur adipi...
</p>
</div>
</div>
<div class="card w-96 bg-neutral text-neutral-focus s-LKxYhcdFgLTA">
<div class="card-body s-LKxYhcdFgLTA">
<div class="text-center s-LKxYhcdFgLTA">
<span class="loading loading-spinner loading-lg s-LKxYhcdFgLTA">
</span>
</div>
</div>
</div>
</div>
`;
18 changes: 18 additions & 0 deletions src/lib/components/Repo.vectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Args as SummaryCardArgs } from "./RepoSummaryCard.svelte";

export let RepoSummaryCardArgsVectors = {
Short: {
name: "Short Name",
description: "short description",
} as SummaryCardArgs,
Long: {
name: "Long Name that goes on and on and on and on and on and on and on and on and on",
description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis quis nisl eget turpis congue molestie. Nulla vitae purus nec augue accumsan facilisis sed sed ligula. Vestibulum sed risus lacinia risus lacinia molestie. Ut lorem quam, consequat eget tempus in, rhoncus vel nunc. Duis efficitur a leo vel sodales. Nam id fermentum lacus. Etiam nec placerat velit. Praesent ac consectetur est. Aenean iaculis commodo enim.",
} as SummaryCardArgs,
LongNoSpaces: {
name: "LongNameLongNameLongNameLongNameLongNameLongNameLongNameLongName",
description:
"LoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsumLoremipsum>",
} as SummaryCardArgs,
};
26 changes: 26 additions & 0 deletions src/lib/components/RepoSummaryCard.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script lang="ts" context="module">
import type { Meta } from "@storybook/svelte";
import RepoSummaryCard from "./RepoSummaryCard.svelte";
import { Story, Template } from "@storybook/addon-svelte-csf";
import { RepoSummaryCardArgsVectors as vectors } from "./Repo.vectors";
export const meta: Meta<RepoSummaryCard> = {
title: "Repo/Summary/Card",
component: RepoSummaryCard,
tags: ["autodocs"],
};
</script>

<Template let:args>
<RepoSummaryCard {...args} />
</Template>

<Story name="Short Details" args={vectors.Short} />

<Story name="Long Details" args={vectors.Long} />

<Story name="Long and No Spaces" args={vectors.LongNoSpaces} />

<Story name="No Details" args={{}} />

<Story name="loading" args={{ loading: true }} />
59 changes: 59 additions & 0 deletions src/lib/components/RepoSummaryCard.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<script lang="ts" context="module">
export interface Args {
name: string;
description: string;
loading?: boolean;
}
export const defaults: Args = {
name: "",
description: "",
loading: false,
};
</script>

<script lang="ts">
import { slide } from "svelte/transition";
export let { name, description, loading } = defaults;
let short_name: string;
$: {
if (name.length > 45) short_name = name.slice(0, 45) + "...";
else if (name.length == 0) short_name = "Untitled";
else short_name = name;
}
$: short_descrption =
description.length > 50 ? description.slice(0, 45) + "..." : description;
</script>

{#if loading}
<div
transition:slide={{ duration: 50 }}
class="card w-96 bg-neutral text-neutral-focus"
>
<div class="card-body">
<div class="text-center">
<span class="loading loading-spinner loading-lg" />
</div>
</div>
</div>
{:else}
<div
transition:slide={{ duration: 50 }}
class="card w-96 bg-primary text-primary-content"
>
<div class="card-body">
<h2 class="card-title">{short_name}</h2>
<p>{short_descrption}</p>
</div>
</div>
{/if}

<style>
h2 {
display: inline-block;
}
p,
h2 {
word-wrap: break-word;
}
</style>
16 changes: 0 additions & 16 deletions src/lib/components/ReposFeatured.svelte

This file was deleted.

56 changes: 56 additions & 0 deletions src/lib/components/ReposSummaryList.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<script lang="ts" context="module">
import type { Meta } from "@storybook/svelte";
import ReposSummaryList from "./ReposSummaryList.svelte";
import { Story, Template } from "@storybook/addon-svelte-csf";
import { RepoSummaryCardArgsVectors as vectors } from "./Repo.vectors";
export const meta: Meta<ReposSummaryList> = {
title: "Repo/Summary/List",
component: ReposSummaryList,
tags: ["autodocs"],
};
</script>

<Template let:args>
<ReposSummaryList {...args} />
</Template>

<Story
name="Default"
args={{
title: "Featured Repositories",
repos: [vectors.Short, vectors.Long, vectors.LongNoSpaces],
}}
/>

<Story
name="No Title"
args={{
repos: [vectors.Short, vectors.Long],
}}
/>
<Story
name="Empty"
args={{
title: "Latest",
repos: [],
}}
/>

<Story
name="Loading"
args={{
title: "Latest",
repos: [],
loading: true,
}}
/>

<Story
name="Partially Loaded"
args={{
title: "Latest",
repos: [vectors.Short, vectors.Long],
loading: true,
}}
/>
Loading

0 comments on commit a17b5fb

Please sign in to comment.