• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language SCSS
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A flexible code implementation of the GEL Grid Guidelines

GEL Grid

A flexible code implementation of the GEL Grid.
Forms part of the GEL Foundations

What is this?

An implementation of the GEL Grid Guidelines. The Grid provides a way of creating flexible and unique layouts whilst also maintaining consistent margins, gutters and containing widths across the BBC, online.

This is implementation of the grid is built using flexbox with an inline-block fallback older browsers. This allows us to support browsers IE8 and above.

It can used in two forms, by simply adding the relevant classes to your markup:

<div class="gel-layout">
    <div class="gel-layout__item gel-1/2"></div>
    <div class="gel-layout__item gel-1/2"></div>
</div>

Or using a Sass mixin:

.my-component {
    @include gel-layout;
}

.my-component__item {
    @include gel-layout-item;
    @include gel-columns(1/2);
}

Installation

The easiest way to get started with the GEL Grid component is to use the compiled version of the grid included within this repository.

If you're a more advanced user and want to integrate the GEL Grid component within your codebase, use one of the following options:

Install using NPM

$ npm install --save gel-grid
// your-app/main.scss
@import 'node_modules/gel-sass-tools/sass-tools';
@import 'node_modules/sass-mq/mq';
@import 'node_modules/gel-grid/grid';

Install manually

You can install this component manually by downloading the content of this Git repo into your project and use a Sass @import to include it in your project.

Note: you will manually need to manage the dependencies below, without these this component will fail to compile.

Compiled CSS

If you require just the built css, it is automatically built to the gel-grid.css repository.

Dependencies

In order to use the component you will need the following components available:

Usage

A collection of grid utility classes can be output by defining $gel-grid-enable--markup-output: true; before you @import the main grid partial.

Example:

$gel-grid-enable--markup-output: true;

@import "gel-grid/grid";

This will allow you to create grids using specific markup within your page. With the grid markup enabled, its possible to create grids like so:

<div class="gel-wrap">
    <div class="gel-layout">
        <div class="gel-layout__item gel-1/2 gel-1/4@m"></div>
        <div class="gel-layout__item gel-1/2 gel-1/4@m"></div>
        <div class="gel-layout__item gel-1/2 gel-1/4@m"></div>
        <div class="gel-layout__item gel-1/2 gel-1/4@m"></div>
    </div>
</div>

This would create a grid with each item being 50% wide. At the medium GEL breakpoint (600px), the width of each item changes to 25%.

Core Grid Classes

  • gel-wrap - the outer grid wrapper, defines the maximum width of the grid and applies page margins
  • gel-layout - a grid row
  • gel-layout__item - an item within the grid, applies gutters between items. Width can be controlled using width classes

Modifier Classes

  • gel-layout--flush - removes gutters between items
  • gel-layout--rev - reversed order of layout items, e.g. items 1, 2, 3, 4 in your markup will display in order 4, 3, 2, 1 on your page
  • gel-layout--middle - align layout items to the vertical centers of each other
  • gel-layout--bottom - align layout items to the vertical bottoms of each other
  • gel-layout--right - make the layout items fill up from the right hand side
  • gel-layout--center - make the layout items fill up from the center outward
  • gel-layout--auto - cause layout items to take up a non-explicit amount of width

Flexbox Only

  • gel-layout--equal - cause each layout item to be of equal height
  • gel-layout--fit - allows each layout items to size itself automatically by dividing the space equally between the total number of items

Widths

Widths can be applied to grid items using a collection of utility classes which are automatically generated when the grid markup is enabled. The utility classes allow widths to be changed at different breakpoints.

The width utility classes are entirely fraction based allowing you to size grid elements proportionally. By default the following fractional groups are output: whole, halves, thirds, quarters, fifths, eighths, tenths, twelfths and twenty-fourths.

The class structure is as follows:

  • .gel-1/1 - 100%
  • .gel-1/2 - 50%
  • .gel-2/3 - 66.666666667%
  • .gel-10/12 - 83.333333333%

In order to reduce page weight we do not output whole fractions for each group as this can be simply normalised to one whole (.gel-1/1). Also, mathematically identical fractions should be normalised to the lowest denominator (for example instead of .gel-2/4 or .gel-6/12 use .gel-1/2)

Breakpoints

It is possible to apply width classes at specific breakpoints by applying a breakpoint specific suffix to the end of the class. That might look something like this:

<div class="gel-layout">
    <div class="gel-layout__item gel-1/1 gel-1/2@m gel-1/4@l"></div>
</div>

Here the item would be 100% wide by default, then 50% wide from 600px and 25% for anything beyond 900px.

The following breakpoint suffixes are available by default:

  • @s - 400px
  • @m - 600px
  • @l - 900px
  • @xl - 1008px
  • @xxl - 1280px

More information:

Specificity

Utility classes like these width classes always need to win when it comes to specificity, otherwise they're not doing their job correctly. You should never need to override a utility class, if you do you're doing something wrong. E.g. if you'd used a class of gel-1/2 you would never want it to be anything other than 50%. If you want something other than 50% you should have used a different class.

To help enforce this way of thinking all width utilities classes proactively carry the !important keyword to boost their specificity.

More information:

Sass Mixins

The GEL grid component exposes a collection of Sass Mixins which can be called within your Sass. Should you need to create a more bespoke component which is not possible using the standard utility classes.

Example

.my-component {
    @include gel-layout;
}

.my-component__item {
    @include gel-layout-item;
    @include gel-columns(1/2);

    @if $enhanced {
        @include mq($from: gel-bp-m) {
            @include gel-columns(1/4);
        }
    }
}

Available Mixins

  • @include gel-wrap - create the outer grid wrapper
  • @include gel-layout - defines a single grid row
  • @include gel-layout-item - a single grid item
  • @include gel-columns($span, $columns) - outputs a width for the requested number of columns, accepts either a fraction or number of columns

Available Functions:

  • gel-columns($span, $columns) - returns a width value for the requested number of columns, accepts either a fraction or number of columns

Flexbox

The grid is developed using flexbox giving us a flexible, powerful grid solution. Flexbox is not fully supported in all browsers and has seen a number of development iterations. With this in mind we have intentionally targeted specific implementations of flexbox and avoided some older more troublesome implementations.

For browsers which do not support flexbox we fallback to an inline-block grid which offers ~80% of the features available in the flexbox grid.

We recommend you include some JavaScript based Feature Detection which can apply a top level class to signify if flexbox is supported or not. This will increase the features available to older browsers. The specific class applied can be controlled using the $gel-grid-flexbox-feature-detection-class option.

The following features are only supported by the flexbox grid and will degrade gracefully:

More information:

1280px

The GEL Grid guideline has been updated to include a wider 1280px breakpoint. By default the grid supports this breakpoint. It can be displayed by setting the $gel-grid-enable--1280-breakpoint to false.

It is also possible to toggle the 1280px breakpoint on and off based on the presence of a specific class. If a class name is supplied e.g. $gel-grid-1280-toggle-class: 'b-pw-1280'; then all wider 1280px styles will be scoped in this class.

More information:

Box Sizing

The GEL Grid consistences of a combination of fixed gutters and margins with fluid width columns. This combination of fixed and fluid units is achieved using box-sizing: border-box.

If you do not have border-box defined globally on your project you will need to enable the $gel-grid-enable--box-sizing flag to enable a bundled fix.

More information:

inline-block & white-space

The GEL Grid is constructed using flexbox with an inline-block fallback for older browsers. Using inline-block allows us to achieve a lot of the same complex layout technique that flexbox offers and provides a more powerful and flexible grid than is possible with more traditional techniques likes the use of floats.

One challenge to the using of display: inline-block; is the white-space which is introduced between inline-block elements. This space is a representation of the space between elements in the HTML. In order for the grid to work correctly this space needs to be removed.

There are a few ways you can do this:

HTML Fix

The best way to get around this issue is to remove the space between elements in your HTML. This could be done by minifying your markup or by using HTML comments to comment out the space:

<div class="gel-layout">
    <div class="gel-layout__item gel-1/2"></div><!--
 --><div class="gel-layout__item gel-1/2"></div>
</div>

If you're building you're grid using something like ReactJS you will not have this problem with space between elements as a result of how the markup is generated by the ReactJS library.

CSS Fix

It is possible to collapse the space using CSS. An optional CSS fix can be enabled by setting the $gel-grid-enable--whitespace-fix flag to true.

Note: This is included as an optional fix as it is not 100% guaranteed to work. There are certain edge cases where this solution falls down. The only 100% guaranteed and recommended solution is to remove the space in the HTML.

Configuration

The following configurable options are available:

General Configuration

  • $gel-grid-namespace: 'gel-'; - the default namespace applied to all grid classes
  • $gel-grid-breakpoint-namespace: 'gel-bp-'; - the default namespace applied to breakpoint variables from GEL Sass Tools
  • $gel-grid-1280-toggle-class: null - an optional scoping class to wrap all 1280px grid style in. Allows the wider grid to be used in a products that do not fully support the wider grid yet
  • $gel-grid-breakpoints - a Sass map containing a list of breakpoints width classes should be generated for
  • $gel-grid-breakpoints--1280 - a Sass map containing a list of breakpoints which relate specifically to the 1280 breakpoint
  • $gel-grid-default-columns: 12 - the default number of columns the grid should be based on
  • $gel-grid-columns - a Sass list containing a list of which fractions utility classes will be generated for
  • $gel-grid-flexbox-feature-detection-class: 'no-flexbox' - The class applied by a feature detection script to signify there the current browser doesn't support Flexbox

Output Configuration

  • $gel-grid-enable--markup-output: false; - output a collection of utility classes
  • $gel-grid-enable--1280-breakpoint: true; - toggle the support for the wider 1280px grid
  • $gel-grid-enable--box-sizing: false; - enable built in box-sizing rules if box-sizing: border-box; is not already defined
  • $gel-grid-enable--whitespace-fix: false; - enable a built CSS fix to collapse the whitespace between inline-block items, this fix is not guaranteed to work 100% of the time

Grid Bookmarklet

The following Grid Bookmarklets can be used to overlay the grid in the browser to check visual alignment of elements:

Who is using this?

The following teams are currently using this component: GEL, News, Sport, Live, Search, BBC Food, Taster & Academy, IPS Web (R&D)

If your team is using this component, let us know and we'll add you to the list.

Credits

The foundations of this grid is based on the great work of Harry Roberts and his Inuit CSS Grid

License

The MIT License (MIT)

Copyright 2016 British Broadcasting Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

wraith

Wraith — A responsive screenshot comparison tool
Ruby
4,813
star
2

Imager.js

Responsive images while we wait for srcset to finish cooking
JavaScript
3,833
star
3

peaks.js

JavaScript UI component for interacting with audio waveforms
JavaScript
2,886
star
4

audiowaveform

C++ program to generate waveform data and render waveform images from audio files
C++
1,658
star
5

sqs-consumer

Build Amazon Simple Queue Service (SQS) based applications without the boilerplate
TypeScript
1,541
star
6

bbplot

R package that helps create and export ggplot2 charts in the style used by the BBC News data team
R
1,434
star
7

simorgh

The BBC's Open Source Web Application. Contributions welcome! Used on some of our biggest websites, e.g.
TypeScript
1,394
star
8

VideoContext

An experimental HTML5 & WebGL video composition and rendering API.
JavaScript
1,318
star
9

waveform-data.js

Audio Waveform Data Manipulation API – resample, offset and segment waveform data in JavaScript.
JavaScript
936
star
10

brave

Basic Real-time AV Editor - allowing you to preview, mix, and route live audio and video streams on the cloud
Python
646
star
11

tal

TV Application Layer
JavaScript
550
star
12

react-transcript-editor

A React component to make correcting automated transcriptions of audio and video easier and faster. By BBC News Labs. - Work in progress
JavaScript
494
star
13

psammead

React component library for BBC World Service and more
JavaScript
320
star
14

newslabs-datastringer

Monitor datasets, gets alerts when something happens
JavaScript
212
star
15

html5-video-compositor

This is the BBC Research & Development UX Team's experimental shader based video composition engine for the browser. For new projects please consider using or new VideoContext library https://github.com/bbc/videocontext .
JavaScript
207
star
16

REST-API-example

Simple REST API example in Sinatra
Ruby
193
star
17

grandstand

BBC Grandstand is a collection of common CSS abstractions and utility helper classes
SCSS
190
star
18

sqs-producer

Simple scaffolding for applications that produce SQS messages
TypeScript
181
star
19

r-audio

A library of React components for building Web Audio graphs.
JavaScript
168
star
20

chaos-lambda

Randomly terminate ASG instances during business hours
Python
163
star
21

turingcodec

Source code for the Turing codec, an HEVC software encoder optimised for fast encoding of large resolution video content
C++
153
star
22

bbc-vamp-plugins

A collection of audio feature extraction algorithms written in the Vamp plugin format.
C++
152
star
23

bbc-a11y

BBC Accessibility Guidelines Checker
Gherkin
134
star
24

rcookbook

Reference manual for creating BBC-style graphics using the BBC's bbplot package built on top of R's ggplot2 library
HTML
127
star
25

audio-offset-finder

Find the offset of an audio file within another audio file
Python
124
star
26

datalab-ml-training

Machine Learning Training
Jupyter Notebook
117
star
27

Similarity

Calculate similarity between documents using TF-IDF weights
Ruby
115
star
28

viewporter

In-browser responsive testing tool.
CSS
114
star
29

flashheart

A fully-featured Node.js REST client built for ease-of-use and resilience
JavaScript
114
star
30

qtff-parameter-editor

QuickTime file parameter editor for modifying transfer function, colour primary and matrix characteristics
C++
114
star
31

gel-typography

A flexible code implementation of the GEL Typography Guidelines
CSS
111
star
32

consumer-contracts

Consumer-driven contracts in JavaScript
JavaScript
105
star
33

color-contrast-checker

An accessibility checker tool for validating the color contrast based on WCAG 2.0 and WCAG 2.1 standards.
JavaScript
81
star
34

slayer

JavaScript time series spike detection for Node.js and the browser; like the Octave findpeaks function.
JavaScript
77
star
35

lrud

Left, Right, Up, Down. A spatial navigation library for devices with input via directional controls.
JavaScript
76
star
36

audio_waveform-ruby

Ruby gem that provides access to audio waveform data files generated by audiowaveform
Ruby
76
star
37

software-engineering-technical-assessments

Technical assessment for hiring
Kotlin
71
star
38

nghq

An implementation of Multicast QUIC https://tools.ietf.org/html/draft-pardue-quic-http-mcast-07
C
67
star
39

bigscreen-player

Simplified media playback for bigscreen devices
JavaScript
65
star
40

speculate

Automatically generates an RPM Spec file for your Node.js project
JavaScript
64
star
41

zeitgeist

Twitter Zeitgeist
Ruby
62
star
42

wally

Cucumber feature viewer and navigator
Ruby
57
star
43

theano-bpr

An implementation of Bayesian Personalised Ranking in Theano
Python
54
star
44

ShouldIT

A language agnostic BDD framework.
JavaScript
53
star
45

news-gem-cloudwatch-sender

Send metrics to InfluxDB from Cloudwatch
Ruby
53
star
46

unicode-bidirectional

A Javascript implementation of the Unicode 9.0.0 Bidirectional Algorithm
JavaScript
45
star
47

subtitles-generator

A node module to generate subtitles by segmenting a list of time-coded text - BBC News Labs
JavaScript
44
star
48

accessibility-news-and-you

We want to be the most accessible news website in the world. This is how.
HTML
44
star
49

codext

VS Code's editor shipped as a browser extension.
JavaScript
42
star
50

talexample

An example TV app written using TAL
JavaScript
40
star
51

rdfspace

RDFSpace constructs a vector space from any RDF dataset which can be used for computing similarities between resources in that dataset.
Python
39
star
52

digital-paper-edit-client

Work in progress - BBC News Labs digital paper edit project - React Client
JavaScript
39
star
53

clientside-recommender

A client-side recommender system implemented in Javascript.
Java
39
star
54

gel

JavaScript
39
star
55

childrens-games-starter-pack

This is the Starter Pack for Children's games, containing everything a games developer might need to start building an HTML5 game for Children's BBC. Every game should be forked into a new repository from this repo.
JavaScript
38
star
56

alephant

The Alephant framework is a collection of isolated Ruby gems, which interconnect to offer powerful message passing functionality built up around the "Broker" pattern.
Ruby
37
star
57

vc2-reference

A reference encoder and decoder for SMPTE ST 2042-1 "VC-2 Video Compression"
C++
34
star
58

ruby-lsh

Locality Sensitive Hashing in Ruby
Ruby
32
star
59

Strophejs-PubSub-Demo

A simple demo of Publish/Subscribe in the browser using Strophe.js
JavaScript
31
star
60

lrud-spatial

Left, Right, Up, Down. A spatial navigation library for devices with input via directional controls.
JavaScript
30
star
61

