Apply prettier over all files

This commit is contained in:
Luis Alvarez
2020-10-01 20:40:40 -05:00
parent 2314ad760a
commit 0ef6449aff
72 changed files with 648 additions and 652 deletions

View File

@@ -1,43 +1,43 @@
import cn from "classnames";
import React, { ButtonHTMLAttributes } from "react";
import s from "./Button.module.css";
import cn from 'classnames'
import React, { ButtonHTMLAttributes } from 'react'
import s from './Button.module.css'
interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
href?: string;
className?: string;
variant?: "filled" | "outlined" | "flat" | "none";
active?: boolean;
type?: "submit" | "reset" | "button";
href?: string
className?: string
variant?: 'filled' | 'outlined' | 'flat' | 'none'
active?: boolean
type?: 'submit' | 'reset' | 'button'
}
export default class Button extends React.Component<Props> {
public render() {
const {
className,
variant = "filled",
variant = 'filled',
children,
disabled = false,
href,
active,
...rest
} = this.props;
} = this.props
let Component: React.ComponentType<
React.AnchorHTMLAttributes<
HTMLAnchorElement | HTMLButtonElement | HTMLDivElement
> &
React.ClassAttributes<HTMLButtonElement | HTMLAnchorElement>
> = "a" as any;
> = 'a' as any
// Catch for buttons / span / stc.
const rootClassName = cn(
s.root,
{
[s.filled]: variant === "filled",
[s.filled]: variant === 'filled',
},
className
);
)
return (
<Component
@@ -49,6 +49,6 @@ export default class Button extends React.Component<Props> {
>
{children}
</Component>
);
)
}
}

View File

@@ -1 +1 @@
export { default } from "./Button";
export { default } from './Button'

View File

@@ -3,47 +3,47 @@ import React, {
MutableRefObject,
useEffect,
useRef,
} from "react";
} from 'react'
import { Component } from "react";
import PropTypes from "prop-types";
import { Component } from 'react'
import PropTypes from 'prop-types'
export interface ClickOutsideProps {
onClickOutside: (e?: MouseEvent) => void;
children: React.ReactNode | any;
render: () => void;
onClickOutside: (e?: MouseEvent) => void
children: React.ReactNode | any
render: () => void
}
export default class ClickOutside extends Component<ClickOutsideProps> {
public domNode: Element | null = null;
public domNode: Element | null = null
handleRef = (element) => {
this.domNode = element;
};
this.domNode = element
}
public componentDidMount() {
document.addEventListener("click", this.handleClick, true);
document.addEventListener('click', this.handleClick, true)
}
public componentWillUnmount() {
document.removeEventListener("mousedown", this.handleClick, true);
document.removeEventListener("touchstart", this.handleClick, true);
document.removeEventListener('mousedown', this.handleClick, true)
document.removeEventListener('touchstart', this.handleClick, true)
}
public handleClick = (event) => {
function hasParent(element, root) {
return root && root.contains(element);
return root && root.contains(element)
}
if (!hasParent(event.target, this.domNode)) {
if (typeof this.props.onClickOutside === "function") {
this.props.onClickOutside(event);
if (typeof this.props.onClickOutside === 'function') {
this.props.onClickOutside(event)
}
}
};
}
render() {
return null;
return null
// return this.props.render({
// innerRef: this.handleRef,
// });

View File

@@ -1 +1 @@
export { default } from "./ClickOutside";
export { default } from './ClickOutside'

View File

@@ -1,25 +1,25 @@
import cn from "classnames";
import { FunctionComponent } from "react";
import s from "./Container.module.css";
import cn from 'classnames'
import { FunctionComponent } from 'react'
import s from './Container.module.css'
interface Props {
className?: string;
children?: any;
el?: HTMLElement;
className?: string
children?: any
el?: HTMLElement
}
const Container: FunctionComponent<Props> = ({
children,
className,
el = "div",
el = 'div',
}) => {
const rootClassName = cn(s.root, className);
const rootClassName = cn(s.root, className)
let Component: React.ComponentType<React.HTMLAttributes<
HTMLDivElement
>> = el as any;
>> = el as any
return <Component className={rootClassName}>{children}</Component>;
};
return <Component className={rootClassName}>{children}</Component>
}
export default Container;
export default Container

View File

@@ -1 +1 @@
export { default } from "./Container";
export { default } from './Container'

View File

@@ -35,6 +35,6 @@ const Logo = () => (
strokeWidth="0.30634"
/>
</svg>
);
)
export default Logo;
export default Logo

View File

@@ -1 +1 @@
export { default } from "./Logo";
export { default } from './Logo'

View File

@@ -1,14 +1,14 @@
import cn from "classnames";
import React, { FunctionComponent } from "react";
import s from "./Sidebar.module.css";
import cn from 'classnames'
import React, { FunctionComponent } from 'react'
import s from './Sidebar.module.css'
interface Props {
className?: string;
children?: any;
className?: string
children?: any
}
const Sidebar: FunctionComponent<Props> = ({ className, children }) => {
const rootClassName = cn(s.root, className);
const rootClassName = cn(s.root, className)
return (
<div className={rootClassName}>
<div className="fixed inset-0 overflow-hidden shadow-sm bg-black bg-opacity-25">
@@ -23,7 +23,7 @@ const Sidebar: FunctionComponent<Props> = ({ className, children }) => {
</div>
</div>
</div>
);
};
)
}
export default Sidebar;
export default Sidebar

View File

@@ -1 +1 @@
export { default } from "./Sidebar";
export { default } from './Sidebar'

View File

@@ -1,15 +1,15 @@
import cn from "classnames";
import { FunctionComponent } from "react";
import s from "./Featurebar.module.css";
import cn from 'classnames'
import { FunctionComponent } from 'react'
import s from './Featurebar.module.css'
interface Props {
className?: string;
children?: any;
className?: string
children?: any
}
const Featurebar: FunctionComponent<Props> = ({ children, className }) => {
const rootClassName = cn(s.root, className);
return <div className={rootClassName}>{children}</div>;
};
const rootClassName = cn(s.root, className)
return <div className={rootClassName}>{children}</div>
}
export default Featurebar;
export default Featurebar

View File

@@ -1 +1 @@
export { default } from "./Featurebar";
export { default } from './Featurebar'

View File

@@ -1,56 +1,56 @@
import React, { FunctionComponent } from "react";
import React, { FunctionComponent } from 'react'
export interface UIState {
displaySidebar: boolean;
openSidebar: () => {};
closeSidebar: () => {};
displaySidebar: boolean
openSidebar: () => {}
closeSidebar: () => {}
}
const initialState = {
displaySidebar: false,
openSidebar: null,
closeSidebar: null,
};
}
export const UIContext = React.createContext(initialState);
UIContext.displayName = "UIContext";
export const UIContext = React.createContext(initialState)
UIContext.displayName = 'UIContext'
export const UIProvider: FunctionComponent = (props) => {
const [state, dispatch] = React.useReducer(uiReducer, initialState);
const [state, dispatch] = React.useReducer(uiReducer, initialState)
const openSidebar = () => dispatch("OPEN_SIDEBAR");
const closeSidebar = () => dispatch("CLOSE_SIDEBAR");
const openSidebar = () => dispatch('OPEN_SIDEBAR')
const closeSidebar = () => dispatch('CLOSE_SIDEBAR')
const value = {
...state,
openSidebar,
closeSidebar,
};
}
return <UIContext.Provider value={value} {...props} />;
};
return <UIContext.Provider value={value} {...props} />
}
export const useUI = () => {
const context = React.useContext(UIContext);
const context = React.useContext(UIContext)
if (context === undefined) {
throw new Error(`useUI must be used within a UIProvider`);
throw new Error(`useUI must be used within a UIProvider`)
}
return context;
};
return context
}
function uiReducer(state, action) {
switch (action) {
case "OPEN_SIDEBAR": {
case 'OPEN_SIDEBAR': {
return {
...state,
displaySidebar: true,
};
}
}
case "CLOSE_SIDEBAR": {
case 'CLOSE_SIDEBAR': {
return {
...state,
displaySidebar: false,
};
}
}
}
}

View File

@@ -1,4 +1,4 @@
export { default as Button } from "./Button";
export { default as Container } from "./Container";
export { default as Sidebar } from "./Sidebar";
export { default as Logo } from "./Logo";
export { default as Button } from './Button'
export { default as Container } from './Container'
export { default as Sidebar } from './Sidebar'
export { default as Logo } from './Logo'

View File

@@ -1 +1 @@
export type Colors = "violet" | "black" | "pink" | "white";
export type Colors = 'violet' | 'black' | 'pink' | 'white'