Add 15 files
Browse files- Dockerfile +57 -0
- README.md +16 -11
- public/favicon.ico +1 -0
- public/index.html +29 -0
- public/vercel.svg +1 -0
- src/components/App.tsx +41 -0
- src/components/AppComponent.tsx +28 -0
- src/components/Button.tsx +17 -0
- src/components/Text.tsx +14 -0
- src/components/Title.tsx +15 -0
- src/main.tsx +11 -0
- src/pages/index.tsx +29 -0
- src/reducers/Reducer1.ts +20 -0
- src/styles.css +48 -0
- tsconfig.json +28 -0
Dockerfile
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM node:18-alpine AS base
|
| 3 |
+
|
| 4 |
+
# Install dependencies only when needed
|
| 5 |
+
FROM base AS deps
|
| 6 |
+
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
| 7 |
+
RUN apk add --no-cache libc6-compat
|
| 8 |
+
WORKDIR /app
|
| 9 |
+
|
| 10 |
+
# Install dependencies based on the preferred package manager
|
| 11 |
+
COPY package.json package-lock.json* ./
|
| 12 |
+
RUN npm install
|
| 13 |
+
|
| 14 |
+
# Uncomment the following lines if you want to use a secret at buildtime,
|
| 15 |
+
# for example to access your private npm packages
|
| 16 |
+
# RUN --mount=type=secret,id=HF_EXAMPLE_SECRET,mode=0444,required=true # $(cat /run/secrets/HF_EXAMPLE_SECRET)
|
| 17 |
+
|
| 18 |
+
# Rebuild the source code only when needed
|
| 19 |
+
FROM base AS builder
|
| 20 |
+
WORKDIR /app
|
| 21 |
+
COPY --from=deps /app/node_modules ./node_modules
|
| 22 |
+
COPY . .
|
| 23 |
+
|
| 24 |
+
# Next.js collects completely anonymous telemetry data about general usage.
|
| 25 |
+
# Learn more here: https://nextjs.org/telemetry
|
| 26 |
+
# Uncomment the following line in case you want to disable telemetry during the build.
|
| 27 |
+
# ENV NEXT_TELEMETRY_DISABLED 1
|
| 28 |
+
|
| 29 |
+
RUN npm run build
|
| 30 |
+
|
| 31 |
+
# Production image, copy all the files and run next
|
| 32 |
+
FROM base AS runner
|
| 33 |
+
WORKDIR /app
|
| 34 |
+
|
| 35 |
+
ENV NODE_ENV production
|
| 36 |
+
# Uncomment the following line in case you want to disable telemetry during runtime.
|
| 37 |
+
# ENV NEXT_TELEMETRY_DISABLED 1
|
| 38 |
+
|
| 39 |
+
RUN addgroup --system --gid 1001 nodejs
|
| 40 |
+
RUN adduser --system --uid 1001 nextjs
|
| 41 |
+
|
| 42 |
+
COPY --from=builder /app/public ./public
|
| 43 |
+
|
| 44 |
+
# Automatically leverage output traces to reduce image size
|
| 45 |
+
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
| 46 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
| 47 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
| 48 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
|
| 49 |
+
# COPY --from=builder --chown=nextjs:nodejs /app/.next/cache/fetch-cache ./.next/cache/fetch-cache
|
| 50 |
+
|
| 51 |
+
USER nextjs
|
| 52 |
+
|
| 53 |
+
EXPOSE 3000
|
| 54 |
+
|
| 55 |
+
ENV PORT 3000
|
| 56 |
+
|
| 57 |
+
CMD ["node", "server.js"]
|
README.md
CHANGED
|
@@ -1,11 +1,16 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# My Next.js & TailwindCSS Starter Template
|
| 2 |
+
|
| 3 |
+
A starter template for building server-side rendered React applications with [Next.js](https://nextjs.org/) and [TailwindCSS](https://tailwindcss.com/).
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
|
| 7 |
+
* Server-side rendering (SSR)
|
| 8 |
+
* Static site generation (SSG)
|
| 9 |
+
* Hot module reloading (HMR)
|
| 10 |
+
* CSS & JavaScript compilation with Webpack
|
| 11 |
+
* TailwindCSS for styling
|
| 12 |
+
* Support for Sass/SCSS
|
| 13 |
+
|
| 14 |
+
## Getting Started
|
| 15 |
+
|
| 16 |
+
Clone the repository and install the dependencies:
|
public/favicon.ico
ADDED
|
|
public/index.html
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>My Next App</title>
|
| 7 |
+
<link rel="icon" href="/favicon.ico" />
|
| 8 |
+
<style>
|
| 9 |
+
:root {
|
| 10 |
+
--brand-primary: #ff007c;
|
| 11 |
+
--brand-primary-light: #ff007c;
|
| 12 |
+
--brand-primary-dark: #ff007c;
|
| 13 |
+
--brand-secondary: #ff007c;
|
| 14 |
+
--brand-secondary-light: #ff007c;
|
| 15 |
+
--brand-secondary-dark: #ff007c;
|
| 16 |
+
--primary-text-color: #444;
|
| 17 |
+
--secondary-text-color: #ccc;
|
| 18 |
+
--primary-background-color: #fff;
|
| 19 |
+
--secondary-background-color: #fff;
|
| 20 |
+
--border-color: #ccc;
|
| 21 |
+
--box-shadow-color: rgba(0, 123, 255, 0.1);
|
| 22 |
+
}
|
| 23 |
+
</style>
|
| 24 |
+
</head>
|
| 25 |
+
<body>
|
| 26 |
+
<div id="root"></div>
|
| 27 |
+
<script type="module" src="src/main.tsx"></script>
|
| 28 |
+
</body>
|
| 29 |
+
</html>
|
public/vercel.svg
ADDED
|
|
src/components/App.tsx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import { Box } from '@chakra-ui/react';
|
| 3 |
+
import {
|
| 4 |
+
applyMiddleware,
|
| 5 |
+
createStore,
|
| 6 |
+
combineReducers,
|
| 7 |
+
compose,
|
| 8 |
+
} from 'redux';
|
| 9 |
+
import thunk from 'redux-thunk';
|
| 10 |
+
import { createLogger } from 'redux-logger';
|
| 11 |
+
import { Provider } from 'react-redux';
|
| 12 |
+
import Reducer1 from './reducers/Reducer1';
|
| 13 |
+
import Reducer2 from './reducers/Reducer2';
|
| 14 |
+
import Reducer3 from './reducers/Reducer3';
|
| 15 |
+
|
| 16 |
+
export type ApplicationState = {
|
| 17 |
+
Reducer1: ReturnType<typeof Reducer1>
|
| 18 |
+
Reducer2: ReturnType<typeof Reducer2>
|
| 19 |
+
Reducer3: ReturnType<typeof Reducer3>
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
const store = createStore(
|
| 23 |
+
combineReducers({
|
| 24 |
+
Reducer1,
|
| 25 |
+
Reducer2,
|
| 26 |
+
Reducer3,
|
| 27 |
+
}),
|
| 28 |
+
compose(applyMiddleware(thunk, createLogger))
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
const App: React.FC = () => {
|
| 32 |
+
return (
|
| 33 |
+
<Provider store={store}>
|
| 34 |
+
<Box p="24px">
|
| 35 |
+
<AppComponent />
|
| 36 |
+
</Box>
|
| 37 |
+
</Provider>
|
| 38 |
+
);
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
export default App;
|
src/components/AppComponent.tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import { useSelector, useDispatch } from 'react-redux';
|
| 3 |
+
import { Title } from './Title';
|
| 4 |
+
import { Text } from './Text';
|
| 5 |
+
import { Button } from './Button';
|
| 6 |
+
|
| 7 |
+
const AppComponent: React.FC = () => {
|
| 8 |
+
const title = useSelector((state: ApplicationState) => state.Reducer1.title);
|
| 9 |
+
const text = useSelector((state: ApplicationState) => state.Reducer1.text);
|
| 10 |
+
const button = useSelector((state: ApplicationState) => state.Reducer1.button);
|
| 11 |
+
const dispatch = useDispatch();
|
| 12 |
+
|
| 13 |
+
return (
|
| 14 |
+
<div>
|
| 15 |
+
<Title title={title} />
|
| 16 |
+
<div>
|
| 17 |
+
{text.map((paragraph) => (
|
| 18 |
+
<Text key={paragraph} text={paragraph} />
|
| 19 |
+
))}
|
| 20 |
+
</div>
|
| 21 |
+
<Button onClick={() => dispatch({ type: 'button_1', text: button })}>
|
| 22 |
+
{button}
|
| 23 |
+
</Button>
|
| 24 |
+
</div>
|
| 25 |
+
);
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
export default AppComponent;
|
src/components/Button.tsx
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import { useMemo } from 'react-redux';
|
| 3 |
+
|
| 4 |
+
interface ButtonProps {
|
| 5 |
+
onClick: () => void;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
const Button: React.FC<ButtonProps> = ({ onClick }) => {
|
| 9 |
+
const dispatch = useDispatch();
|
| 10 |
+
return (
|
| 11 |
+
<button onClick={() => dispatch({ type: 'button_1', text: 'Button 1' })}>
|
| 12 |
+
Button 1
|
| 13 |
+
</button>
|
| 14 |
+
);
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
export default Button;
|
src/components/Text.tsx
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import { useSelector } from 'react-redux';
|
| 3 |
+
|
| 4 |
+
interface TextProps {
|
| 5 |
+
text: string;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
const Text: React.FC<TextProps> = ({ text }) => {
|
| 9 |
+
return (
|
| 10 |
+
<p>{text}</p>
|
| 11 |
+
);
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
export default Text;
|
src/components/Title.tsx
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import { useSelector } from 'react-redux';
|
| 3 |
+
|
| 4 |
+
interface TitleProps {
|
| 5 |
+
title: string;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
const Title: React.FC<TitleProps> = ({ title }) => {
|
| 9 |
+
const dispatch = useDispatch();
|
| 10 |
+
return (
|
| 11 |
+
<h1>{title}</h1>
|
| 12 |
+
);
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
export default Title;
|
src/main.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import ReactDOM from 'react-dom';
|
| 3 |
+
import './styles.css';
|
| 4 |
+
import { App } from './components/App';
|
| 5 |
+
|
| 6 |
+
ReactDOM.render(
|
| 7 |
+
<React.StrictMode>
|
| 8 |
+
<App />
|
| 9 |
+
</React.StrictMode>,
|
| 10 |
+
document.getElementById('root')
|
| 11 |
+
);
|
src/pages/index.tsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import Head from 'next/head';
|
| 3 |
+
|
| 4 |
+
export default function Home() {
|
| 5 |
+
return (
|
| 6 |
+
<div>
|
| 7 |
+
<Head>
|
| 8 |
+
<title>My Next App</title>
|
| 9 |
+
<link rel="icon" href="/favicon.ico" />
|
| 10 |
+
</Head>
|
| 11 |
+
|
| 12 |
+
<main>
|
| 13 |
+
<h1>My 3D Interactive Next.js Landing Page</h1>
|
| 14 |
+
<p>This is my 3D interactive Next.js landing page.</p>
|
| 15 |
+
</main>
|
| 16 |
+
|
| 17 |
+
<footer>
|
| 18 |
+
<a
|
| 19 |
+
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
| 20 |
+
target="_blank"
|
| 21 |
+
rel="noopener noreferrer"
|
| 22 |
+
>
|
| 23 |
+
Powered by{' '}
|
| 24 |
+
<img src="/vercel.svg" alt="Vercel Logo" width="64" height="16" />
|
| 25 |
+
</a>
|
| 26 |
+
</footer>
|
| 27 |
+
</div>
|
| 28 |
+
);
|
| 29 |
+
}
|
src/reducers/Reducer1.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useReducer } from 'react-redux';
|
| 2 |
+
|
| 3 |
+
type ApplicationState = {
|
| 4 |
+
Reducer1: {
|
| 5 |
+
title: string;
|
| 6 |
+
text: string;
|
| 7 |
+
button: string;
|
| 8 |
+
};
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
function Reducer1(state: ApplicationState = { title: "", text: "", button: "" }, action: any): ApplicationState {
|
| 12 |
+
switch (action.type) {
|
| 13 |
+
case 'button_1':
|
| 14 |
+
return { title: action.title, text: action.text, button: "Button 1" };
|
| 15 |
+
default:
|
| 16 |
+
return state;
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
export default Reducer1;
|
src/styles.css
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
body {
|
| 2 |
+
font-family: 'Avenir', Helvetica, Arial, sans-serif;
|
| 3 |
+
margin: 0 auto;
|
| 4 |
+
margin-top: 64px;
|
| 5 |
+
padding-top: 32px;
|
| 6 |
+
padding-bottom: 32px;
|
| 7 |
+
max-width: 1280px;
|
| 8 |
+
display: flex;
|
| 9 |
+
flex-direction: column;
|
| 10 |
+
align-items: center;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
main {
|
| 14 |
+
padding: 24px;
|
| 15 |
+
flex: 1;
|
| 16 |
+
display: flex;
|
| 17 |
+
flex-direction: column;
|
| 18 |
+
align-items: center;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
footer {
|
| 22 |
+
padding: 24px;
|
| 23 |
+
background-color: #f7f7f7;
|
| 24 |
+
display: flex;
|
| 25 |
+
flex-direction: column;
|
| 26 |
+
align-items: center;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
a {
|
| 30 |
+
color: #0070f3;
|
| 31 |
+
text-decoration: none;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
a:hover,
|
| 35 |
+
a:active {
|
| 36 |
+
opacity: 0.6;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
h1 {
|
| 40 |
+
font-size: 36px;
|
| 41 |
+
margin-bottom: 12px;
|
| 42 |
+
padding-top: 32px;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
p {
|
| 46 |
+
font-size: 24px;
|
| 47 |
+
padding: 12px;
|
| 48 |
+
}
|
tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"compilerOptions": {
|
| 3 |
+
"target": "ES2022",
|
| 4 |
+
"lib": ["dom", "dom.iterable", "esnext"],
|
| 5 |
+
"allowJs": true,
|
| 6 |
+
"skipLibCheck": true,
|
| 7 |
+
"strict": true,
|
| 8 |
+
"forceConsistentCasingInFileNames": true,
|
| 9 |
+
"noEmit": true,
|
| 10 |
+
"esModuleInterop": true,
|
| 11 |
+
"module": "esnext",
|
| 12 |
+
"moduleResolution": "node",
|
| 13 |
+
"resolveJsonModule": true,
|
| 14 |
+
"isolatedModules": true,
|
| 15 |
+
"jsx": "preserve",
|
| 16 |
+
"incremental": true,
|
| 17 |
+
"plugins": [
|
| 18 |
+
{
|
| 19 |
+
"name": "next"
|
| 20 |
+
}
|
| 21 |
+
],
|
| 22 |
+
"paths": {
|
| 23 |
+
"@/*": ["./src/*"]
|
| 24 |
+
}
|
| 25 |
+
},
|
| 26 |
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
| 27 |
+
"exclude": ["node_modules"]
|
| 28 |
+
}
|