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 aboutme webcomponents #1

Merged
merged 1 commit into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
80 changes: 80 additions & 0 deletions src/components/aboutme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const id = 't0yohei';

const template = `
<div class="main">
<div class="main-top">
<a href="https://twitter.com/${id}">
<img
class="twitter-image"
src="https://pbs.twimg.com/profile_images/731737341488816130/wH_caJBf_400x400.jpg"
/>
</a>
<div class="top">
<h1><span>とよへい</span></h1>
<p>Software Engineer</p>
</div>
</div>
<p class="description">しがないソフトウェアエンジニャです。</p>
<table class="profile-table">
<tbody>
<tr>
<th class="show">好きな言語 / FW</th>
<td class="show"><p>Ruby, Rails, Vue.js</p></td>
</tr>
<tr>
<th class="show">好きな物</th>
<td class="show"><p>アニメ、コーヒー</p></td>
</tr>
<tr>
<th class="show">住処</th>
<td class="show"><p>東京周辺</p></td>
</tr>
</tbody>
</table>
</div>

<style>
.main {
margin-top: 20px;
}

.main-top {
display: flex;
align-items: center;
gap: 50px;
}

.twitter-image {
width: 150px;
height: 150px;
border-radius: 100px;
}

.description {
margin: 30px 0;
font-size: 18px;
}

.profile-table {
table-layout: auto;
width: 100%;
text-align: left;
}
</style>
`;

class AboutMe extends HTMLElement {
constructor() {
super();
}

connectedCallback() {
this.attachShadow({ mode: 'open' });
const elem = document.createElement('template');
elem.innerHTML = template;

this.shadowRoot.append(elem.content);
}
}

customElements.define('about-me', AboutMe);
5 changes: 5 additions & 0 deletions src/pages/about.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import Layout from '../layouts/Layout.astro';
import '../styles/global.css';
---

<script>
import '../components/aboutme.js';
</script>

<Layout title="About me">
<main>
<h1>About me</h1>
<about-me></about-me>
</main>
</Layout>

Expand Down