dojo/widgets

Name: widgets

Owner: Dojo

Description: :rocket: Dojo 2 - UI components.

Created: 2017-01-24 12:55:57.0

Updated: 2018-05-21 21:34:20.0

Pushed: 2018-05-11 16:14:03.0

Homepage: http://dojo.io

Size: 2698

Language: TypeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

@dojo/widgets

Build Status codecov npm version

A suite of pre-built Dojo 2 widgets, ready to use in your web application. These widgets are built using Dojo 2's widget authoring system (@dojo/widget-core).

Usage

To use @dojo/widgets in your project, you will need to install the package:

install @dojo/widgets

This package contains all of the widgets in this repo.

All of the widgets are on the same release schedule, that is to say, that we release all widgets at the same time. Minor releases may include new widgets and/or features, whereas patch releases may contain fixes to more than 1 widget.

To use a widget in your application, you will need to import each widget individually:

rt Button from '@dojo/widgets/button/Button';

Each widget module has a default export of the widget itself, as well as named exports for things such as properties specific to the widget:

rt Button, { ButtonProperties } from '@dojo/widgets/button/Button';

Because each widget is a separate module, when you create a release build of your application, you will only include the widgets that you have explicitly imported. This allows our dojo cli build tooling to make sure that the production build of your application only includes the widgets you use and is as small as possible.

Features
Widgets

Live examples of current widgets are available in the widget showcase.

Form widgets

Button

Calendar

Checkbox/Switch

ComboBox

EnhancedTextInput

Label

Listbox

Radio

Select

Slider

TextArea

TextInput

TimePicker

Layout widgets

AccordionPane

SlidePane

SplitPane

TabController

TitlePane

Misc widgets

Dialog

GlobalEvent

Icon

Progress

Toolbar

Tooltip

Conventions
EventHandlers

You can register event handlers that get called when the corresponding events occur by passing the handlers into a widget's properties. The naming convention for event handlers is as follows:

on[X], e.g. for a dismiss event, the event handler called by the child widget must be called onDismiss

Icons

We use font awesome for icons. Where a theme requires specific icons that are not part of the Font Awesome set, then those themes will ship their own icons.

There is an icon widget that aids in creating in proper semantics and provides type-checking for the type of icon.

Coding conventions

px vs. em - we specify font sizes in px. When creating a widget, spacing (margin, padding) should be specified using px unless the design calls for proportional spacing, in which case em can be used.

Z-index layering

Widgets adhere to a basic convention for using specific ranges of z-index values based on function and visual context. This convention is followed in both individual widget CSS and in the Dojo theme styles. These values can be overridden in a custom theme if necessary since no z-index values are set in fixed styles.

The range definitions are as follows:

How to customize a widget

There are many ways in which you can customize the behavior and appearance of Dojo 2 widgets. See the widget-core README for examples of how to customize the theme or a specific CSS class of a widget.

Or can you write your own widget that extends an official widget.

Extending widgets

Because all Dojo 2 widgets are Classes, you can simply extend the Class to add or change its behavior.

rt class MyWidget extends Button {


Dojo 2 widgets provide standard extension points to allow you to customize their behavior. For more details, please refer to the widget authoring system.

Individual widgets also provide certain types of extension points where applicable:

How do I contribute?

We appreciate your interest! Please see the Dojo 2 Meta Repository for the Contributing Guidelines and Style Guide.

Installation

To start working with this package, clone the repository and run npm install.

In order to build the project run grunt dev or grunt dist.

Testing

Test cases MUST be written using Intern using the Object test interface and Assert assertion interface.

90% branch coverage MUST be provided for all code submitted to this repository, as reported by istanbul?s combined coverage results for all supported platforms.

To test locally in node run:

grunt test

To test against browsers with a local selenium server run:

grunt test:local

To test against BrowserStack or Sauce Labs run:

grunt test:browserstack

or

grunt test:saucelabs

Viewing widget examples locally

Each Dojo 2 widget includes functioning example code so you can view the widget. To view individual widget example:

  1. Run grunt dev in your terminal
  2. Open the newly built file _build/common/example/index.html in your web browser
  3. By default, no widget is selected, open the dropdown to select a widget
  4. Observe the page reloads and the selected widget displays
To modify/debug widget examples

Running grunt dev each time you wish to view a small change takes more time than simply running this command in your terminal:

-w

With that command, TypeScript watches for changes and recompiles when necessary.

Licensing information

© 2018 JS Foundation. New BSD license.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.