Skip to content

Commit da71e12

Browse files
committed
update deps, use eslint-config-reearth, refactor vite config
1 parent d161a09 commit da71e12

18 files changed

+1194
-3442
lines changed

.eslintrc.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
root: true
2+
extends:
3+
- reearth

example/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "example",
33
"version": "0.0.0",
4+
"private": true,
45
"scripts": {
56
"dev": "vite",
67
"build": "tsc && vite build",
@@ -9,15 +10,14 @@
910
"dependencies": {
1011
"react": "^18.2.0",
1112
"react-align": "link:..",
12-
"react-beautiful-dnd": "^13.1.0",
13+
"react-beautiful-dnd": "^13.1.1",
1314
"react-dom": "^18.2.0"
1415
},
1516
"devDependencies": {
16-
"@types/react": "^18.0.15",
17-
"@types/react-dom": "^18.0.6",
18-
"@vitejs/plugin-react": "^2.0.0",
19-
"typescript": "^4.7.4",
20-
"vite": "^3.0.2",
21-
"vite-plugin-react-svg": "^0.2.0"
17+
"@types/react": "^18.0.24",
18+
"@types/react-dom": "^18.0.8",
19+
"@vitejs/plugin-react": "^2.2.0",
20+
"typescript": "^4.8.4",
21+
"vite": "^3.2.1"
2222
}
2323
}

example/src/App.tsx

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import { useState } from "react";
2-
import {
3-
GridWrapper,
4-
GridSection,
5-
GridArea,
6-
GridItem,
7-
Alignment,
8-
} from "react-align";
2+
import { GridWrapper, GridSection, GridArea, GridItem, Alignment } from "react-align";
93

104
type Item = {
115
id: string;
@@ -41,8 +35,7 @@ const ItemComponent = (item: Item, i: number) => (
4135
index={i}
4236
key={item.id}
4337
extendable={item.extendable}
44-
extended={item.extended}
45-
>
38+
extended={item.extended}>
4639
<div
4740
style={{
4841
fontSize: "24px",
@@ -51,8 +44,7 @@ const ItemComponent = (item: Item, i: number) => (
5144
background: "#ddd",
5245
padding: "10px",
5346
boxSizing: "border-box",
54-
}}
55-
>
47+
}}>
5648
{item.id}
5749
</div>
5850
</GridItem>
@@ -74,14 +66,14 @@ function App() {
7466
editing={edit}
7567
onMove={(...args) => {
7668
console.log("move", ...args);
77-
setItems((items) => {
78-
const target = items.find((i) => i.id === args[0]);
69+
setItems(items => {
70+
const target = items.find(i => i.id === args[0]);
7971
if (!target) return items;
80-
const sibilings = items.filter((i) => i.location === args[1]);
72+
const sibilings = items.filter(i => i.location === args[1]);
8173
if (args[1] === args[3]) {
8274
sibilings.splice(
83-
sibilings.findIndex((i) => i.id === args[0]),
84-
1
75+
sibilings.findIndex(i => i.id === args[0]),
76+
1,
8577
);
8678
}
8779
sibilings.splice(args[2], 0, target);
@@ -94,23 +86,22 @@ function App() {
9486
}}
9587
onAlignChange={(...args) => {
9688
console.log("alignmentChange", ...args);
97-
setAlignments((a) => ({
89+
setAlignments(a => ({
9890
...a,
9991
[args[0]]: args[1],
10092
}));
10193
}}
10294
onExtend={(...args) => {
10395
console.log("extend", ...args);
104-
setItems((items) => {
105-
const target = items.find((i) => i.id === args[0]);
96+
setItems(items => {
97+
const target = items.find(i => i.id === args[0]);
10698
if (!target) return items;
10799
target.extended = args[1];
108100
return [...items];
109101
});
110-
}}
111-
>
102+
}}>
112103
<GridSection>
113-
{["1", "2", "3"].map((l) => (
104+
{["1", "2", "3"].map(l => (
114105
<GridArea
115106
id={l}
116107
key={l}
@@ -124,22 +115,19 @@ function App() {
124115
background: l === "2" ? "blue" : "red",
125116
border: `2px solid ${background}`,
126117
}}
127-
iconColor={l === "2" ? "red" : "blue"}
128-
>
118+
iconColor={l === "2" ? "red" : "blue"}>
129119
{items
130-
.filter((i) => i.location === l)
120+
.filter(i => i.location === l)
131121
.sort((a, b) => a.index - b.index)
132122
.map(ItemComponent)}
133123
</GridArea>
134124
))}
135125
</GridSection>
136126
<GridSection stretch>
137-
{["4", "5", "6"].map((l) =>
127+
{["4", "5", "6"].map(l =>
138128
l === "5" ? (
139129
<div key={l} style={{ flex: "auto" }}>
140-
<button onClick={() => setEdit((e) => !e)}>
141-
{edit ? "Finish" : "Start"} editing
142-
</button>
130+
<button onClick={() => setEdit(e => !e)}>{edit ? "Finish" : "Start"} editing</button>
143131
</div>
144132
) : (
145133
<GridArea
@@ -148,18 +136,17 @@ function App() {
148136
align={alignments[l]}
149137
bottom={l === "6"}
150138
editorStyle={{ background: "red" }}
151-
iconColor={"blue"}
152-
>
139+
iconColor={"blue"}>
153140
{items
154-
.filter((i) => i.location === l)
141+
.filter(i => i.location === l)
155142
.sort((a, b) => a.index - b.index)
156143
.map(ItemComponent)}
157144
</GridArea>
158-
)
145+
),
159146
)}
160147
</GridSection>
161148
<GridSection>
162-
{["7", "8", "9"].map((l) => (
149+
{["7", "8", "9"].map(l => (
163150
<GridArea
164151
id={l}
165152
key={l}
@@ -168,10 +155,9 @@ function App() {
168155
vertical={l === "8"}
169156
stretch={l === "8"}
170157
editorStyle={{ background: l === "8" ? "blue" : "red" }}
171-
iconColor={l === "8" ? "red" : "blue"}
172-
>
158+
iconColor={l === "8" ? "red" : "blue"}>
173159
{items
174-
.filter((i) => i.location === l)
160+
.filter(i => i.location === l)
175161
.sort((a, b) => a.index - b.index)
176162
.map(ItemComponent)}
177163
</GridArea>

example/src/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { StrictMode } from "react";
22
import { createRoot } from "react-dom/client";
3+
34
import "./index.css";
45
import App from "./App";
56

@@ -9,5 +10,5 @@ const root = createRoot(container);
910
root.render(
1011
<StrictMode>
1112
<App />
12-
</StrictMode>
13+
</StrictMode>,
1314
);

example/vite.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { defineConfig } from "vite";
21
import react from "@vitejs/plugin-react";
3-
import reactSvgPlugin from "vite-plugin-react-svg";
2+
import { defineConfig } from "vite";
43

54
// https://vitejs.dev/config/
65
export default defineConfig({
7-
plugins: [reactSvgPlugin({ defaultExport: "component" }), react()],
6+
plugins: [react()],
87
server: {
98
port: 3001,
109
open: true,

0 commit comments

Comments
 (0)