-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated with-ionic-typescript example to utilize the App Router. (#73418
) This PR updates the with-ionic-typescript example for using the App Router. Here are the changes that have been made: - I renamed the `pages` folder and moved it to the `app` folder. - Added the `layout.tsx` file as part of the App Router. - Updated the `package.json` file. CC: @samcx --------- Co-authored-by: Sam Ko <[email protected]>
- Loading branch information
1 parent
0c78009
commit 95acd8b
Showing
20 changed files
with
187 additions
and
151 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
examples/with-ionic-typescript/README.md → examples/with-ionic/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
# Ionic with TypeScript Example | ||
|
||
Example app using Next.js with [Ionic](https://ionicframework.com/) and [TypeScript](https://www.typescriptlang.org/). You can learn more about Ionic in the [documentation](https://ionicframework.com/docs). | ||
Example app using Next.js with [Ionic](https://ionicframework.com/). You can learn more about Ionic in the [documentation](https://ionicframework.com/docs). | ||
|
||
## Deploy your own | ||
|
||
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-ionic-typescript) | ||
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-ionic) | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-ionic-typescript&project-name=with-ionic-typescript&repository-name=with-ionic-typescript) | ||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-ionic&project-name=with-ionic&repository-name=with-ionic) | ||
|
||
## How to use | ||
|
||
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example: | ||
|
||
```bash | ||
npx create-next-app --example with-ionic-typescript with-ionic-typescript-app | ||
npx create-next-app --example with-ionic with-ionic-app | ||
``` | ||
|
||
```bash | ||
yarn create next-app --example with-ionic-typescript with-ionic-typescript-app | ||
yarn create next-app --example with-ionic with-ionic-app | ||
``` | ||
|
||
```bash | ||
pnpm create next-app --example with-ionic-typescript with-ionic-typescript-app | ||
pnpm create next-app --example with-ionic with-ionic-app | ||
``` | ||
|
||
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Image from "next/image"; | ||
|
||
type CardProps = { | ||
imageSrc: string; | ||
title: string; | ||
subtitle: string; | ||
content: string; | ||
}; | ||
|
||
export default function Card({ | ||
imageSrc, | ||
title, | ||
subtitle, | ||
content, | ||
}: CardProps) { | ||
return ( | ||
<ion-card> | ||
<Image | ||
src={imageSrc} | ||
alt={`Image of ${title}`} | ||
width={320} | ||
height={320} | ||
priority={true} | ||
/> | ||
<ion-card-header> | ||
<ion-card-subtitle>{subtitle}</ion-card-subtitle> | ||
<ion-card-title>{title}</ion-card-title> | ||
</ion-card-header> | ||
<ion-card-content> | ||
<ion-icon name="pin" slot="start"></ion-icon> | ||
{content} | ||
</ion-card-content> | ||
</ion-card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use client"; | ||
|
||
import React, { useEffect } from "react"; | ||
import { defineCustomElements as ionDefineCustomElements } from "@ionic/core/loader"; | ||
|
||
export default function IonicLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
useEffect(() => { | ||
ionDefineCustomElements(window); | ||
}, []); | ||
|
||
return ( | ||
<ion-app> | ||
<ion-header translucent> | ||
<ion-toolbar> | ||
<ion-title>Next.js with Ionic</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content fullscreen>{children}</ion-content> | ||
<ion-footer> | ||
<ion-toolbar> | ||
<ion-title>Footer</ion-title> | ||
</ion-toolbar> | ||
</ion-footer> | ||
</ion-app> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import "@ionic/core/css/core.css"; | ||
import "@ionic/core/css/normalize.css"; | ||
import "@ionic/core/css/structure.css"; | ||
import "@ionic/core/css/typography.css"; | ||
import "@ionic/core/css/padding.css"; | ||
import "@ionic/core/css/float-elements.css"; | ||
import "@ionic/core/css/text-alignment.css"; | ||
import "@ionic/core/css/text-transformation.css"; | ||
import "@ionic/core/css/flex-utils.css"; | ||
import "@ionic/core/css/display.css"; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import IonicLayout from "@/_components/IonicLayout"; | ||
import CardComponent from "@/_components/Card"; | ||
|
||
export default function Home() { | ||
const destinations = new Array(8).fill({ | ||
imageSrc: "/img/cat.jpg", | ||
title: "Madison, WI", | ||
subtitle: "Destination", | ||
content: | ||
"Keep close to Nature's heart... and break clear away, once in awhile, and climb a mountain or spend a week in the woods. Wash your spirit clean.", | ||
}); | ||
|
||
return ( | ||
<IonicLayout> | ||
<ion-grid> | ||
<ion-row> | ||
{destinations.map((destination, i) => ( | ||
<ion-col key={i} size="3"> | ||
<CardComponent | ||
imageSrc={destination.imageSrc} | ||
title={destination.title} | ||
subtitle={destination.subtitle} | ||
content={destination.content} | ||
/> | ||
</ion-col> | ||
))} | ||
</ion-row> | ||
</ion-grid> | ||
</IonicLayout> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { NextConfig } from "next"; | ||
|
||
const nextConfig: NextConfig = { | ||
/* config options here */ | ||
}; | ||
|
||
export default nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"@ionic/core": "^8.4.1", | ||
"ionicons": "^7.4.0", | ||
"next": "latest", | ||
"react": "^19.0.0", | ||
"react-dom": "^19.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^22.10.1", | ||
"@types/react": "^19.0.1", | ||
"typescript": "^5.7.2" | ||
} | ||
} |
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2017", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "bundler", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"incremental": true, | ||
"plugins": [ | ||
{ | ||
"name": "next" | ||
} | ||
], | ||
"paths": { | ||
"@/*": ["./*"] | ||
} | ||
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters