-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pages/home): refactor with additional reuseable components
Signed-off-by: Lachlan Heywood <lachieh@users.noreply.github.com>
- Loading branch information
Showing
36 changed files
with
679 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import SvgSparkles from './img/sparkles.svg'; | ||
import { SketchUnderline } from '@site/src/pages/_components/sketch-underline'; | ||
import styles from './styles.module.css'; | ||
import { SketchSparkles } from '../sketch-sparkles'; | ||
|
||
type Props = { | ||
children: string; | ||
}; | ||
|
||
/** | ||
* tagged template function to decorate input with underline `_(.*?)_` and sparkles `\*(.*?)\*` | ||
* @example decorate`Hello _world_ and *everyone*` => <>Hello <SketchUnderline>world</SketchUnderline> and <span>everyone<SvgSparkles /></span></> | ||
* @returns ReactNode with heading decorated | ||
*/ | ||
function DecorateText({ children }: Props): React.ReactNode { | ||
const result = children.split(/(_.*?_|\*.*?\*)/).map((part, i) => { | ||
if (part.startsWith('_')) { | ||
return <SketchUnderline key={i}>{part.slice(1, -1)}</SketchUnderline>; | ||
} | ||
if (part.startsWith('*')) { | ||
return <SketchSparkles>{part.slice(1, -1)}</SketchSparkles>; | ||
} | ||
return part; | ||
}); | ||
return <>{result}</>; | ||
} | ||
|
||
export { DecorateText }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { HTMLProps, PropsWithChildren } from 'react'; | ||
import styles from './styles.module.css'; | ||
import clsx from 'clsx'; | ||
|
||
type BaseProps = PropsWithChildren<HTMLProps<HTMLDivElement>>; | ||
|
||
type GridProps = BaseProps & { | ||
alignLast?: boolean; | ||
center?: boolean; | ||
}; | ||
|
||
type GridItemProps = BaseProps; | ||
|
||
function Grid({ children, className, alignLast, center, ...props }: GridProps) { | ||
return ( | ||
<div | ||
className={clsx(styles.grid, className, { | ||
[styles.alignLast]: alignLast, | ||
[styles.center]: center, | ||
})} | ||
{...props} | ||
> | ||
{children} | ||
</div> | ||
); | ||
} | ||
|
||
function GridItem({ children, className, ...props }: GridItemProps) { | ||
return ( | ||
<div className={clsx(styles.gridItem, className)} {...props}> | ||
{children} | ||
</div> | ||
); | ||
} | ||
|
||
export { Grid, GridItem }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
.grid { | ||
display: flex; | ||
flex-direction: column; | ||
row-gap: 4rem; | ||
column-gap: 2rem; | ||
} | ||
|
||
.gridItem { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: start; | ||
justify-items: start; | ||
gap: 1.25rem; | ||
} | ||
|
||
.grid.alignLast .gridItem > *:last-child { | ||
margin-top: auto; | ||
} | ||
|
||
.grid.center .gridItem { | ||
text-align: center; | ||
align-items: center; | ||
} | ||
|
||
.gridItem:nth-child(1) { | ||
grid-area: a; | ||
} | ||
.gridItem:nth-child(2) { | ||
grid-area: b; | ||
} | ||
.gridItem:nth-child(3) { | ||
grid-area: c; | ||
} | ||
|
||
.gridItem > * { | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
} | ||
|
||
@media (min-width: 768px) { | ||
.grid { | ||
display: grid; | ||
} | ||
.grid:has(.gridItem:nth-child(2)) { | ||
grid-template: 'a b' 1fr / 1fr 1fr; | ||
} | ||
.grid:has(.gridItem:nth-child(3)) { | ||
grid-template: | ||
'a a b b' 1fr | ||
'. c c .' 1fr / 1fr 1fr 1fr 1fr; | ||
} | ||
} | ||
|
||
@media (min-width: 997px) { | ||
.grid:has(.gridItem:nth-child(3)) { | ||
grid-template: 'a b c' 1fr / 1fr 1fr 1fr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import clsx from 'clsx'; | ||
import styles from './section-content.module.css'; | ||
import React from 'react'; | ||
|
||
type Props = { | ||
hasContainer?: boolean; | ||
align?: 'start' | 'center'; | ||
aside?: React.ReactNode; | ||
} & React.HTMLAttributes<HTMLDivElement>; | ||
|
||
function SectionContent({ | ||
children, | ||
className, | ||
aside, | ||
align = 'start', | ||
hasContainer = true, | ||
...props | ||
}: Props) { | ||
return ( | ||
<article | ||
className={clsx( | ||
{ | ||
[styles.content]: true, | ||
[styles.alignCenter]: align === 'center', | ||
container: hasContainer, | ||
}, | ||
className, | ||
)} | ||
{...props} | ||
> | ||
{aside ? ( | ||
<> | ||
<main className={styles.main}>{children}</main> | ||
<aside className={styles.aside}>{aside}</aside> | ||
</> | ||
) : ( | ||
children | ||
)} | ||
</article> | ||
); | ||
} | ||
|
||
export { SectionContent }; |
35 changes: 35 additions & 0 deletions
35
src/pages/_components/section-content/section-content.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.content { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: start; | ||
text-align: start; | ||
width: 100%; | ||
} | ||
|
||
.content.alignCenter { | ||
align-items: center; | ||
text-align: center; | ||
} | ||
|
||
.content + .content { | ||
margin-top: 2rem; | ||
} | ||
|
||
.main { | ||
width: 100%; | ||
grid-area: main; | ||
} | ||
|
||
.aside { | ||
width: 100%; | ||
max-width: 300px; | ||
margin: 0 auto; | ||
grid-area: aside; | ||
} | ||
|
||
@media screen and (min-width: 800px) { | ||
.content:has(.aside) { | ||
display: grid; | ||
grid-template: 'main aside' auto / 2fr 1fr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import React from 'react'; | ||
import styles from './styles.module.css'; | ||
import { DecorateText } from '../decorate'; | ||
|
||
type Props = { | ||
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; | ||
} & React.HTMLAttributes<HTMLHeadingElement>; | ||
|
||
function SectionHeading({ as = 'h3', className, ...props }: Props) { | ||
function SectionHeading({ as = 'h3', className, children, ...props }: Props) { | ||
const Tag = as; | ||
return <Tag className={[styles.heading, className].join(' ')} {...props} />; | ||
return ( | ||
<Tag className={[styles.heading, className].join(' ')} {...props}> | ||
{typeof children === 'string' ? <DecorateText>{children}</DecorateText> : children} | ||
</Tag> | ||
); | ||
} | ||
|
||
export { SectionHeading }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import styles from './sketch-sparkles.module.css'; | ||
import clsx from 'clsx'; | ||
import SvgSparkles from './img/sparkles.svg'; | ||
|
||
function SketchSparkles({ children, ...props }) { | ||
return ( | ||
<span className={clsx(styles.sparkles, 'sketch sketch--sparkles')} {...props}> | ||
{children} | ||
<SvgSparkles className={clsx(styles.image, 'sketch__svg')} /> | ||
</span> | ||
); | ||
} | ||
|
||
export { SketchSparkles }; |
12 changes: 12 additions & 0 deletions
12
src/pages/_components/sketch-sparkles/sketch-sparkles.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.underline { | ||
position: relative; | ||
color: inherit; | ||
} | ||
|
||
.image { | ||
position: absolute; | ||
color: var(--section-color-highlight); | ||
width: 2.5rem; | ||
right: 0; | ||
bottom: 60%; | ||
} |
16 changes: 0 additions & 16 deletions
16
src/pages/_index/_components/case-studies/case-studies.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.