Added TranscendencePopover
This popover is the UI that lets you set an item's transcendence
This commit is contained in:
parent
9c757c2c5b
commit
1f21e9d808
4 changed files with 155 additions and 22 deletions
32
components/TranscendencePopover/index.scss
Normal file
32
components/TranscendencePopover/index.scss
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
.Transcendence.Popover {
|
||||
align-items: center;
|
||||
background: var(--dialog-bg);
|
||||
border-radius: $card-corner;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.18);
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: $unit-half;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
padding: $unit;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
z-index: 31;
|
||||
top: -32px;
|
||||
right: -40px;
|
||||
|
||||
&.open {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: $font-small;
|
||||
font-weight: $medium;
|
||||
}
|
||||
|
||||
.Pending {
|
||||
color: $yellow;
|
||||
}
|
||||
}
|
||||
72
components/TranscendencePopover/index.tsx
Normal file
72
components/TranscendencePopover/index.tsx
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import React, { useEffect, useState } from 'react'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import classNames from 'classnames'
|
||||
|
||||
import TranscendenceStar from '~components/TranscendenceStar'
|
||||
import './index.scss'
|
||||
|
||||
interface Props {
|
||||
className?: string
|
||||
open: boolean
|
||||
stage: number
|
||||
sendValue?: (stage: number) => void
|
||||
}
|
||||
|
||||
const TranscendencePopover = ({
|
||||
className,
|
||||
open: popoverOpen,
|
||||
stage,
|
||||
sendValue,
|
||||
}: Props) => {
|
||||
const { t } = useTranslation('common')
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
const [currentStage, setCurrentStage] = useState(0)
|
||||
|
||||
const classes = classNames({
|
||||
Transcendence: true,
|
||||
Popover: true,
|
||||
open: true, // This is hardcoded for now
|
||||
})
|
||||
|
||||
const levelClasses = classNames({
|
||||
Pending: stage != currentStage,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentStage(stage)
|
||||
}, [stage])
|
||||
|
||||
useEffect(() => {
|
||||
setOpen(popoverOpen)
|
||||
}, [popoverOpen])
|
||||
|
||||
function handleFragmentClicked(newStage: number) {
|
||||
setCurrentStage(newStage)
|
||||
if (sendValue) sendValue(newStage)
|
||||
}
|
||||
|
||||
function handleFragmentHovered(newStage: number) {
|
||||
setCurrentStage(newStage)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classes}>
|
||||
<TranscendenceStar
|
||||
className="Interactive Base"
|
||||
editable={true}
|
||||
interactive={true}
|
||||
stage={stage}
|
||||
onFragmentClick={handleFragmentClicked}
|
||||
onFragmentHover={handleFragmentHovered}
|
||||
/>
|
||||
<h4>
|
||||
<span>{t('level')} </span>
|
||||
<span className={levelClasses}>{100 + 10 * currentStage}</span>
|
||||
</h4>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default TranscendencePopover
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
.Uncap {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.UncapIndicator {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,28 @@
|
|||
import React from 'react'
|
||||
import React, { useState } from 'react'
|
||||
import UncapStar from '~components/UncapStar'
|
||||
import TranscendenceStar from '~components/TranscendenceStar'
|
||||
|
||||
import './index.scss'
|
||||
import TranscendencePopover from '~components/TranscendencePopover'
|
||||
|
||||
interface Props {
|
||||
type: 'character' | 'weapon' | 'summon'
|
||||
rarity?: number
|
||||
uncapLevel?: number
|
||||
transcendenceStep?: number
|
||||
flb: boolean
|
||||
ulb: boolean
|
||||
xlb?: boolean
|
||||
special: boolean
|
||||
updateUncap?: (index: number) => void
|
||||
updateTranscendence?: (index: number) => void
|
||||
}
|
||||
|
||||
const UncapIndicator = (props: Props) => {
|
||||
const numStars = setNumStars()
|
||||
|
||||
const [popoverOpen, setPopoverOpen] = useState(false)
|
||||
|
||||
function setNumStars() {
|
||||
let numStars
|
||||
|
||||
|
|
@ -56,14 +64,16 @@ const UncapIndicator = (props: Props) => {
|
|||
}
|
||||
}
|
||||
|
||||
function openPopover() {
|
||||
setPopoverOpen(true)
|
||||
}
|
||||
|
||||
const transcendence = (i: number) => {
|
||||
return (
|
||||
<UncapStar
|
||||
ulb={true}
|
||||
empty={props.uncapLevel ? i >= props.uncapLevel : false}
|
||||
<TranscendenceStar
|
||||
key={`star_${i}`}
|
||||
index={i}
|
||||
onClick={toggleStar}
|
||||
interactive={false}
|
||||
onClick={openPopover}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
@ -106,7 +116,20 @@ const UncapIndicator = (props: Props) => {
|
|||
)
|
||||
}
|
||||
|
||||
const transcendencePopover = () => {
|
||||
return props.type === 'character' || props.type === 'summon' ? (
|
||||
<TranscendencePopover
|
||||
open={popoverOpen}
|
||||
stage={props.transcendenceStep ? props.transcendenceStep : 0}
|
||||
sendValue={props.updateTranscendence}
|
||||
/>
|
||||
) : (
|
||||
''
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="Uncap">
|
||||
<ul className="UncapIndicator">
|
||||
{Array.from(Array(numStars)).map((x, i) => {
|
||||
if (props.type === 'character' && i > 4) {
|
||||
|
|
@ -123,6 +146,8 @@ const UncapIndicator = (props: Props) => {
|
|||
}
|
||||
})}
|
||||
</ul>
|
||||
{transcendencePopover()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue