Skip to content

Latest commit

 

History

History
executable file
·
925 lines (803 loc) · 32.6 KB

developer-docs.md

File metadata and controls

executable file
·
925 lines (803 loc) · 32.6 KB
layout in-navbar id title
page
true
developer-docs
Developer documentation

UNICEF has defined a visual design specification for our internal web applications. This specification follows our brand guidelines, takes into account accessibility and is rooted in a set of principles that are defined on our UX/UI design guidelines.

Additionally to those specs, UNICEF has created a technology agnostic reference implementation, so it can be used with any modern development framework such as React or Angular. One of the main goals of this implementation is to:

  • Speed up the development of our applications by providing developers with a set of CSS classes that comply with usability, branding and accessibility best practices.
  • Improve the quality of the interfaces with a well thought and designed framework.

This document is for developers that have to implement the user interface of a UNICEF web application. Here you will find the technical documentation with examples of the HTML and CSS classes.

This implementation is based on bootstrap 4.x, one of the most popular and widely used frameworks on the Internet. For brevity, we assume the reader is familiar with this framework, and has a good understanding of HTML as well as CSS.

If you need to design a user interface for a UNICEF application you will need to understand how and when to use each of the elements described in this document. To get that knowledge, please, read our UX/UI design guidelines.

Example

This is an example of a full page.

Getting started

In order to use the UNICEF's UI in your project you can reference a CDN or download using npm.

With CDN

CDNs can offer a performance benefit by hosting on servers spread across the globe. This also offers an advantage that if the visitor to your webpage has already downloaded a copy of the files from the same CDN, it won't have to be re-downloaded.

For the CSS:

<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@unicef/design-system/dist/css/unicef.css">

If you need to include the JavaScript, you have two options. The first one, a minified javascript bundle file that includes all bootstrap JavaScript (bootstrap, popper, jquery). You need this if you require dropdowns, tabs, etc.

<!-- All js bundled -->
<script src="https://cdn.jsdelivr.net/npm/@unicef/design-syste/dist/js/unicef-bundle.min.js"></script>

<!-- only the scripts that were created by UNICEF (no requirement)-->
<script src="https://cdn.jsdelivr.net/npm/@unicef/design-system/dist/js/unicef.min.js"></script>

Using npm

This bootstrap customization is based on SASS, and therefore you can easily override the CSS classes for your particular project.

First, install the npm package

 npm install @unicef/design-system

Import unicef.scss in your global scss file. For example:

/* you may need to change the path to the node_modules dir */
@import "../node_modules/@unicef/design-system/scss/unicef"

We have used bootstrap variables whenever possible. Custom created variables are defined in scss/_variables.scss.

Typography

The default typography is the one defined by user's operating system. That way we don't need to download any font.

{% capture example %}

h1. Heading 1

Lead paragraph. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Heading 2

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Heading 3

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

heading 4

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

heading 5
heading 6
{% endcapture %} {% include example.html content=example %}

Alerts

Alerts use the .alert class followed by the type of alert .alert-success, .alert-warning, .alert-danger.

{% capture example %}

This is a success alert. Check it out!
This is a warning alert. It is used to warn the user about something he has to be aware of.
This is a danger alert. An error or something that blocks current flow happened!
{% endcapture %} {% include example.html content=example %}

Alerts support strong and links.

{% capture example %}

This alert displays how it looks a warning alert with a strong element and a link.
{% endcapture %} {% include example.html content=example %}

Buttons

There are 4 types of buttons. The .btn class is common to all of them:

  • .btn-primary for the main button.
  • .btn-outline-primary, for the default button.
  • .btn-outline-danger, for the danger button.
  • .btn-link, for the link button.

{% capture example %}

Primary button

Normal Active Disabled

Default button

Normal Active Disabled

Danger button

Normal Active Disabled

Link button

Link button Normal Link button

{% endcapture %} {% include example.html content=example %}

Also, it is possible to group an input with a button:

{% capture example %}

Search
{% endcapture %} {% include example.html content=example %}

Navigation Bar

{% capture example %}

unicef-logo Application Name {% endcapture %}

{% include example.html content=example %} {% capture example %}

Application name

{% endcapture %} {% include example.html content=example %} {% capture example %}

Application name {% endcapture %} {% include example.html content=example %}

Accessibility

To support skip navigation, always add the .skip navigation before the navigation bar pointing to the element in which the content starts.

Adding this helps users that browse the web with keyboards, allowing them to skip all the links in your main menu.

<a class="skip" href="#contents" tabindex="0">Skip Navigation</a>
<!-- navbar  goes here--->
<nav class="navbar navbar-expand-md flex-md-row bd-navbar">
  ....
</nav>

<!-- your contents start here -->
<div id="contents">
</div>

Tabs

{% capture example %}

Consequat occaecat ullamco amet non eiusmod nostrud dolore irure incididunt est duis anim sunt officia. Fugiat velit proident aliquip nisi incididunt nostrud exercitation proident est nisi.
Irure magna elit commodo anim ex veniam culpa eiusmod id nostrud sit
cupidatat in veniam ad.
Eiusmod consequat eu adipisicing minim anim aliquip cupidatat culpa
excepteur quis.
Occaecat sit eu exercitation irure Lorem incididunt nostrud.
Ad pariatur nostrud pariatur exercitation ipsum ipsum culpa mollit commodo mollit ex. Aute sunt incididunt amet commodo est sint nisi deserunt pariatur do.
Aliquip ex eiusmod voluptate exercitation cillum id incididunt elit sunt.
Qui minim sit magna Lorem id et dolore velit Lorem amet exercitation
duis deserunt.
Anim id labore elit adipisicing ut in id occaecat pariatur ut ullamco
ea tempor duis.
{% endcapture %} {% include example.html content=example %}

Images

Images should weight the least amount possible.

  1. Use the format that weights for the size and quality you require. Typically, it is recommended to use JPG format for pictures and SVG for graphics and icons.

  2. Use size optimizers such as svgo or jpeg optim.

  3. It is necessary to set the alt description on all images. Keep this description brief, describe what you see and do not interpret the contents of the image. For decorative images, use an empty string alt attribute (alt="").

Forms

Form fields have different status:

{% capture example %}

Input with placeholder
Input with value
Input disabled
Input readonly
{% endcapture %} {% include example.html content=example %}

Form elements can include short texts that provide important information to users.

{% capture example %}

Your email We'll never share your email with anyone else.
Corporate email Domains like hotmail.com or gmail.com are not allowed.
{% endcapture %} {% include example.html content=example %}

Textareas

To add a counter at the bottom of a field add the attributes data-counter="true" and maxlength="100", where 100 is the max number of characters. Add data-autoresize="true" to allow auto resize.

{% capture example %}

Regular textarea <textarea rows="3" id="textarea-regular" class="form-control" placeholder="This is the placeholder"> </textarea>
Textarea with counter <textarea id="textarea-counter" rows="3" class="form-control" placeholder="Counter should decrease while typing" data-counter="true" maxlength="100"></textarea>
Textarea with autoresize <textarea rows="3" id="textarea-autoresize" class="form-control" placeholder="The number of lines shall grow with text." data-autoresize="true"></textarea>
{% endcapture %} {% include example.html content=example %}

These two enhancements require Javascript.

Required fields

Required fields are those that are mandatory to fill in order to submit a form. For required fields we mark <label> contents with an <em> and the form field (input, select, textarea,...) with the attribute required.

{% capture example %}

Input with placeholder
Input with value
Textarea required <textarea rows="3" class="form-control" placeholder="Required textarea" required></textarea>
Select required
Select Value 1 Value 2
{% endcapture %} {% include example.html content=example %}

Errors in forms

UNICEF's reference implementation uses Bootstrap conventions to display errors in forms as base. We slightly customized the look and feel and we only use the .is-invalid class to provide visual feedback.

Example the HTML and classes to display errors (no actual validation is performed)

{% capture example %}

Input with error
Only numbers and letters are allowed.
Select with error
Select Option 1 Option 2 Option 3
Error message.
Textarea with error <textarea rows="3" class="form-control is-invalid" maxlength="200" placeholder="Placeholder text"></textarea>
Error message.
200 characters left
{% endcapture %} {% include example.html content=example %}

Cards

Use .card-deck to have same all cards of a row with the sam length.

{% capture example %}

Card title

This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

Last updated 3 mins ago

Card title

This card has supporting text below as a natural lead-in to additional content.

Last updated 3 mins ago

Card title

This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.

Last updated 3 mins ago

{% endcapture %} {% include example.html content=example %}

Card with actions menu

{% capture example %}

This card has action menu

This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

{% endcapture %} {% include example.html content=example %}

Cards with navigation tabs

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Morbi elit justo, finibus consequat facilisis eget, dictum in justo.

List groups

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros

List group with a button:

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Add an element
    Add an element to the list Add to list

Tables

{% capture example %}

Main Element Date Amount(USD)
Text is a link 29-May-2018 $23.33
This is another link. Vertically align cells to the middle 12-Aug-2017 $99.44
Text is left-aligned 29-May-2018 $1,223.00
{% endcapture %} {% include example.html content=example %}

Loading status

Everytime a asynchronous request is done in the client side, the app should display that status. We use .spinner-border or .spinner-border.spinner-border-sm (small one).

For accessibility, notice you need to include role=status {% capture example %}

Loading...
Loading...
{% endcapture %} {% include example.html content=example %}

To specify the action that is being performed: {% capture example %}

Loading...
{% endcapture %} {% include example.html content=example %}

When the action is performed within a button

{% capture example %} Loading...

Loading... {% endcapture %} {% include example.html content=example %}

More info in bootstrap spinners documentation.

Progress Bar

Indicates the status of completeness of a process.

There are different background colors available (.bg-success, .bg-warning, etc..)

Please, notice the accessibility attributes role, aria-valuenow, aria-valuemin and aria-valuemax.

{% capture example %}

Empty
0% 100%
Without numbers
Filled

Allocated funds: $87,500 (75%)

$0.00 $125,000.00

{% endcapture %} {% include example.html content=example %}

For more information see bootstrap docs