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

Porting electron-api-demos to Electron Fiddle examples in docs #20442

Closed
38 of 50 tasks
erickzhao opened this issue Oct 5, 2019 · 21 comments
Closed
38 of 50 tasks

Porting electron-api-demos to Electron Fiddle examples in docs #20442

erickzhao opened this issue Oct 5, 2019 · 21 comments

Comments

@erickzhao
Copy link
Member

erickzhao commented Oct 5, 2019

Context

This meta-issue addresses a need to bridge the gap between our website's online docs, electron-api-demos, and Electron Fiddle.

  • What's electron-api-demos?

    As the name indicates, electron-api-demos` is a collection of examples for Electron APIs wrapped in an application. Each demo contains a executable example of the API along with sample code and additional explanations.

  • What's Electron Fiddle?

    Electron Fiddle is a code playground allowing developers to tinker around with small experiments that can later be exported into full-fledged Electron applications. The interface allows users to create and run small Electron apps with a single main.js, renderer.js, and index.html.

  • Motivation
    • Although collecting runnable API demos is nice, having the sample code gated behind an application increases friction, and maintaining the app in its current state for more than 1 release line is difficult.
    • Having the code available online makes it easier to find and more accessible to read, but having to manually launch
    • Porting over electron-api-demos into Fiddle-friendly examples is a big step into ultimately having API code samples available in the docs as runnable Fiddles.
  • Current Progress

Task

We will be attempting to port over all of the electron-api-demos examples in the codebase. For context on how API demos are structured, see the docs here.

The task is to ultimately convert each demo into an Electron Fiddle sample that's equivalent in functionality. Please include the explanatory text from the HTML files as well. Note that many of these demos are tightly coupled in logic, and a single PR can be submitted for multiple demos within a Section.

The easiest way to do so is to pick an example in electron-api-demos, recreate the example in Electron Fiddle (using the electron-api-demo source code as a starting point), save the Fiddle locally into a folder, and move that example into /docs/fiddles/[CATEGORY]/[SECTION]/[DEMO].

Example Fiddle

See the following PR for an example of this task (Asynchronous Messages demo): #20441

Code style

Code should follow the StandardJS style guidelines. To format your code, run the following snippet in your directory.

    npm install -g standard # if you don't have it installed
    cd YOUR_FIDDLE_IN_DOCS_FOLDER
    standard --fix

Folder structure

Add the contents of your Fiddle (main.js, renderer.js , and index.html but not package.json) into a new /docs/fiddles/[CATEGORY]/[SECTION]/[DEMO] folder in your fork of electron/electron

For a handy graph on what category/section/demo mean:

PR requirements

  • PR is merging into master branch.
  • File structure adheres to the requirements above.
  • Code in PR runs successfully in Electron Fiddle with the latest release of Electron 6.
  • Code in PR passes a linting check with Standard.

Assignees

Since this is a meta-issue that will require many PRs from contributors, we will attempt to proceed in a first-come-first-serve fashion. Examples will be marked as claimed as soon as a PR is opened for them.

In the interest of focusing on getting each PR reviewed and merged, please only open one PR at a time before opening another.

List of Demos


@97amarnathk
Copy link
Contributor

I would like to work on this. Can this be assigned to me?

@erickzhao
Copy link
Member Author

I would like to work on this. Can this be assigned to me?

@97amarnathk Feel free to submit a PR for any demo (see #20441 for an example). I'll keep the meta-issue with assignees as the PRs flow in.

@97amarnathk
Copy link
Contributor

@erickzhao Where do I find the HTML files related to synchronous communication?

@erickzhao
Copy link
Member Author

@erickzhao Where do I find the HTML files related to synchronous communication?

@97amarnathk You can find all relevant HTML files included in the sections folder of electron-api-demos. For the case of synchronous communications, find the file under sections/communications/ipc.html.

For more info on how electron-api-demos is structured, see this design doc: https://github.com/electron/electron-api-demos/blob/master/docs.md

@97amarnathk
Copy link
Contributor

@erickzhao I have submitted #20451 for Synchronous Messages.

@yashints
Copy link
Contributor

yashints commented Oct 8, 2019

Hey @erickzhao, had a question for you. I am working on adding the manage window section in which the renderer is referencing a local html file by path (modal.html). I can't add additional files to Fiddle to be referenced. What's the workaround?

@wedob13
Copy link
Contributor

wedob13 commented Oct 8, 2019

@erickzhao I have submitted #20480 for 'Create a new Window' i can grab another one as soon as this pull gets merged.

Thanks for checking it out :)

@97amarnathk
Copy link
Contributor

@erickzhao I added a PR for getting app info.
#20487

This was referenced Oct 9, 2019
@harryi3t
Copy link

harryi3t commented Oct 9, 2019

@ericbrumer Raised PR for context menu
#20506

Also, didn't find any view demo button for application menu, it's just static code. Wanted to cover that too in the same PR 🙂
image

@yashints
Copy link
Contributor

yashints commented Oct 9, 2019

@ericbrumer Raised PR for context menu
#20506

Also, didn't find any view demo button for application menu, it's just static code. Wanted to cover that too in the same PR 🙂
image

Hmmm 👉🏼#20468

@harryi3t
Copy link

Hey @yashints,
Sorry didn't see that there was already a PR. The description said that the items would be checked off when someone raises a PR for them

Examples will be marked as claimed as soon as a PR is opened for them.

I will close my PR and I guess I would have to go through all the linked PRs to get an idea of what's already taken.

@erickzhao
Copy link
Member Author

Sorry for the confusion, will update the list ASAP and get to reviewing some PRs today :)

@97amarnathk
Copy link
Contributor

@erickzhao , I provided a PR for app information and not clipboard. Could you update the Issue description accordingly?

@yashints
Copy link
Contributor

@erickzhao I need to find out how to include assets (icons, templates, etc) in Fiddle examples, any hints?

@erickzhao
Copy link
Member Author

erickzhao commented Oct 10, 2019

I need to find out how to include assets (icons, templates, etc) in Fiddle examples, any hints?

@yashints Previous patterns simply generated the image from the Data URL

See: https://github.com/electron/fiddle/blob/master/static/show-me/tray/main.js

@yashints
Copy link
Contributor

Thanks, what about html templates? like modals

@erickzhao
Copy link
Member Author

erickzhao commented Oct 10, 2019

@yashints I talked about this a bit in the Create Window PR, but as a solution, loading an external URL (e.g. https://electronjs.org) could be a standby for loading an HTML partial.

@yashints
Copy link
Contributor

NP, I will create my PR with an external link then

codebytere pushed a commit that referenced this issue Oct 15, 2019
Refs #20442

Adds the basic notification and notification with custom image examples from electron-api-demos into runnable Fiddle examples.

Gist links to Fiddles (same as code submitted in this PR):
Basic Notification: https://gist.github.com/102945f83f559e7944797175d8fd8af4
Notification with image: https://gist.github.com/2688bf4bfc27ce02f5d74224828eb928

Co-Authored-By: Erick Zhao <erick@hotmail.ca>
@wedob13
Copy link
Contributor

wedob13 commented Oct 24, 2019

@erickzhao is it okay if i get started on another pull or should i wait for my previous one to be reviewed?

@erickzhao
Copy link
Member Author

@wedob13 I'd say to go for it! I've been lagging behind on reviewing the PRs lately.

@erickzhao erickzhao changed the title [Hacktoberfest] Porting electron-api-demos to Electron Fiddle examples in docs Porting electron-api-demos to Electron Fiddle examples in docs Nov 2, 2019
zcbenz pushed a commit that referenced this issue Nov 13, 2019
zcbenz pushed a commit that referenced this issue Nov 13, 2019
…her app, including all 3 files main.js, index.html, renderer.js (#20718)
@MarshallOfSound MarshallOfSound unpinned this issue Dec 5, 2019
@erickzhao
Copy link
Member Author

This is pretty much done in 2022 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants