Skip to content

Commit

Permalink
refactor: adjust code style (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue authored Dec 5, 2020
1 parent c51dc83 commit 1dc2ab0
Show file tree
Hide file tree
Showing 73 changed files with 180 additions and 877 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
semi: false
tabWidth: 4
trailingComma: "all"
printWidth: 100
printWidth: 140
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"source.fixAll.eslint": true,
},
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.rulers": [100],
"editor.rulers": [140],
"typescript.tsdk": "node_modules/typescript/lib",
"python.pythonPath": ".venv/bin/python",
"eslint.codeActionsOnSave.mode": "problems",
Expand Down
2 changes: 0 additions & 2 deletions netlify.toml

This file was deleted.

6 changes: 1 addition & 5 deletions packages/common/src/cookie.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
export function setCookie(
name: string,
value: string,
option?: { days?: number; domain?: string },
): void {
export function setCookie(name: string, value: string, option?: { days?: number; domain?: string }): void {
let expires = ""
if (option?.days) {
const date = new Date()
Expand Down
13 changes: 2 additions & 11 deletions packages/home/src/components/appbar-auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,13 @@ const useStyles = makeStyles(
}),
)

const SignInAndSignUp: React.FC<{ signInLink: string; signUpLink: string }> = ({
signInLink,
signUpLink,
}) => (
const SignInAndSignUp: React.FC<{ signInLink: string; signUpLink: string }> = ({ signInLink, signUpLink }) => (
<>
<Button animation href={signInLink} testid="homepage_signin_btn" ariaLabel="Sign in">
Sign in
</Button>
<span style={{ width: "8px" }} />
<Button
animation
href={signUpLink}
testid="homepage_signup_btn"
ariaLabel="Sign up"
primary
>
<Button animation href={signUpLink} testid="homepage_signup_btn" ariaLabel="Sign up" primary>
Sign up
</Button>
</>
Expand Down
15 changes: 2 additions & 13 deletions packages/home/src/components/appbar-mobile-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ export const MobileMenu: React.FC<{
const authInfo = useAuthInfo()

return (
<div
className={animationClassName + " " + classes.root}
hidden={hidden}
data-testid="homepage_appbar_mobile_menu"
>
<div className={animationClassName + " " + classes.root} hidden={hidden} data-testid="homepage_appbar_mobile_menu">
<div
style={{
borderRadius: "0.5rem",
Expand Down Expand Up @@ -126,14 +122,7 @@ export const MobileMenu: React.FC<{
paddingRight: "1.25rem",
}}
>
<Button
href={authInfo.signUpLink}
ariaLabel="Sign up"
testid=""
primary
shadow
fullWidth
>
<Button href={authInfo.signUpLink} ariaLabel="Sign up" testid="" primary shadow fullWidth>
Sign up
</Button>
<p
Expand Down
55 changes: 7 additions & 48 deletions packages/home/src/components/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,7 @@ const useTextButtonStyles = makeStyles(
}),
)

export const Button: React.FC<ButtonProps> = ({
ariaLabel,
testid,
primary,
children,
fullWidth,
shadow,
animation,
...extra
}) => {
export const Button: React.FC<ButtonProps> = ({ ariaLabel, testid, primary, children, fullWidth, shadow, animation, ...extra }) => {
const classes = useTextButtonStyles()
const [show, setShow] = useState(false)
React.useEffect(() => {
Expand All @@ -138,13 +129,7 @@ export const Button: React.FC<ButtonProps> = ({
}

return (
<a
{...extra}
className={className}
type="button"
aria-label={ariaLabel}
data-testid={testid}
>
<a {...extra} className={className} type="button" aria-label={ariaLabel} data-testid={testid}>
{children}
</a>
)
Expand All @@ -153,13 +138,7 @@ export const Button: React.FC<ButtonProps> = ({
export const IconButton: React.FC<IconButtonProps> = ({ onClick, ariaLabel, testid, children }) => {
const classes = useIconButtonStyles()
return (
<button
className={classes.btn}
type="button"
aria-label={ariaLabel}
onClick={onClick}
data-testid={testid}
>
<button className={classes.btn} type="button" aria-label={ariaLabel} onClick={onClick} data-testid={testid}>
{children}
</button>
)
Expand All @@ -168,18 +147,8 @@ export const IconButton: React.FC<IconButtonProps> = ({ onClick, ariaLabel, test
export const CloseIconButton: React.FC<IconButtonProps> = (props) => {
return (
<IconButton {...props}>
<svg
style={{ height: "1.5rem", width: "1.5rem" }}
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M6 18L18 6M6 6l12 12"
></path>
<svg style={{ height: "1.5rem", width: "1.5rem" }} fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</IconButton>
)
Expand All @@ -188,18 +157,8 @@ export const CloseIconButton: React.FC<IconButtonProps> = (props) => {
export const MoreIconButton: React.FC<IconButtonProps> = (props) => {
return (
<IconButton {...props}>
<svg
style={{ height: "1.5rem", width: "1.5rem" }}
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M4 6h16M4 12h16M4 18h16"
></path>
<svg style={{ height: "1.5rem", width: "1.5rem" }} fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M4 6h16M4 12h16M4 18h16"></path>
</svg>
</IconButton>
)
Expand Down
7 changes: 1 addition & 6 deletions packages/home/src/components/cta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ export const CTA: React.FC = () => {
<div className={classes.cta}>
<Logo className={classes.logo} />
<h2 className={classes.header}>Get started with Rino</h2>
<Button
href={authInfo.signUpLink}
testid="homepage_signup_btn"
ariaLabel="create_an_account"
primary
>
<Button href={authInfo.signUpLink} testid="homepage_signup_btn" ariaLabel="create_an_account" primary>
Create an account
</Button>
</div>
Expand Down
6 changes: 1 addition & 5 deletions packages/home/src/components/features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,7 @@ export const Features: React.FC = () => {
<div style={{ marginTop: "2.5rem" }}>
<ul className={classes.blockContainer}>
<FeatureBlock title="What you see is what you get" desc="" svg={wysiwygSvg} />
<FeatureBlock
title="Sync across all your devices"
desc=""
svg={cloudUploadSvg}
/>
<FeatureBlock title="Sync across all your devices" desc="" svg={cloudUploadSvg} />
<FeatureBlock title="Work offline" desc="" svg={offlineSvg} />
<FeatureBlock title="Free and open source" desc="" svg={githubSvg} />
</ul>
Expand Down
7 changes: 0 additions & 7 deletions packages/home/src/components/homepage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createStyles, makeStyles } from "@material-ui/styles"
import { getSignInState } from "@rino.app/common"
import React from "react"

import { breakpoints } from "../styles/breakpoint"
Expand Down Expand Up @@ -70,12 +69,6 @@ export function Homepage(props: HomepageProps) {

const [mobileMenuActivity, setMobileMenuActivity] = React.useState(false)

if (typeof window !== "undefined") {
// client-side-only code
// TODO: use https://github.com/vercel/next.js/issues/2473#issuecomment-587551234
console.log(`sign in state: ${getSignInState()}`)
}

return (
<div className={classes.root} data-testid="homepage_root">
<div className={classes.container}>
Expand Down
8 changes: 1 addition & 7 deletions packages/home/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import "../remedy.css"
import { BaseApp } from "@rino.app/next/dist/app"
import React from "react"

export default function MyApp<T>({
Component,
pageProps,
}: {
Component: React.FC<T>
pageProps: T
}) {
export default function MyApp<T>({ Component, pageProps }: { Component: React.FC<T>; pageProps: T }) {
return (
<BaseApp>
<Component {...pageProps} />
Expand Down
6 changes: 1 addition & 5 deletions packages/next/next.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ function getEnvs() {
}
const exported = {}
for (const key of Object.keys(allEnvs)) {
if (
key === "FIREBASE_DATABASE_EMULATOR_HOST" ||
key === "FIRESTORE_EMULATOR_HOST" ||
key.startsWith("REACT_APP")
) {
if (key === "FIREBASE_DATABASE_EMULATOR_HOST" || key === "FIRESTORE_EMULATOR_HOST" || key.startsWith("REACT_APP")) {
exported[key] = allEnvs[key]
}
}
Expand Down
5 changes: 1 addition & 4 deletions packages/next/src/document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ export function getNextDocument({ host, hasManifest }: { host: string; hasManife
</Head>
<body>
<noscript>
<strong>
We're sorry but Rino doesn't work properly without JavaScript enabled.
Please enable it to continue.
</strong>
<strong>We're sorry but Rino doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<Main />
<NextScript />
Expand Down
4 changes: 1 addition & 3 deletions packages/server/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ const WEB_HOST = "rino.app"
const HOME_HOST = "www.rino.app"

function isIndexPage(req: IncomingMessage) {
return (
req.url === "/" || req.url === "" || req.url === "/index.html" || req.url === "index.html"
)
return req.url === "/" || req.url === "" || req.url === "/index.html" || req.url === "index.html"
}

function serveHTML(res: NowResponse, filePath: string) {
Expand Down
6 changes: 1 addition & 5 deletions packages/web/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ module.exports = {
testMatch: ["**/__test__/**/*.spec.(js|ts|jsx|tsx)"],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: [
"jest-extended",
"jest-prosemirror/environment",
"jest-remirror/environment",
],
setupFilesAfterEnv: ["jest-extended", "jest-prosemirror/environment", "jest-remirror/environment"],

// Required for dom jest-prosemirror and jest-remirror
testEnvironment: "jsdom",
Expand Down
13 changes: 2 additions & 11 deletions packages/web/src/components/AboutDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
Box,
Dialog,
DialogContent,
DialogContentText,
DialogTitle,
Typography,
} from "@material-ui/core"
import { Box, Dialog, DialogContent, DialogContentText, DialogTitle, Typography } from "@material-ui/core"
import React from "react"

import logo from "src/assets/logo.png"
Expand All @@ -29,9 +22,7 @@ export const AboutDialog: React.FC<{
<DialogContentText align="center">
<span data-testid="about_dialog_version">Version {version}</span>
<br />
<span data-testid="about_dialog_copyright">
Copyright © 2020 Ocavue. All rights reserved.
</span>
<span data-testid="about_dialog_copyright">Copyright © 2020 Ocavue. All rights reserved.</span>
</DialogContentText>
</DialogContent>
</Dialog>
Expand Down
9 changes: 1 addition & 8 deletions packages/web/src/components/Auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,7 @@ const StyledButton = withStyles(
}),
)(Button)
export const SubmitButton: React.FC<ButtonProps> = (props) => (
<StyledButton
type="submit"
fullWidth
variant="contained"
color="primary"
size="large"
{...props}
/>
<StyledButton type="submit" fullWidth variant="contained" color="primary" size="large" {...props} />
)

type OnSubmit = (event: React.FormEvent<HTMLFormElement>) => void
Expand Down
9 changes: 1 addition & 8 deletions packages/web/src/components/Auth/PasswordResetForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ type PasswordResetProps = {
setError: (val: string) => void
}

export default function PasswordReset({
email,
setEmail,
progressing,
setProgressing,
setProgressed,
setError,
}: PasswordResetProps) {
export default function PasswordReset({ email, setEmail, progressing, setProgressing, setProgressed, setError }: PasswordResetProps) {
const disableSubmit = useMemo(() => !email || progressing, [email, progressing])
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
Expand Down
13 changes: 2 additions & 11 deletions packages/web/src/components/Auth/SignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import firebase from "firebase"
import { useRouter } from "next/router"
import React, { useMemo, useState } from "react"

import {
AuthForm,
PasswordTextField,
SubmitButton,
UsernameTextField,
} from "src/components/Auth/Auth"
import { AuthForm, PasswordTextField, SubmitButton, UsernameTextField } from "src/components/Auth/Auth"
import { signInWithEmailAndPassword } from "src/controller/auth/actions"
import { AuthContainer } from "src/controller/auth/hook"

Expand All @@ -22,11 +17,7 @@ export default function SignInForm({ progressing, setProgressing, setError }: Si
const router = useRouter()
const [email, setEmail] = useState("")
const [password, setPassword] = useState("")
const disableSubmit = useMemo(() => !email || !password || progressing, [
email,
password,
progressing,
])
const disableSubmit = useMemo(() => !email || !password || progressing, [email, password, progressing])
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
setProgressing(true)
setError("")
Expand Down
13 changes: 2 additions & 11 deletions packages/web/src/components/Auth/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import firebase from "firebase"
import { useRouter } from "next/router"
import React, { useMemo, useState } from "react"

import {
AuthForm,
PasswordTextField,
SubmitButton,
UsernameTextField,
} from "src/components/Auth/Auth"
import { AuthForm, PasswordTextField, SubmitButton, UsernameTextField } from "src/components/Auth/Auth"
import { createUserWithEmailAndPassword } from "src/controller/auth/actions"
import { AuthContainer } from "src/controller/auth/hook"

Expand All @@ -22,11 +17,7 @@ export default function SignUpForm({ progressing, setProgressing, setError }: Si
const router = useRouter()
const [email, setEmail] = useState("")
const [password, setPassword] = useState("")
const disableSubmit = useMemo(() => !email || !password || progressing, [
email,
password,
progressing,
])
const disableSubmit = useMemo(() => !email || !password || progressing, [email, password, progressing])
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
setProgressing(true)
setError("")
Expand Down
Loading

0 comments on commit 1dc2ab0

Please sign in to comment.