Guess when item is species-specific, for UI hints
This commit is contained in:
parent
6f19ef8c88
commit
e788040315
1 changed files with 52 additions and 6 deletions
|
@ -518,6 +518,7 @@ function ItemPageOutfitPreview({ itemId }) {
|
||||||
query ItemPageOutfitPreview($itemId: ID!) {
|
query ItemPageOutfitPreview($itemId: ID!) {
|
||||||
item(id: $itemId) {
|
item(id: $itemId) {
|
||||||
id
|
id
|
||||||
|
name
|
||||||
compatibleBodies {
|
compatibleBodies {
|
||||||
id
|
id
|
||||||
representsAllBodies
|
representsAllBodies
|
||||||
|
@ -531,6 +532,7 @@ function ItemPageOutfitPreview({ itemId }) {
|
||||||
id
|
id
|
||||||
species {
|
species {
|
||||||
id
|
id
|
||||||
|
name
|
||||||
}
|
}
|
||||||
color {
|
color {
|
||||||
id
|
id
|
||||||
|
@ -565,6 +567,23 @@ function ItemPageOutfitPreview({ itemId }) {
|
||||||
|
|
||||||
const compatibleBodies = data?.item?.compatibleBodies || [];
|
const compatibleBodies = data?.item?.compatibleBodies || [];
|
||||||
|
|
||||||
|
// If there's only one compatible body, and the canonical species's name
|
||||||
|
// appears in the item name, then this is probably a species-specific item,
|
||||||
|
// and we should adjust the UI to avoid implying that other species could
|
||||||
|
// model it.
|
||||||
|
const isProbablySpeciesSpecific =
|
||||||
|
compatibleBodies.length === 1 &&
|
||||||
|
!compatibleBodies[0].representsAllBodies &&
|
||||||
|
(data?.item?.name || "").includes(
|
||||||
|
data?.item?.canonicalAppearance?.body?.canonicalAppearance?.species?.name
|
||||||
|
);
|
||||||
|
const couldProbablyModelMoreData = !isProbablySpeciesSpecific;
|
||||||
|
console.log(
|
||||||
|
compatibleBodies,
|
||||||
|
data?.item?.name,
|
||||||
|
data?.item?.canonicalAppearance?.body?.canonicalAppearance?.species?.name
|
||||||
|
);
|
||||||
|
|
||||||
// To check whether the item is compatible with this pet, query for the
|
// To check whether the item is compatible with this pet, query for the
|
||||||
// appearance, but only against the cache. That way, we don't send a
|
// appearance, but only against the cache. That way, we don't send a
|
||||||
// redundant network request just for this (the OutfitPreview component will
|
// redundant network request just for this (the OutfitPreview component will
|
||||||
|
@ -681,7 +700,14 @@ function ItemPageOutfitPreview({ itemId }) {
|
||||||
/>
|
/>
|
||||||
<Box flex="1 0 0" lineHeight="1">
|
<Box flex="1 0 0" lineHeight="1">
|
||||||
{isIncompatible && (
|
{isIncompatible && (
|
||||||
<Tooltip label="No data yet" placement="top">
|
<Tooltip
|
||||||
|
label={
|
||||||
|
couldProbablyModelMoreData
|
||||||
|
? "Not modeled yet"
|
||||||
|
: "Not compatible"
|
||||||
|
}
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
<WarningIcon
|
<WarningIcon
|
||||||
color={errorColor}
|
color={errorColor}
|
||||||
transition="color 0.2"
|
transition="color 0.2"
|
||||||
|
@ -695,6 +721,7 @@ function ItemPageOutfitPreview({ itemId }) {
|
||||||
<SpeciesFacesPicker
|
<SpeciesFacesPicker
|
||||||
selectedSpeciesId={petState.speciesId}
|
selectedSpeciesId={petState.speciesId}
|
||||||
compatibleBodies={compatibleBodies}
|
compatibleBodies={compatibleBodies}
|
||||||
|
couldProbablyModelMoreData={couldProbablyModelMoreData}
|
||||||
onChange={({ speciesId, colorId }) =>
|
onChange={({ speciesId, colorId }) =>
|
||||||
setPetState({
|
setPetState({
|
||||||
speciesId,
|
speciesId,
|
||||||
|
@ -761,6 +788,7 @@ function PlayPauseButton({ isPaused, onClick }) {
|
||||||
function SpeciesFacesPicker({
|
function SpeciesFacesPicker({
|
||||||
selectedSpeciesId,
|
selectedSpeciesId,
|
||||||
compatibleBodies,
|
compatibleBodies,
|
||||||
|
couldProbablyModelMoreData,
|
||||||
onChange,
|
onChange,
|
||||||
isLoading,
|
isLoading,
|
||||||
}) {
|
}) {
|
||||||
|
@ -807,6 +835,7 @@ function SpeciesFacesPicker({
|
||||||
compatibleBodyIds.includes(speciesFace.bodyId)
|
compatibleBodyIds.includes(speciesFace.bodyId)
|
||||||
}
|
}
|
||||||
isSelected={speciesFace.speciesId === selectedSpeciesId}
|
isSelected={speciesFace.speciesId === selectedSpeciesId}
|
||||||
|
couldProbablyModelMoreData={couldProbablyModelMoreData}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
/>
|
/>
|
||||||
|
@ -833,6 +862,7 @@ function SpeciesFaceOption({
|
||||||
neopetsImageHash,
|
neopetsImageHash,
|
||||||
isCompatible,
|
isCompatible,
|
||||||
isSelected,
|
isSelected,
|
||||||
|
couldProbablyModelMoreData,
|
||||||
onChange,
|
onChange,
|
||||||
isLoading,
|
isLoading,
|
||||||
}) {
|
}) {
|
||||||
|
@ -864,7 +894,9 @@ function SpeciesFaceOption({
|
||||||
{speciesName}
|
{speciesName}
|
||||||
{!isLoading && !isCompatible && (
|
{!isLoading && !isCompatible && (
|
||||||
<div style={{ fontStyle: "italic", fontSize: "0.75em" }}>
|
<div style={{ fontStyle: "italic", fontSize: "0.75em" }}>
|
||||||
(Not compatible yet)
|
{couldProbablyModelMoreData
|
||||||
|
? "(Not modeled yet)"
|
||||||
|
: "(Not compatible)"}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -898,7 +930,10 @@ function SpeciesFaceOption({
|
||||||
name="species-faces-picker"
|
name="species-faces-picker"
|
||||||
value={speciesId}
|
value={speciesId}
|
||||||
checked={isSelected}
|
checked={isSelected}
|
||||||
disabled={isLoading || !isCompatible}
|
// It's possible to get this selected via the SpeciesColorPicker,
|
||||||
|
// even if this would normally be disabled. If so, make this
|
||||||
|
// option enabled, so keyboard users can focus and change it.
|
||||||
|
disabled={!isSelected && (isLoading || !isCompatible)}
|
||||||
onChange={() => onChange({ speciesId, colorId })}
|
onChange={() => onChange({ speciesId, colorId })}
|
||||||
onFocus={() => setInputIsFocused(true)}
|
onFocus={() => setInputIsFocused(true)}
|
||||||
onBlur={() => setInputIsFocused(false)}
|
onBlur={() => setInputIsFocused(false)}
|
||||||
|
@ -933,11 +968,22 @@ function SpeciesFaceOption({
|
||||||
alt={speciesName}
|
alt={speciesName}
|
||||||
width={50}
|
width={50}
|
||||||
height={50}
|
height={50}
|
||||||
filter={isCompatible ? "saturate(90%)" : "saturate(0%)"}
|
data-is-compatible={isCompatible}
|
||||||
opacity={isCompatible ? "0.9" : "0.6"}
|
|
||||||
transition="all 0.2s"
|
transition="all 0.2s"
|
||||||
className={css`
|
className={css`
|
||||||
input:checked + * & {
|
filter: saturate(90%);
|
||||||
|
opacity: 0.9;
|
||||||
|
|
||||||
|
&[data-is-compatible="false"] {
|
||||||
|
filter: saturate(0%);
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:checked + * &[data-is-compatible="false"] {
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:checked + * &[data-is-compatible="true"] {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
filter: saturate(110%);
|
filter: saturate(110%);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue