Coder Social home page Coder Social logo

chess-heat's Introduction

Hi, I'm Max! ๐Ÿ‘‹ I'm a software developer with a strong will to learn, research new technologies, and design software architecture. I like creating practical business solutions and making development processes as efficient as possible.

chess-heat's People

Contributors

e6voe9 avatar giri-madhan avatar markkhoo avatar maxdemaio avatar typesafegh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chess-heat's Issues

Light/dark mode toggle

** This isn't really a needed feature but more of an added bonus if possible **

Great example of a light/dark toggle: https://dev.to/whitep4nth3r/the-best-lightdark-mode-theme-toggle-in-javascript-368f

  • Would probably want to use an icon in this collection since our main icon is from there too: https://icones.js.org/collection/bi
  • Toggle would be a button in the top right nav. It would be the last element in the flexbox
  • Similar to https://maxdemaio.com
  • on smaller screens would probably remove the other items on the right and only have the brand on left and toggle button

Keyboard accessibility

I would like to be able to cycle through all squares (to see tooltips) using my keyboard pressing TAB.

To make any element focusable in html you can add tabindex="0" attribute to it.
You can implement it moving mouseover/mouseleave logic from javascript to css. It's possible to make same UX with css :focus / :hover effects.

Reference: github activity table. Hit TAB until you reach first square. Then you can move with arrows.

Ability to choose different game classes

Chess has game classes for all time controls.
For example:
180-599 seconds - blitz
600-1800 seconds - rapid
etc.

We can add dropdown which will sort data and show only specific game class chessheat.

In response from https://api.chess.com/pub/player/{user}/games/{year}/{month} we are getting time_class for every game.

Store last hue value

We don't store user's hue value now. So every time user opens chessheat.com it's 0 by default.
We can store that value in localStorage, to keep last known selected hue.

Dates and cells still off

Self notes:

  • looks like we're just not truncating the right amount of days at the start
  • look into firstDayDate variable and why do we need it

Not requesting json

Simply as that. Pgn takes more space than json, there is no need to request whole pgn, when we can request compact json.

url: https://api.chess.com/pub/player/${user}/games/${loopYear}/${loopMonth}/pgn

data size with pgn: ~1578.8kB

Pasted image 20230504023028

url: https://api.chess.com/pub/player/${user}/games/${loopYear}/${loopMonth}

data size with json: ~489.3kB

Pasted image 20230504025757

~3 times less traffic and what's more, no more need in RegEx (we all know how slow it is, so potentially faster rendering after receiving data).
With json we can easily store all data to localStorage and use in future, to optimize more.

Parse game data from JSON, not PGN embedded in JSON

Relates to #30. Basically, now we're using the JSON endpoint. But, we're still parsing the PGNs embedded in the JSON with regex. Instead, we'll use the fields available on the JSON.

  • use json data and create enum for results
  • update readme

Code cleanup

This is just general code quality stuff. I don't expect anyone to pick this up and I can tackle this as needed ๐Ÿ‘๐Ÿป

Unnecessary comparisons to get the day of the week

https://github.com/maxdemaio/chess-heat/blob/8cf41ec415e7993447d0115c26052c4ebdc46e10/script.js#LL223C5-L257C6

This code compares i to the number 7x7 times.

Can be only 1x7 comparison operations with code below:

const clipPathStyle = i % 2 === 0 ? 'Circle(0)' : 'None';

tdLabelSpanHidden.textContent = DAYS_OF_THE_WEEK[i];
tdLabelSpan.textContent = DAYS_OF_THE_WEEK[i].slice(0, 3);
tdLabelSpan.style.clipPath = clipPathStyle;

This part should be defined somewhere at the start of the file:

const DAYS_OF_THE_WEEK = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];

Days in the hover text do not match the rows

image

It's weird for the user roflman123 for year 2023 it does Fri-Thursday. Then for the user max_mayo and the year 2023 we do Saturday -Friday instead. Will add more details below.

Too many requests when not played all last 12 months

Application makes requests for last 12 months even if player did not played in certain months.
Example:
user: bahanovych
months with number of games > 0: march, april, may

Pasted image 20230504023028

wasted time: ~1463ms
wasted traffic: ~6.56kB

Potential solution

Before fetching 12 months, it's possible to make yet another one request to get all archives of player. Info about all valid months (by valid I mean number of games > 0).
url: https://api.chess.com/pub/player/{user}/games/archives

Response in json

{"archives":[
"https://api.chess.com/pub/player/bahanovych/games/2023/03",
"https://api.chess.com/pub/player/bahanovych/games/2023/04",
"https://api.chess.com/pub/player/bahanovych/games/2023/05"]
}

It's now possible to filter archives array to get links from last 12 months. In that case it would only be 4 requests in total, 3 times less.
potential saved time: ~1400ms
potential saved traffic: ~6.3kB

In worst case scenario, when player played all last 12 months it's only ~150ms and ~1kB more.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.