Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Next.js examples #228

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/nextjs/js/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions examples/nextjs/js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# 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

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions examples/nextjs/js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Binary file added examples/nextjs/js/bun.lockb
Binary file not shown.
13 changes: 13 additions & 0 deletions examples/nextjs/js/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'source.unsplash.com',
},
],
},
};

export default nextConfig;
25 changes: 25 additions & 0 deletions examples/nextjs/js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "jarallax-nextjs-example-ts",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"jarallax": "^2.2.1",
"next": "14.2.3",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.3"
}
}
Binary file added examples/nextjs/js/src/app/favicon.ico
Binary file not shown.
25 changes: 25 additions & 0 deletions examples/nextjs/js/src/app/layout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Inter } from "next/font/google";

import '@/assets/css/globals.css';

const inter = Inter({
subsets: ["latin"]
});

export const metadata = {
title: 'Jarallax Example | Nextjs',
description: "Parallax scrolling for modern browsers",
authors: {
name: 'Nikita',
url: 'https://github.com/nk-o'
}
};

export default function RootLayout({
children
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>)
}
32 changes: 32 additions & 0 deletions examples/nextjs/js/src/app/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Jarallax from '@/components/Jarallax';

export default function Home() {
return <>
<section>
<h1 style={{
fontSize: 64
}}>Next.js Example</h1>
<h2>Scroll Below 🔽</h2>
</section>
<h1 className='eg-text'>Image Example</h1>

<Jarallax options={{
imgSrc: 'https://images.unsplash.com/photo-1607796884038-3638822d5ee2?cs=tinysrgb&fit=crop&fm=jpg&h=720&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJ8fHx8fHwxNzE2MzEzOTA4&ixlib=rb-4.0.3&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1280',
speed: 0.2
}} className='bg-parallax jarallax-img img-style'>
<div className='card'>Your Content here</div>
</Jarallax>

<h1 className='eg-text'>Video Example</h1>

<Jarallax options={{
videoSrc: 'https://youtu.be/mru3Q5m4lkY',
speed: 0.2
}} className='bg-parallax jarallax-img img-style'>
<div className='card'>Your Content here</div>
</Jarallax>
<h1 className='eg-text'>End of Examples</h1>

<hr />
</>;
}
46 changes: 46 additions & 0 deletions examples/nextjs/js/src/assets/css/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
body {
font-size: 20px;
margin: 0;
-webkit-font-smoothing: antialiased;
}

section {
height: 60vh;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}

.jarallax {
height: 80vh;
}

.img-style {
position: relative;
height: 500px;
display: flex;
align-items: center;
}

.eg-text {
text-align: center;
margin-bottom: 100px;
margin-top: 100px;
}

hr {
height: 80vh;
border: none;
}

.card {
height: 180px;
width: 200px;
margin-left:80%;
background-color: whitesmoke;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
}
31 changes: 31 additions & 0 deletions examples/nextjs/js/src/components/Jarallax.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use client";
import { useEffect, useRef } from "react";
import { jarallax, jarallaxVideo } from "jarallax";

import 'jarallax/dist/jarallax.min.css';

const Jarallax = ({ children, options, tag = 'div', ...props }) => {
// html tag can be used as jarallax tag
const Tag = tag;
const ref = useRef(null);

// calling required function for video jarallax
if (options?.videoSrc) jarallaxVideo();

useEffect(() => {
// Initialization of Jarallax
if (ref.current) jarallax(ref.current, { ...options });

// Destroy jarallax Instance on unmount
return () => {
if (ref.current) jarallax(ref.current, 'destroy');
};
}, []);

return (
<Tag ref={ref} {...props}>
{children}
</Tag>
)
};
export default Jarallax;
26 changes: 26 additions & 0 deletions examples/nextjs/js/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"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": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
3 changes: 3 additions & 0 deletions examples/nextjs/ts/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions examples/nextjs/ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# 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

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions examples/nextjs/ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Binary file added examples/nextjs/ts/bun.lockb
Binary file not shown.
13 changes: 13 additions & 0 deletions examples/nextjs/ts/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'source.unsplash.com',
},
],
},
};

export default nextConfig;
Loading