Commit graph

115 commits

Author SHA1 Message Date
62579dc671 Keep outfit thumbnail while individual layers load 2021-01-08 02:53:31 -08:00
2a8be58973 Show thumbnail in wardrobe page while outfit loads
To help the load time for outfits feel shorter, we now reuse the outfit thumbnail from the Your Outfits page as a placeholder!

This doesn't add any overhead when the thumbnail data _isn't_ in your session cache, e.g. if you navigate to the outfit directly. But if we have the thumbnail on hand already, we just show it, easy peasy!
2021-01-08 01:23:24 -08:00
3804457839 fix OutfitPreview fade out bug
Oops, when switching to @emotion/react, it turns out they no longer support that cute hack I was doing to append suffixes to class names!

Here, I change strategy and let `CSSTransition` apply the plain `exit` and `exit-active` classes to its children, and apply Emotion styles to the child to check for _also_ having those classes.
2021-01-07 00:33:51 -08:00
4a352e04e0 simulate login with IMPRESS_LOG_IN_AS flag 2021-01-05 23:22:03 -08:00
1f5a9d60a2 Show saved outfits in wardrobe page!
Still a pretty limited early version, no saving _back_ to the server. But you can click from the Your Outfits page and see the outfit for real! :3 We have a WIPCallout explaining the basics.
2021-01-05 06:29:39 +00:00
c9603a40ea tweak site bg color, to let card elements "pop"
This has been bothering me for a long time, but I couldn't really figure out what to do about it. But tweaking the site bg color a smidge has helped us really add texture to the cards I want to have pop out, like the outfit polaroids!

I kinda went all-in in a burst, but tbh I think it looks great :3

I haven't really touched the wardrobe page with it yet though, that'll probably need some tweaking... for now I'm overriding it to keep the old background!
2021-01-04 09:17:54 +00:00
b01feba038 add items to outfit thumbnails
Now that wasn't so hard! :3
2021-01-04 08:26:05 +00:00
30e0a149be basic outfits page with pet-only thumbnails 2021-01-04 08:10:35 +00:00
778eefbdd5 placeholder Your Outfits page
it requires login, and runs a GQL query that will fail 😅
2021-01-04 07:31:02 +00:00
79bde552e2 move src/images into src/app/images
I'm gonna add a `src/shared` next, and it felt weird for `images` to be a sibling, esp since the images are only for the client app!
2021-01-04 03:49:08 +00:00
4120c7aa88 fix large-icon visual bug
Looks like there was some kind of runtime conflict when running @emotion/css and @emotion/react at the same time in this app? Some styles would just get clobbered, making things look all weird.

Here, I've removed our @emotion/css dependency, and use the `<ClassNames>` utility element from `@emotion/react` instead. I'm not thrilled about the solution, but it seems okay for now...

...one other thing I tried was passing a `css` prop to Chakra elements, which seemed to work, but to clobber the element's own Emotion-based styles. I assumed that the Babel macro wouldn't help us, and wouldn't convert css props to className props for non-HTML elements... but I suppose I'm not sure!

Anyway, I don't love this syntax... but I'm happy for the site to be working again. I wonder if we can find something better.
2021-01-04 03:11:55 +00:00
91982c60d9 update to new Chakra <Wrap> API 2020-12-25 09:17:24 -08:00
b023cbeaf9 use @emotion/css instead of plain emotion 2020-12-25 09:09:16 -08:00
406849182a update chakra imports 2020-12-25 09:08:33 -08:00
0c2ec4685e use react-virtualized to speed up user items page
There's a known bug that items with a lot of zones will overflow the row… filing that as a separate fix tho!
2020-12-07 18:58:10 -08:00
d59a4948a0 fix species/color dropdown focus bug
Oops, creating a new `SpeciesColorPicker` fn on each render meant that React treated it as a whole new dropdown each time. I've extracted it out into a stable component class, and just pass in the extra props now!

This bug caused changes to kick you out of focus for the dropdown, because it had unmounted and remounted.
2020-12-04 13:01:39 -08:00
a5bfadf126 fix missing pause/play button for some animations
We do animation detection during the preload now, but this wasn't always working correctly: some movies don't actually fully mount the children onto the stage until we start playing. This caused the play/pause button to be missing on the outfit page and the item page, but the animations would still play, depending on the user's saved play/pause state in localStorage.
2020-11-08 16:17:07 -08:00
d02f7ced72 add pb badge to pb items, instead of nc/np badge 2020-11-08 15:13:30 -08:00
d701f51c15 move own/want badges to end of wardrobe items
I saw the short-near-the-front and it just frankly looked awkward? Not sure why I liked it before?

I think this medium at the end of the list is better aesthatically, though it's starting to get a bit messy with the different colors mixed around… but I think there's also a semantic argument that we're keeping the facts about the item together, and the _user-specific_ stuff separate at the end… (putting it at the front would be a good semantic argument too, but I think the NC/NP alignment is too important)
2020-11-03 20:24:56 -08:00
045fb95d69 fix spacing bugs with item badges
In a previous change, I moved the margin for item badges onto an ItemBadge element… but I didn't think through how that would break the spacing for the loading state of ItemPage. Now, the loading skeleton items _contained_ the badge margin, and so the spacing between badges was shiny skeleton-y.

Here, I replace ZoneBadgesList with a function that just returns the elements, and go back to using Chakra's Wrap component. That will apply the margin to direct children, and the zone badges are direct children now.

One option I'm thinking of in hindsight is an idea I had earlier: Chakra hacks the margin onto _React_ children, but could we use CSS direct child selector instead? A bit trickier to resolve the margin size to the theme's value, but plenty doable… something to consider!
2020-11-03 20:11:37 -08:00
de974a365b fix bug with items with %20 in movie clip URL
"Beautiful Green Painting Background" wasn't loading! https://impress-2020.openneo.net/items/75594

```Error building movie clips Error: Expected JS movie library http://images.neopets.com/cp/items/data/000/000/491/491273_31368b3745/491273_2_HTML5%20Canvas.js to contain a constructor named _491273_2_HTML5%20Canvas, but it did not: ssMetadata,Bitmap3,Bitmap5,CachedTexturedBitmap_4183,CachedTexturedBitmap_4184,CachedTexturedBitmap_4185,CachedTexturedBitmap_4186,CachedTexturedBitmap_4187,Symbol20,Symbol8,Symbol4,Symbol7,Symbol2,Symbol1,Symbol9,Symbol2copy,Symbol2_1,_491273_2_HTML5Canvas,properties,Stage```

We already had code to strip out spaces, but not encoded spaces like %20. Now, we decode the URL first, so that space-stripping will work even if it was encoded.
2020-10-28 00:29:32 -07:00
4d4d475437 add quick-look trade matches to top of page 2020-10-24 01:06:55 -07:00
5a13959805 fix bug with zone badge wrapping
Oops, the <Wrap> component is nice, but it uses React.Children to apply margin to its _direct_ children, and our badges are not always direct children! (See the new `ZoneBadgeList`.)

I poked my head into how `Wrap` works, and it's honestly pretty simple, so I've applied the same styles manually. Ta da!
2020-10-24 00:32:23 -07:00
274a4f716f add zones to user items page
idk the labels section was feeling empty, and I didn't see a way to streamline it more, so I figured, add info that might be useful! lol
2020-10-23 23:29:54 -07:00
49d3b3685d add CORS for movie clip asset loading
I think the issue with the Spring Topiary Garden Background is that EaselJS is trying to do intermediate canvas reads in order to apply computed filters, but loading from our asset proxy counts as tainted data.

Here's the traceback I got in Chrome for it:
```
Error building movie clips DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
    at a.b._applyFilters (https://code.createjs.com/1.0.0/easeljs.min.js:15:12029)
    at a.b._drawToCache (https://code.createjs.com/1.0.0/easeljs.min.js:15:11806)
    at a.b.update (https://code.createjs.com/1.0.0/easeljs.min.js:15:8638)
    at a.b.define (https://code.createjs.com/1.0.0/easeljs.min.js:15:8148)
    at lib.Flowerfront.b.cache (https://code.createjs.com/1.0.0/easeljs.min.js:13:3361)
    at new lib.Bg (https://images.neopets-asset-proxy.openneo.net/cp/items/data/000/000/441/441520_f4a43d48bf/441520HTML5.js:4266:16)
    at new lib._441520HTML5 (https://images.neopets-asset-proxy.openneo.net/cp/items/data/000/000/441/441520_f4a43d48bf/441520HTML5.js:5291:18)
    at x (https://impress-2020.openneo.net/static/js/11.3a356cfe.chunk.js:1:12286)
    at https://impress-2020.openneo.net/static/js/11.3a356cfe.chunk.js:1:17768
    at Array.map (<anonymous>)
```

To try to fix this, I've updated our Fastly config to version 8, which should accept CORS requests from https://impress-2020.openneo.net. And here, I've updated the movie clip assets to be requested CORS-style, so that the Origin header will actually be set.

It's hard to test this without just, pushing it to prod. I've confirmed in isolation that setting the `Origin` header in the request yields the expected `Access-Control-Allow-Origin` response header, and that the `Vary` header is set correctly too. But, end-to-end, I don't really have great mockability here—maybe with a good proxy setup I could do it? But nah, let's just push and find out!
2020-10-23 00:20:50 -07:00
0387a78574 show error message when preload can't build movies
Not sure why movie clip building is failing! But it happened outside our try-catch, so it left us in an infinite spinner state.

The repro item is the Spring Topiary Garden Background!
2020-10-22 23:52:26 -07:00
57889a3a88 can add own/wanted items from item page
the buttons work now! but only when adding 😅 remove comes next!
2020-10-22 21:20:49 -07:00
d99f5d7ac8 oops, fix missing react hook dep! 2020-10-22 15:46:22 -07:00
9a36a6ec69 don't advance movies by a frame when resizing 2020-10-10 04:51:53 -07:00
7102772f63 fix positioning of movie layers on large screens
Oops, movie canvases were drawing larger than the images, if there was more than 600px of space available! fixed!
2020-10-10 04:32:53 -07:00
afe9fcf392 fade in for movie layers, too
gosh I hope I didn't break everything 😅
2020-10-10 03:46:23 -07:00
82f849f047 fix fade-in for static image layers
I guess something got more picky about the loading sequencing: the fade in animation was happening faster than the cached image could load. Now, we explicitly wait for the image to load (even though we know it's probably cached) before fading it in.
2020-10-10 03:37:43 -07:00
68607e3756 fix infinite spinner on err loading HTML5 layers
Oops, our movie layer promises don't have a .cancel() method, so calling it crashed our error handler. Now, when there's an error loading a layer and there are HTML5 layers visible, we'll correctly show the "Could not load preview. Try again?" message.
2020-10-10 02:42:27 -07:00
1eca5d1e27 add WIP callout to item page 2020-10-10 02:17:21 -07:00
e7359ab51b add WIP callout to user items page 2020-10-10 02:07:49 -07:00
ad43f58a07 fix Download button to use better caching
So I broke the Download button when we switched to impress-2020.openneo.net, and I forgot to update the Amazon S3 config.

But in addition to that, I'm making some code changes here, to make downloads faster: we now use exactly the same URL and crossOrigin configuration between the <img> tag on the page, and the image that the Download button requests, which ensures that it can use the cached copy instead of loading new stuff. (There were two main cases: 1. it always loaded the PNGs instead of the SVG, which doesn't matter for quality if we're rendering a 600x600 bitmap anyway, but is good caching, and 2. send `crossOrigin` on the <img> tag, which isn't necessary there, but is necessary for Download, and having them match means we can use the cached copy.)
2020-10-10 01:21:47 -07:00
423ab5c98d oops, un-break the homepage! 2020-10-08 04:20:23 -07:00
1875931a48 simplify canvas code, just use separate elements
Previously I tried to be clever and pre-optimize by putting all the layers onto one canvas… I think this probably helped by batching their paints, but it made fades less smooth by not taking advantage of native CSS transitions, and it made us dip into JS way more often than necessary.

Here, I take the simpler approach: just layers of <img> and <canvas> tags, with each animated layer on its own canvas, and letting the browser handle transitions and compositing, and separate `setInterval` timers to manage their framerates.

I have a suspicion that batching the paints could help performance more, but honestly, maybe that batching is already happening somehow, because things look pretty great on my big-screen stress test now; and so if it _is_ relevant, I want to wait and see after testing on low-power devices.
2020-10-08 04:13:47 -07:00
42c59328a9 only make a 60fps call if we're actually animating 2020-10-06 08:55:21 -07:00
900d102594 Merge branch 'modeling' into main 2020-10-06 07:06:30 -07:00
6ec6bbec57 first-time modeling UX improvements
These changes are most relevant for playing around in the dev server, modeing against an empty database. But they'll also help in real-world modeling scenarios! e.g. modeling a new species/color combo is now a bit nicer, we don't show a blank entry in the color picker
2020-10-06 06:37:51 -07:00
f543868924 fix bug that broke fades on cache-grouped layers 2020-09-25 07:53:04 -07:00
32c4e540a3 group and cache adjacent static outfit layers
perf win owo!
2020-09-25 07:35:49 -07:00
d52849c7a2 add animations and play/pause button to item page 2020-09-24 08:29:56 -07:00
05f7b3fcc7 oops, fix missing hook deps 2020-09-24 06:43:46 -07:00
ce402c23d7 include animated assets in preloading
Honestly kinda surprised this worked on the first go! I was worried something about the process would make the sorta like, instant-cache expectation not work.

Still thinking it might be considerate to like, keep a LRU cache of MovieClip options, so that we don't double-execute these scripts when adding stuff… we even re-execute the ones already applied lol 😅 and that adds lots of script tags to the body!

But yeah I'm not gonna push on it yet until I see evidence that it actually causes performance issues in practice
2020-09-24 06:25:52 -07:00
53b4d34419 only show play/pause when there are animations 2020-09-24 06:13:27 -07:00
c4a9ee8497 a bit more perf for static assets 2020-09-24 06:04:51 -07:00
5879324ebb play/pause button for animations 2020-09-22 05:39:48 -07:00
88f5c1f1aa fix bug where resizes pause the animations 2020-09-22 05:14:31 -07:00