Giter VIP home page Giter VIP logo

samples's Introduction

Build Status

Add-in Playground Samples

A collection of samples for the Add-in Playground

To contribute:

  • Fork this repo
  • Add samples using the instructions below
  • Submit a pull request that Bhargav or Michael Z. will review.

Folder Structure

  • All snippets must be inside the samples folder.
  • The base folders such as Excel, Word etc. are all the various broad level categories.
  • Inside of each base folder, there are group folders for the group in which a sample belongs to.
  • Inside of each group folder, there are .yaml which represent a snippet.

Adding a new sample

  1. Create a snippet using the Add-in Playground.
  2. Click on Copy to Clipboard in the Share menu.
  3. Fill in the author, name, description, source properties if they are empty so that we can generate the playlist correctly.
  4. Add that snippet into the respective folders. Make sure that the snippet file names and folder names are in kebabcase.

Style guidelines:

Basic snippet structure is as follows:

$("#run").click(run);

async function run() {
    try {
        await Word.run(async (context) => {
            let range = context.document.getSelection();
            range.font.color = "red";

            await context.sync();
        });
    }
    catch (error) {
        OfficeHelpers.Utilities.log(error);
    }
}

A few style rules to observe:

  • Each button-click handler should have its own async function, called "run" if there is only one button on the page -- otherwise, name it as you will.
  • Inside the function there shall be a try/catch. In it you will await the Excel.run or Word.run, and use async/await inside of the .run as well.
  • All HTML IDs should be all-lower-case-and-hyphenated.
  • Unless you are explicitly showing pretty UI, I wouldn't do the popup notification except for one or two samples. It's a lot of HTML & JS code, and it's also not strictly Fabric-y (there is a more "correct" way of doing this with components).
  • Strings should be in double-quotes.
  • Don't forget the semicolons.

samples's People

Contributors

jakobpn avatar juanelojuanelo avatar rick-kirkham avatar wrathofzombies avatar zlatkovsky avatar

Watchers

 avatar  avatar

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.