Implements Editor in edit team and team footer
This implements the Editor component in EditPartyModal and PartyFooter. In PartyFooter, it is read-only.
This commit is contained in:
parent
d950d3a935
commit
b641091695
3 changed files with 40 additions and 27 deletions
|
|
@ -6,12 +6,13 @@ import classNames from 'classnames'
|
||||||
import debounce from 'lodash.debounce'
|
import debounce from 'lodash.debounce'
|
||||||
|
|
||||||
import Alert from '~components/common/Alert'
|
import Alert from '~components/common/Alert'
|
||||||
|
import Button from '~components/common/Button'
|
||||||
import { Dialog, DialogTrigger } from '~components/common/Dialog'
|
import { Dialog, DialogTrigger } from '~components/common/Dialog'
|
||||||
import DialogHeader from '~components/common/DialogHeader'
|
import DialogHeader from '~components/common/DialogHeader'
|
||||||
import DialogFooter from '~components/common/DialogFooter'
|
import DialogFooter from '~components/common/DialogFooter'
|
||||||
import DialogContent from '~components/common/DialogContent'
|
import DialogContent from '~components/common/DialogContent'
|
||||||
import Button from '~components/common/Button'
|
|
||||||
import DurationInput from '~components/common/DurationInput'
|
import DurationInput from '~components/common/DurationInput'
|
||||||
|
import Editor from '~components/common/Editor'
|
||||||
import Input from '~components/common/Input'
|
import Input from '~components/common/Input'
|
||||||
import InputTableField from '~components/common/InputTableField'
|
import InputTableField from '~components/common/InputTableField'
|
||||||
import RaidCombobox from '~components/raids/RaidCombobox'
|
import RaidCombobox from '~components/raids/RaidCombobox'
|
||||||
|
|
@ -24,6 +25,7 @@ import Textarea from '~components/common/Textarea'
|
||||||
import capitalizeFirstLetter from '~utils/capitalizeFirstLetter'
|
import capitalizeFirstLetter from '~utils/capitalizeFirstLetter'
|
||||||
import type { DetailsObject } from 'types'
|
import type { DetailsObject } from 'types'
|
||||||
import type { DialogProps } from '@radix-ui/react-dialog'
|
import type { DialogProps } from '@radix-ui/react-dialog'
|
||||||
|
import type { JSONContent } from '@tiptap/core'
|
||||||
|
|
||||||
import { appState } from '~utils/appState'
|
import { appState } from '~utils/appState'
|
||||||
|
|
||||||
|
|
@ -129,6 +131,11 @@ const EditPartyModal = ({
|
||||||
setErrors(newErrors)
|
setErrors(newErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleEditorUpdate(content: JSONContent) {
|
||||||
|
console.log('Editor updated')
|
||||||
|
setDescription(JSON.stringify(content))
|
||||||
|
}
|
||||||
|
|
||||||
function handleChargeAttackChanged(checked: boolean) {
|
function handleChargeAttackChanged(checked: boolean) {
|
||||||
setChargeAttack(checked)
|
setChargeAttack(checked)
|
||||||
}
|
}
|
||||||
|
|
@ -338,7 +345,6 @@ const EditPartyModal = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateDetails(event: React.MouseEvent) {
|
async function updateDetails(event: React.MouseEvent) {
|
||||||
const descriptionValue = descriptionInput.current?.innerHTML
|
|
||||||
const details: DetailsObject = {
|
const details: DetailsObject = {
|
||||||
fullAuto: fullAuto,
|
fullAuto: fullAuto,
|
||||||
autoGuard: autoGuard,
|
autoGuard: autoGuard,
|
||||||
|
|
@ -349,7 +355,7 @@ const EditPartyModal = ({
|
||||||
turnCount: turnCount,
|
turnCount: turnCount,
|
||||||
chainCount: chainCount,
|
chainCount: chainCount,
|
||||||
name: name,
|
name: name,
|
||||||
description: descriptionValue,
|
description: description,
|
||||||
raid: raid,
|
raid: raid,
|
||||||
extra: extra,
|
extra: extra,
|
||||||
}
|
}
|
||||||
|
|
@ -457,6 +463,15 @@ const EditPartyModal = ({
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const editorField = (
|
||||||
|
<Editor
|
||||||
|
bound={true}
|
||||||
|
content={description}
|
||||||
|
editable={true}
|
||||||
|
onUpdate={handleEditorUpdate}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
const chargeAttackField = (
|
const chargeAttackField = (
|
||||||
<SwitchTableField
|
<SwitchTableField
|
||||||
name="charge_attack"
|
name="charge_attack"
|
||||||
|
|
@ -560,7 +575,7 @@ const EditPartyModal = ({
|
||||||
{nameField}
|
{nameField}
|
||||||
{raidField}
|
{raidField}
|
||||||
{extraNotice()}
|
{extraNotice()}
|
||||||
{descriptionField}
|
{editorField}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: $unit-2x;
|
gap: $unit-2x;
|
||||||
margin: $unit-4x auto 0 auto;
|
margin: $unit-4x auto $unit-10x auto;
|
||||||
max-width: $grid-width;
|
max-width: $grid-width;
|
||||||
|
|
||||||
@include breakpoint(phone) {
|
@include breakpoint(phone) {
|
||||||
|
|
@ -22,8 +22,7 @@
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
margin: 0 auto $unit-2x;
|
margin: 0 auto $unit-2x;
|
||||||
margin-bottom: $unit-12x;
|
min-height: 20vh;
|
||||||
min-height: 10vh;
|
|
||||||
max-width: $unit * 94;
|
max-width: $unit * 94;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
@ -32,22 +31,6 @@
|
||||||
padding: 0 $unit;
|
padding: 0 $unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
.noRemixes,
|
|
||||||
.noDescription {
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: $unit-2x;
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: $unit-4x 0;
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
font-size: $font-small;
|
|
||||||
font-weight: $medium;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
p {
|
||||||
font-size: $font-regular;
|
font-size: $font-regular;
|
||||||
line-height: $font-regular * 1.2;
|
line-height: $font-regular * 1.2;
|
||||||
|
|
@ -147,6 +130,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.noRemixes,
|
||||||
|
.noDescription {
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 20vh;
|
||||||
|
gap: $unit-2x;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: $unit-4x 0;
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: $font-small;
|
||||||
|
font-weight: $medium;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.PartyInfo {
|
.PartyInfo {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import type { DetailsObject } from 'types'
|
||||||
import RemixIcon from '~public/icons/Remix.svg'
|
import RemixIcon from '~public/icons/Remix.svg'
|
||||||
import EditIcon from '~public/icons/Edit.svg'
|
import EditIcon from '~public/icons/Edit.svg'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import Editor from '~components/common/Editor'
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -210,10 +211,7 @@ const PartyFooter = (props: Props) => {
|
||||||
{partySnapshot &&
|
{partySnapshot &&
|
||||||
partySnapshot.description &&
|
partySnapshot.description &&
|
||||||
partySnapshot.description.length > 0 && (
|
partySnapshot.description.length > 0 && (
|
||||||
<section
|
<Editor content={partySnapshot.description} />
|
||||||
className={styles.description}
|
|
||||||
dangerouslySetInnerHTML={{ __html: sanitizedDescription }}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
{(!partySnapshot || !partySnapshot.description) && (
|
{(!partySnapshot || !partySnapshot.description) && (
|
||||||
<section className={styles.noDescription}>
|
<section className={styles.noDescription}>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue