diff --git a/hiro/.gitignore b/hiro/.gitignore new file mode 100644 index 0000000..49f32c6 --- /dev/null +++ b/hiro/.gitignore @@ -0,0 +1,2 @@ +chapter10 +chapter11 diff --git a/hiro/nextjs01/README.md b/hiro/nextjs01/README.md new file mode 100644 index 0000000..f354300 --- /dev/null +++ b/hiro/nextjs01/README.md @@ -0,0 +1,15 @@ +### 新規プロジェクトの作成 +``` +npx create-next-app@latest nextjs-dashboard --use-npm --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example" +``` + +- プロジェクトに入る +``` +cd nextjs-dashboard +``` + +### サーバーの起動 +``` +npm run dev +``` +わーい diff --git a/hiro/nextjs02/README.md b/hiro/nextjs02/README.md new file mode 100644 index 0000000..40f4d55 --- /dev/null +++ b/hiro/nextjs02/README.md @@ -0,0 +1,4 @@ +layout.tsxでグローバルスタイルを設定する. +tailwind クラスがすごい +CSSmodule スコープが作れる +clsx クラス名を切り替えれる diff --git a/hiro/nextjs03/README.md b/hiro/nextjs03/README.md new file mode 100644 index 0000000..84941ea --- /dev/null +++ b/hiro/nextjs03/README.md @@ -0,0 +1,9 @@ +- latinフォントを追加する +- lusitanaフォントを追加する +fonts.tsに加筆してpage.tsxでimportする. + +- ロゴを有効にする +AcmeLogoコンポーネントがlusitanaを使うのでコメントアウトされていたがいけるようになった + +- 画像を表示する +- モバイル用の画像を表示する diff --git a/hiro/nextjs04/README.md b/hiro/nextjs04/README.md new file mode 100644 index 0000000..1d1fa9e --- /dev/null +++ b/hiro/nextjs04/README.md @@ -0,0 +1,75 @@ +### ルーティング +フォルダ構造がURLのルーティングに使用される. + + +それぞれのフォルダに`page.tsx`や`layout.tsx`を配置してページを作っていく. + + +### Dashboardの作成 +- `/app/dashboard/page.tsx`を作成してダッシュボードページを作る. +``` +. +├── dashboard +│ └── page.tsx +``` + +- 適当なコンポーネントを返すようにすると`localhost:3000/dashboard`にアクセスできるようになる +```TypeScript +export default function Page() { + return
Dashboard Page
; +} +``` + + +- `page.tsx`という名前のファイルのみがルーティングされるので,UIコンポーネント`/app`以下の好きなところに配置できる. +``` +. +├── dashboard +│ └── page.tsx +├── layout.tsx +├── page.tsx +└── ui + ├── acme-logo.tsx + ├── button.tsx + ├── customers + │ └── table.tsx + +``` + +#### CustomerページとInvoiceページの作成 +``` +. +├── dashboard +│ ├── customers +│ │ └── page.tsx +│ ├── invoices +│ │ └── page.tsx +│ └── page.tsx +``` +中身は適当なコンポーネントを返しておく.チュートリアル参照 + +### Dashboardのレイアウト +- `/app/dashboard/layout.tsx`でレイアウトを書く +```TypeScript +import SideNav from '@/app/ui/dashboard/sidenav'; + +export default function Layout({ children }: { children: React.ReactNode }) { + return ( +