forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1699515 - Switching to react for Save to Pocket panels. r=gvn
Differential Revision: https://phabricator.services.mozilla.com/D128753
- Loading branch information
1 parent
f596f45
commit 2077e6e
Showing
25 changed files
with
1,931 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
module.exports = { | ||
plugins: [ | ||
"react", // require("eslint-plugin-react") | ||
], | ||
settings: { | ||
react: { | ||
version: "17.0.2", | ||
}, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["content/**/*.js", "content/**/*.jsx"], | ||
parserOptions: { | ||
sourceType: "module", | ||
}, | ||
}, | ||
], | ||
rules: { | ||
"react/jsx-uses-react": 2, | ||
"react/jsx-uses-vars": 2, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
12.22.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Pocket Integration | ||
|
||
This is mostly everything related to Pocket in the browser. There are a few exceptions, like newtab, some reader mode integration, and some JSWindowActors, that live in other places. | ||
|
||
Primarily though this directory includes code for setting up the save to Pocket button, setting up the panels that are used once the Pocket button is clicked, setting up the Pocket context menu item, and a little scaffolding for the reader mode Pocket integration. | ||
|
||
## Basic Code Structure | ||
|
||
We have three primary areas code wise. | ||
|
||
There are some JSMs that handle communication with the browser. This includes some telemetry, some API functions usable by other parts of the browser, like newtab, and some initialization and setup code. These files live in `/content` | ||
|
||
There is also some standard js, html, and css that run inside the panels. Panels are the contents inside the drop downs if you click the save to Pocket button. Panels run in their own browser process, and have their own js. This js also has a build/bundle step. These files live in `/content/panels`. We have three panels. There is a sign up panel that is displayed if you click the save to Pocket button while not signed in. There is a saved panel, if you click the save to Pocket button while signed in, and on a page that is savable. Finally there is a home panel, if you click the save to Pocket button while signed in, on a page that is not savable, like about:home. | ||
|
||
## Build Panels | ||
|
||
We use webpack and node to build the panel bundle. So if you change anything in `/content/panels/js` or `/content/panels/css`, you probably need to build the bundle. | ||
|
||
The build step makes changes to the bundle files, that need to be included in your patch. | ||
|
||
### Prerequisites | ||
|
||
You need node.js installed, and a working local build of Firefox. The current or active version of node is probably fine. At the time of this writing, node version 14 and up is active, and is recommended. | ||
|
||
### How to Build | ||
|
||
From `/browser/components/pocket` | ||
|
||
If you're making a patch that's ready for review: | ||
run `npm install` | ||
then `npm run build` | ||
|
||
For active development instead of `npm run build` use `npm run watch`, which should update bundles as you work. | ||
|
||
## React and JSX | ||
|
||
We use React and JSX for most of the panel html and js. You can find the React components in `/content/panels/js/components`. | ||
|
||
We are trying to keep the React implementation and dependencies as small as possible. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
browser/components/pocket/content/panels/js/components/PopularTopics.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import React from "react"; | ||
|
||
function PopularTopics(props) { | ||
return ( | ||
<> | ||
<h3 data-l10n-id="pocket-panel-home-explore-popular-topics"></h3> | ||
<ul> | ||
{props.topics.map(item => ( | ||
<li key={`item-${item.topic}`}> | ||
<a | ||
className="pkt_ext_topic" | ||
href={`https://${props.pockethost}/explore/${item.topic}?utm_source=${props.utmsource}`} | ||
> | ||
{item.title} | ||
<span className="pkt_ext_chevron_right"></span> | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
<a | ||
className="pkt_ext_discover" | ||
href={`https://${props.pockethost}/explore?utm_source=${props.utmsource}`} | ||
data-l10n-id="pocket-panel-home-discover-more" | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
export default PopularTopics; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* global PKT_PANEL:false */ | ||
|
||
function onDOMLoaded() { | ||
if (!window.thePKT_PANEL) { | ||
var thePKT_PANEL = new PKT_PANEL(); | ||
/* global thePKT_PANEL */ | ||
window.thePKT_PANEL = thePKT_PANEL; | ||
thePKT_PANEL.initHome(); | ||
} | ||
window.thePKT_PANEL.create(); | ||
} | ||
|
||
if (document.readyState != `loading`) { | ||
onDOMLoaded(); | ||
} else { | ||
document.addEventListener(`DOMContentLoaded`, onDOMLoaded); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
browser/components/pocket/content/panels/js/main.bundle.js.LICENSE.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
object-assign | ||
(c) Sindre Sorhus | ||
@license MIT | ||
*/ | ||
|
||
/** @license React v0.20.2 | ||
* scheduler.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** @license React v17.0.2 | ||
* react-dom.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** @license React v17.0.2 | ||
* react.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.