-
Notifications
You must be signed in to change notification settings - Fork 941
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
Implement Gradient background for NTP #14783
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mostly LGTM. I have one question though - could we get away without adding a new background type to the backend? Maybe instead of having separate UseSolidColorBackground
and UseGradientColorBackground
we could just have a UseColorBackground
which stores anything which can be assigned to background
in the CSS?
We could still have a separate gradient
and solid
section in the UI but they'd write to the same pref. What do you think?
Thinking about it we might even be able to set it to url('data:...')
but that might not work in WebUI.
It'd just reduce the number of branches we have to worry about here 😆
components/brave_new_tab_ui/stories/default/data/backgroundWallpaper.ts
Outdated
Show resolved
Hide resolved
* Reuse most of components used for Solid color background
63bf7a0
to
f6ba210
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we get away without adding a new background type to the backend?
Yeah, that sounds good! Let me try again :)
components/brave_new_tab_ui/stories/default/data/backgroundWallpaper.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ 👍🏼
One thing I'm concerned about storing css value into pref is if it could be a vulnerability for attackers to change NTP background or inject their css our NTP background - I know almost nothing about security, though. If so, we might have to keep the backend types as is, and store pref only when it's compliant with the format. |
Oh yeah, good call! I didn't think of that |
How about instead storing the index of the gradient in a fixed array, as a key? We can do the same for the background color. It seems strange to me to store the full code values in pref, which we can do simply because css is a dynamic language (sort of). Storing index would help with e.g. android and iOS using the same pref value. edit: or if we're worried about using indexes because we may want to insert new items in the middle, then assigning a key to each value, e.g.: const backgroundValues = {
red1: '#3C790B',
gradientA: 'linear-gradient(125.83deg, #392DD1 0%, #A91B78 99.09%)'
} I'm happy if you want to combine colors and gradients, or keep them separate, internally. |
Yeah, from my experience, when we store index of a preset, we have migration issue in case we change the preset(add, remove, reorder, etc ...). To give a name to each value and store the name sounds cool. I've used "https://colornamer.robertcooper.me/" once to name colors, I think we can use this this time too. |
Update: security team confirmed that it's okay as is. I'd like to refactor as @fallaciousreasoning suggested :) @petemill Please let me know if you think storing key instead of value is desirable. |
A Storybook has been deployed to preview UI for the latest push |
We don't have to keep both of them. They're not that diffrent.
@simonhong @fallaciousreasoning @petemill Merged two prefs and paths. Could you check this again, please? |
A Storybook has been deployed to preview UI for the latest push |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM
components/brave_new_tab_ui/containers/newTab/settings/backgroundImage.tsx
Outdated
Show resolved
Hide resolved
components/brave_new_tab_ui/containers/newTab/settings/backgroundImage.tsx
Outdated
Show resolved
Hide resolved
components/brave_new_tab_ui/containers/newTab/settings/backgroundImage.tsx
Outdated
Show resolved
Hide resolved
@@ -20,15 +20,18 @@ class GURL; | |||
|
|||
namespace ntp_background_images { | |||
|
|||
// TODO(sko) Rename this to NTPCustomBackgroundService. It's dealing with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: Upstream has that class already :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, dear.. Let me think about better name
A Storybook has been deployed to preview UI for the latest push |
Thank you all for reviewing this! It was really helpful, as always :) |
Verification PASSED on
1. Gradients
2. Solid colors
Regression on NTP
|
Resolves brave/brave-browser#24889
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: