Platform Contributor Guide
[Legacy v3] Platform
[Legacy v3] Platform
  • 👋[Legacy v3] Welcome | README
  • Contributing | Getting Involved
    • Specific tasks needed for COVID19-support
    • Add code to Ushahidi
    • Encouraging contribution from non-developers
  • Frequently Asked Questions
  • Join the Ushahidi community
  • Contributors ✨
  • 🛣️ The Ushahidi Platform Roadmap
    • V2-V3+ Migration tool
  • Privacy and security best practices
    • Security as a user
    • Security for deployment admins
    • Security for deployment hosts
  • Development & Code
    • Development: Overview
    • How to get the source code
    • Setup Guides
      • Installing for production environments
      • Development environment with XAMPP
      • Development environment setup with Vagrant
      • [Client] Setting up the Platform Client for development
        • Migration from AngularJS
      • Setting up the Pattern Library for development
      • [API & Client] Bundled release install
    • Add code to Ushahidi
    • Development process
    • Coding Standards
    • Track and submit issues in Github
    • Upgrading Ushahidi
      • Upgrading to latest release
      • Upgrading from V3.x.x to V4.x.x
    • ⚙️ Installation Helper‌
  • Tech Stack
    • API Documentation
    • Third party app development
      • Web hooks
    • Database | Tables overview
    • Database | Database Schema Diagram
    • Database | Table details
    • 📐Architecture
    • Use case internals
  • QA & Testing
    • The QA process
    • How to run QA tests
    • Defect Management
    • How to write QA test scripts
    • Hotfixes
  • Front-end development
    • Changing UI styles: introduction to the pattern library
      • File-structure
      • Installing new packages
      • How to Apply to the Platform
      • Using the changed styles in platform-client
      • Syntax and Formatting
      • Grid, Breakpoints, & Media Queries
      • Variables
      • Mixins
      • Helpers
      • Icons
      • Create a New Component from Scratch
      • Read Direction
  • Design
    • 🎨Design: overview
    • 'Best practice' design
    • Ushahidi Platform 'Sticker Sheet'
    • User testing process
    • User testing script examples
    • Synthesising user testing results examples
      • Synthesis example 1
      • Synthesis example 2
      • Synthesis example 3
      • Synthesis recommendations example 1
      • Synthesis recommendations example 2
    • Open Source Design
  • Documentation
    • Documentation
    • Contributing docs via GitHub
  • Translation
    • Localization and Translation
  • The Ushahidi Platform Facebook bot
    • The Facebook bot
      • Installing the bot
      • The bot script
  • Hackathon and events
    • Installathon, May 2019
      • Welcome to the hackathon!
    • Write/Speak/Code 2019
    • Open Design: Bangalore
    • Open Design: Taipei
    • 📑Google season of docs
    • 💻Google Summer of Code
      • GSoC 2024
  • Enhancement Proposals
    • Exchange Format
    • Importing data from previous versions
Powered by GitBook
On this page
  • Nesting
  • Sass
  • Compiled CSS Output
  • Color Formats
  • Hex
  • RGB
  • Numbers
  • Zeros:
  • Units:
  • Calculations
  • Strings
  • Font Stack Example:
  • Image URL Example:
  • Commenting
  • Css Rulesets
  • Letter Case Usage & Naming Conventions
  1. Front-end development
  2. Changing UI styles: introduction to the pattern library

Syntax and Formatting

The Ushahidi Platform uses the SCSS syntax because it is more consistent and familiar with vanilla CSS.

Indentation should be 4 space tabs. CSS rules should be written on multi-lines.

// Yes
.foo {
    display: block;
    overflow: hidden;
    padding: 0 1em;
}

// No
.foo {
  display: block; overflow: hidden;

  padding: 0 1em;
}

White space after each declaration and after each ending curly brace.

// Yes
p {
    font-size: em(16);

    @include media($small) {
        font-size: em(18);
    }

}

// No
p {
    font-size: em(16);
    @include media($small) {
        font-size: em(18);
    }
}

Nesting

Nesting is one of the best features in Sass, but it can be overused and create unwanted CSS. A best practice is to nest no more than 3 levels deep and to only nest classes when that relationship is absolutely necessary to declare in order to achieve the desired style. Nesting for the sake of organizing the stylesheet is discouraged.

Sass

.unordered-list {
    list-style-type: none;

    .unordered-list__item {
        display: inline;

        a {
            color: blue;

            span {
                text-decoration: underline;
            }

        }

    }

}

Compiled CSS Output

.unordered-list {
    list-style-type: none;
}
.unordered-list .unordered-list__item {
    display: inline;
}
.unordered-list .unordered-list__item a {
    color: blue;
}
.unordered-list .unordered-list__item a span {
    text-decoration: underline;
}

Color Formats

Hex is the default color format with RGBA being used when opacity is needed.

Hex

Hex values should be written in all caps.

// Yes
.foo {
  color: #FF0000;
}

// No
.foo {
  color: red;
}

RGB

When using RGB, single space after commas and no spaces after parentheses.

// Yes
.foo {
  color: rgba(0, 0, 0, 0.1);
}

// No
.foo {
  color: rgba( 0,0,0,0.1 );
}

Numbers

Numbers should display leading zeros before a decimal value less than one and never display trailing zeros.

Zeros:

// Yes
.foo {
  padding: 2em;
  opacity: 0.5;
}

// No
.foo {
  padding: 2.0em;
  opacity: .5;
}

Units:

// Yes
$length: 2em;

// No
$length: 2;

Calculations

// Yes
.foo {
  width: (100% / 3);
}

// No
.foo {
  width: 100% / 3;
}

Strings

Single quotes should be used with strings.

Font Stack Example:

// Yes
$font-stack: 'Helvetica Neue Light', 'Helvetica', 'Arial', sans-serif;

// No
$font-stack: "Helvetica Neue Light", "Helvetica", "Arial", sans-serif;

// No
$font-stack: Helvetica Neue Light, Helvetica, Arial, sans-serif;

Image URL Example:

// Yes
.foo {
  background-image: url('/images/kittens.jpg');
}

// No
.foo {
  background-image: url(/images/kittens.jpg);
}

Commenting

Commenting is CSS is an essential practice that can help explain why and how code is written. Ushahidi's CSS commenting is simple.

// Comments are preceeded by two backslashes
.foo {
    background: #000;
}

Css Rulesets

  • related selectors on the same line; unrelated selectors on new lines;

  • the opening brace ({) spaced from the last selector by a single space;

  • each declaration on its own new line;

  • a space after the colon (:);

  • a trailing semi-colon (;) at the end of all declarations;

  • the closing brace (}) on its own new line;

  • a new line after the closing brace (}).

// Yes
.foo, .foo-bar,
.baz {
  display: block;
  overflow: hidden;
  margin: 0 auto;
}

// No
.foo,
.foo-bar, .baz {
    display: block;
    overflow: hidden;
    margin: 0 auto }

Letter Case Usage & Naming Conventions

When naming classes use lower case letters and a hypen between words.

// Yes
.button-primary

//No
.ButtonPrimary

//No
.button_primary
PreviousUsing the changed styles in platform-clientNextGrid, Breakpoints, & Media Queries