Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: add a sprite #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

POC: add a sprite #4

wants to merge 3 commits into from

Conversation

aquino-luane
Copy link

@aquino-luane aquino-luane commented Oct 15, 2024

What this PR does?

Adds a sprite to library:

image

Reference: https://gist.github.com/summerscar/586b88772c598efdbfecffa3c1212b79

How to setup mock API?

We are using Mockoon for API mock
Here are the files you need to set the mock API:

  • route-get-image.json
  • 60f720956ab1840431dcf0616ce98f14.svg

Link to drive: https://drive.google.com/drive/folders/1ASWqP-JZXjmFqD_akaFnZ5IdqY4hKGRQ

To import the route to Mockoon, you copy the contents of the json file, then in Mockoon you select from the menu Routes>Add routes from clipboard
https://mockoon.com/docs/latest/mockoon-data-files/environment-clipboard-copy/#create-a-new-route-from-clipboards-data

After you import the route, you need to update the file path to point to the image you downloaded:

image

@aquino-luane aquino-luane self-assigned this Oct 15, 2024
@aquino-luane aquino-luane requested a review from hissy October 15, 2024 02:38
Copy link
Member

@hissy hissy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much.

Could you find the difference between costumes and sprites? Must we create both json files?

Also, can you update this PR to get json data from a mock API?
If you can, we can create a sprites database on the Concrete CMS side.

@aquino-luane
Copy link
Author

aquino-luane commented Oct 22, 2024

Could you find the difference between costumes and sprites?

It is a good question 😄. The difference is small:

  • if you are in the "Costumes" tab and select a costume you can stay in the same place, but if you select a sprite you go to "Code" tab
    image
  • costumes.json is what is shown in here:
    image
  • you can keep a list of customized sprites
    image

Must we create both json files?

sprites.json is needed. If we don't need the functionality to choose costumes then we don't need to create the costumes.json file


while I was searching about what you asked, I found that when I select Neko from the costumes, it is giving this error. I will investigate
image

@hissy

@aquino-luane
Copy link
Author

aquino-luane commented Oct 22, 2024

Also, can you update this PR to get json data from a mock API?
If you can, we can create a sprites database on the Concrete CMS side.

@hissy do you mean an API to return sprites.json?
would we still download the sprite by requesting it by its md5 id like http://localhost:3000/image/${asset.assetId}.${asset.dataFormat} ?

@hissy
Copy link
Member

hissy commented Oct 22, 2024

@aquino-luane

do you mean an API to return sprites.json?

Yes.

would we still download the sprite by requesting it by its md5 id like http://localhost:3000/image/${asset.assetId}.${asset.dataFormat} ?

Yes.

Please check this sequence diagram, this is what I thought about loading sprites

https://cacoo.com/diagrams/nfYGhe7SZMAEv6sh/699AB

@aquino-luane
Copy link
Author

aquino-luane commented Oct 23, 2024

@hissy
It seems to have no way to download the json and save to a specific location, because security reasons the file can only be saved into the downloads folder https://spin.atomicobject.com/create-export-react-frontend

The other way would be to save the json in redux. As it might be a big file, I am not sure if is good way, what do you think?

Will there be frequent update in the sprites and costumes? is it an option to keep the file locally without the request to server?

@hissy
Copy link
Member

hissy commented Oct 23, 2024

@aquino-luane

The other way would be to save the json in redux. As it might be a big file, I am not sure if is good way, what do you think?

I think there's no problem. sprites.json is not small, but the same size will be removed from the built JS file.

Will there be frequent update in the sprites and costumes? is it an option to keep the file locally without the request to server?

If API returns json data with cache-control header, your browser will keep it locally.

@aquino-luane
Copy link
Author

@hissy I committed the code to get json from API, could you review please?

Also uploaded the routes and files to drive:
route-get-sprites.json
route-get-costumes.json
costumes.json
sprites.json

@hissy
Copy link
Member

hissy commented Oct 23, 2024

@aquino-luane

Thanks, it looks fine for now. Let's wait for the API doc.

Copy link
Member

@hissy hissy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to get from the APIs instead of mock APIs.
Please check the design doc.
https://docs.google.com/document/d/1m8f_VfWhc2BbnyFnzLbr4iE4WsF2NjJ-uiD8b1_P6wY/edit?usp=sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants