Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement remixes #175

Merged
merged 31 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
35402dc
Add translations
jedmund Jan 28, 2023
2534728
Extract capitalizeFirstLetter into util
jedmund Jan 28, 2023
1baf8d3
Add support for left and right button accessories
jedmund Jan 28, 2023
ceb87a8
Add wrapper for Radix DropdownMenu
jedmund Jan 28, 2023
fa1bf57
Implement new header design (so far)
jedmund Jan 28, 2023
199b02b
Fix unauth menu
jedmund Jan 28, 2023
0bbd027
Move copy function and remove copy button
jedmund Jan 28, 2023
191f444
Fix save button states
jedmund Jan 28, 2023
6da5a4f
Add toast on copy link
jedmund Jan 28, 2023
ab928f4
Add modal for network errors
jedmund Jan 28, 2023
6c76053
Fixed link to new party
jedmund Jan 28, 2023
1337668
Remove console logs
jedmund Jan 28, 2023
0901fbf
Change how we handle modals
jedmund Jan 28, 2023
49c463d
Add Remix icon and button
jedmund Jan 28, 2023
f68785f
Add shortcode to party state object
jedmund Jan 28, 2023
f450c87
Add remix endpoint
jedmund Jan 28, 2023
c224184
Fix how we handle state
jedmund Jan 28, 2023
f2a1d80
Add Remix button
jedmund Jan 28, 2023
52875eb
Fix colors of context menu text
jedmund Jan 28, 2023
534d608
Add localizations
jedmund Jan 28, 2023
0b3861e
Update Party type and state
jedmund Jan 28, 2023
522be62
Display remixes on parties
jedmund Jan 28, 2023
86b48f5
Add source party to Party definition
jedmund Jan 28, 2023
9a6e333
Add link back to source party
jedmund Jan 28, 2023
9812f09
Add Radix tooltip dependency
jedmund Jan 28, 2023
0613f75
Add TooltipProvider
jedmund Jan 28, 2023
2172647
Add generic Tooltip component
jedmund Jan 28, 2023
ea8fd7a
Add tooltip over remix icon
jedmund Jan 28, 2023
3d71ad1
Add localizations
jedmund Jan 28, 2023
89e1709
Fix styles for remixed teams
jedmund Jan 28, 2023
da43f80
Fix optional error
jedmund Jan 28, 2023
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
546 changes: 276 additions & 270 deletions components/AccountModal/index.tsx

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion components/Alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const Alert = (props: Props) => {
<AlertDialog.Overlay className="Overlay" onClick={props.cancelAction} />
<div className="AlertWrapper">
<AlertDialog.Content className="Alert">
{props.title ? <AlertDialog.Title>Error</AlertDialog.Title> : ''}
{props.title ? (
<AlertDialog.Title>{props.title}</AlertDialog.Title>
) : (
''
)}
<AlertDialog.Description className="description">
{props.message}
</AlertDialog.Description>
Expand Down
42 changes: 29 additions & 13 deletions components/Button/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
background: transparent;
}

&.IconButton.medium {
height: inherit;
padding: $unit-half;

&:hover {
background: none;
}
}

&.Contained {
background: var(--button-contained-bg);

Expand All @@ -43,7 +52,7 @@
stroke: #ff4d4d;
}

&.Active.Save {
&.Save {
color: #ff4d4d;

.Accessory svg {
Expand Down Expand Up @@ -99,24 +108,27 @@
}
}

&.save:hover {
color: #ff4d4d;

&.Save {
.Accessory svg {
fill: #ff4d4d;
stroke: #ff4d4d;
fill: none;
stroke: var(--button-text);
}
}

&.save.Active {
color: #ff4d4d;
&.Saved {
color: #ff4d4d;

.Accessory svg {
fill: #ff4d4d;
stroke: none;
}
}

&:hover {
color: darken(#ff4d4d, 30);
color: #ff4d4d;

.icon svg {
fill: darken(#ff4d4d, 30);
stroke: darken(#ff4d4d, 30);
.Accessory svg {
fill: none;
stroke: #ff4d4d;
}
}
}
Expand All @@ -138,6 +150,10 @@

display: flex;

&.Arrow {
margin-top: $unit-half;
}

svg {
fill: var(--button-text);
height: $dimension;
Expand Down
57 changes: 42 additions & 15 deletions components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ interface Props
React.ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
> {
accessoryIcon?: React.ReactNode
leftAccessoryIcon?: React.ReactNode
leftAccessoryClassName?: string
rightAccessoryIcon?: React.ReactNode
rightAccessoryClassName?: string
active?: boolean
blended?: boolean
contained?: boolean
Expand All @@ -24,22 +27,45 @@ const defaultProps = {
}

const Button = React.forwardRef<HTMLButtonElement, Props>(function button(
{ accessoryIcon, active, blended, contained, buttonSize, text, ...props },
{
leftAccessoryIcon,
leftAccessoryClassName,
rightAccessoryIcon,
rightAccessoryClassName,
active,
blended,
contained,
buttonSize,
text,
...props
},
forwardedRef
) {
const classes = classNames(
{
Button: true,
Active: active,
Blended: blended,
Contained: contained,
},
buttonSize,
props.className
)
const classes = classNames(buttonSize, props.className, {
Button: true,
Active: active,
Blended: blended,
Contained: contained,
})

const leftAccessoryClasses = classNames(leftAccessoryClassName, {
Accessory: true,
Left: true,
})

const rightAccessoryClasses = classNames(rightAccessoryClassName, {
Accessory: true,
Right: true,
})

const hasLeftAccessory = () => {
if (leftAccessoryIcon)
return <span className={leftAccessoryClasses}>{leftAccessoryIcon}</span>
}

const hasAccessory = () => {
if (accessoryIcon) return <span className="Accessory">{accessoryIcon}</span>
const hasRightAccessory = () => {
if (rightAccessoryIcon)
return <span className={rightAccessoryClasses}>{rightAccessoryIcon}</span>
}

const hasText = () => {
Expand All @@ -48,8 +74,9 @@ const Button = React.forwardRef<HTMLButtonElement, Props>(function button(

return (
<button {...props} className={classes} ref={forwardedRef}>
{hasAccessory()}
{hasLeftAccessory()}
{hasText()}
{hasRightAccessory()}
</button>
)
})
Expand Down
33 changes: 31 additions & 2 deletions components/CharacterGrid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react'
import { getCookie } from 'cookies-next'
import { useSnapshot } from 'valtio'
import { useTranslation } from 'next-i18next'

import { AxiosResponse } from 'axios'
import { AxiosError, AxiosResponse } from 'axios'
import debounce from 'lodash.debounce'

import Alert from '~components/Alert'
Expand Down Expand Up @@ -31,12 +32,19 @@ const CharacterGrid = (props: Props) => {
// Constants
const numCharacters: number = 5

// Localization
const { t } = useTranslation('common')

// Cookies
const cookie = getCookie('account')
const accountData: AccountCookie = cookie
? JSON.parse(cookie as string)
: null

// Set up state for error handling
const [axiosError, setAxiosError] = useState<AxiosResponse>()
const [errorAlertOpen, setErrorAlertOpen] = useState(false)

// Set up state for view management
const { party, grid } = useSnapshot(appState)
const [slug, setSlug] = useState()
Expand Down Expand Up @@ -111,7 +119,15 @@ const CharacterGrid = (props: Props) => {
if (party.editable)
saveCharacter(party.id, character, position)
.then((response) => handleCharacterResponse(response.data))
.catch((error) => console.error(error))
.catch((error) => {
const axiosError = error as AxiosError
const response = axiosError.response

if (response) {
setErrorAlertOpen(true)
setAxiosError(response)
}
})
}
}

Expand Down Expand Up @@ -482,6 +498,18 @@ const CharacterGrid = (props: Props) => {
}

// Render: JSX components
const errorAlert = () => {
return (
<Alert
open={errorAlertOpen}
title={axiosError ? `${axiosError.status}` : 'Error'}
message={t(`errors.${axiosError?.statusText.toLowerCase()}`)}
cancelAction={() => setErrorAlertOpen(false)}
cancelActionText={t('buttons.confirm')}
/>
)
}

return (
<div>
<Alert
Expand Down Expand Up @@ -526,6 +554,7 @@ const CharacterGrid = (props: Props) => {
})}
</ul>
</div>
{errorAlert()}
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion components/CharacterUnit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const CharacterUnit = ({
<ContextMenu onOpenChange={handleContextMenuOpenChange}>
<ContextMenuTrigger asChild>
<Button
accessoryIcon={<SettingsIcon />}
leftAccessoryIcon={<SettingsIcon />}
className={buttonClasses}
onClick={handleButtonClicked}
/>
Expand Down
Loading