Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(images): size images upfront #1

Merged
merged 1 commit into from
Dec 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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