Fabric Explorer v2 Published

Version 2.0.1 of my free Chrome Extension which can help you to explore, learn and use the Office UI Fabric has been published to the Chrome webstore.  More details on Fabric Explorer and the companion project FabEx Playground are available on GitHub:

If you already have the extension installed, it should update itself to the new version within a few hours.  If not, you can always select the Developer Mode checkbox from the Chrome Extensions page (chrome://extensions/) and click the button to update extensions immediately.

With these complete, I’m hoping to get my updated Fabric course published to Pluralsight by early December.

Github: Updating a forked repo

This one is entirely for me.  I know this is pretty basic stuff, but I don’t do this often enough to remember the steps and finally got sick of looking it up each time.

Here’s the scenario this covers: In my Github account, I have a forked copy (I’ll call this origin) of a repo owned by someone else (I’ll call this upstream).  I also have a local copy on my development machine (I’ll call this local).  The owner of upstream is continuing to make changes, and I am making changes to local and pushing them to origin.  Periodically, I need to pull copies made to upstream into my development efforts (local and origin) to make sure I’m not going to have problems merging my changes into upstream when I’m ready.

Here are the steps:

  1. [Only the first time you go through this process]: From a git bash prompt in your local git repo folder, add a git remote pointing to upstreamgit remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
  2. Fetch upstream to local: git fetch upstream
  3. Make sure you have local/master checked out: git checkout master
  4. Merge upstream/master with local/master: git merge upstream/master.  If you have local changes to files that are part of the merge, you’ll need to commit or stash them first.
  5. You now have an updated copy of upstream merged with local.  All you need to do is push it to origin: git push origin master

All done.

Delaying the Display of SharePoint’s ECB Menu

A viewer of my Pluralsight course Developing SharePoint 2013 Solutions with JavaScript, part 3 posed a question about working with the ECB (Edit Control Block) available in SharePoint and Office 365.  In their situation, they needed to delay the showing of the ECB menu while they called back to the server to do some checking and they weren’t sure how to do it.

Before getting to the code sample, a quick word of caution – realize that this could present potential performance problems depending on how quickly the call makes it’s roundtrip to the server and back.  In any case, this would be a situation in which you would want to trim the response down to the bare minimum necessary – don’t pull down extra fields that you don’t need or else your users are likely to notice the impact and not be too thrilled with it.

With that said, here is a quick code sample that that will delay the presentation of the ECB for 5 seconds.  Normally, you would not simply add the delay, but instead replace it with whatever calls you need to make.  All this code is doing is:

  1. storing the current function that displays the ECB in a new variable
  2. overwriting the function that display the ECB with our own function to store some information we need later
  3. calling the code to do whatever you need it to do (make a call back to the server, etc) , in the example, simply delaying for 5 seconds
  4. Using the stored function from #1 to call the ECB display and pass in the information stored in #3
//store the function before overwriting it
ecbFunc = ShowECBMenuForTr;
ShowECBMenuForTr = function(t,e){
    ecbTarget = t;
    ecbEvent = e;
    //now do whatever you need.  In this case, I'm just delaying 5 seconds
    setTimeout(function(){
        // call the function we stored above and pass in variables
        ecbFunc(ecbTarget, ecbEvent);
    }, 5000);
};

And that’s it.  When a user clicks on the ellipsis to show the ECB on any page where this code is loaded will now run our custom ShowECBMenuForTr function (because monkey patching, which I cover in the Pluralsight courses).

A few final points:

  1. I’m using global variables here, which isn’t recommended for production code.  I discuss namespacing in the Pluralsight courses to avoid this
  2. The out-of-the-box function ShowECBMenuForTr is what shows the ECB and it *is* in the global namespace, so you don’t want to hide that inside your own custom namespace.
  3. This code should go into your own code file, *not* one of the out-of-the-box JavaScript files provided by SharePoint

Dave

Office UI Fabric Snippets 1.0 Release

Office Fabric UI Snippets for VS Code

Release Date: March 25, 2016

Status: 1.0

Provided By: Sector 43 Software (David Mann)

Project: https://github.com/Sector43/FabricSnippets

Based on: Fabric release 2.01 (Feb 5, 2016)


These snippets are intended to make the Office UI Fabric easier to use. In general, the HTML is taken directly from the Office UI Fabric GitHub repository, with some tweaking.

Snippets generally fall into one of two flavors:

  • Simple Components: these have no JavaScript elements and so the snippet just expands into the correct HTML to render the component

  • Complex Components: these aren’t really “complex” they simply have some JavaScript associated with them. In these cases, there is a snippet for the component and one for an example of the JavaScript required to make the component work.

All of the core snippets have a trigger that starts with uif- so you can see what’s available by simply typing uif- and looking at the Intellisense popup shown by VS Code. These snippets were originally developed for my Pluralsight course so there are a handful of snippets that I built for the demos in that course. I’ve left them in just in case they provide value, or if you’re following along with the course. Here’s the info on them:

  • htmlShell – Creates the shell of an HTML page with the proper doctype for Fabric
  • jsAddPeoplePickerResult – sample code for adding a result into the Peoplepicker
  • gridRefRow – adds a single grid row with each cell set to 1 column wide. Useful for building a grid below and having a reference to see how many columns each cell takes up
  • gridDemoStyle – some style overrides used to differentiate the sample grid in the course
  • gridDemoRows – inserts the sample markup for a three column grid used as a demo in the course
  • callOutPositioning – sample styles for positioning a callOut
  • callOutPositioningJS – sample code for showing the callout in the demo
  • spinnerDemo – sample markup for working with the Spinner component
  • commandBarDemo – sample code for adding a ContextualMenu to a CommandBar
  • progressDemo – sample code and markup for the Progress Indicator demo

Installation Instructions

For the time being, installation is manual. Once I’ve ironed out any bugs, I’ll make a true VS Code extension and deploy it to the Extension Gallery. At that point, I’ll also create a Visual Studio Extension and deploy that to the Visual Studio Gallery as well. If there is interest, I’ll convert the snippets to other editors – Sublime is one I’m considering, but am open to other suggestions as well.

To Install:

  • Open the file VSCodeFabricSnippets.txt from the GitHub repo (direct link:https://raw.githubusercontent.com/Sector43/FabricSnippets/master/VSCodeFabricSnippets.txt
  • Select all of the contents and copy it to the clipboard
  • In VS Code, click File | Preferences | User Snippets and select HTML from the Language dropdown
  • Paste the contents from the GitHub file into the html.json file that is now open in VS Code
  • Save the html.json file and close it

The snippets are now available when you are editing an HTML file in VS Code. (NOTE: Snippets in VS Code only seem to work if the HTML file is open as part of a folder, not if you just open a standalone file. I’m looking into whether this is really true, and if so whether it is by design or a bug)

Installation and usage is shown in the short video here: https://youtu.be/VsfUTwgNdgg

Known Issues

  • None

Next Steps

  • Updating for latest Fabric release (currently 2.2.0)
  • Creating Visual Studio snippets

Please report other issues here: https://github.com/Sector43/FabricSnippets/issues

Developing with Office UI Fabric Course is Live

The second and final course in my series on the Office UI Fabric is now live: http://s43.io/FabricCourse2.  Following on from the introduction in the first course, this course dives in to hands-on working with Fabric as a developer.  It is very light on slides and heavy on demos.

Here’s a look at the Table of Contents:

  1. Getting Started with Office UI Fabric (including an introduction to the Fabric Snippets)
  2. Handling Multiple Resolutions with the Responsive Grid
  3. Building Forms
  4. Improving User Interactions with Display Components
  5. Enhancing Layout and Navigation
  6. Building Fabric and Contributing to the Project
  7. Using Fabric in Angular
  8. Resources and Fabric Futures

Obviously, I’m a little biased, but I think the course covers everything you need to know as a developer to use Fabric in your own applications, sites and add-ins.  I cover every component in Fabric, showing the HTML and JavaScript necessary to make it work as well as a deep dive on all aspects of the responsive grid and then cover the Fabric project itself on GitHub and the community project ngOfficeUIFabric for using Fabric in Angular.

Enjoy!

Pluralsight course: Introducing Office UI Fabric

My Pluralsight course Introducing the Office UI Fabric went live yesterday.  It’s a quick hit (clocking in at just over an hour) intro to all of the goodness Fabric has to offer.  Here’s the Table of Contents:

  1. Introducing Office UI Fabric
  2. UI Elements
  3. Components
  4. Fabric Futures

If you’re new to Fabric, this is the place to start as it gives a great overview of the what and why of Fabric.

My next course (on track to be out in March or early April) – Developing with the Office UI Fabric – goes further into the how of Fabric, covering details on the components, working with Fabric in Angular, Building and Contributing to the project and much more.  Most of the Developing course is demos, just a handful of slides.

Fabric Explorer Updated

To coincide with the publication of my new Pluralsight course on Office UI Fabric, I’ve updated the Fabric Explorer Chrome extension I published a while back to version 1.3.  This is a minor update, but it fixes a few bugs:

  1. Added support for pages loaded into the browser via a file:// URL
  2. Fixed bugs that prevented the “Reset” button from correctly returning an element back to it’s original state when the page was loaded

In addition, I added the remainder of the Fabric Responsive Grid classes (hidden, offset, push, pull), did some minor code cleanup and published the source code to GitHub.

The update was published on the Chrome Web Store this morning and should be automatically updated if you already have it installed.  If you haven’t installed it already, now is the perfect time to do so!  You’ll get the latest and greatest bits right away.

Please log any bugs here: https://github.com/Sector43/FabricExplorer/issues

The extension is available here: https://chrome.google.com/webstore/detail/fabric-explorer/iealmcjmkenoicmjpcebflbpcendnjnm 

Office Fabric UI Snippets for VS Code

Update for 1.0 Release.  See here: http://blog.mannsoftware.com/?p=2371

Release Date: Feb 26, 2016

Status: Beta

Provided By: Sector 43 Software (David Mann)

Details: s43.io/FabricSnippets

Repo: https://github.com/Sector43/FabricSnippets

Based on: Fabric release 2.01 (Feb 5, 2016)


These snippets are a first go at making the Office UI Fabric easier to use. In general, the HTML is taken directly from the Office UI Fabric GitHub repository, with some tweaking.

Snippets generally fall into one of two flavors:

  • Simple Components: these have no JavaScript elements and so the snippet just expands into the correct HTML to render the component

  • Complex Components: these aren’t really “complex” they simply have some JavaScript associated with them. In these cases, there is a snippet for the component and one for an example of the JavaScript required to make the component work.

All of the snippets have a trigger that starts with uif- so you can see what’s available by simply typing uif- and looking at the Intellisense popup shown by VS Code.

Installation Instructions

For the time being, installation is manual. Once I’ve ironed out any bugs, I’ll make a true VS Code extension and deploy it to the Extension Gallery. At that point, I’ll also create a Visual Studio Extension and deploy that to the Visual Studio Gallery as well. If there is interest, I’ll convert the snippets to other editors – Sublime is one I’m considering, but am open to other suggestions as well.

To Install:

  • Open the file VSCodeFabricSnippets.txt from the GitHub repo (direct link: https://raw.githubusercontent.com/Sector43/FabricSnippets/master/VSCodeFabricSnippets.txt)
  • Select all of the contents and copy it to the clipboard
  • In VS Code, click File | Preferences | User Snippets and select HTML from the Language dropdown
  • Paste the contents from the GitHub file into the html.json file that is now open in VS Code
  • Save the html.json file and close it

The snippets are now available when you are editing an HTML file in VS Code. (NOTE: Snippets in VS Code only seem to work if the HTML file is open as part of a folder, not if you just open a standalone file. I’m looking into whether this is really true, and if so whether it is by design or a bug)

Installation and usage is shown in the short video here: https://youtu.be/VsfUTwgNdgg

Known Issues

The following components are not currently supported by the snippets:

  • Facepile
  • People Picker
  • Persona
  • Persona Card

They’ll be coming in the next release.

Please report other issues here: https://github.com/Sector43/FabricSnippets/issues