Skip to content

Commit 65e7053

Browse files
committed
no more imports with ../../../
1 parent 1d0df58 commit 65e7053

File tree

12 files changed

+311
-250
lines changed

12 files changed

+311
-250
lines changed

hackathon/react-native-heroes/.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"extends": "react-native-wcandillon",
33
"rules": {
44
"camelcase": "off",
5+
"import/no-extraneous-dependencies": 0
56
}
67
}
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
/* eslint-disable import/no-default-export */
21
import { ApolloProvider } from "@apollo/client";
32
import { ThemeProvider } from "@shopify/restyle";
3+
import React from "react";
44

5-
import { HeroesList } from "./src/components/HeroesList";
6-
import theme from "./src/theme/theme";
7-
import { ScreenContainer } from "./src/components/ScreenContainer";
8-
import { client } from "./graphql/client";
5+
import { HeroesList } from "~/components/HeroesList";
6+
import { client } from "~/graphql/client";
7+
import theme from "~/theme/theme";
8+
import { ScreenContainer } from "~/components/ScreenContainer";
99

10-
export default function App() {
10+
function App() {
1111
return (
1212
<ApolloProvider client={client}>
1313
<ThemeProvider theme={theme}>
@@ -18,3 +18,7 @@ export default function App() {
1818
</ApolloProvider>
1919
);
2020
}
21+
22+
// App.tsx always exports a single component
23+
// eslint-disable-next-line import/no-default-export
24+
export default App;

hackathon/react-native-heroes/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"ios": "expo start --ios",
99
"web": "expo start --web",
1010
"eject": "expo eject",
11-
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx ."
11+
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
12+
"cache:clear": "watchman watch-del-all && rm -rf node_modules yarn.lock && yarn install"
1213
},
1314
"dependencies": {
1415
"@apollo/client": "^3.5.8",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createBox } from "@shopify/restyle";
22

3-
import type { Theme } from "../theme/theme";
3+
import type { Theme } from "~/theme/theme";
44

55
export const Box = createBox<Theme>();

hackathon/react-native-heroes/src/components/HeroesListItem.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import {
66
TouchableOpacity,
77
Linking,
88
Modal,
9-
Dimensions,
109
} from "react-native";
1110
import { Colors, Headline } from "react-native-paper";
1211
import { AntDesign } from "@expo/vector-icons";
1312
import React, { useState } from "react";
1413

15-
import { Box } from "./Box";
16-
import { Upvote } from "./Upvote";
14+
import { Box } from "~/components/Box";
15+
import { Upvote } from "~/components/Upvote";
1716

1817
export type HeroProps = {
1918
item: {
@@ -22,10 +21,10 @@ export type HeroProps = {
2221
full_name: string;
2322
github_username: string;
2423
twitter_username: string;
25-
counter: string;
24+
counter: number;
2625
};
2726
};
28-
const screenWidth = Dimensions.get("window").width;
27+
2928
export const HeroesListItem = (hero: HeroProps) => {
3029
const [modalVisible, setModalVisible] = useState(false);
3130

@@ -125,7 +124,6 @@ export const styles = StyleSheet.create({
125124
paddingVertical: 2,
126125
paddingHorizontal: 10,
127126
},
128-
129127
middle: {
130128
flex: 1,
131129
width: "60%",

hackathon/react-native-heroes/src/components/ScreenContainer.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import React from "react";
33
import { StatusBar } from "expo-status-bar";
44
import { Colors, Headline } from "react-native-paper";
55

6-
import { Box } from "./Box";
6+
import { Box } from "~/components/Box";
7+
import theme from "~/theme/theme";
78

89
type Props = {
910
children: React.ReactNode;
@@ -25,13 +26,12 @@ const styles = StyleSheet.create({
2526
container: {
2627
flex: 1,
2728
backgroundColor: Colors.black,
28-
paddingTop: 16,
29+
paddingTop: theme.spacing.s,
2930
},
3031
text: {
31-
color: "white",
32-
fontSize: 30,
32+
color: Colors.white,
33+
fontSize: 32,
3334
fontWeight: "bold",
34-
marginVertical: 20,
35-
textAlign: "center",
35+
marginVertical: theme.spacing.m,
3636
},
3737
});

hackathon/react-native-heroes/src/components/Upvote.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from "react";
22
import { AntDesign } from "@expo/vector-icons";
33
import { Button, Colors, Paragraph } from "react-native-paper";
4-
import { gql, useMutation } from "@apollo/client";
4+
import { useMutation } from "@apollo/client";
55
import {
66
Linking,
77
Modal,
@@ -10,7 +10,19 @@ import {
1010
StyleSheet,
1111
} from "react-native";
1212

13-
export const Upvote = ({ idHero, heroCounter, twitterUsername }) => {
13+
import { MUTATION_COUNTER } from "~/graphql/mutations";
14+
15+
interface UpvoteProps {
16+
idHero: string;
17+
heroCounter: number;
18+
twitterUsername: string;
19+
}
20+
21+
export const Upvote = ({
22+
idHero,
23+
heroCounter,
24+
twitterUsername,
25+
}: UpvoteProps) => {
1426
const [counter, setCounter] = useState<number>(heroCounter);
1527
const [hasUpvoted, setHasUpvoted] = useState<boolean>(false);
1628
const [addTodo] = useMutation(MUTATION_COUNTER);
@@ -30,14 +42,14 @@ export const Upvote = ({ idHero, heroCounter, twitterUsername }) => {
3042
const style = hasUpvoted
3143
? {
3244
borderColor: Colors.orange900,
33-
backgroundColor: "white",
45+
backgroundColor: Colors.white,
3446
borderWidth: 2,
3547
}
36-
: { backgroundColor: "white" };
48+
: { backgroundColor: Colors.white };
3749

3850
const styleIcon = hasUpvoted
3951
? { color: Colors.orange900 }
40-
: { color: "black" };
52+
: { color: Colors.black };
4153

4254
return (
4355
<>
@@ -79,18 +91,6 @@ export const Upvote = ({ idHero, heroCounter, twitterUsername }) => {
7991
);
8092
};
8193

82-
const MUTATION_COUNTER = gql`
83-
mutation update_counter($id: Int!) {
84-
update_heroes(where: { id: { _eq: $id } }, _inc: { counter: 1 }) {
85-
affected_rows
86-
returning {
87-
id
88-
counter
89-
}
90-
}
91-
}
92-
`;
93-
9494
export const styles = StyleSheet.create({
9595
modalShareView: {
9696
margin: 20,
@@ -100,7 +100,7 @@ export const styles = StyleSheet.create({
100100
width: "70%",
101101
height: "20%",
102102
alignItems: "center",
103-
shadowColor: "#000",
103+
shadowColor: Colors.black,
104104
shadowOffset: {
105105
width: 0,
106106
height: 2,

hackathon/react-native-heroes/src/config/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable import/no-default-export */
2+
/* eslint-disable import/no-anonymous-default-export */
13
import Constants from "expo-constants";
24

35
export default {

hackathon/react-native-heroes/graphql/client.ts renamed to hackathon/react-native-heroes/src/graphql/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ApolloClient, InMemoryCache } from "@apollo/client";
22

3-
import config from "../src/config/config";
3+
import config from "~/config/config";
44

55
export const client = new ApolloClient({
66
uri: config.HASURA_API_URL,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { gql } from "@apollo/client";
2+
3+
export const MUTATION_COUNTER = gql`
4+
mutation update_counter($id: Int!) {
5+
update_heroes(where: { id: { _eq: $id } }, _inc: { counter: 1 }) {
6+
affected_rows
7+
returning {
8+
id
9+
counter
10+
}
11+
}
12+
}
13+
`;

0 commit comments

Comments
 (0)