Skip to content
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

fix: donation banner tweaks #7703

Merged
merged 12 commits into from
Dec 5, 2022

Conversation

sultanowski
Copy link
Contributor

@sultanowski sultanowski commented Nov 15, 2022

What

  1. Replace checkbox and text to [X] button.
  2. Better display on both mobile and desktop.
  3. Refactor of document.cookie code and placed it directly in donate_banner.tt.html file.
  4. Set the banner cookie time to 14 days.

Screenshot

https://imgur.com/a/3KPz3Ov

Related issue(s) and discussion

@sultanowski sultanowski requested a review from a team as a code owner November 15, 2022 21:31
@github-actions github-actions bot added CSS 🎁 donations Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. labels Nov 15, 2022
@sultanowski sultanowski changed the title fix: Added [x] button to donation banner, changed cookie JS and refac… fix: Donation banner. Nov 15, 2022
@sultanowski sultanowski marked this pull request as draft November 15, 2022 21:35
@sultanowski sultanowski changed the title fix: Donation banner. [wip] fix: Donation banner. Nov 15, 2022
@sultanowski sultanowski changed the title [wip] fix: Donation banner. fix: donation banner tweaks Nov 15, 2022
@sultanowski sultanowski marked this pull request as ready for review November 15, 2022 21:41
@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Nov 16, 2022
Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

@sultanowski really cool !

I tested it, it works for me.

I think there is code in Display.pm (line 7621) that should be cleaned up.

I wait for some suggestion resolutions to approve.

d.setTime(d.getTime() + (bcexdays*60*60*24*1000));
let expires = 'expires=' + d.toUTCString();
document.cookie = bcname + '=' + bcval + ';' + expires + ';path=/';
console.log(expires);
Copy link
Member

Choose a reason for hiding this comment

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

we should remove this :-)

Suggested change
console.log(expires);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, forgot about those! Thank you, I will remove it soon, also unused vars and logs.

Comment on lines 38 to 42
function deleteBannerCookie(bcname) {
d.setTime(d.getTime() + (60*60*24*1000));
let expires = 'expires=' + d.toUTCString();
document.cookie = bcname + '=;' + expires + ';path=/';
}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this, and not only call setBannerCookie ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's like a double-check for me - cleans the cookie value and set expire for current time, if you feel like it is not really important I can test the code without it.

Copy link
Member

Choose a reason for hiding this comment

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

ok, it's ok if we keep it, but maybe a comment to explain is good :-)


<script>
let d = new Date();
let expires = 'expires=' + d.toUTCString();
Copy link
Member

Choose a reason for hiding this comment

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

it seems we don't need this any-more ?

let d = new Date();
let expires = 'expires=' + d.toUTCString();
let bannerID = document.getElementById('donate-banner');
let bcval = "1";
Copy link
Member

Choose a reason for hiding this comment

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

it seems we don't need this any-more ?


function DonationButton() {
deleteBannerCookie('off-donation-banner');
setBannerCookie('off-donation-banner', 1, 14);
Copy link
Member

Choose a reason for hiding this comment

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

I seems to me 14 days is not enough, it's a bit pushy to users.

If I donate, I would expect this not to show up again for at least 180 days !

If possible, I would set it on whole openfoodfacts.xx subdomain (not only for eg. world) (that is you can set domain to the last two components of domain).

@teolemon what is your though ?

@stephanegigandet
Copy link
Contributor

On mobile, the banner is now more a full screen banner than a banner:

after:
image

before:
image

And if we remove the message to close the box, and put the cross instead we would get a smaller banner:

image

@stephanegigandet
Copy link
Contributor

And on wide screen, we lose the max width that we had before, which makes the text hard to read on a very long line.

after:
image

before:
image

It's certainly a personal test, but I prefer the behaviour we had before for mobile and desktop.

Would it be possible to have a behaviour more like we had before, but with the new "Close" mark you added?

@stephanegigandet
Copy link
Contributor

Note that yesterday we added a 2nd donation box (identical except that it cannot be closed) at the bottom of the page, so unfortunately it's causing some conflicts.

@sultanowski
Copy link
Contributor Author

Pushed cosmetic changes mentioned in this discussion, banner is slightly smaller than the actual one. What should I do to resolve this conflict? I didn't pulled to this branch during development and I don't want to merge it with main - that might be even worse I think.

@alexgarel
Copy link
Member

@sultanowski the best would be to sync main branch on your project, update main locally, switch to your branch, then use "rebase main" (read some tutorial, it's a good command to master). Then you have to "git push --force".

@sultanowski
Copy link
Contributor Author

@alexgarel I found solution to apply a cookie for all subdomains and all possible versions (.org, .net, etc.) now I am going to rebase and update this branch.

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

Thank you !
@sultanowski still a small problem and we are done :-)

templates/web/common/includes/donate_banner.tt.html Outdated Show resolved Hide resolved
@github-actions github-actions bot added the product history We have kept 10 years of product revisions. This is useful to monitor edits & product improvements label Nov 29, 2022
@sultanowski sultanowski marked this pull request as draft November 29, 2022 18:56
@github-actions github-actions bot added 💥 Merge Conflicts 💥 Merge Conflicts and removed 💥 Merge Conflicts 💥 Merge Conflicts labels Nov 30, 2022
@sonarcloud
Copy link

sonarcloud bot commented Dec 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sultanowski
Copy link
Contributor Author

What I've done in small summary:

  • Delete donate_banner_bottom.tt.html file and create new instance of it inside donate_banner.tt.html file.
  • Replace long checkbox with label to graphical [x] button.
  • Banner's cookie should work with every type of open...facts page. Now URL is dynamically taken from client's URL and it apply on close button click.
  • Fix max-width of donation-banner content, so now it works like previously on wide screens.
  • Reduce margins and paddings to make donation banner compact in size.
  • Clean-up of Display.pm file and delete unused cookie jQuery function.

@sultanowski sultanowski marked this pull request as ready for review December 5, 2022 12:59
@github-actions github-actions bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Dec 5, 2022
@alexgarel
Copy link
Member

Fine @sultanowski, thank you so much for your dedication !

I think we could improve styling because the banner is a bit deported on the right because of the "hand-heart" icon on the right… but that would be for another PR :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Display 🎁 donations product history We have kept 10 years of product revisions. This is useful to monitor edits & product improvements Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants