-
Notifications
You must be signed in to change notification settings - Fork 113
feat (systemaddon): #2944 add tippy top icons #3049
Conversation
We still need to cut a limited tippy top release but that can be done as a quick followup. r? @Mardak and/or @jaredkerim and/or ? |
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.
Looks like things are working fine. Just a bunch of various nits
} | ||
{!showScreenshot && | ||
<div className="tippy-top-icon" style={style} /> | ||
} |
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 like it could just be maybe <div className={imageClassName} style={imageStyle} />
and unconditionally render that.
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.
Or… we could be even fancier :p ?
<div {...imageAttributes} />
@@ -43,12 +43,24 @@ class TopSite extends React.Component { | |||
const title = link.pinTitle || shortURL(link); | |||
const screenshotClassName = `screenshot${link.screenshot ? " active" : ""}`; | |||
const topSiteOuterClassName = `top-site-outer${isContextMenuOpen ? " active" : ""}`; | |||
const style = {backgroundImage: (link.screenshot ? `url(${link.screenshot})` : "none")}; | |||
const tippyTopIcon = link.tippyTopIcon; | |||
const showScreenshot = !tippyTopIcon; |
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.
nit: just make this const {tippyTopIcon} = link;
const style = {backgroundImage: (link.screenshot ? `url(${link.screenshot})` : "none")}; | ||
const tippyTopIcon = link.tippyTopIcon; | ||
const showScreenshot = !tippyTopIcon; | ||
let style; |
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 we're going to have a imageClassName
then let's make this imageStyle
.
if (showScreenshot) { | ||
style = {backgroundImage: (link.screenshot ? `url(${link.screenshot})` : "none")}; | ||
} else { | ||
style = {backgroundImage: `url(${tippyTopIcon})`, backgroundColor: link.backgroundColor || "none"}; |
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.
nit: let's split this latter object (with 2 keys) onto multiple lines. And just make the condition
if (tippyTopIcon) {
imageClassName = "tippy-top-icon";
imageStyle = {
backgroundColor: …,
backgroundImage: …
};
} else {
imageClassName = `screenshot${link.screenshot ? " active" : ""}`; // can get rid of the const screenshotClassName
imageStyle = {backgroundImage: …}
}
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 turned out nice like that 👍
// Load the Tippy Top sites from the json manifest. | ||
fetch(TIPPYTOP_JSON_PATH) | ||
.then(response => response.json()) | ||
.then(sites => { |
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.
These should be await
s given that we're inside an async
function
try {
for (const site of await (await fetch(PATH)).json()) {
…
} catch(error) …
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.
Do I need to stub it out differently in tests to do this? I can't get them to work now for some 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.
oops nvm. there waz a typo
for (let link of links) { | ||
if (!link) { continue; } | ||
|
||
// Check for tippy top icon. | ||
link = this._tippyTopProvider.processSite(link); |
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.
So, this seems like it could fail or give wrong results if TippyTopProvider
hasn't finished adding to _sitesByDomain
. I would guess the correct fix is to make processSite
async
. But we can skip this for now.
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.
Yeah, figured it should just should just move on if it isn't fully init'd instead of waiting. I guess we would want to dispatch an action when init is done to refresh again. Maybe there should be a tippy top feed like you suggested 🤔
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.
Well, Provider doesn't have the usual dispatch, but it async init returns a promise that TopSitesFeed could use to have refresh wait until Provider is init
ed . E.g.,
TopSitesFeed {
constructor() {
const provider = new TippyTopProvider();
this._initedProvider = provider.init(); // init needs to resolve the provider
}
async refresh() {
…
(await this._initedProvider).processSite(link);
This can be separately handled as a followup as I expect the tests would need to change a bit.
Also, it wouldn't allow for the "just move on" if that's desired.
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.
cool, I'll look into that after doing the tippy top release for default sites
@@ -22,8 +23,11 @@ const DEFAULT_TOP_SITES = []; | |||
this.TopSitesFeed = class TopSitesFeed { | |||
constructor() { | |||
this.lastUpdated = 0; | |||
this._tippyTopProvider = new TippyTopProvider(); |
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.
@k88hudson any thoughts on having this TippyTopProvider
vs a TippyTopFeed
? If we do want a feed, we should just refactor it later. I could see the feed dispatching a mapping of domains to urls, but then again, would we want all that data going to stores and the content process?
yamscripts.yml
Outdated
|
||
copyTippyTopManifest: cpx "node_modules/tippy-top-sites/top_sites.json" system-addon/data/content/tippytop | ||
|
||
copyTippyTopImages: cpx "node_modules/tippy-top-sites/images/**/*" system-addon/data/content/tippytop/images |
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.
nit: this seems better organized as
tippymc:
pre: rimraf …
manifest: cpx …
images: cpx …
yamscripts.yml
Outdated
# buildmc: Export the bootstraped add-on to mozilla central | ||
buildmc: | ||
pre: rimraf ../mozilla-central/browser/extensions/activity-stream | ||
pre: =>cleanmc && =>cleanTippyTop && =>copyTippyTopManifest && =>copyTippyTopImages |
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.
then this would just be => cleanmc && => tippymc
} | ||
if ("urls" in site) { | ||
for (let url of site.urls) { | ||
this._sitesByDomain[getDomain(url)] = site; |
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.
nit: This seems a bit awkward with the repetition. Maybe
for (const url of site.url ? [site.url] : site.urls || []) {
this._sitesByDomain.set(getDomain(url), site);
Or maybe that's just too clever :p It would want a comment ;) Also not quite exactly the same logic as it doesn't allow for both url
and urls
to exist..
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 kind of likey 😉
system-addon/lib/TopSitesFeed.jsm
Outdated
} | ||
init() { | ||
this._tippyTopProvider.init(); |
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.
Sorry for the conflict with removing TopSitesFeed.init
Maybe just call this just after constructing it from TopSitesFeed.constructor
?
f0de704
to
5aae927
Compare
Fixes #2944