Improve tabIndex on CharacterGrid
This commit is contained in:
parent
c9ae4cd90b
commit
eb8183fe29
7 changed files with 57 additions and 17 deletions
|
|
@ -286,7 +286,11 @@ const CharacterUnit = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
const image = (
|
const image = (
|
||||||
<div className="CharacterImage" onClick={openSearchModal}>
|
<div
|
||||||
|
className="CharacterImage"
|
||||||
|
onClick={openSearchModal}
|
||||||
|
tabIndex={gridCharacter ? gridCharacter.position * 7 : 0}
|
||||||
|
>
|
||||||
<img
|
<img
|
||||||
alt={character?.name[locale]}
|
alt={character?.name[locale]}
|
||||||
className="grid_image"
|
className="grid_image"
|
||||||
|
|
@ -314,8 +318,9 @@ const CharacterUnit = ({
|
||||||
flb={character.uncap.flb || false}
|
flb={character.uncap.flb || false}
|
||||||
ulb={character.uncap.ulb || false}
|
ulb={character.uncap.ulb || false}
|
||||||
uncapLevel={gridCharacter.uncap_level}
|
uncapLevel={gridCharacter.uncap_level}
|
||||||
editable={editable}
|
|
||||||
transcendenceStage={gridCharacter.transcendence_step}
|
transcendenceStage={gridCharacter.transcendence_step}
|
||||||
|
position={gridCharacter.position}
|
||||||
|
editable={editable}
|
||||||
updateUncap={passUncapData}
|
updateUncap={passUncapData}
|
||||||
updateTranscendence={passTranscendenceData}
|
updateTranscendence={passTranscendenceData}
|
||||||
special={character.special}
|
special={character.special}
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,7 @@ const SummonUnit = ({
|
||||||
ulb={gridSummon.object.uncap.ulb || false}
|
ulb={gridSummon.object.uncap.ulb || false}
|
||||||
flb={gridSummon.object.uncap.flb || false}
|
flb={gridSummon.object.uncap.flb || false}
|
||||||
uncapLevel={gridSummon.uncap_level}
|
uncapLevel={gridSummon.uncap_level}
|
||||||
|
position={gridSummon.position}
|
||||||
updateUncap={passUncapData}
|
updateUncap={passUncapData}
|
||||||
special={false}
|
special={false}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,15 @@ import classNames from 'classnames'
|
||||||
import TranscendenceStar from '~components/TranscendenceStar'
|
import TranscendenceStar from '~components/TranscendenceStar'
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
interface Props {
|
interface Props
|
||||||
|
extends React.DetailedHTMLProps<
|
||||||
|
React.DialogHTMLAttributes<HTMLDivElement>,
|
||||||
|
HTMLDivElement
|
||||||
|
> {
|
||||||
className?: string
|
className?: string
|
||||||
open: boolean
|
open: boolean
|
||||||
stage: number
|
stage: number
|
||||||
|
onOpenChange?: (open: boolean) => void
|
||||||
sendValue?: (stage: number) => void
|
sendValue?: (stage: number) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -16,6 +21,8 @@ const TranscendencePopover = ({
|
||||||
className,
|
className,
|
||||||
open: popoverOpen,
|
open: popoverOpen,
|
||||||
stage,
|
stage,
|
||||||
|
tabIndex,
|
||||||
|
onOpenChange,
|
||||||
sendValue,
|
sendValue,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { t } = useTranslation('common')
|
const { t } = useTranslation('common')
|
||||||
|
|
@ -52,8 +59,15 @@ const TranscendencePopover = ({
|
||||||
setCurrentStage(newStage)
|
setCurrentStage(newStage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleKeyPress(event: React.KeyboardEvent<HTMLDivElement>) {
|
||||||
|
console.log(`Key pressed, ${event.key}`)
|
||||||
|
if (event.key === 'Escape') {
|
||||||
|
if (onOpenChange) onOpenChange(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes}>
|
<div className={classes} onKeyPress={handleKeyPress} tabIndex={tabIndex}>
|
||||||
<TranscendenceStar
|
<TranscendenceStar
|
||||||
className="Interactive Base"
|
className="Interactive Base"
|
||||||
editable={true}
|
editable={true}
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,16 @@ import classnames from 'classnames'
|
||||||
import TranscendenceFragment from '~components/TranscendenceFragment'
|
import TranscendenceFragment from '~components/TranscendenceFragment'
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
interface Props {
|
interface Props
|
||||||
|
extends React.DetailedHTMLProps<
|
||||||
|
React.DialogHTMLAttributes<HTMLDivElement>,
|
||||||
|
HTMLDivElement
|
||||||
|
> {
|
||||||
className?: string
|
className?: string
|
||||||
stage: number
|
stage: number
|
||||||
editable: boolean
|
editable: boolean
|
||||||
interactive: boolean
|
interactive: boolean
|
||||||
onClick?: () => void
|
onStarClick?: () => void
|
||||||
onFragmentClick?: (newStage: number) => void
|
onFragmentClick?: (newStage: number) => void
|
||||||
onFragmentHover?: (newStage: number) => void
|
onFragmentHover?: (newStage: number) => void
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +25,8 @@ const TranscendenceStar = ({
|
||||||
interactive,
|
interactive,
|
||||||
stage,
|
stage,
|
||||||
editable,
|
editable,
|
||||||
onClick,
|
tabIndex,
|
||||||
|
onStarClick,
|
||||||
onFragmentClick,
|
onFragmentClick,
|
||||||
onFragmentHover,
|
onFragmentHover,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
|
|
@ -52,8 +57,8 @@ const TranscendenceStar = ({
|
||||||
}, [stage])
|
}, [stage])
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
if (onClick) {
|
if (onStarClick) {
|
||||||
onClick()
|
onStarClick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,6 +86,7 @@ const TranscendenceStar = ({
|
||||||
className={starClasses}
|
className={starClasses}
|
||||||
onClick={editable ? handleClick : () => {}}
|
onClick={editable ? handleClick : () => {}}
|
||||||
onMouseLeave={interactive ? handleMouseLeave : () => {}}
|
onMouseLeave={interactive ? handleMouseLeave : () => {}}
|
||||||
|
tabIndex={tabIndex}
|
||||||
>
|
>
|
||||||
<div className="Fragments">
|
<div className="Fragments">
|
||||||
{[...Array(NUM_FRAGMENTS)].map((e, i) => {
|
{[...Array(NUM_FRAGMENTS)].map((e, i) => {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ interface Props {
|
||||||
type: 'character' | 'weapon' | 'summon'
|
type: 'character' | 'weapon' | 'summon'
|
||||||
rarity?: number
|
rarity?: number
|
||||||
uncapLevel?: number
|
uncapLevel?: number
|
||||||
|
position: number
|
||||||
transcendenceStage?: number
|
transcendenceStage?: number
|
||||||
editable: boolean
|
editable: boolean
|
||||||
flb: boolean
|
flb: boolean
|
||||||
|
|
@ -81,7 +82,8 @@ const UncapIndicator = (props: Props) => {
|
||||||
stage={props.transcendenceStage}
|
stage={props.transcendenceStage}
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
interactive={false}
|
interactive={false}
|
||||||
onClick={() => togglePopover(true)}
|
onStarClick={() => togglePopover(true)}
|
||||||
|
tabIndex={props.position * 7 + i + 1}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +96,8 @@ const UncapIndicator = (props: Props) => {
|
||||||
empty={props.uncapLevel != null ? i >= props.uncapLevel : false}
|
empty={props.uncapLevel != null ? i >= props.uncapLevel : false}
|
||||||
key={`star_${i}`}
|
key={`star_${i}`}
|
||||||
index={i}
|
index={i}
|
||||||
onClick={toggleStar}
|
onStarClick={toggleStar}
|
||||||
|
tabIndex={props.position * 7 + i + 1}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -107,7 +110,8 @@ const UncapIndicator = (props: Props) => {
|
||||||
empty={props.uncapLevel != null ? i >= props.uncapLevel : false}
|
empty={props.uncapLevel != null ? i >= props.uncapLevel : false}
|
||||||
key={`star_${i}`}
|
key={`star_${i}`}
|
||||||
index={i}
|
index={i}
|
||||||
onClick={toggleStar}
|
onStarClick={toggleStar}
|
||||||
|
tabIndex={props.position * 7 + i + 1}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +123,8 @@ const UncapIndicator = (props: Props) => {
|
||||||
empty={props.uncapLevel != null ? i >= props.uncapLevel : false}
|
empty={props.uncapLevel != null ? i >= props.uncapLevel : false}
|
||||||
key={`star_${i}`}
|
key={`star_${i}`}
|
||||||
index={i}
|
index={i}
|
||||||
onClick={toggleStar}
|
onStarClick={toggleStar}
|
||||||
|
tabIndex={props.position * 7 + i + 1}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +134,9 @@ const UncapIndicator = (props: Props) => {
|
||||||
<TranscendencePopover
|
<TranscendencePopover
|
||||||
open={popoverOpen}
|
open={popoverOpen}
|
||||||
stage={props.transcendenceStage ? props.transcendenceStage : 0}
|
stage={props.transcendenceStage ? props.transcendenceStage : 0}
|
||||||
|
onOpenChange={togglePopover}
|
||||||
sendValue={sendTranscendenceStage}
|
sendValue={sendTranscendenceStage}
|
||||||
|
tabIndex={props.position * 7 + 7 + 1}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
''
|
''
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,17 @@ import classnames from 'classnames'
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
interface Props {
|
interface Props
|
||||||
|
extends React.DetailedHTMLProps<
|
||||||
|
React.DialogHTMLAttributes<HTMLDivElement>,
|
||||||
|
HTMLDivElement
|
||||||
|
> {
|
||||||
empty: boolean
|
empty: boolean
|
||||||
special: boolean
|
special: boolean
|
||||||
flb: boolean
|
flb: boolean
|
||||||
ulb: boolean
|
ulb: boolean
|
||||||
index: number
|
index: number
|
||||||
onClick: (index: number, empty: boolean) => void
|
onStarClick: (index: number, empty: boolean) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const UncapStar = (props: Props) => {
|
const UncapStar = (props: Props) => {
|
||||||
|
|
@ -23,10 +27,12 @@ const UncapStar = (props: Props) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
function clicked() {
|
function clicked() {
|
||||||
props.onClick(props.index, props.empty)
|
props.onStarClick(props.index, props.empty)
|
||||||
}
|
}
|
||||||
|
|
||||||
return <li className={classes} onClick={clicked}></li>
|
return (
|
||||||
|
<li className={classes} tabIndex={props.tabIndex} onClick={clicked}></li>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
UncapStar.defaultProps = {
|
UncapStar.defaultProps = {
|
||||||
|
|
|
||||||
|
|
@ -548,6 +548,7 @@ const WeaponUnit = ({
|
||||||
ulb={gridWeapon.object.uncap.ulb || false}
|
ulb={gridWeapon.object.uncap.ulb || false}
|
||||||
flb={gridWeapon.object.uncap.flb || false}
|
flb={gridWeapon.object.uncap.flb || false}
|
||||||
uncapLevel={gridWeapon.uncap_level}
|
uncapLevel={gridWeapon.uncap_level}
|
||||||
|
position={gridWeapon.position}
|
||||||
updateUncap={passUncapData}
|
updateUncap={passUncapData}
|
||||||
special={false}
|
special={false}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue