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
Change icon: overlaid button to background image #462
Conversation
b67e3e5
to
f8c64bc
Compare
// When generating a new mask, `newRelayAddressResponse` contains a mask object | ||
// with the `full_address` property. When selecting an existing mask, | ||
// however, it only has the properties `address` and `currentDomain`, but | ||
// `address` does contain the full address (i.e. including @mozmail.com): |
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 miss TypeScript :(
Added two more features based on PM feedback:
Edit: also fixed some issues with metrics events being sent twice. |
197d3fe
to
30b1e77
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.
This PR has been a long time coming! Thanks, @Vinnl (and @czlucius too!) We'll need to do some extensive testing across sites to confirm there's no major breakage, but this so less invasive from our current approach.
Approving with some nits/suggestions/questions!
One minor UI inconsistency to call-out:
The in-page menu has both rounded corners and a small tooltip pointing towards the input:
I called out in the code where I believe it would be set, if that helps?
const detectedInputs = email_detector_ruleset | ||
.against(domRoot) | ||
.get("email") | ||
.filter((node) => node.scoreFor("email") > 0.5) | ||
.map((node) => node.element); | ||
|
||
return typeEmailInputs.concat(detectedInputs); |
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.
Question: Why this re-write?
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.
It was a generator function, where that didn't add much value as far as I could see (checking the commit log), while making it hard to pass around the list of email inputs. And then the rest was to make sure I actually understood what was going on here, and writing it myself was a good way to do so :) But happy to change it back to for loops if you prefer, now that I know what's going on :)
src/js/other-websites/icon.js
Outdated
function intersectsRelayIcon( | ||
element, | ||
coords | ||
) { | ||
return element.clientWidth - coords.x <= 25 + 2 * getPaddingRight(element); | ||
} |
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.
Suggestion: Add comment here explaining the math
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.
Good callout. Updated for all such calculations: a628c53.
iframe.src = browser.runtime.getURL("inpage-panel.html"); | ||
iframe.style.position = "absolute"; | ||
iframe.style.width = `${RELAY_INPAGE_MENU_WIDTH}px`; | ||
iframe.style.maxWidth = `95vw`; |
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.
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.
Hmm crap, in my spike I added this icon inside the iframe. I'll have to do some rework to be able to add it here, since you can't add ::before
elements (or other children) to an iframe, so all the positioning will have to be redone to apply to a wrapper div. Hopefully I can find some time for that next week.
(Btw, this PR does already have rounded corners, and as far as I can see they're the same size -4px- as the current implementation?)
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.
OK, I've struggled with making this appear properly for a bit now (in particular, getting it to take up the right space and have a consistent size), and I can't seem to make it work. My proposal would be to go without the chevron for now - it's relatively clear that the icon is related to the icon, so I think not having it for now would be better than having the current buggy icon implementation. I'm going to ask QA to test this.
const onUnderlayClick = (_event) => { | ||
closeMenu(); | ||
}; | ||
underlay.addEventListener("click", onUnderlayClick); |
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.
Question/thought: Do we need any touchstart
support for the Android version of this add-on?
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 think so, as MDN mentions a bug in old Safari versions for click
events, implying that they're supposed to fire, and StackOverflow says so. But I'm not sure how to verify - do you know if there's an easy way to test .xpi
files on Firefox mobile?
src/js/other-websites/icon.js
Outdated
`, linear-gradient(to left, #f68fff ${ | ||
getPaddingRight(element) * 2 + 25 |
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.
Suggestion: Can you move #f68fff
to a variable at the top of the file? I feel like this is hidden/buried CSS in this file that we'd want to better surface.
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.
Extra suggestion: Move all/any CSS attributes to the top of the file.
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.
Moved all colors in 3722328. Not sure if there were additional properties you were thinking of? (Note that most styles are dynamically generated based on existing styles for a particular input element, so I can't just move them to the top as hardcoded strings.)
25b1581
to
3722328
Compare
febacc4
to
b7990b6
Compare
b7990b6
to
3722328
Compare
@maxxcrawford I added cbde420 that fixes an issue where the spinner would never stop in Chrome - the commit message should explain more. Could you review that too, please? With that, I think that this might be ready to go. |
cbde420
to
f9c73bf
Compare
With this method, we don't have to change the stacking order of the website, and thus should avoid a lot of issues where we break the website we're injecting in. It did require some extra work to stay accessible; we still inject a button that is visually hidden, but accessible to screen reader users and people who navigate using the keyboard. I've also modified the hover/focus state styling to make it easier. Note that I carried over the code in src/js/other-websites/icon.js from the experimental extension I prototyped this in, so the code style might be a little different from the rest of the codebase.
Whereas Firefox appears to unload the iframe when it is hidden, Chrome seems to preserve it. Unfortunately, our iframe contents currently assumes that it is unloaded (i.e. it only fetches data when it gets loaded, and never stops loading animations after inserting a mask), so when we kept the iframe in the DOM, that would cause issues in Chrome. Hence, this change ensures that the injected iframe gets destroyed whenever the menu is closed.
f9c73bf
to
e06c3ae
Compare
Rebased to clean up commits and resolve confilcts - specifically, I reapplied #499 in e06c3ae. There were also 056a91e#diff-6d657968b51497d6080c30b3704a5e0cbac32a4707fb358dd33955f628c5d192 and 9b31315#diff-59a5db4e9a139708113dc0d0e60807e300b556f19ce611a5ffaa4a764c83f14b, but as far as I could see those were concerned with setting a particular height for the in-page popup, which IIRC should get determined automatically after this PR. |
@Vinnl just checking if there's plans to merge this any time soon. Looks like you have this approved? Is there a timeline set for this? |
@hecerinc I moved to work on Monitor and handed this over to other folks, but it looks like they haven't gotten around to releasing it yet. I'll bug some folks again to see if we can get this released :) |
This PR fixes #22, #80, #227, #253, #360, #358, #394, #397, #400, #429, #447, #454, #497, #509.
(For anyone coming across this PR: we'll still need to do some extensive testing to make sure this doesn't break commonly-used websites, so please be patient — it may still take a while to land.)
New feature description
This applies a new method of injecting the Relay icon that I prototyped a while ago; a helpful description of this method can be found here, by @czlucius who independently landed on the same approach.
With this method, we don't have to change the stacking order of the website, and thus should avoid a lot of issues where we break the website we're injecting in. It did require some extra work to stay accessible; we still inject a button that is visually hidden, but accessible to screen reader users and people who navigate using the keyboard. I've also modified the hover/focus state styling to make it easier. Scrolling with the menu open is no longer possible; I can probably re-enable that with a re-positioning scroll listener, but I feel like the user experience is probably fine if you dismiss the menu first, and should be better for performance.
Note that I carried over the code in src/js/other-websites/icon.js from the experimental extension I prototyped this in, so the code style might be a little different from the rest of the codebase - the experimental extension had TypeScript and helpers I've to rip out.
Screenshot (if applicable)
Screencast.from.2023-01-27.11-26-42.webm
How to test
Visit websites with the Relay icon, and make sure that everything looks and works OK.
Checklist
/frontend/src/styles/tokens.scss
).