Skip to content

Commit

Permalink
Merge branch 'frontend' into mayu-QRcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Nano3013 committed Oct 27, 2021
2 parents 8b1beeb + 9490bf1 commit 6120045
Show file tree
Hide file tree
Showing 18 changed files with 205 additions and 158 deletions.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Additional context**
Add any other context or screenshots about the feature request here.
35 changes: 35 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: format and commit when PR

on:
push:
branches: [main]
pull_request:

jobs:
frontend:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
defaults:
run:
working-directory: ./frontend
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
ref: ${{ github.head_ref }}
- name: Install package
run: yarn install --frozen-lockfile
- name: Run formatter
run: yarn run format
- name: Build test
run: yarn run build
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: applied prettier
5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"format": "prettier --write --ignore-path .gitignore \"./**/*.{js,jsx,ts,tsx,json,css,scss}\""
},
"eslintConfig": {
"extends": [
Expand All @@ -56,5 +56,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"prettier": "^2.4.1"
}
}
8 changes: 8 additions & 0 deletions frontend/prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
singleQuote: true,
trailingComma: 'none',
semi: false,
tabWidth: 2,
htmlWhitespaceSensitivity: 'ignore',
printWidth: 100
}
21 changes: 10 additions & 11 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from "react";
import { BrowserRouter, Switch, Route } from "react-router-dom";
import AppContextProvider from "./contexts/AppContext";
import Home from "./pages/Home";
import Signup from "./pages/Signup";

import { ChakraProvider } from "@chakra-ui/react";
import React from 'react'
import { BrowserRouter, Switch, Route } from 'react-router-dom'
import AppContextProvider from './contexts/AppContext'
import Home from './pages/Home'
import Signup from './pages/Signup'
import { ChakraProvider } from '@chakra-ui/react'

function App() {
return (
Expand All @@ -16,7 +15,7 @@ function App() {
</Switch>
</BrowserRouter>
</div>
);
)
}

const AppContainer = () => {
Expand All @@ -26,7 +25,7 @@ const AppContainer = () => {
<App />
</AppContextProvider>
</ChakraProvider>
);
};
)
}

export default AppContainer;
export default AppContainer
14 changes: 7 additions & 7 deletions frontend/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
import React from 'react'
import { render, screen } from '@testing-library/react'
import App from './App'

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
render(<App />)
const linkElement = screen.getByText(/learn react/i)
expect(linkElement).toBeInTheDocument()
})
28 changes: 14 additions & 14 deletions frontend/src/contexts/AppContext.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import React, { createContext, useEffect, useState } from "react";
import { getUserIdFromLocalStorage, storageAvailable } from "../utils/storage";
import React, { createContext, useEffect, useState } from 'react'
import { getUserIdFromLocalStorage, storageAvailable } from '../utils/storage'

export const AuthContext = createContext();
export const AuthContext = createContext()

const AppContextProvider = ({ children }) => {
const [initialLoading, setInitialLoading] = useState(true);
const [localStorageAvailable, setLocalStorageAvailable] = useState(false);
const [userId, setUserId] = useState(undefined);
const [initialLoading, setInitialLoading] = useState(true)
const [localStorageAvailable, setLocalStorageAvailable] = useState(false)
const [userId, setUserId] = useState(undefined)
useEffect(() => {
if (storageAvailable()) {
setLocalStorageAvailable(true);
let id = getUserIdFromLocalStorage();
setLocalStorageAvailable(true)
let id = getUserIdFromLocalStorage()
if (!id) {
// TODO: なまえを入力してIDを取得して保存しておく
}
}
setInitialLoading(false);
}, []);
setInitialLoading(false)
}, [])
return (
<AuthContext.Provider
value={{
userId,
setUserId,
initialLoading,
setInitialLoading,
localStorageAvailable,
localStorageAvailable
}}
>
{children}
</AuthContext.Provider>
);
};
)
}

export default AppContextProvider;
export default AppContextProvider
20 changes: 10 additions & 10 deletions frontend/src/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import React from "react";
import ReactDOM from "react-dom";
import "./index.scss";
import App from "./App";
import * as serviceWorkerRegistration from "./serviceWorkerRegistration";
import reportWebVitals from "./reportWebVitals";
import React from 'react'
import ReactDOM from 'react-dom'
import './index.scss'
import App from './App'
import * as serviceWorkerRegistration from './serviceWorkerRegistration'
import reportWebVitals from './reportWebVitals'

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById("root")
);
document.getElementById('root')
)

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://cra.link/PWA
serviceWorkerRegistration.unregister();
serviceWorkerRegistration.unregister()

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
reportWebVitals()
8 changes: 3 additions & 5 deletions frontend/src/index.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}
36 changes: 9 additions & 27 deletions frontend/src/pages/Home.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styles from "../styles/Home.module.scss";
import maskPic from "../assets/mask.png";
import styles from '../styles/Home.module.scss'
import maskPic from '../assets/mask.png'
import {
Box,
HStack,
Expand Down Expand Up @@ -35,7 +35,7 @@ const Home = () => {
<Button variant="ghost" onClick={onOpen}>
<BsPersonPlus size={25} />
</Button>
<Modal isOpen={isOpen} onClose={onClose} size={"sm"}>
<Modal isOpen={isOpen} onClose={onClose} size={'sm'}>
<ModalOverlay />
<ModalContent>
<ModalHeader>マイ QR コード</ModalHeader>
Expand All @@ -54,36 +54,18 @@ const Home = () => {
</Modal>
</HStack>
<hr className={styles.border} />
<Box
boxShadow="xs"
w="100%"
p={3}
marginBottom="1.5px"
_hover={{ background: "gray.200" }}
>
<Box boxShadow="xs" w="100%" p={3} marginBottom="1.5px" _hover={{ background: 'gray.200' }}>
<p className={styles.friendName}>山田 太郎</p>
</Box>
<Box
boxShadow="xs"
w="100%"
p={3}
marginBottom="1.5px"
_hover={{ background: "gray.200" }}
>
<Box boxShadow="xs" w="100%" p={3} marginBottom="1.5px" _hover={{ background: 'gray.200' }}>
<p className={styles.friendName}>aaaaaaaa</p>
</Box>
<Box
boxShadow="xs"
w="100%"
p={3}
marginBottom="1.5px"
_hover={{ background: "gray.200" }}
>
<Box boxShadow="xs" w="100%" p={3} marginBottom="1.5px" _hover={{ background: 'gray.200' }}>
<p className={styles.friendName}>bbbbbbbb</p>
</Box>
</div>
</div>
);
};
)
}

export default Home;
export default Home
6 changes: 3 additions & 3 deletions frontend/src/pages/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ const Signup = () => {
Create account
</Button>
</div>
);
};
export default Signup;
)
}
export default Signup
16 changes: 8 additions & 8 deletions frontend/src/reportWebVitals.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const reportWebVitals = (onPerfEntry) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
getCLS(onPerfEntry)
getFID(onPerfEntry)
getFCP(onPerfEntry)
getLCP(onPerfEntry)
getTTFB(onPerfEntry)
})
}
};
}

export default reportWebVitals;
export default reportWebVitals
Loading

0 comments on commit 6120045

Please sign in to comment.