Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "all",
"singleAttributePerLine": true
}
31 changes: 27 additions & 4 deletions app/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ module.exports = {
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
// project structure
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
'react/jsx-filename-extension': [
'error',
{ extensions: ['.js', '.jsx', '.ts', '.tsx'] },
],
'import/extensions': [
'error',
'ignorePackages',
Expand All @@ -43,11 +46,31 @@ module.exports = {
'no-use-before-define': 'off',
'no-unused-vars': 'off',
'react/require-default-props': 'off',
'operator-linebreak': 'off',
'object-curly-newline': ['error', { consistent: true }],
'react/no-unknown-property': 'off',
'react/jsx-one-expression-per-line': 'off',
'implicit-arrow-linebreak': 0,
'react/jsx-curly-newline': 'off',
'react/jsx-wrap-multilines': [
'error',
{
declaration: 'parens',
assignment: 'parens',
return: 'parens',
arrow: 'parens',
},
],
// 'function-paren-newline': ['error', 'multiline'],
'function-paren-newline': ['off', 'multiline'],
// due to DB IDs we have to disable this
'no-underscore-dangle': 'off',
camelcase: ['error', {
allow: ['redirect_uri', 'client_id', 'response_type'],
}],
camelcase: [
'error',
{
allow: ['redirect_uri', 'client_id', 'response_type'],
},
],
// preferences
'@typescript-eslint/no-use-before-define': 'off',
'no-plusplus': 'off',
Expand Down
93 changes: 55 additions & 38 deletions app/components/common/CleanButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ButtonType } from 'antd/lib/button';
interface CleanButtonProps {
children?: React.ReactNode;
style?: CSSProperties;
onClick?: React.MouseEventHandler<HTMLElement>,
onClick?: React.MouseEventHandler<HTMLElement>;
size?: SizeType;
backColor?: string;
textColor?: string;
Expand All @@ -22,14 +22,14 @@ interface CleanButtonProps {
}

const getButtonPadding = (size: SizeType) => {
switch (size) {
case 'small':
if (size === 'small') {
return '0rem 1rem';
case 'middle':
}
if (size === 'middle') {
return '0rem 1.5rem';
default:
return '0rem 2rem';
}
// Default to large size padding
return '0rem 2rem';
};

const ButtonComponent = ({
Expand All @@ -51,11 +51,14 @@ const ButtonComponent = ({

const parsedBackColor = backColor && parse(backColor);

const darkenedBackColor = backColor && parsedBackColor
&& `hsl(${parsedBackColor.hsl[0]}, ${parsedBackColor.hsl[1]}%, ${parsedBackColor.hsl[2] * 0.8}%)`;
const darkenedBackColor = useMemo(() => {
if (!darkenOnHover || !parsedBackColor) return backColor;
return `hsl(${parsedBackColor.hsl[0]}, ${parsedBackColor.hsl[1]}%, ${
parsedBackColor.hsl[2] * 0.8
}%)`;
}, [darkenOnHover, parsedBackColor, backColor]);

const cssTextColor = textColor
|| 'rgba(255, 255, 255, 0.95)';
const cssTextColor = textColor || 'rgba(255, 255, 255, 0.95)';

const buttonStyle = {
default: {
Expand Down Expand Up @@ -117,48 +120,62 @@ const CleanButton = ({
darkenOnHover,
className,
}: CleanButtonProps): JSX.Element => {
const buttonComponent: React.ReactNode = useMemo(() => (
<ButtonComponent
onClick={onClick}
style={style}
backColor={backColor}
textColor={textColor}
type={type}
url={url}
size={size}
openInNewTab={openInNewTab}
hoverAnimation={hoverAnimation}
disabled={disabled}
darkenOnHover={darkenOnHover}
className={className}
>
{children}
</ButtonComponent>
), [children, onClick, style, backColor, textColor, type, url, size,
openInNewTab, hoverAnimation, disabled, darkenOnHover, className]);
const buttonComponent: React.ReactNode = useMemo(
() => (
<ButtonComponent
onClick={onClick}
style={style}
backColor={backColor}
textColor={textColor}
type={type}
url={url}
size={size}
openInNewTab={openInNewTab}
hoverAnimation={hoverAnimation}
disabled={disabled}
darkenOnHover={darkenOnHover}
className={className}
>
{children}
</ButtonComponent>
),
[
children,
onClick,
style,
backColor,
textColor,
type,
url,
size,
openInNewTab,
hoverAnimation,
disabled,
darkenOnHover,
className,
],
);

// If there is no URL, return button directly
if (!url) {
return (
<>
{buttonComponent}
</>
);
return <>{buttonComponent}</>;
}

// Handle URL return types depending on whether it should opened in a new tab
return (
<>
{openInNewTab ? (
<Link href={url}>
<a target="_blank" rel="noreferrer" href={url}>
<a
target="_blank"
rel="noreferrer"
href={url}
>
{buttonComponent}
</a>
</Link>
) : (
<Link href={url}>
{buttonComponent}
</Link>
<Link href={url}>{buttonComponent}</Link>
)}
</>
);
Expand Down
17 changes: 11 additions & 6 deletions app/components/common/DiscordButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
import React from 'react';
import Link from 'next/link';
import Icon from '@ant-design/icons';
import {
Button,
} from 'antd';
import { Button } from 'antd';

import DiscordSVG from '../../assets/discord.svg';

Expand All @@ -19,9 +17,17 @@ const DISCORD_URL = 'https://discord.gg/RPbZHvxNRG';

const DiscordButton = (): JSX.Element => (
<Link href={DISCORD_URL}>
<a target="_blank" rel="noreferrer" href={DISCORD_URL}>
<a
target="_blank"
rel="noreferrer"
href={DISCORD_URL}
>
<Button
style={{ borderColor: '#5865f2aa', color: '#5865f2', fontWeight: 500 }}
style={{
borderColor: '#5865f2aa',
color: '#5865f2',
fontWeight: 500,
}}
size="small"
icon={<DiscordIcon />}
className="inline-flex items-center dojo-discord-button"
Expand All @@ -30,7 +36,6 @@ const DiscordButton = (): JSX.Element => (
</Button>
</a>
</Link>

);

export default DiscordButton;
4 changes: 1 addition & 3 deletions app/components/common/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react';

const Footer = () => (
<div
className="flex flex-row mt-10 lg:mt-20 px-10 items-center justify-end w-full h-20 shadow-md bg-gray-750"
>
<div className="flex flex-row mt-10 lg:mt-20 px-10 items-center justify-end w-full h-20 shadow-md bg-gray-750">
<div className="flex flex-row gap-3 items-center">
<img
src="/images/tmdojo_logo.png"
Expand Down
22 changes: 10 additions & 12 deletions app/components/common/PageHeaderBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import React from 'react';
import UserDisplay from './UserDisplay';

interface PageHeaderBarProps {
title: string,
subtitle?: string,
backUrl?: string,
children?: React.ReactNode
title: string;
subtitle?: string;
backUrl?: string;
children?: React.ReactNode;
}
const PageHeaderBar = ({
title, subtitle, children, backUrl,
title,
subtitle,
children,
backUrl,
}: PageHeaderBarProps) => {
const router = useRouter();

Expand All @@ -37,16 +40,11 @@ const PageHeaderBar = ({
/>

<div className="flex flex-wrap gap-4 items-baseline">
<span className="text-xl font-bold">
{title}
</span>
<span className="text-xl font-bold">{title}</span>
{subtitle && (
<span className="text-gray-400">
{subtitle}
</span>
<span className="text-gray-400">{subtitle}</span>
)}
</div>

</div>

<div className="flex flex-wrap justify-center gap-4">
Expand Down
6 changes: 2 additions & 4 deletions app/components/common/PlayerLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ interface PlayerLinkProps {
webId: string;
name: string;
className?: string;
style?: React.CSSProperties
style?: React.CSSProperties;
}
const PlayerLink = ({
webId, name, className, style,
}: PlayerLinkProps) => (
const PlayerLink = ({ webId, name, className, style }: PlayerLinkProps) => (
<Link href={`${ABSOLUTE_USERS_PATH}/${webId}`}>
<a
target="_blank"
Expand Down
5 changes: 4 additions & 1 deletion app/components/common/SideDrawerExpandButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ interface SideDrawerExpandButtonProps {
includeArrowIcon?: boolean;
}
const SideDrawerExpandButton = ({
onClick, content, side, includeArrowIcon = true,
onClick,
content,
side,
includeArrowIcon = true,
}: SideDrawerExpandButtonProps) => (
<Button
onClick={onClick}
Expand Down
22 changes: 12 additions & 10 deletions app/components/common/UserDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,19 @@ const UserDisplay = () => {
}
};

return user === undefined
? <LoginButton onClick={startAuthFlow} />
: (
<div className="flex flex-col md:flex-row gap-1 md:gap-6 items-center text-sm md:text-base text-right">
{`Welcome, ${user.displayName}!`}
<div className="flex gap-4">
<ProfileButton webId={user.accountId} />
<LogoutButton onClick={onLogout} />
</div>
if (user === undefined) {
return <LoginButton onClick={startAuthFlow} />;
}

return (
<div className="flex flex-col md:flex-row gap-1 md:gap-6 items-center text-sm md:text-base text-right">
{`Welcome, ${user.displayName}!`}
<div className="flex gap-4">
<ProfileButton webId={user.accountId} />
<LogoutButton onClick={onLogout} />
</div>
);
</div>
);
};

export default UserDisplay;
Loading