Skip to content

Commit 27effd2

Browse files
committed
feat: add strength detail sections
1 parent 948f477 commit 27effd2

File tree

2 files changed

+138
-1
lines changed

2 files changed

+138
-1
lines changed

src/pages/present/strengths.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,47 @@
1+
import { graphql, PageProps } from 'gatsby';
12
import { FormattedMessage } from 'react-intl';
23
import { DefaultLayout } from '../../layouts/DefaultLayout';
4+
import { StrengthsDetailSection } from '../../sections/StrengthsDetailSection';
35

4-
export default function StrengthsPage() {
6+
export default function StrengthsPage({ data }: PageProps<Queries.StrengthsPageQuery>) {
57
return (
68
<DefaultLayout>
79
<section>
810
<h2>
911
<FormattedMessage id="page.strengths.title" />
1012
</h2>
1113
</section>
14+
{data.strengths.nodes.map((strength, index) => (
15+
<StrengthsDetailSection strength={strength} index={index} />
16+
))}
1217
</DefaultLayout>
1318
);
1419
}
20+
21+
export const query = graphql`
22+
query StrengthsPage($locale: String) {
23+
strengths: allMarkdownRemark(
24+
filter: { fields: { locale: { eq: $locale }, kind: { eq: "sections/strengths/services" } } }
25+
sort: { frontmatter: { order: ASC } }
26+
) {
27+
nodes {
28+
html
29+
frontmatter {
30+
title
31+
order
32+
sprite
33+
skills {
34+
childMarkdownRemark {
35+
html
36+
frontmatter {
37+
title
38+
link
39+
sprite
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}
47+
`;
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { PropsWithChildren } from 'react';
2+
import { IterableElement } from 'type-fest';
3+
import { css, Theme, useTheme } from '@emotion/react';
4+
import { Markup } from 'interweave';
5+
import { DividedSection } from '../components/DividedSection';
6+
import { Sprite, SpriteProps } from '../components/Sprite';
7+
8+
const sectionStyle = (theme: Theme) => css`
9+
position: relative;
10+
z-index: 0;
11+
overflow: hidden;
12+
13+
&:nth-of-type(odd) {
14+
background-color: ${theme.whiteColor};
15+
> svg {
16+
fill: ${theme.backgroundColor};
17+
right: 0;
18+
left: unset;
19+
}
20+
}
21+
22+
> svg {
23+
position: absolute;
24+
top: 0;
25+
left: 0;
26+
height: 90%;
27+
width: auto;
28+
fill: ${theme.whiteColor};
29+
opacity: 0.5;
30+
z-index: -1;
31+
}
32+
33+
&:last-of-type + svg {
34+
display: none;
35+
}
36+
`;
37+
38+
const skillStyles = (isWhiteSection: boolean) => (theme: Theme) =>
39+
css`
40+
padding: ${theme.gutter};
41+
list-style: none;
42+
display: flex;
43+
gap: ${theme.gutter};
44+
45+
background-color: ${isWhiteSection ? theme.backgroundColor : theme.whiteColor};
46+
47+
&:not(:last-child) {
48+
margin-bottom: ${theme.gutter};
49+
}
50+
51+
--offset-size: 10rem;
52+
53+
&:nth-of-type(even) {
54+
margin-left: var(--offset-size);
55+
flex-direction: row-reverse;
56+
}
57+
58+
&:nth-of-type(odd) {
59+
margin-right: var(--offset-size);
60+
}
61+
62+
> div {
63+
flex: 1;
64+
65+
h3 {
66+
margin-top: 0;
67+
}
68+
}
69+
70+
svg {
71+
width: var(--offset-size);
72+
height: auto;
73+
fill: ${isWhiteSection ? theme.whiteColor : theme.backgroundColor};
74+
}
75+
`;
76+
77+
type StrengthsDetailSectionProps = {
78+
strength: IterableElement<Queries.StrengthsPageQuery['strengths']['nodes']>;
79+
index: number;
80+
};
81+
82+
export function StrengthsDetailSection({ strength, index }: StrengthsDetailSectionProps) {
83+
const theme = useTheme();
84+
85+
const isWhiteSection = index % 2 === 1;
86+
87+
return (
88+
<DividedSection upperColor={theme.whiteColor} lowerColor={theme.whiteColor} flipVertically={isWhiteSection} css={sectionStyle}>
89+
<Sprite name={strength.frontmatter?.sprite as SpriteProps['name']} />
90+
91+
<ul>
92+
{strength.frontmatter?.skills?.map(skill => (
93+
<li css={skillStyles(isWhiteSection)}>
94+
<Sprite name={skill?.childMarkdownRemark?.frontmatter?.sprite as SpriteProps['name']} />
95+
<div>
96+
<h3>{skill?.childMarkdownRemark?.frontmatter?.title}</h3>
97+
<Markup content={skill?.childMarkdownRemark?.html} />
98+
</div>
99+
</li>
100+
))}
101+
</ul>
102+
</DividedSection>
103+
);
104+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy