Skip to content

feat(client): respect user color scheme in editor - #48974

Merged
ojeytonwilliams merged 4 commits into
freeCodeCamp:mainfrom
Sboonny:feat/respect-user-color-scheme-in-editor
Jan 9, 2023
Merged

ojeytonwilliams merged 4 commits into
freeCodeCamp:mainfrom
Sboonny:feat/respect-user-color-scheme-in-editor

Conversation

@Sboonny

@Sboonny Sboonny commented Jan 9, 2023

Copy link
Copy Markdown
Member

Checklist:

  • I have read freeCodeCamp's contribution guidelines.
  • My pull request has a descriptive title (not a vague title like Update index.md)
  • My pull request targets the main branch of freeCodeCamp.
  • I have tested these changes either locally on my machine, or GitPod.

Closes #48936

@Sboonny
Sboonny requested review from a team, Nirajn2311 and raisedadead January 9, 2023 10:23
@github-actions github-actions Bot added the platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. label Jan 9, 2023
@Sboonny Sboonny added the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Jan 9, 2023
@ghost

ghost commented Jan 9, 2023 •

Copy link
Copy Markdown

👀 Review this PR in a CodeSee Review Map

View the CodeSee Map of this change

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@raisedadead raisedadead left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, can you also add a test because you are fixing a regression?

@Sboonny

Sboonny commented Jan 9, 2023

Copy link
Copy Markdown
Member Author

Nope, the test would require creating a cypress test, and the time and the effort it would take me to create a cypress test is not worth it, somebody who have full access to cypress tools can do a better job than me.

I want to focus on UI-Component issue.

@raisedadead raisedadead left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One test is worth the time wasted in fixing a regression. Keeping this on hold for a quick test.

Is anyone on @freeCodeCamp/dev-team willing to take it up? I might beat you to it over the week.

Co-authored-by: Oliver Eyton-Williams <[email protected]>
@ojeytonwilliams

Copy link
Copy Markdown
Contributor

A Cypress test for this is probably overkill. All we really care about is the value of the theme prop that's passed to MonacoEditor in a few situations.

A jest test with a mocked MonacoEditor should be just fine.

@raisedadead

Copy link
Copy Markdown
Member

Agreed — We want to include tests every time we introduce regressions.

@Sboonny

Sboonny commented Jan 9, 2023 •

Copy link
Copy Markdown
Member Author

Needed tests

  1. When the user is logged in and have preferred-color-scheme set to dark, the editor theme shouldn't change to dark when their chosen theme isn't night.
  2. When the user isn't logged in and have preferred-color-scheme set to dark, the editor should change to dark.

@Sboonny Sboonny added status: blocked In a transient & temporary hold. and removed status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. labels Jan 9, 2023
@ojeytonwilliams

Copy link
Copy Markdown
Contributor

Thinking about it, this bug only exists because the logic governing which theme is used is duplicated. It is defined in both editor.tsx and default.tsx, but should only be defined once.

@Sboonny

Sboonny commented Jan 9, 2023

Copy link
Copy Markdown
Member Author

Is there a way to set theme value for not logged in user, without local storage?

@ojeytonwilliams

Copy link
Copy Markdown
Contributor

Only cookies, to my knowledge, and they're like local storage, but slightly worse (they're transmitted with the request, but there's nothing gained by doing so). Why do you ask?

@Sboonny

Sboonny commented Jan 9, 2023 •

Copy link
Copy Markdown
Member Author

The current state management ignores theme values, if the user isn't logged in. Edit: I may be missing something, but for it to not be duplicated, we use the prefered color scheme to set the theme value in the whole app, then that theme apply both default and editor files

@ojeytonwilliams

Copy link
Copy Markdown
Contributor

Throwing local storage into the mix complicates things, but fortunately we aren't using it yet, so we don't need to worry about it.

Anyways, isn't #48757 going to change this logic in a fairly fundamental way?

With that in mind @raisedadead how about we treat this as a hotfix and move the test requirement into #48757

@raisedadead

Copy link
Copy Markdown
Member

Sure, as long as it is not forgotten.

@ojeytonwilliams ojeytonwilliams mentioned this pull request Jan 9, 2023
4 tasks done
@Sboonny

Sboonny commented Jan 9, 2023

Copy link
Copy Markdown
Member Author

I will create issue and link system one to it

@ojeytonwilliams ojeytonwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This all LGTM 👍

@ojeytonwilliams
ojeytonwilliams enabled auto-merge (squash) January 9, 2023 19:05
@ojeytonwilliams
ojeytonwilliams merged commit d349e53 into freeCodeCamp:main Jan 9, 2023
@Sboonny
Sboonny deleted the feat/respect-user-color-scheme-in-editor branch January 25, 2023 11:33
@Sboonny Sboonny removed the status: blocked In a transient & temporary hold. label Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: learn UI side of the client application that needs familiarity with React, Gatsby etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor does not use the right theme

5 participants