* Preliminary work around making an Element type * Disabled Youtube code for now * Clean description with DOMPurify * Update GranblueElement with slug * Add new api endpoint for searching all resources * Add new variables and themes * Remove fixed height on html tag for now * Update README.md We renamed the folders for character images from `chara-` to `character-` * Add no results string * Add tiptap and associated packages * Update .gitignore * Update components that use character images * Add Editor component This commit adds the bulk of the code for our new rich-text editor. The Editor component will be used to edit and display rich text via Tiptap. * Add mention components This adds the code required for us to mention objects in rich text fields like team descriptions. The mentionSuggestion util fetches data from the server and serves it to MentionList for the user to select, then inserts it into the Editor as a token. * Implements Editor in edit team and team footer This implements the Editor component in EditPartyModal and PartyFooter. In PartyFooter, it is read-only. * Remove min-width on tokens * Add rudimentary conversion for old descriptions Old descriptions just translate as a blob of text, so we try to insert some paragraphs and newlines to keep things presentable and lessen the load if users decide to update * Add support for displaying jobs in MentionList * Handle numbers and value=0 better * Keep description reactive This shouldn't work? The snapshot should be the reactive one? I don't fucking know * Send locale to api with search query * Delete getLocale.tsx We didn't actually use this * Fix build errors
150 lines
4.3 KiB
TypeScript
150 lines
4.3 KiB
TypeScript
import { useRouter } from 'next/router'
|
|
|
|
import UncapIndicator from '~components/uncap/UncapIndicator'
|
|
import WeaponLabelIcon from '~components/weapon/WeaponLabelIcon'
|
|
|
|
import styles from './index.module.scss'
|
|
|
|
interface Props {
|
|
gridObject: GridCharacter | GridSummon | GridWeapon
|
|
object: Character | Summon | Weapon
|
|
type: 'character' | 'summon' | 'weapon'
|
|
}
|
|
|
|
const Element = ['null', 'wind', 'fire', 'water', 'earth', 'dark', 'light']
|
|
const Proficiency = [
|
|
'none',
|
|
'sword',
|
|
'dagger',
|
|
'axe',
|
|
'spear',
|
|
'bow',
|
|
'staff',
|
|
'fist',
|
|
'harp',
|
|
'gun',
|
|
'katana',
|
|
]
|
|
|
|
const HovercardHeader = ({ gridObject, object, type, ...props }: Props) => {
|
|
const router = useRouter()
|
|
const locale =
|
|
router.locale && ['en', 'ja'].includes(router.locale) ? router.locale : 'en'
|
|
|
|
const overlay = () => {
|
|
if (type === 'character') {
|
|
const gridCharacter = gridObject as GridCharacter
|
|
if (gridCharacter.perpetuity) return <i className={styles.perpetuity} />
|
|
} else if (type === 'summon') {
|
|
const gridSummon = gridObject as GridSummon
|
|
if (gridSummon.quick_summon) return <i className={styles.quickSummon} />
|
|
}
|
|
}
|
|
|
|
const characterImage = () => {
|
|
const gridCharacter = gridObject as GridCharacter
|
|
const character = object as Character
|
|
|
|
// Change the image based on the uncap level
|
|
let suffix = '01'
|
|
if (gridCharacter.uncap_level == 6) suffix = '04'
|
|
else if (gridCharacter.uncap_level == 5) suffix = '03'
|
|
else if (gridCharacter.uncap_level > 2) suffix = '02'
|
|
|
|
return `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/character-grid/${character.granblue_id}_${suffix}.jpg`
|
|
}
|
|
|
|
const summonImage = () => {
|
|
const summon = object as Summon
|
|
const gridSummon = gridObject as GridSummon
|
|
|
|
const upgradedSummons = [
|
|
'2040094000',
|
|
'2040100000',
|
|
'2040080000',
|
|
'2040098000',
|
|
'2040090000',
|
|
'2040084000',
|
|
'2040003000',
|
|
'2040056000',
|
|
]
|
|
|
|
let suffix = ''
|
|
if (
|
|
upgradedSummons.indexOf(summon.granblue_id.toString()) != -1 &&
|
|
gridSummon.uncap_level == 5
|
|
) {
|
|
suffix = '_02'
|
|
} else if (
|
|
gridSummon.object.uncap.xlb &&
|
|
gridSummon.transcendence_step > 0
|
|
) {
|
|
suffix = '_03'
|
|
}
|
|
|
|
// Generate the correct source for the summon
|
|
return `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/summon-grid/${summon.granblue_id}${suffix}.jpg`
|
|
}
|
|
|
|
const weaponImage = () => {
|
|
const gridWeapon = gridObject as GridWeapon
|
|
const weapon = object as Weapon
|
|
|
|
if (gridWeapon.object.element == 0 && gridWeapon.element)
|
|
return `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-grid/${weapon.granblue_id}_${gridWeapon.element}.jpg`
|
|
else
|
|
return `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-grid/${weapon.granblue_id}.jpg`
|
|
}
|
|
|
|
const image = () => {
|
|
switch (type) {
|
|
case 'character':
|
|
return characterImage()
|
|
case 'summon':
|
|
return summonImage()
|
|
case 'weapon':
|
|
return weaponImage()
|
|
}
|
|
}
|
|
|
|
return (
|
|
<header className={styles.root}>
|
|
<div className={styles.title}>
|
|
<h4>{object.name[locale]}</h4>
|
|
<div className={styles.image}>
|
|
{overlay()}
|
|
<img alt={object.name[locale]} src={image()} />
|
|
</div>
|
|
</div>
|
|
<div className={styles.subInfo}>
|
|
<div className={styles.icons}>
|
|
<WeaponLabelIcon labelType={Element[object.element]} />
|
|
{'proficiency' in object && Array.isArray(object.proficiency) && (
|
|
<WeaponLabelIcon labelType={Proficiency[object.proficiency[0]]} />
|
|
)}
|
|
{'proficiency' in object && !Array.isArray(object.proficiency) && (
|
|
<WeaponLabelIcon labelType={Proficiency[object.proficiency]} />
|
|
)}
|
|
{'proficiency' in object &&
|
|
Array.isArray(object.proficiency) &&
|
|
object.proficiency.length > 1 && (
|
|
<WeaponLabelIcon labelType={Proficiency[object.proficiency[1]]} />
|
|
)}
|
|
</div>
|
|
<UncapIndicator
|
|
type={type}
|
|
ulb={object.uncap.ulb || false}
|
|
flb={object.uncap.flb || false}
|
|
transcendenceStage={
|
|
'transcendence_step' in gridObject
|
|
? gridObject.transcendence_step
|
|
: 0
|
|
}
|
|
special={'special' in object ? object.special : false}
|
|
/>
|
|
</div>
|
|
</header>
|
|
)
|
|
}
|
|
|
|
export default HovercardHeader
|