rename EaselCanvas to OutfitCanvas, etc

reflecting further on the abstraction, I'm noticing that this isn't an Easel abstraction like I envisioned early, and that we're baking some Neopets stuff into it. And I think that's the right call, esp with the tricky MovieClip stuff coming up, where I think more barriers would hurt more than they help. So, a new name!
This commit is contained in:
Emi Matchu 2020-09-22 01:49:12 -07:00
parent 9a8047c613
commit c806de4e83
3 changed files with 24 additions and 22 deletions

View file

@ -6,7 +6,7 @@ const EaselContext = React.createContext({
removeResizeListener: () => {}, removeResizeListener: () => {},
}); });
function EaselCanvas({ children, width, height }) { function OutfitCanvas({ children, width, height }) {
const [stage, setStage] = React.useState(null); const [stage, setStage] = React.useState(null);
const resizeListenersRef = React.useRef([]); const resizeListenersRef = React.useRef([]);
const canvasRef = React.useRef(null); const canvasRef = React.useRef(null);
@ -109,7 +109,7 @@ function EaselCanvas({ children, width, height }) {
); );
} }
export function EaselBitmap({ src, zIndex }) { export function OutfitCanvasImage({ src, zIndex }) {
const { const {
width, width,
height, height,
@ -183,8 +183,8 @@ export function EaselBitmap({ src, zIndex }) {
} }
/** /**
* useEaselDependenciesLoader loads the CreateJS scripts we use in EaselCanvas. * useEaselDependenciesLoader loads the CreateJS scripts we use in OutfitCanvas.
* We load it as part of EaselCanvas, but callers can also use this to preload * We load it as part of OutfitCanvas, but callers can also use this to preload
* the scripts and track loading progress. * the scripts and track loading progress.
*/ */
export function useEaselDependenciesLoader() { export function useEaselDependenciesLoader() {
@ -246,4 +246,4 @@ export function loadImage(url) {
return promise; return promise;
} }
export default EaselCanvas; export default OutfitCanvas;

View file

@ -4,11 +4,11 @@ import { WarningIcon } from "@chakra-ui/icons";
import { css, cx } from "emotion"; import { css, cx } from "emotion";
import { CSSTransition, TransitionGroup } from "react-transition-group"; import { CSSTransition, TransitionGroup } from "react-transition-group";
import EaselCanvas, { import OutfitCanvas, {
EaselBitmap, OutfitCanvasImage,
loadImage, loadImage,
useEaselDependenciesLoader, useEaselDependenciesLoader,
} from "./EaselCanvas"; } from "./OutfitCanvas";
import HangerSpinner from "./HangerSpinner"; import HangerSpinner from "./HangerSpinner";
import useOutfitAppearance from "./useOutfitAppearance"; import useOutfitAppearance from "./useOutfitAppearance";
@ -151,15 +151,15 @@ export function OutfitLayers({
engine === "canvas" ? ( engine === "canvas" ? (
!loadingEasel && ( !loadingEasel && (
<FullScreenCenter> <FullScreenCenter>
<EaselCanvas width={canvasSize} height={canvasSize}> <OutfitCanvas width={canvasSize} height={canvasSize}>
{visibleLayers.map((layer) => ( {visibleLayers.map((layer) => (
<EaselBitmap <OutfitCanvasImage
key={layer.id} key={layer.id}
src={getBestImageUrlForLayer(layer)} src={getBestImageUrlForLayer(layer)}
zIndex={layer.zone.depth} zIndex={layer.zone.depth}
/> />
))} ))}
</EaselCanvas> </OutfitCanvas>
</FullScreenCenter> </FullScreenCenter>
) )
) : ( ) : (

View file

@ -1,37 +1,39 @@
import React from "react"; import React from "react";
import EaselCanvas, { EaselBitmap } from "../app/components/EaselCanvas"; import OutfitCanvas, {
OutfitCanvasImage,
} from "../app/components/OutfitCanvas";
export default { export default {
title: "Dress to Impress/EaselCanvas", title: "Dress to Impress/OutfitCanvas",
component: EaselCanvas, component: OutfitCanvas,
}; };
export const BlueAcara = () => ( export const BlueAcara = () => (
<EaselCanvas width={300} height={300}> <OutfitCanvas width={300} height={300}>
<EaselBitmap <OutfitCanvasImage
src="http://images.neopets.com/cp/bio/data/000/000/002/2426_898928db88/2426.svg" src="http://images.neopets.com/cp/bio/data/000/000/002/2426_898928db88/2426.svg"
zIndex={10} zIndex={10}
/> />
<EaselBitmap <OutfitCanvasImage
src="http://images.neopets.com/cp/bio/data/000/000/002/2425_501f596cef/2425.svg" src="http://images.neopets.com/cp/bio/data/000/000/002/2425_501f596cef/2425.svg"
zIndex={20} zIndex={20}
/> />
<EaselBitmap <OutfitCanvasImage
src="http://images.neopets.com/cp/bio/data/000/000/002/2427_f12853f18a/2427.svg" src="http://images.neopets.com/cp/bio/data/000/000/002/2427_f12853f18a/2427.svg"
zIndex={30} zIndex={30}
/> />
<EaselBitmap <OutfitCanvasImage
src="http://images.neopets.com/cp/bio/data/000/000/032/32185_dc8f076ae3/32185.svg" src="http://images.neopets.com/cp/bio/data/000/000/032/32185_dc8f076ae3/32185.svg"
zIndex={40} zIndex={40}
/> />
<EaselBitmap <OutfitCanvasImage
src="http://images.neopets.com/cp/bio/data/000/000/002/2428_991dcdedc7/2428.svg" src="http://images.neopets.com/cp/bio/data/000/000/002/2428_991dcdedc7/2428.svg"
zIndex={50} zIndex={50}
/> />
<EaselBitmap <OutfitCanvasImage
src="http://images.neopets.com/cp/bio/data/000/000/002/2430_87edccba4c/2430.svg" src="http://images.neopets.com/cp/bio/data/000/000/002/2430_87edccba4c/2430.svg"
zIndex={60} zIndex={60}
/> />
</EaselCanvas> </OutfitCanvas>
); );