Skip to content

Commit

Permalink
Merge pull request #1 from nfroidure/feat/sized_images
Browse files Browse the repository at this point in the history
feat(images): size images upfront
  • Loading branch information
nfroidure authored Dec 24, 2022
2 parents 1a1e1b5 + cba18d2 commit 7c39c50
Show file tree
Hide file tree
Showing 16 changed files with 161 additions and 91 deletions.
4 changes: 3 additions & 1 deletion src/components/cite.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { HTMLAttributes } from "react";

const Cite = ({
children,
...props
}: {
children: React.ReactNode;
} & React.HTMLAttributes<HTMLElement>) => (
} & HTMLAttributes<HTMLElement>) => (
<cite className="root" {...props}>
{children}
<style jsx>{`
Expand Down
4 changes: 3 additions & 1 deletion src/components/code.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { HTMLAttributes } from "react";

const Code = ({
children,
...props
}: {
children: React.ReactNode;
} & React.HTMLAttributes<HTMLElement>) => (
} & HTMLAttributes<HTMLElement>) => (
<code className="root" {...props}>
{children}
<style jsx>{`
Expand Down
4 changes: 3 additions & 1 deletion src/components/em.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { HTMLAttributes } from "react";

const Emphasis = ({
children,
...props
}: {
children: React.ReactNode;
} & React.HTMLAttributes<HTMLElement>) => (
} & HTMLAttributes<HTMLElement>) => (
<em className="root" {...props}>
{children}
<style jsx>{`
Expand Down
1 change: 1 addition & 0 deletions src/components/gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const Gallery = ({ imagesNodes }: { imagesNodes: MarkdownImageNode[] }) => {
clear: both;
background: var(--secondary);
padding: calc(var(--vRythm) / 2) calc(var(--gutter) / 2);
margin: 0 0 var(--vRythm) 0;
}
p {
text-align: center;
Expand Down
4 changes: 3 additions & 1 deletion src/components/h1.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { HTMLAttributes } from "react";

const Heading1 = ({
children,
className,
...props
}: { children: React.ReactNode } & React.HTMLAttributes<HTMLElement>) => (
}: { children: React.ReactNode } & HTMLAttributes<HTMLElement>) => (
<h1 className={`root${className ? ' ' + className : ""}`} {...props}>
{children}
<style jsx>{`
Expand Down
4 changes: 3 additions & 1 deletion src/components/h2.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { HTMLAttributes } from "react";

const Heading2 = ({
children,
className,
...props
}: { children: React.ReactNode } & React.HTMLAttributes<HTMLElement>) => (
}: { children: React.ReactNode } & HTMLAttributes<HTMLElement>) => (
<h2 className={`root${className ? " " + className : ""}`} {...props}>
{children}
<style jsx>{`
Expand Down
4 changes: 3 additions & 1 deletion src/components/h3.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { HTMLAttributes } from "react";

const Heading3 = ({
children,
...props
}: { children: React.ReactNode } & React.HTMLAttributes<HTMLElement>) => (
}: { children: React.ReactNode } & HTMLAttributes<HTMLElement>) => (
<h3 className="root" {...props}>
{children}
<style jsx>{`
Expand Down
4 changes: 3 additions & 1 deletion src/components/h4.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { HTMLAttributes } from "react";

const Heading4 = ({
children,
...props
}: { children: React.ReactNode } & React.HTMLAttributes<HTMLElement>) => (
}: { children: React.ReactNode } & HTMLAttributes<HTMLElement>) => (
<h4 className="root" {...props}>
{children}
<style jsx>{`
Expand Down
4 changes: 3 additions & 1 deletion src/components/h5.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { HTMLAttributes } from "react";

const Heading5 = ({
children,
...props
}: { children: React.ReactNode } & React.HTMLAttributes<HTMLElement>) => (
}: { children: React.ReactNode } & HTMLAttributes<HTMLElement>) => (
<h5 className="root" {...props}>
{children}
<style jsx>{`
Expand Down
4 changes: 3 additions & 1 deletion src/components/h6.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { HTMLAttributes } from "react";

const Heading6 = ({
children,
...props
}: { children: React.ReactNode } & React.HTMLAttributes<HTMLElement>) => (
}: { children: React.ReactNode } & HTMLAttributes<HTMLElement>) => (
<h6 className="root" {...props}>
{children}
<style jsx>{`
Expand Down
2 changes: 1 addition & 1 deletion src/components/hr.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HTMLAttributes } from "react";
import type { HTMLAttributes } from "react";

const HorizontalRule = (props: HTMLAttributes<HTMLHRElement>) => (
<>
Expand Down
51 changes: 51 additions & 0 deletions src/components/img.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {
CSS_BREAKPOINT_START_M,
CSS_BREAKPOINT_START_L,
} from "../utils/constants";
import type { HTMLAttributes } from "react";

const Img = ({
float,
...props
}: {
float?: "left" | "right";
} & HTMLAttributes<HTMLImageElement>) => {
return (
<>
<img
className={`${float ? float + " " : ""}${props.className || ""}`}
{...props}
/>
<style jsx>{`
img {
clear: both;
display: block;
width: 100%;
max-width: 100%;
}
@media screen and (min-width: ${CSS_BREAKPOINT_START_M}) {
img.left,
img.right {
width: var(--block);
}
img.left {
float: left;
margin-right: var(--gutter);
}
img.right {
float: right;
margin-left: var(--gutter);
}
}
@media screen and (min-width: ${CSS_BREAKPOINT_START_L}) {
img.left,
img.right {
width: calc(calc(var(--column) * 4) + calc(var(--gutter) * 3));
}
}
`}</style>
</>
);
};

export default Img;
4 changes: 3 additions & 1 deletion src/components/p.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { HTMLAttributes } from "react";

const Paragraph = ({
children,
...props
}: {
children: React.ReactNode;
} & React.HTMLAttributes<HTMLParagraphElement>) => (
} & HTMLAttributes<HTMLParagraphElement>) => (
<p className="root" {...props}>
{children}
<style jsx>{`
Expand Down
4 changes: 3 additions & 1 deletion src/components/strong.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { HTMLAttributes } from "react";

const Strong = ({
children,
...props
}: {
children: React.ReactNode;
} & React.HTMLAttributes<HTMLElement>) => (
} & HTMLAttributes<HTMLElement>) => (
<strong className="root" {...props}>
{children}
<style jsx>{`
Expand Down
4 changes: 3 additions & 1 deletion src/components/ul.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { HTMLAttributes } from "react";

const UnorderedList = ({
children,
...props
}: { children: React.ReactNode } & React.HTMLAttributes<HTMLUListElement>) => (
}: { children: React.ReactNode } & HTMLAttributes<HTMLUListElement>) => (
<ul className="root" {...props}>
{children}
<style jsx>{`
Expand Down
Loading

0 comments on commit 7c39c50

Please sign in to comment.