diarize-jruby

A simple toolkit for speaker segmentation and identification
Ruby
30
star
62

pydvbcss

Python library that implements DVB protocols for companion synchronisation
Python
28
star
63

gel-sass-tools

A collection of Sass Settings & Tools which align to key GEL values
SCSS
27
star
64

a11y-tests-web

Runs automated accessibility tests against configurable lists of webpages
JavaScript
27
star
65

RadioVisDemo

RadioDNS and RadioVIS Slideshow Protocol Demo
Python
27
star
66

device-discovery-pairing

Analysis and background research on discovery and pairing for the MediaScape project
26
star
67

node-canvas-lambda-deps

Node Canvas AWS Lambda dependencies i.e. compiled shared object files for Cairo, Pixman, libpng, libjpeg etc.
JavaScript
26
star
68

clever-thumbnailer

Audio thumbnail generator
C
25
star
69

spassky

Distributed web testing tool
JavaScript
25
star
70

bbc-speech-segmenter

A complete speech segmentation system using Kaldi and x-vectors for voice activity detection (VAD) and speaker diarisation.
Shell
24
star
71

genie

BBC Genie Games Framework
JavaScript
24
star
72

media-sequence

HTML5 media sequenced playback API: play one or multiple sequences of a same audio or video with plain JavaScript.
JavaScript
24
star
73

Chart.Bands.js

Chart.js plugin to allow banding on a chart
JavaScript
23
star
74

newslabs-Text_Analytics

A space for code and projects around analysing news content
Python
23
star
75

curriculum-data

BBC Curriculum Instance Data
23
star
76

cloudflare-queue-consumer

Build Cloudflare Queues based applications without the boilerplate (based on SQS Consumer)
TypeScript
23
star
77

videocontext-devtools

Chrome DevTools extension for easy VideoContext debugging.
JavaScript
22
star
78

bmx

Library and utilities to read and write broadcasting media files. Primarily supports the MXF file format
C++
22
star
79

adaptivepodcasting

A project exploring the potential of media which adapts based on sensors and data
JavaScript
21
star
80

UCMythTV

A full implementation of Universal Control 0.6.0 for use on a computer running Mythbuntu with a slightly modified version of MythTV (patches and configure script included).
Python
20
star
81

rdfsim

Large RDF hierarchies as vector spaces
Python
20
star
82

bug

Started life at BBC News - BUG enables control and monitoring of broadcast kit from a single web interface.
JavaScript
20
star
83

digital-paper-edit-electron

Work in progress - BBC News Labs digital paper edit project - Electron, Cross Platform Desktop app - Mac, Windows, Linux
C++
20
star
84

gst-ttml-subtitles

Library and elements that add support for TTML subtitles to GStreamer.
C
19
star
85

dvbcss-synctiming

Measuring synchronisation timing accuracy for DVB Compainion Screen Synchronisation TVs and Companions
Python
19
star
86

fcpx-xml-composer

Work in progress - Module to Convert a json sequence into an FCPX XML. For BBC News Labs digital paper edit project
JavaScript
18
star
87

bbcrd-brirs

An impulse response dataset for dynamic data-based auralisation of advanced sound systems
Common Lisp
18
star
88

MiD

Make it Digital: the BBC's Digital Creativity initiative
Arduino
17
star
89

device_api-android

DeviceAPI-Android
Ruby
17
star
90

tams

Time Addressable Media Store API
Makefile
17
star
91

gs-sass-tools

A collection of Sass variables, functions and mixins, part of BBC Grandstand
CSS
16
star
92

enzyme-adapter-inferno

Inferno enzyme adapter
JavaScript
16
star
93

get-title

Extract the best title value from within HTML head elements.
JavaScript
16
star
94

morty-docs

Generate a static website from markdown files
JavaScript
16
star
95

storyplayer

BBC Research & Development's Object Based Media Player
TypeScript
15
star
96

dialogger

Text-based media editing interface
JavaScript
15
star
97

bbcat-base

Base library for the BBC Audio Toolbox
C++
15
star
98

origin_simulator

A tool to simulate a (flaky) upstream origin during load and stress tests.
Elixir
15
star
99

catflap-camera

Raspberry Pi based catflap-triggered camera. As seen on TV.
Python
15
star
100

citron

Citron is an experimental quote extraction system created by BBC R&D
Python
15
star