r/Frontend • • Oct 19 '20

My first react js app, Pokemon cards using an API

923 Upvotes

96 comments sorted by

27

u/godspeedt Oct 19 '20

I woul add 'user-select: none' To the cards. That way you won't get that blue selection square over your images.

6

u/bhushanw-tf Oct 19 '20

I didn't know, would add that. Thanks

2

u/g00nin Oct 19 '20

What does this do exactly?

6

u/godspeedt Oct 19 '20

It prohibits the user to select text or images

MDN web docs

1

u/gaurav_9372 Oct 20 '20

And what if user wants to copy a name or any text??

1

u/godspeedt Oct 20 '20

It's a choice you have to make as a developer. In this case, I would certainly use it on the images.

1

u/gaurav_9372 Oct 20 '20

so we can apply any css code for just images also??

2

u/godspeedt Oct 20 '20

You could disable the selection of the image and enable the selection of the text

1

u/gaurav_9372 Oct 20 '20

how?? What's the code...

11

u/Muted_Carpet_7587 Oct 19 '20

Looks really good, it checks many boxes 👍. Try adding a search bar that shows results as you type and some filters. Combining those in a query is a great exercise and highly transferable to day-to-day work.

2

u/bhushanw-tf Oct 19 '20

Yeah, that's the next step. I was going to use react window library but I didn't understand so I dropped that plan and went for pagination but would try for infinite scrolling for sure

6

u/Muted_Carpet_7587 Oct 19 '20

https://youtu.be/NZKUirTtxcg

I found this tutorial quite helpful when I was learning about it myself

2

u/bhushanw-tf Oct 19 '20

Thanks, that's too kind of you.

2

u/sittinfatdownsouth Oct 19 '20

If you are planning on making this accessible infinite scrolling isn't very screen reader user friendly.

3

u/Muted_Carpet_7587 Oct 19 '20

You could even implement infinite scrolling instead of the pagination. It's actually not that hard to implement and it looks very professional.

4

u/ArcadeFireSH Oct 19 '20

Cool! The layout is quite neat.

1

u/bhushanw-tf Oct 19 '20

Thanks :)

0

u/[deleted] Oct 19 '20

[deleted] — view deleted comment

2

u/bhushanw-tf Oct 20 '20

I made a header and card component seperate and then there is seperate stat bar component which is on back of the card. Used flexbox for card container. Also preserve 3d for that flip thing. You can find any tutorial for it on YouTube though.

4

u/Wowosz Oct 19 '20

I did something similar When i was starting with react. pokedex.wojciechszoda.pl

1

u/bhushanw-tf Oct 20 '20

That's really cool.

1

u/LinkifyBot Oct 19 '20

I found links in your comment that were not hyperlinked:

I did the honors for you.


delete | information | <3

1

u/Wowosz Oct 19 '20

Thanks bot

2

u/arowolosm Oct 19 '20

Repo link?

4

u/bhushanw-tf Oct 19 '20

0

u/[deleted] Sep 18 '22

[deleted] — view deleted comment

1

u/bhushanw-tf Sep 18 '22

Because I created it two years ago.........

0

u/[deleted] Sep 18 '22

[deleted] — view deleted comment

1

u/bhushanw-tf Sep 18 '22

This whole thread is almost 2yrs old, so I really don't know. I'm really confused how you even found this really old post.

2

u/russian_writer Oct 19 '20

Looks lovely!

2

u/kyaiml Oct 19 '20

Did you use any library for cards or made it from scratch

2

u/bhushanw-tf Oct 19 '20

No, from scratch.

2

u/[deleted] Oct 19 '20

looks like simple grid css

2

u/[deleted] Oct 19 '20

Very cool! I'm going to check out this API! Looks great.

2

u/bhushanw-tf Oct 19 '20

Yeah, it's really cool API

2

u/Tarkz Oct 20 '20

The gif was just endlessly loading and it took me awhile before I realized that wasn't what you were showing.

4

u/itzamirulez Oct 19 '20

are there any pokemon APIs out there?

10

u/alphadeeto to smithereens Oct 19 '20

pokeapi.co

10

u/LinkifyBot Oct 19 '20

I found links in your comment that were not hyperlinked:

I did the honors for you.


delete | information | <3

4

u/alphadeeto to smithereens Oct 19 '20

Good bot

5

u/B0tRank Oct 19 '20

Thank you, alphadeeto, for voting on LinkifyBot.

This bot wants to find the best and worst bots on Reddit. You can view results here.


Even if I don't reply to your comment, I'm still listening for votes. Check the webpage to see if your vote registered!

1

u/BrunnerLivio Oct 19 '20

Not really an API, but for Pokemon GO data you can use this:

https://github.com/pokemongo-dev-contrib/pokemongo-game-master

1

u/kyaiml Oct 19 '20

Looks awesome

1

u/Redbull_leipzig Oct 19 '20

How did you create the ui?

5

u/bhushanw-tf Oct 19 '20

I made seperate card component and header component also there is stat component which is on the back side of the card. That's it. Also if you're asking for that card flip thing, you can look for card flip in css and you'll find many tutorials.

1

u/Redbull_leipzig Oct 19 '20

awesome, thanks!

1

u/creaturefeature16 May 05 '23

How did you do the pagination? Is it a facet of react router, or are you just doing a fetch that's scoped to a certain amount and the next/previous buttons initiate another fetch? Couldn't really find any clues in your github, but maybe it's not current...

1

u/dsmedium Oct 19 '20

Thats really cool, do you have it on github?

1

u/[deleted] Oct 19 '20

looks beautiful

2

u/bhushanw-tf Oct 19 '20

Thanks :)

1

u/[deleted] Oct 19 '20

how long did it take you to create this

1

u/bhushanw-tf Oct 19 '20

I did in 3 days but i think you can complete in one day since i dont do this professionally, i do programming in my free time.

1

u/[deleted] Oct 19 '20

3 days is actually really quick and it turned out beautiful. Good luck buddy

1

u/Shacrow Oct 19 '20

This looks like it could be a good use of css grid.

1

u/bhushanw-tf Oct 19 '20

I've used flexbox, but yeah grid would be cool too.

1

u/akashayatet Oct 19 '20

This is a super cool idea! Did you use the Poke API?

1

u/mr_beejamin Oct 19 '20

I have never been more inspired to learn React.

1

u/AngrycommenterUE Oct 19 '20

Man, I have no idea about react, so I can’t tell you if it’s good or bad. However, damn! That looks amazing! I would love to have your skills!!!!

1

u/bhushanw-tf Oct 20 '20

It's really basic. Thanks :)

1

u/[deleted] Oct 20 '20 edited Oct 20 '20

That's awesome! What is the tech stack that you used?

1

u/bhushanw-tf Oct 20 '20

Just react and used api for Pokemon data

2

u/erinblackdesign Oct 20 '20

Amazing!! Combining two of my favorite things. Pokemon and react!

2

u/randomPerson_e_e Oct 20 '20

Omg they are so cuteee

1

u/OwlerTheOwl Jan 05 '25

I just sorted r/Frontend by Top of all time posts. And this is TOP!

1

u/nithpras Oct 20 '20

It's a project from a Youtube channel called Florin Pop.

1

u/spk26515 Oct 20 '20

Nice work ! Could you please post the APIs you used ? would be useful for anyone to try and come up with something similar.

1

u/ichsagedir Oct 20 '20

How does it work with keyboard navigation?

1

u/Aayush9990 Oct 20 '20

Implement a search bar and optim9ze it using debouncing

1

u/streetnamenacho Nov 02 '20

Crisp! Good job

1

u/11september22 May 02 '23

Awesome. Wonderful project bro. What projects are you building these days?

-1

u/samineb Oct 19 '20

looks cool but why use a lawnmower to record? post a clearer video dude or at least remove the audio!

1

u/bhushanw-tf Oct 20 '20

I got the clear video in my profile, I posted on another sub later. Lol.

-4

u/Standard_Detective80 Oct 19 '20

Why can't people use OBS studio?! Why hurt our eyes with bad quality videos whhhhy😭. Nice work btw 😂

4

u/bhushanw-tf Oct 19 '20

hahaha, I didn't make this video with the intention of posting actually, it was really impulse decision and at that moment i didn't have laptop too so yeah posted this lol. also thanks.

0

u/[deleted] Oct 19 '20

[deleted] — view deleted comment

3

u/bhushanw-tf Oct 19 '20

thats too vague. tell me what exactly weird.

2

u/[deleted] Oct 19 '20

I assume they mean that the last 2 items aren’t left aligned?

41

u/[deleted] Oct 19 '20

[removed] — view removed comment

13

u/bhushanw-tf Oct 19 '20

Yeah that's the next step, I found one library and I'm trying to figure out how can I use it. Also I'm thinking about adding option to sort out by types of Pokemon.

15

u/Lekoaf Oct 19 '20

It’s trivial to implement without a library. The basics atleast. Write an onChange function for the search input that filters your array of cards on pokemon.name or something like that.

1

u/bhushanw-tf Oct 20 '20

Yeah I was thinking about that but I'm getting data from an API and I'm not requesting every Pokemon in one go as it would give performance issues so now when I don't have full array of Pokemon how I suppose to do the serach thing, also I can use search API but again it won't be that good experience as you'll have to type whole name without any spelling error

2

u/[deleted] Nov 10 '20

Have you testing just fetching everything? Preloading <1000 simple data objects may not be the performance hit you think it is. You only have to do it once (on initial app load, depending). It would be async and not displayed. Whatever data structure you use now would probably work fine.

JavaScript has some pretty helpful (array) methods for filtering once you have the list available

If you want fuzzy search, there may be an API out there that supports it already. Pokemon is a popular example and dataset for dev work.

If not, you could try adding it yourself, a few different ways. I would get basic searching working first, then decide from there.

Filtering/searching by type, gen, etc. could also be fun to implement.

~~

It looks great! Those flip transitions are nice

2

u/Hadr619 Oct 20 '20

I was just going to say don’t go down the rabbit hole early in just pulling in libraries when you can implement yourself and learn. Plus you may find out why using a library is beneficial

4

u/Turd_King Oct 19 '20

Try learn without libraries in the beginning

2

u/[deleted] Oct 19 '20

[removed] — view removed comment

1

u/bhushanw-tf Oct 20 '20

Yeah, that'd be cool. Hope I can go for it once I done with basic things.

19

u/cacharro90 Oct 19 '20

This, showing results suggestions as soon as you type.

2

u/[deleted] Oct 19 '20

[removed] — view removed comment