Skip to content

Commit

Permalink
Merge pull request #17 from taga3s/refac/styles
Browse files Browse the repository at this point in the history
refac: change style object to style variables to reduce bundle size
  • Loading branch information
taga3s authored Sep 4, 2024
2 parents 1650009 + 990caed commit a92deb6
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 88 deletions.
1 change: 1 addition & 0 deletions app/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./Footer";
export * from "./Header";
export * from "./Section";
44 changes: 22 additions & 22 deletions app/components/posts/Posts.css.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { css } from "hono/css";

const postsStyle = {
wrapper: css`
display: flex;
flex-direction: column;
gap: 16px;
margin-top: 32px;
`,
item: css`
display: flex;
flex-direction: column;
gap: 8px;
width: 100%;
padding: 16px;
border: 1px solid #ccc;
border-radius: 8px;
`,
itemTitle: css`
font-size: 20px;
font-weight: bold;
`,
};
const postsWrapper = css`
display: flex;
flex-direction: column;
gap: 16px;
margin-top: 32px;
`;

export { postsStyle };
const postsItem = css`
display: flex;
flex-direction: column;
gap: 8px;
width: 100%;
padding: 16px;
border: 1px solid #ccc;
border-radius: 8px;
`;

const postsItemTitle = css`
font-size: 20px;
font-weight: bold;
`;

export { postsItem, postsItemTitle, postsWrapper };
8 changes: 4 additions & 4 deletions app/components/posts/Posts.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FC } from "hono/jsx";
import type { Post } from "../../api/posts/model";
import { Section } from "../Section";
import { postsStyle } from "./Posts.css";
import { postsItem, postsItemTitle, postsWrapper } from "./Posts.css";

type Props = {
posts: Post[];
Expand All @@ -10,12 +10,12 @@ type Props = {
const Posts: FC<Props> = ({ posts }) => {
return (
<Section title="Posts">
<div class={postsStyle.wrapper}>
<div class={postsWrapper}>
{posts.map((post) => {
return (
<a key={post.id} href={`/${post.id}`} class={postsStyle.item}>
<a key={post.id} href={`/${post.id}`} class={postsItem}>
<span>{post.publishedAt}</span>
<span class={postsStyle.itemTitle}>{post.title}</span>
<span class={postsItemTitle}>{post.title}</span>
</a>
);
})}
Expand Down
14 changes: 7 additions & 7 deletions app/components/profile/ProfileLinks.css.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from "hono/css";

const linkCardContainer = css`
const profileLinkCardContainer = css`
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
Expand All @@ -11,36 +11,36 @@ const linkCardContainer = css`
}
`;

const linkCard = css`
const profileLinkCard = css`
display: flex;
justify-content: center;
align-items: center;
height: 100px;
border-radius: 8px;
`;

const linkCardIcon = css`
const profileLinkCardIcon = css`
width: 67px;
height: 67px;
`;

const github = css`
${linkCard}
${profileLinkCard}
fill: #ffffff;
background: rgb(205,188,255);
background: linear-gradient(90deg, rgba(205,188,255,0.4515931372549019) -27%, rgba(92,80,118,1) 0%, rgba(116,84,205,1) 0%, rgba(118,83,196,1) 0%, rgba(129,92,200,1) 0%, rgba(46,47,62,0.9137780112044818) 0%, rgba(198,195,209,0.8521533613445378) 100%, rgba(230,14,221,1) 100%, rgba(237,235,246,1) 100%, rgba(0,0,82,1) 100%, rgba(3,1,9,0.4515931372549019) 100%);
`;

const qiita = css`
${linkCard}
${profileLinkCard}
background: rgb(205,188,255);
background: linear-gradient(90deg, rgba(205,188,255,0.4515931372549019) -27%, rgba(92,80,118,1) 0%, rgba(116,84,205,1) 0%, rgba(118,83,196,1) 0%, rgba(92,200,121,1) 0%, rgba(25,230,34,0.4515931372549019) 100%, rgba(106,217,191,0.9249824929971989) 100%, rgba(198,195,209,0.8521533613445378) 100%, rgba(230,14,221,1) 100%, rgba(237,235,246,1) 100%, rgba(0,0,82,1) 100%);
`;

const cosense = css`
${linkCard}
${profileLinkCard}
background: rgb(2,0,36);
background: linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(208,108,7,1) 0%, rgba(194,156,24,1) 0%, rgba(187,180,32,1) 40%, rgba(0,212,255,1) 100%);
`;

export { linkCardContainer, linkCard, linkCardIcon, github, qiita, cosense };
export { profileLinkCard, profileLinkCardIcon, profileLinkCardContainer, github, qiita, cosense };
6 changes: 3 additions & 3 deletions app/components/profile/ProfileLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CosenseIcon, GitHubIcon, QiitaIcon } from "../icons";
import { Section } from "../Section";
import { cosense, github, linkCardContainer, linkCardIcon, qiita } from "./ProfileLinks.css";
import { cosense, github, profileLinkCardContainer, profileLinkCardIcon, qiita } from "./ProfileLinks.css";

const links = [
{
Expand All @@ -26,10 +26,10 @@ const links = [
const ProfileLinks = () => {
return (
<Section title="Links">
<div class={linkCardContainer}>
<div class={profileLinkCardContainer}>
{links.map((link) => (
<a href={link.url} class={link.style} key={link.title}>
<div class={linkCardIcon}>{link.icon}</div>
<div class={profileLinkCardIcon}>{link.icon}</div>
</a>
))}
</div>
Expand Down
21 changes: 14 additions & 7 deletions app/components/profile/ProfileMain.css.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { css } from "hono/css";

const main = css`
const profileMain = css`
display: flex;
justify-content: space-between;
align-items: center;
`;

const mainBox = css`
const profileMainBox = css`
display: flex;
flex-direction: column;
gap: 12px;
`;

const mainImage = css`
const profileMainImage = css`
width: 100px;
height: 100px;
border-radius: 12px;
Expand All @@ -23,24 +23,31 @@ const mainImage = css`
}
`;

const mainName = css`
const profileMainName = css`
font-size: 28px;
font-weight: bold;
`;

const mainBelonging = css`
const profileMainBelonging = css`
display: flex;
flex-direction: column;
gap: 8px;
font-size: 16px;
`;

const mainIntroduction = css`
const profileMainIntroduction = css`
display: flex;
flex-direction: column;
gap: 16px;
margin-top: 32px;
font-size: 16px;
`;

export { main, mainBox, mainImage, mainName, mainBelonging, mainIntroduction };
export {
profileMain,
profileMainBox,
profileMainImage,
profileMainName,
profileMainBelonging,
profileMainIntroduction,
};
21 changes: 14 additions & 7 deletions app/components/profile/ProfileMain.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import { main, mainBelonging, mainBox, mainImage, mainIntroduction, mainName } from "./ProfileMain.css";
import {
profileMain,
profileMainBelonging,
profileMainBox,
profileMainImage,
profileMainIntroduction,
profileMainName,
} from "./ProfileMain.css";

const ProfileMain = () => {
return (
<section>
<div class={main}>
<div class={mainBox}>
<span class={mainName}>Seiya Tagami / taga3s</span>
<ul class={mainBelonging}>
<div class={profileMain}>
<div class={profileMainBox}>
<span class={profileMainName}>Seiya Tagami / taga3s</span>
<ul class={profileMainBelonging}>
<li>Web Developer (working as an intern)</li>
</ul>
</div>
<div>
<img class={mainImage} src="https://github.com/taga3s.png" alt="me" />
<img class={profileMainImage} src="https://github.com/taga3s.png" alt="me" />
</div>
</div>
<ul class={mainIntroduction}>
<ul class={profileMainIntroduction}>
<li>🛠️ わくわくするようなモノづくりがしたい。</li>
<li>🐳 Web、法律、ラーメン...な日常。</li>
<li>🍀 アニメ/漫画やゲームが好き。</li>
Expand Down
74 changes: 42 additions & 32 deletions app/components/works/WorksList.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,46 @@ const worksListItemImg = css`
border-radius: 8px;
`;

const worksListItemDetail = {
wrapper: css`
position: absolute;
bottom: 0;
left: 0;
right: 0;
display: flex;
flex-direction: column;
gap: 6px;
width: 100%;
padding: 16px;
opacity: 0.9;
border-radius: 4px;
color: #6a5ed1;
`,
header: css`
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
`,
icon: css`
width: 24px;
height: 24px;
fill: #6a5ed1;
`,
title: css`
font-size: 24px;
font-weight: bold;
`,
};
const worksListItemDetailWrapper = css`
position: absolute;
bottom: 0;
left: 0;
right: 0;
display: flex;
flex-direction: column;
gap: 6px;
width: 100%;
padding: 16px;
opacity: 0.9;
border-radius: 4px;
color: #6a5ed1;
`;

export { worksListContainer, worksList, worksListItem, worksListItemImg, worksListItemDetail };
const worksListItemDetailHeader = css`
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
`;

const worksListItemDetailTitle = css`
font-size: 20px;
font-weight: bold;
`;

const worksListItemDetailIcon = css`
width: 24px;
height: 24px;
fill: #6a5ed1;
`;

export {
worksListContainer,
worksList,
worksListItem,
worksListItemImg,
worksListItemDetailWrapper,
worksListItemDetailHeader,
worksListItemDetailTitle,
worksListItemDetailIcon,
};
18 changes: 13 additions & 5 deletions app/components/works/WorksList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import type { FC } from "hono/jsx";
import { Section } from "../Section";
import { worksList, worksListItem, worksListItemDetail, worksListItemImg } from "./WorksList.css";
import {
worksList,
worksListItem,
worksListItemDetailHeader,
worksListItemDetailIcon,
worksListItemDetailTitle,
worksListItemDetailWrapper,
worksListItemImg,
} from "./WorksList.css";
import type { Work } from "../../api/works";
import { GitHubIcon } from "../icons";

Expand All @@ -15,10 +23,10 @@ const WorksList: FC<Props> = ({ works }) => {
{works.map((work) => (
<li key={work.title} class={worksListItem}>
<img src={work.image.url} alt={work.title} class={worksListItemImg} />
<div class={worksListItemDetail.wrapper}>
<div class={worksListItemDetail.header}>
<h3 class={worksListItemDetail.title}>{work.title}</h3>
<a href={work.githubUrl} class={worksListItemDetail.icon}>
<div class={worksListItemDetailWrapper}>
<div class={worksListItemDetailHeader}>
<h3 class={worksListItemDetailTitle}>{work.title}</h3>
<a href={work.githubUrl} class={worksListItemDetailIcon}>
<GitHubIcon />
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default jsxRenderer(({ children, title }) => {
<body class={bodyLayout}>
<ErrorBoundary fallback={<p>Sorry, Out of Service.</p>}>
<HeaderMemorized />
{children}
<main>{children}</main>
<FooterMemorized />
</ErrorBoundary>
</body>
Expand Down

0 comments on commit a92deb6

Please sign in to comment.