commit 2450d8a7c88c43cd70bffd312340cb06f446dd3b Author: yude Date: Mon Jan 15 22:28:35 2024 +0900 Initial commit diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..d6c9537 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,18 @@ +module.exports = { + root: true, + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react-hooks/recommended', + ], + ignorePatterns: ['dist', '.eslintrc.cjs'], + parser: '@typescript-eslint/parser', + plugins: ['react-refresh'], + rules: { + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/README.md b/README.md new file mode 100644 index 0000000..0d6babe --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# React + TypeScript + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: + +- Configure the top-level `parserOptions` property like this: + +```js +export default { + // other rules... + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + project: ['./tsconfig.json', './tsconfig.node.json'], + tsconfigRootDir: __dirname, + }, +} +``` + +- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` +- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` +- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..24250f5 Binary files /dev/null and b/bun.lockb differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..386052c --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + + yude.jp + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..db97aab --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "yude.jp", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "@fortawesome/fontawesome-svg-core": "^6.5.1", + "@fortawesome/free-brands-svg-icons": "^6.5.1", + "@fortawesome/free-regular-svg-icons": "^6.5.1", + "@fortawesome/free-solid-svg-icons": "^6.5.1", + "@fortawesome/react-fontawesome": "^0.2.0", + "@heroicons/vue": "^2.1.1", + "autoprefixer": "^10.4.16", + "postcss": "^8.4.33", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-scroll-percentage": "^4.3.2", + "tailwindcss": "^3.4.1" + }, + "devDependencies": { + "@types/react": "^18.2.43", + "@types/react-dom": "^18.2.17", + "@typescript-eslint/eslint-plugin": "^6.14.0", + "@typescript-eslint/parser": "^6.14.0", + "@vitejs/plugin-react-swc": "^3.5.0", + "eslint": "^8.55.0", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.4.5", + "typescript": "^5.2.2", + "vite": "^5.0.8" + } +} diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/public/avatar.webp b/public/avatar.webp new file mode 100644 index 0000000..da989e7 Binary files /dev/null and b/public/avatar.webp differ diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..fe9063c --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,106 @@ +import Card from "./components/Card" + +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faChevronDown } from '@fortawesome/free-solid-svg-icons' + +import React, { useState, useEffect } from 'react'; + +export default function App() { + const [scrollPercentage, setScrollPercentage] = useState(0); + const [cardY, setCardY] = useState(0); + const [contentY, setContentY] = useState(0); + + const handleScroll = () => { + const card = Math.max((window.innerHeight / 2) - window.scrollY, 0); + setCardY(card); + + const windowHeight = window.innerHeight; + const fullHeight = document.documentElement.scrollHeight; + const currentPosition = window.scrollY; + + const scrollPercentage = (currentPosition / (fullHeight - windowHeight)); + + setScrollPercentage(scrollPercentage); + setContentY(card + (window.innerHeight / 2)); + console.log(scrollPercentage) + }; + + useEffect(() => { + handleScroll(); + window.addEventListener('scroll', handleScroll); + + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }, []); + + useEffect(() => { + handleScroll(); + window.addEventListener('scroll', handleScroll, { passive: true }); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }, []); + + return ( +
+
+
+ +

{document.documentElement.clientHeight}, {(window.innerHeight / 2) - window.scrollY}

+
+
+ +
+
+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+

AAAAAAAAAA

+
+
+
+ + ) +} diff --git a/src/components/Card.tsx b/src/components/Card.tsx new file mode 100644 index 0000000..8593f38 --- /dev/null +++ b/src/components/Card.tsx @@ -0,0 +1,30 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faEnvelope } from '@fortawesome/free-regular-svg-icons' +import { faPhone } from '@fortawesome/free-solid-svg-icons' + +export default function Card() { + return ( + <> +
+
+ +
+
+

+ yude +

+

Hiroshima City University

+
+

+ i@yude.jp +

+

+ +81 70-8909-1949 +

+
+
+
+ + ) + } + \ No newline at end of file diff --git a/src/components/Header.tsx b/src/components/Header.tsx new file mode 100644 index 0000000..6770bfd --- /dev/null +++ b/src/components/Header.tsx @@ -0,0 +1,8 @@ +export default function Header() { + return ( +

+ Hello world! +

+ ) + } + \ No newline at end of file diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..dc36a44 --- /dev/null +++ b/src/index.css @@ -0,0 +1,7 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +body { + background-color: rgb(23 23 23); +} diff --git a/src/main.tsx b/src/main.tsx new file mode 100644 index 0000000..3d7150d --- /dev/null +++ b/src/main.tsx @@ -0,0 +1,10 @@ +import React from 'react' +import ReactDOM from 'react-dom/client' +import App from './App.tsx' +import './index.css' + +ReactDOM.createRoot(document.getElementById('root')!).render( + + + , +) diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..dca8ba0 --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,11 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: [ + "./index.html", + "./src/**/*.{js,ts,jsx,tsx}", + ], + theme: { + extend: {}, + }, + plugins: [], +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..a7fc6fb --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 0000000..42872c5 --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..861b04b --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react-swc' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +})