Unverified Commit 8bfe06e8 authored by Tom's avatar Tom Committed by GitHub

GraphCMS example - Upgrade to React 17 / Tailwind 2 and next/image (#20772)

parent d0f1e33d
import Image from 'next/image'
export default function Avatar({ name, picture }) { export default function Avatar({ name, picture }) {
return ( return (
<div className="flex items-center"> <div className="flex items-center">
<img src={picture} className="w-12 h-12 rounded-full mr-4" alt={name} /> <div className="w-12 h-12 relative mr-4">
<Image
src={picture}
layout="fill"
className="rounded-full"
alt={name}
/>
</div>
<div className="text-xl font-bold">{name}</div> <div className="text-xl font-bold">{name}</div>
</div> </div>
) )
......
import cn from 'classnames' import Image from 'next/image'
import Link from 'next/link' import Link from 'next/link'
import cn from 'classnames'
export default function CoverImage({ title, url, slug }) { export default function CoverImage({ title, url, slug }) {
const image = ( const image = (
<img <Image
width={2000} width={2000}
height={1000} height={1000}
alt={`Cover Image for ${title}`} alt={`Cover Image for ${title}`}
......
...@@ -6,7 +6,7 @@ export default function MoreStories({ posts }) { ...@@ -6,7 +6,7 @@ export default function MoreStories({ posts }) {
<h2 className="mb-8 text-6xl md:text-7xl font-bold tracking-tighter leading-tight"> <h2 className="mb-8 text-6xl md:text-7xl font-bold tracking-tighter leading-tight">
More Stories More Stories
</h2> </h2>
<div className="grid grid-cols-1 md:grid-cols-2 md:col-gap-16 lg:col-gap-32 row-gap-20 md:row-gap-32 mb-32"> <div className="grid grid-cols-1 md:grid-cols-2 md:gap-x-16 lg:gap-x-32 gap-y-20 md:gap-y-32 mb-32">
{posts.map((post) => ( {posts.map((post) => (
<PostPreview <PostPreview
key={post.slug} key={post.slug}
......
module.exports = {
images: {
domains: ['media.graphcms.com'],
},
}
...@@ -7,16 +7,18 @@ ...@@ -7,16 +7,18 @@
"start": "next start" "start": "next start"
}, },
"dependencies": { "dependencies": {
"autoprefixer": "10.1.0",
"classnames": "2.2.6", "classnames": "2.2.6",
"date-fns": "2.10.0", "date-fns": "2.10.0",
"next": "latest", "next": "latest",
"react": "^16.13.0", "postcss": "8.2.2",
"react-dom": "^16.13.0" "react": "17.0.1",
"react-dom": "17.0.1"
}, },
"devDependencies": { "devDependencies": {
"postcss-flexbugs-fixes": "^4.2.1", "postcss-flexbugs-fixes": "^5.0.2",
"postcss-preset-env": "^6.7.0", "postcss-preset-env": "^6.7.0",
"tailwindcss": "^1.4.6" "tailwindcss": "2.0.2"
}, },
"license": "MIT" "license": "MIT"
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment