Giter Site home page Giter Site logo

electron-api-demos's Introduction

Electron API Demos icon Electron API Demos

Build Status JavaScript Standard Style

This is a desktop app that interactively and with sample code demonstrates core features of the Electron API. It's built with Electron, too, of course. This app works on Windows, macOS and Linux operating systems.

Use this app to see what you can do with Electron and use the source code to learn how to create a basic Electron app.

Electron API Demos Screenshots


This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].

Follow @ElectronJS on Twitter for important announcements. Visit the electron website.

Using

You can download the latest release for your operating system or build it yourself (see below).

Building

You'll need Node.js installed on your computer in order to build this app.

$ git clone https://github.com/electron/electron-api-demos
$ cd electron-api-demos
$ npm install
$ npm start

If you don't wish to clone, you can download the source code.

For easier developing you can launch the app in fullscreen with DevTools open:

$ npm run dev

Extending

Read the docs to learn more about how this app is built or how to add a new demo.

Translations

Note: these versions are maintained by outside contributors and may not always be in sync with this version.

electron-api-demos's People

Contributors

andypavia avatar benjiko99 avatar binarymuse avatar builder-machine avatar cherniavskii avatar ckerr avatar codebytere avatar demopark avatar dependabot[bot] avatar ergenekonyigit avatar haacked avatar jlord avatar kevinsawicki avatar kilian avatar lee-dohm avatar maarekj avatar malept avatar marshallofsound avatar matjaz avatar ms10596 avatar muan avatar nathanbuchar avatar pd4d10 avatar saraford avatar simonkaspersen avatar simurai avatar stve avatar teameh avatar trott avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

electron-api-demos's Issues

Quality Control Check List

Various things to not forget about:

  • new ipc modules
  • standardize on => (nah)
  • add ;s
  • testing branch
  • templating not doing because of scale
  • be consistent with render vs renderer

Development To Do List

These are development tasks to be done in the app:

  • complete tests
  • Build out each section with copy and working demos:
    • Communication
      • Async
      • Sync
    • Menus
      • Context Menu
      • Application Menu
    • Native UI
      • External Links and File Manager
        • External Links
        • File Manager
      • Dialogs
        • Open File
        • Info
        • Alert
        • Save
      • Tray
        • Tray
    • Printing
      • PDF
    • System
      • App and System Information
      • Clipboard
    • Windows
      • Create Window
      • Window State
  • Make app less website-y
    • Style of links/click behavior #17
    • Load page content so there is no flash of white
  • Design Refinement #23
  • Language/Copy Refinement #7
  • Vendor script tags currently using CDN
  • Pro tip about how much time a sync ipc call takes and to avoid them
  • New icon for tray
  • Button event listener code in one place
  • Check platform compatibility of each example
  • Add main/render process tag for each
  • Sign app
  • Hook up Travis
  • Docs! #37
  • Move to electron

Windows icon

I've packaged it up and tried it out on Windows and the icon looks great except for in the bottom toolbar (what is that called?) it seems a little pixelated. I opened up Atom to compare and it definitely looks crisper.

Looking greatβ€”

windowsicon copy

APIs that don't have demos yet

This list is an attempt to gather all the APIs listed at https://github.com/atom/electron/tree/master/docs/api that don't yet have a corresponding demo:

In Process

  • accelerator (keyboard shortcuts)
  • global-shortcut
    • 🚧 We could set a global shortcut to the menu item we create for the menu demo?

Hard to demo or wouldn't be very valuable.

Done

Perhaps we should filter and prioritize this list, then get to as many as we can in time for the 1.0 launch.

OS Menu Item Naming Conventions

I was thinking of having a pro tip on the menus page about different naming conventions for menu items on different OSes. Like Preferences : Settings for OS X : Win.

Our docs have some OS X tips but not a table like this so I'm trying to pick y'alls brains:

β€”Are there enough of these to warrant a pro-tip?
β€”If there are enough, what are they?
β€”If not this as a pro tip, any other menu pro tip ideas?

/cc @kevinsawicki @zcbenz and @amytruong because you visit Windowsland.

screen shot 2016-01-28 at 5 09 20 pm

New App icon?

Hey.. I'm still not too happy with the app icon. There isn't a big connection to the app itself. And the dark green doesn't look that friendly.. so how about this:

screen shot 2016-03-12 at 9 55 33 pm

It's made of the 6 colors used for the sections and similar to the About graphic.

Support auto-updates before 1.0 launch

@jlord pointed out that once we open-source this app, we'll likely be getting contributions from the community. It would be aweome if the demo app we release on launch day is able to update itself automatically, so anyone who has ever downloaded it will always have an up-to-date version.

@kevinsawicki we would need your help on this one!

Language

I'm going to jot down notes here of questions around language and phrasing that I have as I'm going through this.

  • You can create : Create
  • your app : an app
  • native : operating system (in re: to readability for beginners)
  • renderer

Turn ProTipsβ„’ into regular tasks

On our 1:1 call today, @jlord and I decided to do away with the pro-tips in the app, and instead use "tasks" for everything. This will make the UI less busy and the codebase more consistent.

The extant tips, as of today:

  • run background tasks
  • OS menu differences
  • open outbound links externally
  • sheet dialog for os x
  • tray support in linux
  • Find versions of Chromium Node.js V8
  • Use a print stylesheet

Pairing with the Quick Start App

What are the ways we can give the Quick Start App more ⨫ synergy ⨬ with the Demo App?

(many of these changes will happen in the quick start app but since that one is open/public right now I felt it better to talk it through over here)

  • Add comments to code like / place your main process code here
  • Link to a starter render process js file from index.html

Windows

I'm starting to test out the app in Windows (8) and will keep track of bugs here:

  • Print to PDF fails
  • Open file manager does nothing with no errors
  • Font isn't rendered in window demo
  • Move window demo just flickers

Windows Screenshot

electron-demo-2

Text Pileup on Section Change

On master when I click to change sections in the sidebar I'm getting this text pileup:

I think the gif removes some frames which makes it appear like it doesn't happen at every click, but it does.

text-pileup

cc @simurai

Terminology

@jlord and I just had a quick call to give formal names to various parts of the app's UI hierarchy. We ended up with Category > Section > Demo. This is not currently reflected in HTML and CSS class names, but maybe we can gradually move towards it as we continue developing.

screen shot 2016-04-01 at 12 20 58 pm

Cookbook!

@simurai and I chatted today about keeping this app away from pure documentation styles, to make it more of a story, more about... recipes.

He shared this cookbook that he worked on previously which is similar. It shares examples for how to do x, y, z.

I like this though I think the word "cookbook" feels odd paired with "Electron" and isn't commonly used enough that people would get it. But maybe there is a science-y, space-y word that is similar that would work better?

  • blueprint
  • formula
  • mode
  • procedure
  • manual (!?)

CSS Normalizing for Electron Demo App (and Beyond)

We talked (at mini-summit) about potentially creating CSS that Electron app builders could include in order to give them a starting point for making their Electron app feel more native and not website-y.

I'd like to do at least some level of this for the demo app (it could later be expanded on and moved into its own repo to accomplish ☝️). It would be awesome to 🍐 some with you @simurai on this. Do you have time in the next couple of weeks to work on this?

External Links Style

@simurai how do you feel about using a small octicon along side external links to signal that they are external? I think I like it, but I defer to you!

screen shot 2016-02-24 at 3 37 36 pm

I have a quick mock up of it on exlinks branch.

Accessibility

Before we launch lets cover the bases with accessibility to set a good example and to help us better document anything we come across during the process.

Self-assigning but happy to 🍐 I'll be pinging @maun a lot on this πŸ˜„

Write main process code as you would in a normal app

In order to automate the runtime setup of this demo, each demo's main process code is wrapped in a module.exports function:

var ipc = require('electron').ipcMain
var dialog = require('electron').dialog

module.exports.setup = function () {
  ipc.on('open-error-dialog', function (event) {
    dialog.showErrorBox('An Error Message', 'Demonstrating an error message.')
  })
}

Then each file is required and its function invoked:

// Require and setup each JS file in the main-process dir
glob(__dirname + '/main-process/**/*.js', function (error, files) {
  if (error) return console.log(error)
  files.forEach(function (file) {
    require(file).setup()
  })
})

However, most users wouldn't write an electron app this way. They would just write:

var ipc = require('electron').ipcMain
var dialog = require('electron').dialog

ipc.on('open-error-dialog', function (event) {
  dialog.showErrorBox('An Error Message', 'Demonstrating an error message.')
})

It would be great if we could write the main process files as a user would, then figure out a way to eval them at runtime. Something like this:

// Require and setup each JS file in the main-process dir
glob(__dirname + '/main-process/**/*.js', function (error, files) {
  if (error) return console.log(error)
  files.forEach(function (file) {
    eval(fs.readFileSync(file, 'utf8'))
  })
})

Add an intro section about the quickstart app

@jlord and I are thinking it would be good for demo users to use electron-quick-start as their sandbox app while working through the demo. We should add an introductory section that covers the basics of getting the app up and running:

git clone https://github.com/atom/electron-quick-start
cd electron-quick-start
atom .
npm install
npm start

Might wanna also mention that git and node are required. We could use https://github.com/jlord/git-it-electron as a starting point for that content. I like that it recommends using GitHub Desktop as a simple way to install git.

Structure, a different take

I've been thinking about this and sketching out how this may all be laid out and I am thinking rather than present it as just documentation that you can click on, that it can be structured by what you can do with Electron and in human-speak. Rather than needing to guess and search for the module name that you need, you can learn by wha you want to do.

So, for instance, the main view would pose these topics in bold sections, Do you want to:

  • Create a new window
    • New window
    • New web view
    • New hidden window
    • New frameless window
  • Use native dialogs
    • alerts
    • information
    • open file
    • save file
    • sheet style & default dialogs
  • Creating Shortcuts
    • Create global shortcut
  • Communicate with another process
    • Create custom ipc message
    • Use remote in renderer process
  • Build a menu
    • Native menu
    • Context menu
  • Find out info on the app, or user’s system
  • Open external links or window manager
    • Open external links
    • Open window manager
  • Using the tray icon
  • Using the clipboard
  • Managing window state
    • Managing recent documents
    • Dealing with modified files (window state to edited)
    • Demo showing all the events (focus, blur, min, max, resize, move, etc)
    • Programmatically changing the window (size, position, etc)
  • Printing to PDF

The Guides section is one that can come after shipping the rest of the app and doesn't contain demos per say but rather best practices and tips.

Each of these (and there can be more) can be grouped/colored by category:

  • Native UIs
  • Process Communication
  • System Information
  • Packaging

Each page, would demo the APIs and link to the code of the app (I've gone back and forth on if the code snippet should also be shown, but it seems hard to maintain this way should to app code change, then the sample code has to be too)

There would be some shared UI elements within each page:

  • Pro Tip
  • OS support labels

This is just an initial brain dump based on the stuff I've been experimenting with and I'll likely update/refine it as I keep working on it.

Navigation

I'm not sure anymore about the navigation. I think it's fine if you try to find something, but if you try to look at each demo, one by one, it takes some effort to:

  1. scroll up
  2. click the back button
  3. scroll to the next item (since it doesn't keep previous scroll position)
  4. click on next item

So maybe at the bottom of each "page", there could be a "next" button to keep going forward and not having to go back all the time.

screen shot 2016-02-17 at 3 01 07 pm

Add Chrome Accessibility DevTools Extension

This is related to #121 but specifically about trying to get the Chrome Accessibility DevTools Extension working here (and in Electron).

Electron apps are websites in a sense, but not in the sense that they have urls that can use be used with online accessibility auditors. Getting this devtools extension working would be really helpful for Electron app developers in making their apps accessible to more people.

Not all of the chrome.* APIs have been implemented so we need to compare what this extension uses against what is currently implemented, then we'll see how far we have to go.

🍐 with @kevinsawicki

  • Get list of chrome.* APIs used in extension #126 (comment)
  • Get list of currently implemented chrome.* APIs

Tone down the external links

I find the current external link treatment a bit distracting and out of sync with the color scheme. @jlord and @simurai: What do you think of just using underlines and desaturating the external link image?

Before:

screen shot 2016-04-18 at 12 27 12 pm

After:

screen shot 2016-04-18 at 12 27 04 pm

Linux

I'm taking the app for a spin in Linux (Ubuntu 12.04.5 LTS) and making some notes here.

electron api demos_001

  • No tray icon (and no error) #42
    • Get Gtk-Message: Failed to load module "unity-gtk-module" message on startup (console)
  • PDF doesn't open because my system doesn't have a default viewer 796a714

Closing Old Windows

If you do one of the demos that creates a new window and then you don't close that new window and you at some point refresh the app and then decide to close the window, you get an error:

screen shot 2016-02-29 at 3 38 26 pm

Not sure what best practice is for handling this.

App icon

Did we settle on the name "Electron Demos"? See #3

If so, we could have an icon in a shape of a big D. Like

screen shot 2016-03-01 at 11 09 48 pm

Welcome Page

I want to create an about/welcome page that is the first page people see when they open the app.

This page will be brief but explain a little about what the app is and how to use it. πŸ•

CI

Should we set it up on this repo?

Welcome illustration?

Should we add some kind of fun/friendly illustration on the welcome page? No idea what.. but just to illustrate here is Inspectocat:

inspectocat

Or is that too cheesy. It doesn't have to be an Octocat, or maybe more subtle. Just to give it a tiny bit more recognizability and fill the empty space.

Structure

This app will be lightweight, a few pages based on Electron API categories, which demonstrate the API.

  • Index
  • Main process modules
  • Render process modules
  • Shared modules
  • Custom DOM elements

A lot of will be figured out as this is put together, like perhaps each module has its own page and perhaps there is a page explaining the two process types. And likely some static site generating happening, too.

Introduce ES2015 features used in the demo

A followup to #79

To quote @lee-dohm

So it sounds like there are multiple potential groups that have conflicting sets of things that are "unclear". Could we use this as an opportunity to educate people? Perhaps for anything that isn't typical ES5 (or anything we want/have to use that we feel might be confusing to one camp or another) we have a section in the demo for, "Hey, what's this strange syntax?" with links to relevant documentation?

@jlord and I discussed this today and decided we should preface the demo with a blurb about electron's support for ES2015, and cover the specific new language features that will be used throughout the demo app: template strings, const, and let.

Code Scrolling

I can't horizontally scroll in the code blocks. It's super weird because when I open DevTools and toggle off and then back on the overflow and overflow-x properties of .hljs and pre, then it works. Even though it's returned back to it's original CSS state... So that makes no sense.

Are you seeing this behavior @simurai?

screen shot 2016-02-24 at 3 55 10 pm

Style scrollbars on Windows?

Loading the app on Windows 10 shows a scrollbar on the left hand side:

screen shot 2016-04-27 at 1 59 40 pm

Maybe it should be styled explicitly or at least make the default height high enough to not show it?

/cc @simurai

Design Refinement

Here some (random) styling improvements. Feel free to add more.

  • Add more contrast to the colors #23
  • Fix scrolling after navigating #31
  • Add link to repo/source #39
  • App icon #49
  • Use <button> for the .content h2 so keyboard can be used to open?
  • Add some padding at the bottom if there is no pro tip.

Minimal demo of demo...

I've got things wired up for a minimal demo of how it would be with one section, the dialog, section fleshed out. All of the colors/design stuff is just placeholder.

It would be good to maybe have a πŸ‘– with @simurai and @benogle this week if possible to take a look at it?

main page (all of the categories aren't built out yet, just dialogs one)

screen shot 2015-11-24 at 6 09 39 pm

dialogs page with collapsed sections

screen shot 2015-11-24 at 6 12 41 pm

expanded section

screen shot 2015-11-24 at 6 12 46 pm

Ideas

A rough list of ideas I had while going through the app:

Adapt more demos

https://github.com/hokein/electron-sample-apps has lots of goodies:

  • camera
  • client-certificate
  • cookies
  • crash-report
  • desktop-capture
  • file-explorer
  • frameless-window
  • helloworld
  • helloworld-sharedobj
  • menus
  • mini-code-edit
  • mp3-encoder
  • notifications
  • pepper-flash-plugin
  • power-save-blocker
  • printing
  • spellcheck
  • tray
  • webgl
  • webview

Some of these are already covered in our demo. Others not. Thoughts?

Update dependencies that use a deprecated version of graceful-fs

❯ npm i              
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.

The Offenders

This is kind of a wild goose chase, as the dependency is pretty deep in the tree in some spots. The two top-level offenders are mocha and eletron-packager.

❯ npm ls graceful-fs@'<4'
[email protected] /Users/zeke/atom/electron-api-demos
β”œβ”€β”¬ [email protected]
β”‚ └─┬ [email protected]
β”‚   └─┬ [email protected]
β”‚     └─┬ [email protected]
β”‚       └── [email protected] 
└─┬ [email protected]
  └─┬ [email protected]
    └── [email protected] 

Outstanding PRs

Consistent Consts...and Others

We started using the const, let and string templates in places but we don't use them everywhere. It makes sense to be consistent all over, right? Just wanted to check because I can go through and do a sweet to make this so πŸ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.