Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bio component #5

Merged
merged 5 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ jobs:
- name: 🏞️ Biome Check
run: bun run check:biome

test:
name: 🧪 Test
runs-on: Ubuntu-Latest

steps:
- name: 🚚 Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: 🍞 Setup Bun with Cache
uses: ./.github/actions/setup-bun-with-cache

- name: 🧪 Run Tests
run: bun run test:cov

- name: ☂️ Upload Coverage
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: ☂️ Upload Test Results
if: ${{ !cancelled() }}
uses: codecov/test-results-action@9739113ad922ea0a9abb4b2c0f8bf6a4aa8ef820 # v1.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

build-check:
name: 🛠️ Build Check
runs-on: Ubuntu-Latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules/
dist/
.astro/
coverage/
junit.xml
10 changes: 9 additions & 1 deletion astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import type { AstroIntegration } from "astro";
import { defineConfig } from "astro/config";
import astrobook from "astrobook";

Check warning on line 3 in astro.config.ts

View check run for this annotation

Codecov / codecov/patch

astro.config.ts#L3

Added line #L3 was not covered by tests

export default defineConfig({});
const integrations: AstroIntegration[] = [];

Check warning on line 5 in astro.config.ts

View check run for this annotation

Codecov / codecov/patch

astro.config.ts#L5

Added line #L5 was not covered by tests

if (process.env.ASTROBOOK) {
integrations.push(astrobook({ directory: "src/components" }));
}

Check warning on line 9 in astro.config.ts

View check run for this annotation

Codecov / codecov/patch

astro.config.ts#L7-L9

Added lines #L7 - L9 were not covered by tests

export default defineConfig({ integrations });

Check warning on line 11 in astro.config.ts

View check run for this annotation

Codecov / codecov/patch

astro.config.ts#L11

Added line #L11 was not covered by tests
Binary file modified bun.lockb
5ouma marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@
"version": "0.0.0",
"scripts": {
"dev": "astro dev",
"astrobook": "ASTROBOOK=1 astro dev",
"build": "astro build",
"preview": "astro preview",
"check:astro": "astro check",
"check:biome": "biome check"
"check:biome": "biome check",
"test": "vitest run",
"test:cov": "vitest run --coverage"
},
"dependencies": {
"astro": "4.16.10",
"typescript": "5.6.3"
},
"devDependencies": {
"@astrojs/check": "0.9.4",
"@biomejs/biome": "1.9.4"
"@biomejs/biome": "1.9.4",
"@types/node": "22.9.0",
"@vitest/coverage-v8": "2.1.4",
"astrobook": "0.5.1",
"vitest": "2.1.4"
}
}
Binary file added public/fonts/LINESeedJP_Bd.otf
Binary file not shown.
Binary file added public/fonts/LINESeedJP_Rg.otf
Binary file not shown.
19 changes: 19 additions & 0 deletions src/components/Bio/Bio.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
import "../../styles/global.css";
import "./style.css";

export type Props = {
name: string;
description: string;
icon: string;
};
const props = Astro.props;
---

<div id="bio">
<div id="profile">
<img src={props.icon} alt="icon" loading="lazy" decoding="async" />
<span id="name">{props.name}</span>
</div>
<span id="description">{props.description}</span>
</div>
11 changes: 11 additions & 0 deletions src/components/Bio/Bio.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Bio from "./Bio.astro";
import * as stories from "./story.ts";

export default {
title: "Bio",
component: Bio,
};

Check warning on line 7 in src/components/Bio/Bio.stories.ts

View check run for this annotation

Codecov / codecov/patch

src/components/Bio/Bio.stories.ts#L4-L7

Added lines #L4 - L7 were not covered by tests

export const Default = { args: stories.Default };
export const Japanese = { args: stories.Japanese };
export const Long = { args: stories.Long };

Check warning on line 11 in src/components/Bio/Bio.stories.ts

View check run for this annotation

Codecov / codecov/patch

src/components/Bio/Bio.stories.ts#L9-L11

Added lines #L9 - L11 were not covered by tests
18 changes: 18 additions & 0 deletions src/components/Bio/Bio.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { experimental_AstroContainer as AstroContainer } from "astro/container";
import { describe, expect, test } from "vitest";

import Bio from "./Bio.astro";
import * as stories from "./story.ts";

describe("Bio", () => {
for (const [name, props] of Object.entries(stories)) {
test(name, async () => {
const container: AstroContainer = await AstroContainer.create();
const result: string = await container.renderToString(Bio, { props });

expect(result).toContain(`>${props.name}</span>`);
expect(result).toContain(`>${props.description}</span>`);
expect(result).toContain(`<img src="${props.icon}"`);
});
}
});
20 changes: 20 additions & 0 deletions src/components/Bio/story.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Props } from "./Bio.astro";

export const Default: Props = {
name: "Bio Name",
description: "Bio Description",
icon: "https://github.com/withastro.png",
};

export const Japanese: Props = {
name: "名前",
description: "説明",
icon: "https://github.com/withastro.png",
};

export const Long: Props = {
name: "Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Bio Name",
description:
"Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Bio Description",
icon: "https://github.com/withastro.png",
};
36 changes: 36 additions & 0 deletions src/components/Bio/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#bio {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: 0.3rem;
}

#profile {
display: flex;
align-items: center;
gap: 0.3rem;
}

img {
width: 6rem;
height: auto;
}

span {
font-family: "LINE Seed JP" sans-serif;
font-style: normal;
line-height: normal;
color: var(--foreground);
}

#name {
font-size: 2.5rem;
font-weight: bold;
}

#description {
font-size: 0.9rem;
font-weight: normal;
white-space: pre-line;
}
25 changes: 25 additions & 0 deletions src/styles/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@font-face {
font-family: "LINE Seed JP";
src: url("/fonts/LINESeedJP_Rg.otf") format("opentype");
font-weight: normal;
font-style: normal;
font-display: swap;
}

@font-face {
font-family: "LINE Seed JP";
src: url("/fonts/LINESeedJP_Bd.otf") format("opentype");
font-weight: bold;
font-style: normal;
font-display: swap;
}

:root {
color-scheme: light dark;
--foreground-light: #242424;
--foreground-dark: #f4f4f4;
--background-light: #f4f4f4;
--background-dark: #242424;
--foreground: light-dark(var(--foreground-light), var(--foreground-dark));
--background: light-dark(var(--background-light), var(--background-dark));
}
10 changes: 10 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference types="vitest" />

import { getViteConfig } from "astro/config";

export default getViteConfig({
test: {
reporters: ["verbose", ["junit", { suiteName: "Component Tests" }]],
outputFile: "junit.xml",
},
});