Skip to content

Commit

Permalink
Merge branch 'canary' into i18n/href-resolving-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Dec 12, 2020
2 parents f64cafb + 748bcb9 commit ce7591c
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 0 deletions.
37 changes: 37 additions & 0 deletions examples/with-ionic-typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

# Ionic
public/svg
21 changes: 21 additions & 0 deletions examples/with-ionic-typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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).

## Deploy your own

Deploy the example using [Vercel](https://vercel.com):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/with-ionic-typescript)

## How to use

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example with-ionic-typescript with-ionic-typescript-app
# or
yarn create next-app --example with-ionic-typescript with-ionic-typescript-app
```

Deploy it to the cloud with [Vercel](https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
24 changes: 24 additions & 0 deletions examples/with-ionic-typescript/ionic.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ReactText, HTMLAttributes } from 'react'
import { JSX as LocalJSX } from '@ionic/core'
import { JSX as IoniconsJSX } from 'ionicons'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import IonicIntrinsicElements = LocalJSX.IntrinsicElements
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import IoniconsIntrinsicElements = IoniconsJSX.IntrinsicElements

type ToReact<T> = {
[P in keyof T]?: T[P] &
Omit<HTMLAttributes<Element>, 'className'> & {
class?: string
key?: ReactText
}
}

declare global {
export namespace JSX {
interface IntrinsicElements
extends ToReact<IonicIntrinsicElements & IoniconsIntrinsicElements> {
key?: string
}
}
}
2 changes: 2 additions & 0 deletions examples/with-ionic-typescript/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
20 changes: 20 additions & 0 deletions examples/with-ionic-typescript/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const path = require('path')
const CopyPlugin = require('copy-webpack-plugin')
module.exports = {
webpack: (config) => {
config.plugins.push(
new CopyPlugin({
patterns: [
{
from: path.join(
__dirname,
'node_modules/ionicons/dist/ionicons/svg'
),
to: path.join(__dirname, 'public/svg'),
},
],
})
)
return config
},
}
24 changes: 24 additions & 0 deletions examples/with-ionic-typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "with-ionic-typescript",
"version": "0.1.0",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"export": "next export -o build"
},
"dependencies": {
"@ionic/core": "^5.4.1",
"ionicons": "^5.2.3",
"next": "latest",
"react": "17.0.1",
"react-dom": "17.0.1"
},
"devDependencies": {
"@types/node": "^14.14.6",
"@types/react": "^16.9.55",
"copy-webpack-plugin": "6.2.1",
"typescript": "^4.0.5"
},
"license": "MIT"
}
44 changes: 44 additions & 0 deletions examples/with-ionic-typescript/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { useEffect } from 'react'
import { defineCustomElements as ionDefineCustomElements } from '@ionic/core/loader'

/* Core CSS required for Ionic components to work properly */
import '@ionic/core/css/core.css'

/* Basic CSS for apps built with Ionic */
import '@ionic/core/css/normalize.css'
import '@ionic/core/css/structure.css'
import '@ionic/core/css/typography.css'

/* Optional CSS utils that can be commented out */
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'

function MyApp({ Component, pageProps }) {
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>
<Component {...pageProps} />
</ion-content>
<ion-footer>
<ion-toolbar>
<ion-title>Footer</ion-title>
</ion-toolbar>
</ion-footer>
</ion-app>
)
}

export default MyApp
32 changes: 32 additions & 0 deletions examples/with-ionic-typescript/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Image from 'next/image'

export default function Home() {
return (
<ion-grid>
<ion-row>
{new Array(8).fill('').map((k, i) => (
<ion-col key={i} size="3">
<ion-card>
<Image
src="/cat.jpg"
alt="Picture of the author"
width={500}
height={500}
/>
<ion-card-header>
<ion-card-subtitle>Destination</ion-card-subtitle>
<ion-card-title>Madison, WI</ion-card-title>
</ion-card-header>
<ion-card-content>
<ion-icon name="pin" slot="start"></ion-icon>
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.
</ion-card-content>
</ion-card>
</ion-col>
))}
</ion-row>
</ion-grid>
)
}
Binary file added examples/with-ionic-typescript/public/cat.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/with-ionic-typescript/public/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/with-ionic-typescript/public/vercel.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions examples/with-ionic-typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "ionic.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

0 comments on commit ce7591c

Please sign in to comment.