Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Make use of base64 for contributionStatement img #8107

Merged
merged 1 commit into from
Apr 7, 2017
Merged

Make use of base64 for contributionStatement img #8107

merged 1 commit into from
Apr 7, 2017

Conversation

cezaraugusto
Copy link
Contributor

@cezaraugusto cezaraugusto commented Apr 6, 2017

Fix #8062
Auditors: @luixxiul, @willy-b

Note: We still can't make use of external files to append images on contributionStatement if we want to save it.

After component refactor to Aphrodite (#7887) LESS file with hard-coded image string was removed and I missed that case while merging by removing hard-coded string from refactor.

This PR makes use of getBase64FromImageUrl method to solve the issue and avoid hardcoding base64 strings, which could have made style edits harder.

You can follow convo here: #7887 (comment)

Test plan:

  • Make sure Brave logo and verified icon are base64 strings (devTools -> inspect element)
  • Make sure that while saving contributionStatement both Brave logo and verified icon are always shown, even on PDF preview and saved document.

@cezaraugusto cezaraugusto added this to the 0.14.2 milestone Apr 6, 2017
@cezaraugusto cezaraugusto self-assigned this Apr 6, 2017
@cezaraugusto cezaraugusto requested review from luixxiul and willy-b April 6, 2017 23:02
Copy link
Contributor

@willy-b willy-b left a comment

Choose a reason for hiding this comment

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

tested, lgtm!

@@ -160,10 +174,19 @@ class ContributionStatement extends ImmutableComponent {
}

get ContributionStatementHeader () {
const imgStyle = StyleSheet.create({
Copy link
Contributor

Choose a reason for hiding this comment

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

curious: why separate the brave logo style here rather than keeping it with the other styles as before (styles.braveLogo)?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. If we will do so, why won't we do that for all files in a lump to avoid inconsistency? @cezaraugusto would you mind opening an issue to track that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

method to transform image to base64 is a thenable, so I had to pass result to a state, and styles is not bound to the component, so I can't call this.state there. That's why I had to create a separate stylesheet for each image

@@ -285,6 +308,17 @@ class ContributionStatement extends ImmutableComponent {
}

ContributionStatementDetailTable (page, pageIdx, totalPages) {
const imgStyle = StyleSheet.create({
Copy link
Contributor

Choose a reason for hiding this comment

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

same question as above: why not keep this style with the others as before (styles.verified) rather than creating it here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pls see comment above

const braveLogo = require('../../app/extensions/brave/img/braveAbout.png')
const verifiedIcon = require('../../app/extensions/brave/img/ledger/verified_green_icon.svg')

class ContributionStatement extends React.Component {
Copy link
Contributor

Choose a reason for hiding this comment

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

why switch from ImmutableComponent to React.Component?

Copy link
Member

Choose a reason for hiding this comment

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

@willy-b looks like this is now using React's setState(). Our ImmutableComponent wrapper will only trigger a re-render if properties are updated (not state). Changing this forces the setState() to re-render

Copy link
Member

Choose a reason for hiding this comment

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

Overall, we want to avoid React.Component in favor of ImmutableComponent... but About pages are a little different. We tend to need to keep state, because of how data gets transferred to it (see Frame.js)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't manipulate component-level state without using actions/stores with Immutable. Creating an action/store for that is overkill. Since we're on an about:page there's no big deal to use React.Component

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. Thanks!

@bsclifton
Copy link
Member

Merging! if we to update based on feedback by @luixxiul or @willy-b, let's do in a follow up. Thanks 😄

@bsclifton bsclifton merged commit a8f0334 into brave:master Apr 7, 2017
@cezaraugusto cezaraugusto deleted the hotfix/7887 branch April 7, 2017 17:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants