1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-21 07:01:19 -04:00

CSS modules ➡️ Stitches 🧵 (#799)

This commit is contained in:
2022-03-03 09:18:26 -05:00
committed by GitHub
parent ac7ac71c10
commit c2dde042b7
93 changed files with 2392 additions and 3000 deletions

View File

@@ -1,10 +1,25 @@
import Image from "../Image/Image";
import innerText from "react-innertext";
import classNames from "classnames";
import { styled } from "../../lib/styles/stitches.config";
import type { PropsWithChildren } from "react";
import type { ImageProps as NextImageProps } from "next/image";
import styles from "./Figure.module.css";
const Wrapper = styled("figure", {
margin: "1em auto",
textAlign: "center",
});
const Caption = styled("figcaption", {
fontSize: "0.9em",
lineHeight: 1.5,
color: "$medium",
marginTop: "-0.4em",
/* some figcaptions contain paragraphs, some don't, so reset all of them */
"& p": {
margin: "0 !important",
},
});
export type FigureProps = Omit<NextImageProps, "alt"> &
PropsWithChildren<{
@@ -13,10 +28,10 @@ export type FigureProps = Omit<NextImageProps, "alt"> &
const Figure = ({ children, alt, className, ...imageProps }: FigureProps) => {
return (
<figure className={classNames(styles.figure, className)}>
<Wrapper className={className}>
<Image alt={alt || innerText(children)} {...imageProps} />
<figcaption className={styles.caption}>{children}</figcaption>
</figure>
<Caption>{children}</Caption>
</Wrapper>
);
};