From 5297ea175fb83cd91ccf0d0964dfbc04f9229016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Jaenisch?= Date: Mon, 24 Jun 2024 10:38:02 +0200 Subject: [PATCH] docs: create stories for new components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I have added atoms, molecules and icons. Signed-off-by: André Jaenisch --- stories/atoms/CommitBody.stories.ts | 34 +++ stories/atoms/CommitDate.stories.ts | 32 +++ stories/icons/Copy16.stories.ts | 36 +++ stories/icons/FileDirectory16.stories.ts | 36 +++ stories/icons/GitCommit24.stories.ts | 36 +++ stories/molecules/History.stories.ts | 324 +++++++++++++++++++++++ 6 files changed, 498 insertions(+) create mode 100644 stories/atoms/CommitBody.stories.ts create mode 100644 stories/atoms/CommitDate.stories.ts create mode 100644 stories/icons/Copy16.stories.ts create mode 100644 stories/icons/FileDirectory16.stories.ts create mode 100644 stories/icons/GitCommit24.stories.ts create mode 100644 stories/molecules/History.stories.ts diff --git a/stories/atoms/CommitBody.stories.ts b/stories/atoms/CommitBody.stories.ts new file mode 100644 index 0000000..760ab66 --- /dev/null +++ b/stories/atoms/CommitBody.stories.ts @@ -0,0 +1,34 @@ +/* Stories for CommitBody atom. + * Copyright (C) 2024 André Jaenisch + * SPDX-FileCopyrightText: 2024 André Jaenisch + * SPDX-License-Identifier: AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License along with this program. If not, see . + */ + +import type { Meta, StoryObj } from '@storybook/svelte'; + +import CommitBody from '$lib/components/atoms/CommitBody.svelte'; + +const meta = { + title: 'Atoms/CommitBody', + component: CommitBody, + tags: ['autodocs'] +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Plain: Story = { + args: { + commit: { + hash: 'abc123def456ghi789jkl0', + name: 'Added moar tests.', + committed: new Date().toISOString() + } + } +}; diff --git a/stories/atoms/CommitDate.stories.ts b/stories/atoms/CommitDate.stories.ts new file mode 100644 index 0000000..7c78401 --- /dev/null +++ b/stories/atoms/CommitDate.stories.ts @@ -0,0 +1,32 @@ +/* Stories for CommitDate atom. + * Copyright (C) 2024 André Jaenisch + * SPDX-FileCopyrightText: 2024 André Jaenisch + * SPDX-License-Identifier: AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License along with this program. If not, see . + */ + +import type { Meta, StoryObj } from '@storybook/svelte'; + +import CommitDate from '$lib/components/atoms/CommitDate.svelte'; + +const meta = { + title: 'Atoms/CommitDate', + component: CommitDate, + tags: ['autodocs'] +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Plain: Story = { + args: { + commitDate: new Date().toISOString().slice(0, '1970-01-01'.length), + numberOfCommits: 2, + repoName: 'Anvil Testing' + } +}; diff --git a/stories/icons/Copy16.stories.ts b/stories/icons/Copy16.stories.ts new file mode 100644 index 0000000..0ab6818 --- /dev/null +++ b/stories/icons/Copy16.stories.ts @@ -0,0 +1,36 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Eric Liu + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + */ + +/* + * SPDX-FileCopyrightText: 2020 - 2024 Eric Liu + * SPDX-License-Identifier: MIT + */ + +import type { Meta, StoryObj } from '@storybook/svelte'; +import { Copy16 } from 'svelte-octicons'; + +const meta = { + title: 'Icons/Copy16', + component: Copy16, + tags: ['autodocs'], + argTypes: { + fill: { + control: 'color' + } + } +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Plain: Story = {}; diff --git a/stories/icons/FileDirectory16.stories.ts b/stories/icons/FileDirectory16.stories.ts new file mode 100644 index 0000000..7ce3827 --- /dev/null +++ b/stories/icons/FileDirectory16.stories.ts @@ -0,0 +1,36 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Eric Liu + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + */ + +/* + * SPDX-FileCopyrightText: 2020 - 2024 Eric Liu + * SPDX-License-Identifier: MIT + */ + +import type { Meta, StoryObj } from '@storybook/svelte'; +import { FileDirectory16 } from 'svelte-octicons'; + +const meta = { + title: 'Icons/FileDirectory16', + component: FileDirectory16, + tags: ['autodocs'], + argTypes: { + fill: { + control: 'color' + } + } +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Plain: Story = {}; diff --git a/stories/icons/GitCommit24.stories.ts b/stories/icons/GitCommit24.stories.ts new file mode 100644 index 0000000..a8bf214 --- /dev/null +++ b/stories/icons/GitCommit24.stories.ts @@ -0,0 +1,36 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Eric Liu + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + */ + +/* + * SPDX-FileCopyrightText: 2020 - 2024 Eric Liu + * SPDX-License-Identifier: MIT + */ + +import type { Meta, StoryObj } from '@storybook/svelte'; +import { GitCommit24 } from 'svelte-octicons'; + +const meta = { + title: 'Icons/GitCommit24', + component: GitCommit24, + tags: ['autodocs'], + argTypes: { + fill: { + control: 'color' + } + } +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Plain: Story = {}; diff --git a/stories/molecules/History.stories.ts b/stories/molecules/History.stories.ts new file mode 100644 index 0000000..3cc43b3 --- /dev/null +++ b/stories/molecules/History.stories.ts @@ -0,0 +1,324 @@ +/* Stories for History molecule. + * Copyright (C) 2024 André Jaenisch + * SPDX-FileCopyrightText: 2024 André Jaenisch + * SPDX-License-Identifier: AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License along with this program. If not, see . + */ + +import type { Meta, StoryObj } from '@storybook/svelte'; + +import History from '$lib/components/molecules/History.svelte'; + +const meta = { + title: 'Molecules/History', + component: History, + tags: ['autodocs'] +} satisfies Meta; + +const followingsMap = [ + { + '@context': [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v2', + 'https://forgefed.org/ns' + ], + id: 'https://fig.fr33domlover.site/repos/9nOkn', + inbox: 'https://fig.fr33domlover.site/repos/9nOkn/inbox', + outbox: 'https://fig.fr33domlover.site/repos/9nOkn/outbox', + followers: 'https://fig.fr33domlover.site/repos/9nOkn/followers', + publicKey: ['https://fig.fr33domlover.site/akey1', 'https://fig.fr33domlover.site/akey2'], + type: 'Repository', + name: 'Very fun demo', + summary: 'Testing MR demo', + team: null, + versionControlSystem: 'https://forgefed.org/ns#git', + sendPatchesTo: 'https://fig.fr33domlover.site/looms/9nOkn', + cloneUri: 'https://fig.fr33domlover.site/repos/9nOkn', + collaborators: 'https://fig.fr33domlover.site/repos/9nOkn/collabs', + context: 'https://fig.fr33domlover.site/repos/9nOkn/projects' + }, + { + '@context': [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v2', + 'https://forgefed.org/ns' + ], + id: 'https://fig.fr33domlover.site/repos/Pn9Yn', + inbox: 'https://fig.fr33domlover.site/repos/Pn9Yn/inbox', + outbox: 'https://fig.fr33domlover.site/repos/Pn9Yn/outbox', + followers: 'https://fig.fr33domlover.site/repos/Pn9Yn/followers', + publicKey: ['https://fig.fr33domlover.site/akey1', 'https://fig.fr33domlover.site/akey2'], + type: 'Repository', + name: 'Anvil', + summary: 'Mirror of Anvil so I can develop its UI', + team: null, + versionControlSystem: 'https://forgefed.org/ns#git', + cloneUri: 'https://fig.fr33domlover.site/repos/Pn9Yn', + collaborators: 'https://fig.fr33domlover.site/repos/Pn9Yn/collabs', + context: 'https://fig.fr33domlover.site/repos/Pn9Yn/projects' + } +]; + +export default meta; +type Story = StoryObj; + +export const Empty: Story = { + args: { + commitsMap: [], + followingsMap: [] + } +}; + +export const SingleDateSingleProjectSingleCommit: Story = { + args: { + commitsMap: generateCommits([ + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + } + ]), + followingsMap + } +}; + +export const SingleDateSingleProjectMultipleCommits: Story = { + args: { + commitsMap: generateCommits([ + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Best commit ever', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + } + ]), + followingsMap + } +}; + +export const SingleDateMultipleProjectsSingleCommit: Story = { + args: { + commitsMap: generateCommits([ + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: 'd6e409a6b536e026c95f64d2732946ba0136ddb1', + commitName: 'Best commit ever', + committed: '2022-09-28T17:06:36Z', + repoId: '9nOkn' + } + ]), + followingsMap + } +}; + +export const SingleDateMultipleProjectsMultipleCommits: Story = { + args: { + commitsMap: generateCommits([ + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Best commit ever', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-09-28T17:01:30Z', + repoId: '9nOkn' + }, + { + commitId: 'd6e409a6b536e026c95f64d2732946ba0136ddb1', + commitName: 'Best commit ever', + committed: '2022-09-28T17:06:36Z', + repoId: '9nOkn' + } + ]), + followingsMap + } +}; + +export const MultipleDatesSingleProjectSingleCommit: Story = { + args: { + commitsMap: generateCommits([ + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Best commit ever', + committed: '2022-10-28T17:01:30Z', + repoId: 'Pn9Yn' + } + ]), + followingsMap + } +}; + +export const MultipleDatesSingleProjectMultipleCommits: Story = { + args: { + commitsMap: generateCommits([ + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Best commit ever', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-10-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Best commit ever', + committed: '2022-10-28T17:01:30Z', + repoId: 'Pn9Yn' + } + ]), + + followingsMap + } +}; + +export const MultipleDatesMultipleProjectsSingleCommit: Story = { + args: { + commitsMap: generateCommits([ + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-10-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: 'd6e409a6b536e026c95f64d2732946ba0136ddb1', + commitName: 'Best commit ever', + committed: '2022-09-28T17:06:36Z', + repoId: '9nOkn' + }, + { + commitId: 'd6e409a6b536e026c95f64d2732946ba0136ddb1', + commitName: 'Best commit ever', + committed: '2022-10-28T17:06:36Z', + repoId: '9nOkn' + } + ]), + followingsMap + } +}; + +export const MultipleDatesMultipleProjectsMultipleCommits: Story = { + args: { + commitsMap: generateCommits([ + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Best commit ever', + committed: '2022-09-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-10-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Best commit ever', + committed: '2022-10-28T17:01:30Z', + repoId: 'Pn9Yn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-09-28T17:01:30Z', + repoId: '9nOkn' + }, + { + commitId: 'd6e409a6b536e026c95f64d2732946ba0136ddb1', + commitName: 'Best commit ever', + committed: '2022-09-28T17:06:36Z', + repoId: '9nOkn' + }, + { + commitId: '36e1bb146fa3a6fb5c8d490f76ff4cca5f8f2e78', + commitName: 'Initial commit', + committed: '2022-10-28T17:01:30Z', + repoId: '9nOkn' + }, + { + commitId: 'd6e409a6b536e026c95f64d2732946ba0136ddb1', + commitName: 'Best commit ever', + committed: '2022-10-28T17:06:36Z', + repoId: '9nOkn' + } + ]), + followingsMap + } +}; + +function generateCommits(metadata) { + return metadata.map((metadatum) => { + const { repoId, commitId, commitName, committed } = metadatum; + + return { + '@context': ['https://www.w3.org/ns/activitystreams', 'https://forgefed.org/ns'], + id: `https://fig.fr33domlover.site/repos/${repoId}/commits/${commitId}`, + type: 'Commit', + context: `https://fig.fr33domlover.site/repos/${repoId}`, + attributedTo: 'https://fig.fr33domlover.site/people/qn870', + committedBy: { + name: 'vervis', + mbox: 'mailto:vervis@vervis.vervis' + }, + name: commitName, + hash: commitId, + created: committed, + committed + }; + }); +}