0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

imdb clone Part14 11 CardComponent カードコンポーネント新規作成 idのみ表示

Posted at

概要

目次

今回は映画のidのみを表示するコンポーネントを新規作成します。
下gifアニメは実装後の様子です。

zzzzzzzzzzzzzzzzz.gif

開発環境

OS:Windows10
IDE:VSCode

"@next/font": "13.1.5",
"autoprefixer": "10.4.14",
"eslint": "8.39.0",
"eslint-config-next": "13.3.1",
"next": "13.3.1",
"postcss": "8.4.23",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.8.0",
"tailwindcss": "3.3.2"

実装のポイント

ディスプレイのサイズについてレイアウトを変える

640px~1024px

カードは2個配置されます。
image.png

1024~1280px

カードは3個配置されます。
image.png

1280~1536px

カードは4個配置されます。

image.png

1536px以上

カードは5個配置されます。

image.png

カード上にカーソルを合わせたときの処理

ディスプレイサイズ問わずに同じ処理が実行されます。

image.png

コード部分

Results

Results.jsx
+import Card from "./Card";

export default function Results({results}) {
  return (
-    <div>
+    <div className="sm:grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5  max-w-6xl mx-auto py-4">
        {results.map((result) => (
-                <div key={result.id}>{result.original_title}</div>
+                <Card key={result.id} result={result} />
            ))}
    </div>
  );

Card

Card.jsx
import React from 'react'

export default function Card({result}) {
  return (
    <div className="cursor-pointer sm:p-3 sm:hover:shadow-slate-400 sm:shadow-md rounded-lg sm:border sm:border-slate-400 sm:m-2 transition-shadow duration-200 group">
        {result.id}
    </div>
  )
}

参考

css

sm lg xl 2xl

image.png

grid

image.png

grid-cols

image.png

max-w-6xl

image.png

mx-auto

duration

yyyyyyyyyyy.gif

transition-shadow

image.png

その他

Udemy

githubコミット分

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?