-
Notifications
You must be signed in to change notification settings - Fork 969
Add compact bravery panel with Aphrodite #8990
Add compact bravery panel with Aphrodite #8990
Conversation
Closes #8954 Fixes #8953: Align 'Reload' text and icon Fixes #8952: Set opacity to FormDropdown's wrappers and their titles Fixes #8949: Rename 'general.blocked-count-badge' to 'shields.blocked-count-badge' Closes #5726: The bravery panel should be much wider Addresses #8913: Refactor braveryPanel.js with Aphrodite Addresses #7989: Refactor forms.less with Aphrodite ---- Replace display:flex with display:grid (grid makes it easier than flex to place elements) Reorganize styles - braveryPanelHeader - braveryPanelStats - braveryPanelBody - controlWrapper Based on Cezar's feedback - Replace '.braveryPanelBody li' with braveryPanelBodyList - Move data-l10n-id - Move 'large' inside SwitchControl - Create compactBraveryHeader and defaultBraveryPanelHeader Also: - BEM optimization - Introduce 'gridStyles' - Remove redundant divs and div wrappers from counters - Update tests Test plan 1. Run tests locally; npm run test -- --grep='Bravery Panel' 2. Open about:preferences#shields 3. Enable the compact panel option 4. Run manual tests described here: https://github.com/brave/browser-laptop/wiki/Manual-Tests#bravery-settings Test Plan 2: 1. Open about:preferences#shields 2. Make sure 'Display block count badge on shields button' works
Closes #8913 Also: - Add no-important to Aphrodite - Add shields settings to state.md - Remove .trackersBlockedStat which has not been used - Create BraveryPanelDropdown - Add BraveryPanelDropdown to about:styles Addresses #7321: Refactor switchControl - customWrapper - customTopText - customInfoButton Remove reduntant classNames by replacing cx with css (Note: some of the classNames were intentionally unchanged for readability) Test Plan 1: 1. Run tests locally; npm run test -- --grep='Bravery Panel' 2. Open about:preferences#shields 3. Enable the compact panel option 4. Run manual tests described here: https://github.com/brave/browser-laptop/wiki/Manual-Tests#bravery-settings Test Plan 2: 1. Open about:styles 2. Click "Dropdowns" 3. Make sure BraveryPanelDropdown is displayed
Related with #8986 - Reorganize const
On about:preferences#shields: If the option is off: If the option is on: Updated to this one with #9078. |
I must say that this looks amazing and I will most certainly use it 👍 |
@@ -37,6 +38,12 @@ class SettingDropdown extends ImmutableComponent { | |||
} | |||
} | |||
|
|||
class BraveryPanelDropdown extends ImmutableComponent { | |||
render () { | |||
return <FormDropdown data-isBraveryPanel='true' {...this.props} /> |
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.
I think if you just let data-isBraveryPanel
works. Above you're passing true
as a string, which would evaluate prop to true anyway, so would any other string. For example, data-isBraveryPanel='brave'
would be true as well.
You can double-check that if you pass data-isBraveryPanel={true}
which will evaluate to boolean. Standardjs will warn you saying that it is not necessary:
Value must be omitted for boolean attributes
I would just <FormDropdown data-isBraveryPanel {...this.props} />
.
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.
Fixed with 5670822
[css(styles.braveryPanel__stats__item_count_clickable)]: !!adsBlockedStat, | ||
[css(styles.braveryPanel__stats__item_count_disabled)]: !shieldsUp || adControl === 'allowAdsAndTracking', | ||
[css(gridStyles.row1col1)]: !compactBraveryPanel, | ||
[css(gridStyles.row1col1)]: compactBraveryPanel, |
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.
if gridStyles.row1col1
appear in both conditions then you could only [css(gridStyles.row1col1)]: true
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.
sure, I just missed that.
[css(gridStyles.row1col1)]: compactBraveryPanel, | ||
[css(styles.braveryPanel__stats__item_count_adsBlockedStat)]: true, | ||
[css(styles.braveryPanel__stats__item, styles.braveryPanel__stats__item_count)]: !compactBraveryPanel, | ||
[css(styles.braveryPanel_compact__stats__item_count)]: compactBraveryPanel |
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.
since all styles use Aphrodite we could make use of its recommended syntax as well:
className={css(
!!adsBlockedStat && styles.braveryPanel__stats__item_count_clickable,
(!shieldsUp || adControl === 'allowAdsAndTracking') && styles.braveryPanel__stats__item_count_disabled,
gridStyles.row1col1,
styles.braveryPanel__stats__item_count_adsBlockedStat,
!compactBraveryPanel && styles.braveryPanel__stats__item,
!compactBraveryPanel && styles.braveryPanel__stats__item_count,
compactBraveryPanel && styles.braveryPanel_compact__stats__item_count
)}
it may seem weird at first but it looks for the first assumption and only execute the latest if condition evaluates to true. condition && style
would write nothing if condition is false.
Same tip applies for next cases. Let me know if you need a hand rewriting it
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.
that's an example however. I would make (!shieldsUp || adControl === 'allowAdsAndTracking')
a variable for better readability and put styles that don't need conditionals (such as gridStyles.row1col1
) at first for the same reason.
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.
I have already tried ^^ once but don't you think it is hard to read? (well it is, at least for me..)
In this case I would stick to cx
for readability of classNames in BEM, still I'm fine with your suggestion too.
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.
that's an example however.
I'm going to try that and compare it with the current version.
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.
Fixed with 6b041ce
whiteSpace: 'nowrap', | ||
overflow: 'hidden' | ||
} | ||
const editGlobalMarginBottom = '.25rem' |
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.
I don't mind having relative units but curious why we have it?
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.
Since I set 1rem
to padding of braveryPanel_compact__body
and I wanted to set .25rem
as 25% of that padding. We know 1rem=16px, so it should be clear that .25rem=16px*25%
and .75rem=16px*75%
without doing math (no matter how easy it is in this case).
Using px
sometimes makes it hard to know how and why this value has been set so. that's why I prefer relative units for elements which I added by myself. I avoided converting the units of other elements which already have existed because we can trust the value.
}, | ||
row8col1: { | ||
gridRow: 8, | ||
gridColumn: 1 |
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.
grid ftw ++
right: '20px', | ||
userSelect: 'none', | ||
cursor: 'default', | ||
color: '#3B3B3B', |
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.
can we move it to global.js
and so other colors? you can copy browserButton way and create an object like:
braveryPanel: {
color: '#3B3B3B'
}
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.
Done with a237c9d
comments aside, changes look great and new look will please a lot of users. Can't wait to see this landing |
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.
Addressed feedbacks.
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 looks incredible ++
I would leave a comment but I think we have a lot of improvements here so I created #9016 to keep track of that. Will label as ready-for-merge
feel free to merge once squashed.
- Replace cx with css - Fix data-isBraveryPanel - Move color properties to global.js Also: - Add braveryPanel__stats__item_label_clickable - Add braveryPanel__stats__item_label_disabled - Remove globalStyles.color.statsGray It is no longer used: https://github.com/brave/browser-laptop/blob/b831100570616921b388ab4f79fc60b751616642/less/forms.less#L89
@cezaraugusto thanks! Let's discuss the follow ups there. |
Great job with this, @luixxiul! 😻 |
Closes #8954: Add compact bravery panel with Aphrodite
Closes #8913: Refactor braveryPanel with Aphrodite
Closes #5726: The bravery panel should be much wider
Fixes #8953: Align 'Reload' text and icon
Fixes #8952: Set opacity to FormDropdown's wrappers and their titles
Fixes #8949: Rename 'general.blocked-count-badge' to 'shields.blocked-count-badge'
Addresses #7989: Refactor forms.less with Aphrodite
Addresses #7321: Refactor switchControl
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test plan 1:
about:preferences#shields
Test Plan 2:
Test Plan 3:
Reviewer Checklist:
Tests