Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed Dec 17, 2023
1 parent f4572c0 commit ed6b719
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 82 deletions.
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
public
public
src/vendor
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"plugins": [
"prettier-plugin-organize-imports",
"prettier-plugin-tailwindcss"
]
],
"tailwindFunctions": ["clsx"]
}
9 changes: 2 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"[typescript]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Expand All @@ -38,11 +38,6 @@
},
"editor.tabSize": 2,
"editor.detectIndentation": false,
"[typescript][typescriptreact]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"tailwindCSS.experimental.classRegex": [
["clsx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
]
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function App({ children }: PropsWithChildren<any>) {

export function BodyLayout({ children }: PropsWithChildren<any>) {
return (
<div className="min-w-screen bg-taupe-100 relative flex h-full min-h-screen w-full flex-col justify-between text-black">
<div className="min-w-screen relative flex h-full min-h-screen w-full flex-col justify-between bg-taupe-100 text-black">
<Header />
<main className="w-full flex-1">{children}</main>
<Footer />
Expand Down
16 changes: 8 additions & 8 deletions src/components/animation/Fade.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { PropsWithChildren, useEffect, useState } from 'react'
import { PropsWithChildren, useEffect, useState } from 'react';

export function Fade(props: PropsWithChildren<{ show: boolean }>) {
const { show, children } = props
const [render, setRender] = useState(show)
const { show, children } = props;
const [render, setRender] = useState(show);

useEffect(() => {
if (show) setRender(true)
}, [show])
if (show) setRender(true);
}, [show]);

const onAnimationEnd = () => {
if (!show) setRender(false)
}
if (!show) setRender(false);
};

return render ? (
<div
Expand All @@ -22,5 +22,5 @@ export function Fade(props: PropsWithChildren<{ show: boolean }>) {
>
{children}
</div>
) : null
) : null;
}
8 changes: 4 additions & 4 deletions src/components/animation/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { memo } from 'react'
import styles from 'src/components/animation/Spinner.module.css'
import { memo } from 'react';
import styles from 'src/components/animation/Spinner.module.css';

// From https://loading.io/css/
function _Spinner() {
Expand All @@ -10,7 +10,7 @@ function _Spinner() {
<div></div>
<div></div>
</div>
)
);
}

export const Spinner = memo(_Spinner)
export const Spinner = memo(_Spinner);
2 changes: 1 addition & 1 deletion src/components/buttons/OutlineButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function OutlineButton({
}: PropsWithChildren<ButtonHTMLAttributes<HTMLButtonElement>>) {
return (
<button
className={`border-taupe-300 btn btn-outline h-fit min-h-fit rounded-full px-4 py-2.5 font-semibold text-black hover:bg-black/5 ${className}`}
className={`btn btn-outline h-fit min-h-fit rounded-full border-taupe-300 px-4 py-2.5 font-semibold text-black hover:bg-black/5 ${className}`}
{...props}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/SolidButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function SolidButton({
}: PropsWithChildren<ButtonHTMLAttributes<HTMLButtonElement>>) {
return (
<button
className={`border-taupe-300 btn h-fit min-h-fit rounded-full bg-yellow-500 px-5 py-2.5 font-semibold text-black hover:bg-yellow-500 hover:opacity-90 ${className}`}
className={`btn h-fit min-h-fit rounded-full border-taupe-300 bg-yellow-500 px-5 py-2.5 font-semibold text-black hover:bg-yellow-500 hover:opacity-90 ${className}`}
{...props}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/errors/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ErrorBoundary extends Component<any, ErrorBoundaryState> {
<div className="flex h-screen w-screen items-center justify-center bg-gray-50">
<div className="flex flex-col items-center">
<Image src={ErrorIcon} width={80} height={80} alt="" />
<h1 className="text-lg mt-5">Fatal Error Occurred</h1>
<h1 className="mt-5 text-lg">Fatal Error Occurred</h1>
<div className="mt-5 text-sm">{details}</div>
<a
href={links.discord}
Expand Down
2 changes: 1 addition & 1 deletion src/components/icons/Identicon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Identicon extends PureComponent<Props> {
const jazziconResult = jazzicon(size, addressToSeed(address));

return (
<div className="border-taupe-300 flex w-fit items-center justify-center rounded-full border p-px">
<div className="flex w-fit items-center justify-center rounded-full border border-taupe-300 p-px">
<div
style={{ height: size, width: size, ...styles }}
ref={(nodeElement) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/menus/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function Dropdown({
</div>
<div
tabIndex={0}
className="border-taupe-300 dropdown-content z-[1] mt-3 border bg-white p-4 shadow"
className="dropdown-content z-[1] mt-3 border border-taupe-300 bg-white p-4 shadow"
>
{content}
</div>
Expand All @@ -46,7 +46,7 @@ export function DropdownMenu({
</div>
<ul
tabIndex={0}
className="border-taupe-300 menu dropdown-content z-[1] mt-3 w-52 border bg-white p-2 shadow"
className="menu dropdown-content z-[1] mt-3 w-52 border border-taupe-300 bg-white p-2 shadow"
>
{items.map((item, index) => (
<li key={index}>{item}</li>
Expand Down
2 changes: 1 addition & 1 deletion src/components/nav/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function ThemeToggle() {
<div className="text-[15px] font-normal leading-tight text-gray-950 dark:text-neutral-400">
Theme
</div>
<div className="trainsition-color relative flex items-center justify-center gap-[5px] rounded-[32px] border border border border border-gray-950 px-0.5 py-[1px] dark:bg-fuchsia-200">
<div className="trainsition-color dark:bg-fuchsia-200 relative flex items-center justify-center gap-[5px] rounded-[32px] border border border border border-gray-950 px-0.5 py-[1px]">
<div className="relative flex h-5 w-4 flex-col items-start justify-start p-1 pr-0">
<Image src={Sun} alt="light theme icon" width={14} height={14} />
</div>
Expand Down
20 changes: 10 additions & 10 deletions src/config/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export enum ChainId {
}

export interface ChainMetadata {
chainId: ChainId
name: string
rpcUrl: string
explorerUrl: string
explorerApiUrl: string
chainId: ChainId;
name: string;
rpcUrl: string;
explorerUrl: string;
explorerApiUrl: string;
}

export const Alfajores: ChainMetadata = {
Expand All @@ -18,28 +18,28 @@ export const Alfajores: ChainMetadata = {
rpcUrl: 'https://alfajores-forno.celo-testnet.org',
explorerUrl: 'https://alfajores.celoscan.io',
explorerApiUrl: 'https://api-alfajores.celoscan.io/api',
}
};

export const Baklava: ChainMetadata = {
chainId: ChainId.Baklava,
name: 'Baklava',
rpcUrl: 'https://baklava-forno.celo-testnet.org',
explorerUrl: 'https://explorer.celo.org/baklava',
explorerApiUrl: 'https://explorer.celo.org/baklava/api',
}
};

export const Celo: ChainMetadata = {
chainId: ChainId.Celo,
name: 'Celo',
rpcUrl: 'https://forno.celo.org',
explorerUrl: 'https://celoscan.io',
explorerApiUrl: 'https://api.celoscan.io/api',
}
};

export const chainIdToChain: Record<number, ChainMetadata> = {
[ChainId.Alfajores]: Alfajores,
[ChainId.Baklava]: Baklava,
[ChainId.Celo]: Celo,
}
};

export const allChains = [Celo, Alfajores, Baklava]
export const allChains = [Celo, Alfajores, Baklava];
1 change: 1 addition & 0 deletions src/features/staking/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function useValidatorGroups() {}
4 changes: 2 additions & 2 deletions src/features/wallet/WalletDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function WalletDropdown() {
{address && isConnected ? (
<Dropdown
button={
<OutlineButton className="all:py-1 pl-1.5 pr-3">
<OutlineButton className="pl-1.5 pr-3 all:py-1">
<div className="flex items-center justify-center space-x-1">
<Identicon address={address} size={26} />
<div className="text-sm">{shortenAddress(address, true)}</div>
Expand Down Expand Up @@ -73,7 +73,7 @@ function DropdownContent({ address, disconnect }: { address: Address; disconnect

function ValueRow({ label, value }: { label: string; value: string | number | bigint }) {
return (
<div className="border-taupe-300 flex flex-col border p-3">
<div className="flex flex-col border border-taupe-300 p-3">
<label className="text-sm">{label}</label>
<Amount value={value} className="text-xl" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
declare type Address = string
declare type Address = string;
declare type HexString = string;
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
declare module '@metamask/jazzicon'
declare module '@metamask/jazzicon';
4 changes: 2 additions & 2 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ Toasts
--toastify-color-light: #ffffff;
--toastify-color-dark: #2e3338;
--toastify-color-info: #3498db;
--toastify-color-success: #56DF7C;
--toastify-color-success: #56df7c;
--toastify-color-warning: #fcd34d;
--toastify-color-error: #E70532;
--toastify-color-error: #e70532;
--toastify-color-transparent: rgba(255, 255, 255, 0.7);

--toastify-icon-color-info: var(--toastify-color-info);
Expand Down
16 changes: 8 additions & 8 deletions src/utils/debounce.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { useEffect, useState } from 'react'
import { useEffect, useState } from 'react';

// Based on https://usehooks.com/useDebounce
export function useDebounce<T>(value: T, delayMs = 500): T {
const [debouncedValue, setDebouncedValue] = useState<T>(value)
const [debouncedValue, setDebouncedValue] = useState<T>(value);

useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value)
}, delayMs)
setDebouncedValue(value);
}, delayMs);

return () => {
clearTimeout(handler)
}
}, [value, delayMs])
clearTimeout(handler);
};
}, [value, delayMs]);

return debouncedValue
return debouncedValue;
}
2 changes: 1 addition & 1 deletion src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export const logger = {
info: (...args: any[]) => console.info(...args),
warn: (...args: any[]) => console.warn(...args),
error: (...args: any[]) => console.error(...args),
}
};
33 changes: 13 additions & 20 deletions src/utils/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,29 @@ export function deepCopy(v: any) {

export type ValueOf<T> = T[keyof T];

export function objMapEntries<
M extends Record<K, I>,
K extends keyof M,
O,
I = ValueOf<M>,
>(obj: M, func: (k: K, v: I) => O): [K, O][] {
export function objMapEntries<M extends Record<K, I>, K extends keyof M, O, I = ValueOf<M>>(
obj: M,
func: (k: K, v: I) => O,
): [K, O][] {
return Object.entries<I>(obj).map(([k, v]) => [k as K, func(k as K, v)]);
}

// Map over the values of the object
export function objMap<
M extends Record<K, I>,
K extends keyof M,
O,
I = ValueOf<M>,
>(obj: M, func: (k: K, v: I) => O): Record<K, O> {
export function objMap<M extends Record<K, I>, K extends keyof M, O, I = ValueOf<M>>(
obj: M,
func: (k: K, v: I) => O,
): Record<K, O> {
return Object.fromEntries<O>(objMapEntries(obj, func)) as Record<K, O>;
}

export function objFilter<K extends string, I, O extends I>(
obj: Record<K, I>,
func: (k: K, v: I) => v is O,
): Record<K, O> {
return Object.fromEntries(
Object.entries<I>(obj).filter(([k, v]) => func(k as K, v)),
) as Record<K, O>;
return Object.fromEntries(Object.entries<I>(obj).filter(([k, v]) => func(k as K, v))) as Record<
K,
O
>;
}

// promiseObjectAll :: {k: Promise a} -> Promise {k: a}
Expand All @@ -64,11 +61,7 @@ export function pick<K extends string, V = any>(obj: Record<K, V>, keys: K[]) {

// Recursively merges b into a
// Where there are conflicts, b takes priority over a
export function objMerge(
a: Record<string, any>,
b: Record<string, any>,
max_depth = 10,
): any {
export function objMerge(a: Record<string, any>, b: Record<string, any>, max_depth = 10): any {
if (max_depth === 0) {
throw new Error('objMerge tried to go too deep');
}
Expand Down
10 changes: 5 additions & 5 deletions src/utils/ssr.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useEffect, useState } from 'react'
import { useEffect, useState } from 'react';

// Is the component server-side rendering or not
export function useIsSsr() {
const [isSsr, setIsSsr] = useState(true)
const [isSsr, setIsSsr] = useState(true);
useEffect(() => {
setIsSsr(false)
}, [])
return isSsr
setIsSsr(false);
}, []);
return isSsr;
}
4 changes: 1 addition & 3 deletions src/utils/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export function sanitizeString(str: string) {
export function trimToLength(value: string, maxLength: number) {
if (!value) return '';
const trimmed = value.trim();
return trimmed.length > maxLength
? trimmed.substring(0, maxLength) + '...'
: trimmed;
return trimmed.length > maxLength ? trimmed.substring(0, maxLength) + '...' : trimmed;
}

export function errorToString(error: any, maxLength = 300) {
Expand Down

0 comments on commit ed6b719

Please sign in to comment.