leetcode-patterns icon indicating copy to clipboard operation
leetcode-patterns copied to clipboard

Problems pattern frequency doesn't show colors for new companies

Open leo-step opened this issue 2 years ago • 6 comments

These pills are gray for the newly added companies (e.g. Airbnb) while they are supposed to be colored by difficulty. The pills work correctly for the companies we previously had like Apple and Microsoft.

Expected:

Screen Shot 2022-08-07 at 6 26 55 PM

Current:

Screen Shot 2022-08-07 at 6 23 44 PM

leo-step avatar Aug 07 '22 22:08 leo-step

Steps to reproduce:

  1. Select any company from the dropdown list under Companies
  2. Observe the pills under Problems pattern frequency

Possibly related to either https://github.com/seanprashad/leetcode-patterns/pull/214/files#diff-9aa6b25aa4aab24215ebcedc56e0ff3c2a2e481a30b42eb3ca0fcce2c7752789R402 or #227

seanprashad avatar Aug 07 '22 23:08 seanprashad

One problem that I see here is from a UX perspective - the colouring is also used in the Difficulty column to denote Easy/Medium/Hard questions.

Here, we use the same colour schema, but for a different purpose:

https://github.com/seanprashad/leetcode-patterns/blob/bdbb042f1514a5bf836e133226ec338020446073/src/components/PatternFrequencies/index.js#L31-L35

Since we have two different contexts, we should look into a better colouring scheme when revisiting this!

seanprashad avatar Aug 07 '22 23:08 seanprashad

More breadcrumbs: https://github.com/seanprashad/leetcode-patterns/blob/2409a6018fc903d596a28be15c551f956370f450/src/components/PatternFrequencies/index.js#L47

seanprashad avatar Aug 08 '22 02:08 seanprashad

Looks like some companies, like Apple, show up correctly: image

seanprashad avatar Aug 11 '22 03:08 seanprashad

The issue is in this line: https://github.com/seanprashad/leetcode-patterns/blob/2409a6018fc903d596a28be15c551f956370f450/src/components/PatternFrequencies/index.js#L27

The colors will only show up if a given company has a category of questions (e.g. heap) that has a frequency of at least three. I tested this with Airbnb by adding the company and the "Heap" pattern to the first question in questions.json (Contains Duplicate), and the colors immediately show for all of them.

Screen Shot 2022-08-13 at 11 28 54 PM

How do we want the colors to be in these cases?

leo-step avatar Aug 14 '22 03:08 leo-step

How do we want the colors to be in these cases?

Hmm well, I'm not sure to be honest. Ideally, I think some sort of coloured gradient would look nice, where a darker shade maps to a pattern that is more frequent. There's a bunch of websites to help do the CSS, like https://coolors.co/gradient-maker.

Edit: On second thought, let's choose something easy - red if the frequency is >=5 and orange for everything else. We can fiddle around with an appropriate colour scheme after fixing this bug!

seanprashad avatar Aug 14 '22 14:08 seanprashad