init: шаблон Next.js приложения
- Next.js 16 + React 19 + TypeScript - Mantine UI + PostCSS Modules - Biome (линтинг и форматирование) - Zustand, SWR - Структура FSD (screens, widgets, features, entities, shared) - Шаблоны генерации (.templates/): component, screen, feature, widget, entity, layout, store - Конфигурация VS Code (расширения, настройки) - CSS-токены (цвета, отступы, радиусы, медиа) - Open Graph метаданные - Тестовый home screen с Mantine
This commit is contained in:
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/versions
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# env files (can opt-in for committing if needed)
|
||||
.env*
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
1
.templates/component/{{name.kebabCase}}/index.ts
Normal file
1
.templates/component/{{name.kebabCase}}/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { {{name.pascalCase}} } from './{{name.kebabCase}}.ui'
|
||||
@@ -0,0 +1,3 @@
|
||||
.root {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { HTMLAttributes } from 'react'
|
||||
|
||||
/**
|
||||
* Параметры {{name.pascalCase}}.
|
||||
*/
|
||||
export interface {{name.pascalCase}}Props extends HTMLAttributes<HTMLDivElement> {}
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { FC } from 'react'
|
||||
import cl from 'clsx'
|
||||
import type { {{name.pascalCase}}Props } from './types/{{name.kebabCase}}.interface'
|
||||
import styles from './styles/{{name.kebabCase}}.module.css'
|
||||
|
||||
/**
|
||||
* {{name.pascalCase}}.
|
||||
*/
|
||||
export const {{name.pascalCase}}: FC<{{name.pascalCase}}Props> = ({ className, ...htmlAttr }) => {
|
||||
return (
|
||||
<div {...htmlAttr} className={cl(styles.root, className)}>
|
||||
{{name.kebabCase}}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
1
.templates/entity/{{name.kebabCase}}/index.ts
Normal file
1
.templates/entity/{{name.kebabCase}}/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { {{name.pascalCase}}Entity } from './{{name.kebabCase}}.entity'
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { FC } from 'react'
|
||||
|
||||
/**
|
||||
* Сущность {{name.pascalCase}}.
|
||||
*/
|
||||
export const {{name.pascalCase}}Entity: FC = () => {
|
||||
return (
|
||||
<div>
|
||||
{{name.kebabCase}}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
1
.templates/feature/{{name.kebabCase}}/index.ts
Normal file
1
.templates/feature/{{name.kebabCase}}/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { {{name.pascalCase}}Feature } from './{{name.kebabCase}}.feature'
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { FC } from 'react'
|
||||
|
||||
/**
|
||||
* Фича {{name.pascalCase}}.
|
||||
*/
|
||||
export const {{name.pascalCase}}Feature: FC = () => {
|
||||
return (
|
||||
<div>
|
||||
{{name.kebabCase}}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
1
.templates/layout/{{name.kebabCase}}/index.ts
Normal file
1
.templates/layout/{{name.kebabCase}}/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { {{name.pascalCase}}Layout } from './{{name.kebabCase}}.layout'
|
||||
@@ -0,0 +1,3 @@
|
||||
.root {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Параметры {{name.pascalCase}}Layout.
|
||||
*/
|
||||
export interface {{name.pascalCase}}LayoutProps {
|
||||
children: React.ReactNode
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { FC } from 'react'
|
||||
import type { {{name.pascalCase}}LayoutProps } from './types/{{name.kebabCase}}.interface'
|
||||
import styles from './styles/{{name.kebabCase}}.module.css'
|
||||
|
||||
/**
|
||||
* Layout {{name.pascalCase}}.
|
||||
*/
|
||||
export const {{name.pascalCase}}Layout: FC<{{name.pascalCase}}LayoutProps> = ({ children }) => {
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
1
.templates/screen/{{name.kebabCase}}/index.ts
Normal file
1
.templates/screen/{{name.kebabCase}}/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { {{name.pascalCase}}Screen } from './{{name.kebabCase}}.screen'
|
||||
@@ -0,0 +1,3 @@
|
||||
.root {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { FC } from 'react'
|
||||
import styles from './styles/{{name.kebabCase}}.module.css'
|
||||
|
||||
/**
|
||||
* Экран {{name.pascalCase}}.
|
||||
*/
|
||||
export const {{name.pascalCase}}Screen: FC = () => {
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
{{name.kebabCase}}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
2
.templates/store/{{name.kebabCase}}/index.ts
Normal file
2
.templates/store/{{name.kebabCase}}/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { use{{name.pascalCase}}Store } from './{{name.kebabCase}}.store'
|
||||
export type { {{name.pascalCase}}State } from './{{name.kebabCase}}.type'
|
||||
@@ -0,0 +1,9 @@
|
||||
import { create } from 'zustand'
|
||||
import type { {{name.pascalCase}}State } from './{{name.kebabCase}}.type'
|
||||
|
||||
/**
|
||||
* Стор {{name.pascalCase}}.
|
||||
*/
|
||||
export const use{{name.pascalCase}}Store = create<{{name.pascalCase}}State>()(() => ({
|
||||
|
||||
}))
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Состояние {{name.pascalCase}}.
|
||||
*/
|
||||
export interface {{name.pascalCase}}State {
|
||||
|
||||
}
|
||||
1
.templates/widget/{{name.kebabCase}}/index.ts
Normal file
1
.templates/widget/{{name.kebabCase}}/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { {{name.pascalCase}}Widget } from './{{name.kebabCase}}.widget'
|
||||
@@ -0,0 +1,3 @@
|
||||
.root {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { FC } from 'react'
|
||||
import styles from './styles/{{name.kebabCase}}.module.css'
|
||||
|
||||
/**
|
||||
* Виджет {{name.pascalCase}}.
|
||||
*/
|
||||
export const {{name.pascalCase}}Widget: FC = () => {
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
{{name.kebabCase}}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
7
.vscode/extensions.json
vendored
Normal file
7
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"biomejs.biome",
|
||||
"MyTemplateGenerator.mytemplategenerator",
|
||||
"csstools.postcss"
|
||||
]
|
||||
}
|
||||
11
.vscode/settings.json
vendored
Normal file
11
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"editor.defaultFormatter": "biomejs.biome",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"quickfix.biome": "explicit",
|
||||
"source.organizeImports.biome": "explicit"
|
||||
},
|
||||
"files.associations": {
|
||||
"*.css": "postcss"
|
||||
}
|
||||
}
|
||||
5
AGENTS.md
Normal file
5
AGENTS.md
Normal file
@@ -0,0 +1,5 @@
|
||||
<!-- BEGIN:nextjs-agent-rules -->
|
||||
# This is NOT the Next.js you know
|
||||
|
||||
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
|
||||
<!-- END:nextjs-agent-rules -->
|
||||
36
README.md
Normal file
36
README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/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/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||
|
||||
## 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/app/building-your-application/deploying) for more details.
|
||||
34
biome.json
Normal file
34
biome.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
|
||||
"vcs": {
|
||||
"enabled": true,
|
||||
"clientKind": "git",
|
||||
"useIgnoreFile": true
|
||||
},
|
||||
"files": {
|
||||
"ignoreUnknown": true,
|
||||
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true
|
||||
},
|
||||
"domains": {
|
||||
"next": "recommended",
|
||||
"react": "recommended"
|
||||
}
|
||||
},
|
||||
"assist": {
|
||||
"actions": {
|
||||
"source": {
|
||||
"organizeImports": "on"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
next.config.ts
Normal file
7
next.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
1521
package-lock.json
generated
Normal file
1521
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
29
package.json
Normal file
29
package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "nextjs",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "biome check",
|
||||
"format": "biome format --write"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mantine/core": "^8.3.18",
|
||||
"@mantine/hooks": "^8.3.18",
|
||||
"clsx": "^2.1.1",
|
||||
"next": "16.2.1",
|
||||
"react": "19.2.4",
|
||||
"react-dom": "19.2.4",
|
||||
"swr": "^2.4.1",
|
||||
"zustand": "^5.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "2.2.0",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
17
postcss.config.mjs
Normal file
17
postcss.config.mjs
Normal file
@@ -0,0 +1,17 @@
|
||||
/** @type {import('postcss-load-config').Config} */
|
||||
const config = {
|
||||
plugins: {
|
||||
'postcss-preset-mantine': {},
|
||||
'postcss-simple-vars': {
|
||||
variables: {
|
||||
'mantine-breakpoint-xs': '36em',
|
||||
'mantine-breakpoint-sm': '48em',
|
||||
'mantine-breakpoint-md': '62em',
|
||||
'mantine-breakpoint-lg': '75em',
|
||||
'mantine-breakpoint-xl': '88em',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default config
|
||||
BIN
public/og-image.png
Normal file
BIN
public/og-image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
public/rick-and-morty-dance.gif
Normal file
BIN
public/rick-and-morty-dance.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 326 KiB |
71
src/app/globals.css
Normal file
71
src/app/globals.css
Normal file
@@ -0,0 +1,71 @@
|
||||
/* Цвета */
|
||||
:root {
|
||||
--color-text: #1a1a1a;
|
||||
--color-text-secondary: #6b7280;
|
||||
--color-bg: #ffffff;
|
||||
--color-bg-secondary: #f9fafb;
|
||||
--color-border: #e5e7eb;
|
||||
--color-primary: #228be6;
|
||||
--color-error: #fa5252;
|
||||
--color-success: #40c057;
|
||||
--color-warning: #fab005;
|
||||
}
|
||||
|
||||
/* Отступы */
|
||||
:root {
|
||||
--space-1: 4px;
|
||||
--space-2: 8px;
|
||||
--space-3: 12px;
|
||||
--space-4: 16px;
|
||||
--space-5: 20px;
|
||||
--space-6: 24px;
|
||||
--space-8: 32px;
|
||||
--space-10: 40px;
|
||||
--space-12: 48px;
|
||||
--space-16: 64px;
|
||||
}
|
||||
|
||||
/* Скругления */
|
||||
:root {
|
||||
--radius-sm: 4px;
|
||||
--radius-md: 8px;
|
||||
--radius-lg: 12px;
|
||||
--radius-xl: 16px;
|
||||
--radius-full: 9999px;
|
||||
}
|
||||
|
||||
/* Медиа-запросы (Mobile First) */
|
||||
@custom-media --xs (min-width: 36em);
|
||||
@custom-media --sm (min-width: 48em);
|
||||
@custom-media --md (min-width: 62em);
|
||||
@custom-media --lg (min-width: 75em);
|
||||
@custom-media --xl (min-width: 88em);
|
||||
|
||||
/* Базовые стили */
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
max-width: 100vw;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
body {
|
||||
min-height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
color: var(--color-text);
|
||||
background: var(--color-bg);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
43
src/app/layout.tsx
Normal file
43
src/app/layout.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { PropsWithChildren } from 'react'
|
||||
import type { Metadata } from 'next'
|
||||
import { ColorSchemeScript, MantineProvider } from '@mantine/core'
|
||||
import '@mantine/core/styles.css'
|
||||
import './globals.css'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: {
|
||||
default: 'App',
|
||||
template: '%s | App',
|
||||
},
|
||||
description: 'Описание приложения',
|
||||
metadataBase: new URL('https://example.com'),
|
||||
openGraph: {
|
||||
type: 'website',
|
||||
locale: 'ru_RU',
|
||||
siteName: 'App',
|
||||
images: [
|
||||
{
|
||||
url: '/og-image.png',
|
||||
width: 1200,
|
||||
height: 630,
|
||||
alt: 'App',
|
||||
},
|
||||
],
|
||||
},
|
||||
twitter: {
|
||||
card: 'summary_large_image',
|
||||
},
|
||||
}
|
||||
|
||||
export default function RootLayout({ children }: PropsWithChildren) {
|
||||
return (
|
||||
<html lang="ru" suppressHydrationWarning>
|
||||
<head>
|
||||
<ColorSchemeScript />
|
||||
</head>
|
||||
<body>
|
||||
<MantineProvider>{children}</MantineProvider>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
11
src/app/page.tsx
Normal file
11
src/app/page.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { HomeScreen } from '@/screens/home'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Главная',
|
||||
description: 'Главная страница приложения',
|
||||
}
|
||||
|
||||
export default function HomePage() {
|
||||
return <HomeScreen />
|
||||
}
|
||||
0
src/entities/.gitkeep
Normal file
0
src/entities/.gitkeep
Normal file
0
src/features/.gitkeep
Normal file
0
src/features/.gitkeep
Normal file
28
src/screens/home/home.screen.tsx
Normal file
28
src/screens/home/home.screen.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { FC } from 'react'
|
||||
import { Container, Title, Text, Image, Stack } from '@mantine/core'
|
||||
import styles from './styles/home.module.css'
|
||||
|
||||
/**
|
||||
* Главный экран приложения.
|
||||
*/
|
||||
export const HomeScreen: FC = () => {
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<Container size="sm">
|
||||
<Stack align="center" gap="lg">
|
||||
<Image
|
||||
src="/rick-and-morty-dance.gif"
|
||||
alt="Dancing Rick"
|
||||
w={200}
|
||||
h={200}
|
||||
fit="contain"
|
||||
/>
|
||||
<Title order={1}>Добро пожаловать</Title>
|
||||
<Text c="dimmed">
|
||||
Шаблон приложения на Next.js и TypeScript.
|
||||
</Text>
|
||||
</Stack>
|
||||
</Container>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
1
src/screens/home/index.ts
Normal file
1
src/screens/home/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { HomeScreen } from './home.screen'
|
||||
5
src/screens/home/styles/home.module.css
Normal file
5
src/screens/home/styles/home.module.css
Normal file
@@ -0,0 +1,5 @@
|
||||
.root {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
}
|
||||
0
src/shared/lib/.gitkeep
Normal file
0
src/shared/lib/.gitkeep
Normal file
0
src/shared/types/.gitkeep
Normal file
0
src/shared/types/.gitkeep
Normal file
0
src/shared/ui/.gitkeep
Normal file
0
src/shared/ui/.gitkeep
Normal file
0
src/widgets/.gitkeep
Normal file
0
src/widgets/.gitkeep
Normal file
34
tsconfig.json
Normal file
34
tsconfig.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"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": "react-jsx",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts",
|
||||
".next/dev/types/**/*.ts",
|
||||
"**/*.mts"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user