diff --git a/__snapshots__/prs-list-item--loading.png b/__snapshots__/prs-list-item--loading.png new file mode 100644 index 0000000..7895296 Binary files /dev/null and b/__snapshots__/prs-list-item--loading.png differ diff --git a/__snapshots__/prs-list-item--long-and-no-spaces.png b/__snapshots__/prs-list-item--long-and-no-spaces.png new file mode 100644 index 0000000..ac2ce81 Binary files /dev/null and b/__snapshots__/prs-list-item--long-and-no-spaces.png differ diff --git a/__snapshots__/prs-list-item--long-details.png b/__snapshots__/prs-list-item--long-details.png new file mode 100644 index 0000000..d704a66 Binary files /dev/null and b/__snapshots__/prs-list-item--long-details.png differ diff --git a/__snapshots__/prs-list-item--no-details.png b/__snapshots__/prs-list-item--no-details.png new file mode 100644 index 0000000..b22b18a Binary files /dev/null and b/__snapshots__/prs-list-item--no-details.png differ diff --git a/__snapshots__/prs-list-item--short-details.png b/__snapshots__/prs-list-item--short-details.png new file mode 100644 index 0000000..54a389d Binary files /dev/null and b/__snapshots__/prs-list-item--short-details.png differ diff --git a/__snapshots__/prs-list-item.test.js.snap b/__snapshots__/prs-list-item.test.js.snap new file mode 100644 index 0000000..c0d1a90 --- /dev/null +++ b/__snapshots__/prs-list-item.test.js.snap @@ -0,0 +1,133 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PRs/List/Item Long Details test 1`] = ` +
  • + + + + +
    +
    + rather long title that goes on and on and on and on and on and on... +
    + +
    +
  • +`; + +exports[`PRs/List/Item Long and No Spaces test 1`] = ` +
  • + + + + +
    +
    + LongNameLongNameLongNameLongNameLongNameLongNameLongNameLongNameL... +
    + +
    +
  • +`; + +exports[`PRs/List/Item No Details test 1`] = ` +
  • + + + + +
    +
    + Untitled +
    + +
    +
  • +`; + +exports[`PRs/List/Item Short Details test 1`] = ` +
  • + + + + +
    +
    + short title +
    + +
    +
  • +`; + +exports[`PRs/List/Item loading test 1`] = ` +
  • +
    +
    +
    +
    +
    +
    +
    +
    +
  • +`; diff --git a/__snapshots__/prs-list-list--default.png b/__snapshots__/prs-list-list--default.png new file mode 100644 index 0000000..b07f968 Binary files /dev/null and b/__snapshots__/prs-list-list--default.png differ diff --git a/__snapshots__/prs-list-list--empty.png b/__snapshots__/prs-list-list--empty.png new file mode 100644 index 0000000..787ad17 Binary files /dev/null and b/__snapshots__/prs-list-list--empty.png differ diff --git a/__snapshots__/prs-list-list--loading.png b/__snapshots__/prs-list-list--loading.png new file mode 100644 index 0000000..3c28386 Binary files /dev/null and b/__snapshots__/prs-list-list--loading.png differ diff --git a/__snapshots__/prs-list-list--no-title.png b/__snapshots__/prs-list-list--no-title.png new file mode 100644 index 0000000..ee1c272 Binary files /dev/null and b/__snapshots__/prs-list-list--no-title.png differ diff --git a/__snapshots__/prs-list-list--partially-loaded.png b/__snapshots__/prs-list-list--partially-loaded.png new file mode 100644 index 0000000..65ce8ce Binary files /dev/null and b/__snapshots__/prs-list-list--partially-loaded.png differ diff --git a/__snapshots__/prs-list-list.test.js.snap b/__snapshots__/prs-list-list.test.js.snap new file mode 100644 index 0000000..b14fab4 --- /dev/null +++ b/__snapshots__/prs-list-list.test.js.snap @@ -0,0 +1,293 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PRs/List/List Default test 1`] = ` +
    +
    +

    + Open PRs +

    +
    + +
    +`; + +exports[`PRs/List/List Empty test 1`] = ` +
    +
    +

    + Open PRs +

    +
    +

    + None +

    + +
    +`; + +exports[`PRs/List/List Loading test 1`] = ` +
    +
    +

    + Open PRs +

    +
    + +
    +`; + +exports[`PRs/List/List No Title test 1`] = ` +
    + +
    +`; + +exports[`PRs/List/List Partially Loaded test 1`] = ` +
    +
    +

    + Open PRs +

    +
    + +
    +`; diff --git a/package.json b/package.json index c537b3a..96c4639 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ "@nostr-dev-kit/ndk": "^1.3.0", "@nostr-dev-kit/ndk-svelte": "^1.3.0", "@nostr-dev-kit/ndk-svelte-components": "^1.3.0", - "daisyui": "^4.4" + "daisyui": "^4.4", + "dayjs": "^1.11.10" }, "resolutions": { "jackspeak": "2.1.1" diff --git a/src/lib/components/PR.vectors.ts b/src/lib/components/PR.vectors.ts new file mode 100644 index 0000000..9550e35 --- /dev/null +++ b/src/lib/components/PR.vectors.ts @@ -0,0 +1,26 @@ +import type { Args as PRListItemArgs } from "./PRsListItem.svelte"; +import dayjs from "dayjs"; +import relativeTime from "dayjs/plugin/relativeTime"; + +dayjs.extend(relativeTime); + +export let PRsListItemArgsVectors = { + Short: { + title: "short title", + author: "fred", + created_at: dayjs().subtract(7, 'days').unix(), + comments: 2, + } as PRListItemArgs, + Long: { + title: "rather long title that goes on and on and on and on and on and on and on and on and on and on and on and on and on and on and on", + author: "carole", + created_at: dayjs().subtract(1, 'minute').unix(), + comments: 0, + } as PRListItemArgs, + LongNoSpaces: { + title: "LongNameLongNameLongNameLongNameLongNameLongNameLongNameLongNameLongNameLongNameLongNameLongNameLongNameLongName", + author: "steve", + created_at: dayjs().subtract(3, 'month').subtract(3, 'days').unix(), + comments: 1, + } as PRListItemArgs, +}; \ No newline at end of file diff --git a/src/lib/components/PRsList.stories.svelte b/src/lib/components/PRsList.stories.svelte new file mode 100644 index 0000000..0d2c2a2 --- /dev/null +++ b/src/lib/components/PRsList.stories.svelte @@ -0,0 +1,56 @@ + + + + + + + + + + + + diff --git a/src/lib/components/PRsList.svelte b/src/lib/components/PRsList.svelte new file mode 100644 index 0000000..10e4734 --- /dev/null +++ b/src/lib/components/PRsList.svelte @@ -0,0 +1,35 @@ + + +
    + {#if title.length > 0} +
    +

    {title}

    +
    + {/if} + {#if prs.length == 0 && !loading} +

    None

    + {/if} +
      + {#each prs as { title, comments, author, created_at }} + + {/each} + {#if loading} + + {#if prs.length == 0} + + + {/if} + {/if} +
    +
    diff --git a/src/lib/components/PRsListItem.stories.svelte b/src/lib/components/PRsListItem.stories.svelte new file mode 100644 index 0000000..f1a51bb --- /dev/null +++ b/src/lib/components/PRsListItem.stories.svelte @@ -0,0 +1,26 @@ + + + + + + + + + + + + + diff --git a/src/lib/components/PRsListItem.svelte b/src/lib/components/PRsListItem.svelte new file mode 100644 index 0000000..e463f57 --- /dev/null +++ b/src/lib/components/PRsListItem.svelte @@ -0,0 +1,109 @@ + + + + +
  • + + + {#if loading} +
    + {:else} + + + {/if} + +
    + {#if loading} +
    +
    + {:else} +
    + {short_title} +
    + +
      + {#if comments > 0} +
    • + + + {comments} +
    • + {/if} +
    • + opened {created_at_ago} +
    • +
    • + {author} +
    • +
    + {/if} +
    + +
  • diff --git a/yarn.lock b/yarn.lock index fc4e3b1..de7da83 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4221,7 +4221,7 @@ data-uri-to-buffer@^4.0.0: resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz#d8feb2b2881e6a4f58c2e08acfd0e2834e26222e" integrity sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A== -dayjs@^1.11.9: +dayjs@^1.11.10, dayjs@^1.11.9: version "1.11.10" resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0" integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==