Skip to content

Commit

Permalink
ライブラリバージョンアップデート
Browse files Browse the repository at this point in the history
  • Loading branch information
erutobusiness committed Apr 29, 2024
1 parent c745ab5 commit 4dd41eb
Show file tree
Hide file tree
Showing 16 changed files with 777 additions and 1,174 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ module.exports = {
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:react-hooks/recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ export default {
}
```

- 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

---

# 環境構築
Expand All @@ -49,19 +45,21 @@ export default {

### 拡張機能

#### 必須

`.vscode\extensions.json`

- JavaScript and TypeScript Nightly
- Biome

## 起動

以下のコマンドでローカル起動できる。

```
npm run dev
```

以下のコマンドで `dist` ディレクトリにビルド内容が出力される。

```
num run build
```
Expand Down
1,795 changes: 694 additions & 1,101 deletions package-lock.json

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@
"preview": "vite preview"
},
"dependencies": {
"@stylexjs/stylex": "^0.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"vite-plugin-stylex": "^0.5.1"
"@stylexjs/stylex": "^0.6.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vite-plugin-stylex": "^0.8.3"
},
"devDependencies": {
"@biomejs/biome": "^1.6.0",
"@biomejs/biome": "^1.7.1",
"@types/lodash": "^4.17.0",
"@types/node": "^20.12.2",
"@types/react": "^18.2.37",
"@types/node": "^20.12.7",
"@types/react": "^18.3.1",
"@types/react-beautiful-dnd": "^13.1.8",
"@types/react-dom": "^18.2.15",
"@types/react-dom": "^18.3.0",
"@types/react-scroll": "^1.8.10",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"clsx": "^2.0.0",
"eslint": "^8.55.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.4",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"@vitejs/plugin-react-swc": "^3.6.0",
"clsx": "^2.1.1",
"eslint": "^9.1.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.6",
"lodash": "^4.17.21",
"prettier": "^3.1.0",
"prettier": "^3.2.5",
"react-beautiful-dnd": "^13.1.1",
"react-router-dom": "^6.20.1",
"react-router-dom": "^6.23.0",
"react-scroll": "^1.9.0",
"react-sortablejs": "^6.1.4",
"stylelint": "^15.11.0",
"stylelint-config-recess-order": "^4.4.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-prettier": "^4.1.0",
"typescript": "^5.2.2",
"vite": "^5.0.0"
"stylelint": "^16.4.0",
"stylelint-config-recess-order": "^5.0.1",
"stylelint-config-standard": "^36.0.0",
"stylelint-prettier": "^5.0.0",
"typescript": "^5.4.5",
"vite": "^5.2.10"
},
"overrides": {
"vite-plugin-stylex": {
"@stylexjs/babel-plugin": "0.5.1"
"@stylexjs/babel-plugin": "0.6.1"
}
}
}
2 changes: 1 addition & 1 deletion src/components/button/ButtonVite.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as stylex from '@stylexjs/stylex';
import stylex from '@stylexjs/stylex';
import type { StyleXStyles } from '@stylexjs/stylex';
import type { UserAuthoredStyles } from '@stylexjs/stylex/lib/StyleXTypes';
import { type ButtonHTMLAttributes, forwardRef, memo } from 'react';
Expand Down
13 changes: 0 additions & 13 deletions src/hooks/useEnv.tsx

This file was deleted.

12 changes: 6 additions & 6 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { type FC } from 'react';
import reactDom from 'react-dom/client';
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
import { LinkIndex } from './components/link/LinkIndex.tsx';
import { useEnv } from './hooks/useEnv.tsx';
import './main.css';
import { Button } from './pages/Button.tsx';
import { Index } from './pages/Index.tsx';
Expand All @@ -11,23 +10,24 @@ import { Query } from './pages/Query.tsx';
import { Beautiful } from './pages/dnd/Beautiful.tsx';
import { HTML5 } from './pages/dnd/HTML5.tsx';
import { Pointer } from './pages/dnd/Pointer.tsx';
import { Sortablejs } from './pages/dnd/Sortablejs.tsx';
// import { Sortablejs } from './pages/dnd/Sortablejs.tsx';
import { Scroll } from './pages/scroll/Scroll.tsx';
import { ScrollCss } from './pages/scroll/ScrollCss.tsx';
import { ScrollDiv } from './pages/scroll/ScrollDiv.tsx';
import { getEnv } from './utils/getEnv.ts';

const App: FC = () => {
const { ROOT_NAME } = useEnv();
const { rootName } = getEnv();

const App: FC = () => {
return (
<BrowserRouter basename={ROOT_NAME}>
<BrowserRouter basename={rootName}>
<Routes>
<Route path='/' element={<Index />} />
<Route path='btn' element={<Button />} />
<Route path='dnd' element={<LinkIndex path='/dnd' />} />
<Route path='dnd/htmlapi' element={<HTML5 />} />
<Route path='dnd/pointer' element={<Pointer />} />
<Route path='dnd/sortablejs' element={<Sortablejs />} />
{/* <Route path='dnd/sortablejs' element={<Sortablejs />} /> */}
<Route path='dnd/beautiful' element={<Beautiful />} />
<Route path='query' element={<Query />} />
<Route path='public' element={<Public />} />
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Component: FC = () => {
<DivCustom styleTypes={['margin']}>
<H3>aタグとして振る舞う</H3>
<DivCustom styleTypes={['margin']}>
<ButtonZenn variant='primary' asChild>
<ButtonZenn variant='primary' asChild={true}>
<a href='./btn'>Btn</a>
</ButtonZenn>
</DivCustom>
Expand All @@ -42,7 +42,7 @@ const Component: FC = () => {
<DivCustom styleTypes={['margin']}>
<H3>Linkとして振る舞う</H3>
<DivCustom styleTypes={['margin']}>
<ButtonZenn variant='primary' asChild>
<ButtonZenn variant='primary' asChild={true}>
<Link to=''>Btn</Link>
</ButtonZenn>
</DivCustom>
Expand All @@ -51,7 +51,7 @@ const Component: FC = () => {
<DivCustom styleTypes={['margin']}>
<H3>イチオシ挙動</H3>
<DivCustom styleTypes={['margin']}>
<ButtonZenn disabled asChild>
<ButtonZenn disabled={true} asChild={true}>
<a href='dnd'>Dnd</a>
</ButtonZenn>
</DivCustom>
Expand Down
16 changes: 8 additions & 8 deletions src/pages/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DivCustom } from '../components/div/DivCustom';
import { H1 } from '../components/heading/H1';
import { Logo } from '../components/image/Logo';
import { LinkIndex } from '../components/link/LinkIndex';
import { useEnv } from '../hooks/useEnv';
import { getEnv } from '../utils/getEnv';

const styles = stylex.create({
notProd: {
Expand All @@ -21,35 +21,35 @@ const styles = stylex.create({
},
});

const Component: FC = () => {
const { ROOT_NAME, ANY_NUMBER, IS_PROD } = useEnv();
const { rootName, anyNumber, isProd } = getEnv();

const [count, setCount] = useState<number>(ANY_NUMBER);
const Component: FC = () => {
const [count, setCount] = useState<number>(anyNumber);

const handleClickButton = () => {
setCount(count => count + 1);
};

return (
<div>
<H1>{ROOT_NAME.toUpperCase()}</H1>
<H1>{rootName.toUpperCase()}</H1>
<DivCustom
styleTypes={['flexCenter']}
styles={!IS_PROD && styles.notProd}
styles={!isProd && styles.notProd}
>
<Logo
url='https://vitejs.dev'
src={logoVite}
alt='Vite Logo'
styles={styles.vite}
isSpin
isSpin={true}
/>
<Logo
url='https://react.dev'
src={logoReact}
alt='React Logo'
styles={styles.react}
isSpin
isSpin={true}
/>
</DivCustom>
<DivCustom styleTypes={['center', 'margin2']}>
Expand Down
9 changes: 4 additions & 5 deletions src/pages/Public.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { type FC, memo } from 'react';
import type { JsonConfigs } from '../@types';
import { H1 } from '../components/heading/H1';
import { loadJson } from '../utils/loadJson';

const configsWindow = window.configs;
const configsJson: JsonConfigs = await fetch('./json/config.json').then(res =>
res.json(),
);
const configsJson: JsonConfigs = await loadJson('/json/config.json');

const Component: FC = () => {
return (
<>
<H1 isLeft>JS: window.configs</H1>
<H1 isLeft={true}>JS: window.configs</H1>
{configsWindow &&
Object.keys(configsWindow).map(key => (
<div key={key}>{configsWindow?.[key]?.keyString}</div>
))}
<H1 isLeft>JSON: FETCH</H1>
<H1 isLeft={true}>JSON: FETCH</H1>
{configsJson &&
Object.keys(configsJson).map(key =>
configsJson?.[key]?.map(val => (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Query.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as stylex from '@stylexjs/stylex';
import stylex from '@stylexjs/stylex';
import { type FC, memo, useCallback } from 'react';
import { ButtonVite } from '../components/button/ButtonVite';
import { H1 } from '../components/heading/H1';
Expand Down
4 changes: 2 additions & 2 deletions src/pages/dnd/Sortablejs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stylex from '@stylexjs/stylex';
import React, { type FC, memo } from 'react';
import { type FC, memo, useState } from 'react';
import { ReactSortable } from 'react-sortablejs';
import { H1 } from '../../components/heading/H1';

Expand Down Expand Up @@ -34,7 +34,7 @@ const styles = stylex.create({
});

const Component: FC = () => {
const [list, setList] = React.useState(draggableList);
const [list, setList] = useState(draggableList);

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/scroll/Ultimate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ const Component: FC = () => {
{/* */}
<DivScrollable
ref={refScroll}
isSnap
isAnimate
isSnap={true}
isAnimate={true}
stylesParent={styles.parent}
stylesScroll={styles.scroll}
onSetChap={setChapIdx}
Expand Down
14 changes: 14 additions & 0 deletions src/utils/getEnv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { castStrToBoolean } from './castStrToBoolean';
import { castStrToNum } from './castStrToNum';

export function getEnv() {
// Viteの場合はimport.meta.env.を使用
const baseUrl: string = import.meta.env.BASE_URL;
const rootName: string = import.meta.env.VITE_ROOT_NAME || 'RN';
const anyNumber: number = castStrToNum(
import.meta.env.VITE_ANY_NUMBER || '123',
);
const isProd: boolean = castStrToBoolean(import.meta.env.VITE_IS_PROD);

return { baseUrl, rootName, anyNumber, isProd };
}
8 changes: 8 additions & 0 deletions src/utils/loadJson.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getEnv } from './getEnv';

const { baseUrl } = getEnv();

export const loadJson = async (src: string) => {
const response = await fetch(baseUrl + src);
return await response.json();
};
2 changes: 2 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'vite';
import styleX from 'vite-plugin-stylex';

// https://vitejs.dev/config/
// biome-ignore lint/style/noDefaultExport: <explanation>
export default defineConfig({
plugins: [react(), styleX()],
base: '/react_ui_comparison',
Expand All @@ -11,4 +12,5 @@ export default defineConfig({
'top-level-await': true,
},
},
optimizeDeps: { exclude: ['react-sortablejs'] },
});

0 comments on commit 4dd41eb

Please sign in to comment.