Code Monkey home page Code Monkey logo

gel-typography's Introduction

GEL Typography

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

What is this?

An implementation of the GEL Typography Guidelines. Providing typefaces, type sizes, weights, line-heights and tracking. The GEL Typography scale has been established to work on all devices and is independent of device size and resolution.

The typographic scale has been optimised based on the size of the viewport and the input method being used. We take a 'touch first' approach to typography, adjustments are then made if a primary input other than touch has been detected.

It can used in two forms, using a Sass mixin:

.my-component {
    @include gel-typography('canon-bold');
}

Or by simply adding the relevant classes to your markup:

<h1 class="gel-canon-bold">Global Experience Language</h1>

Installation

The easiest way to get started with the GEL Typography component is to use the combined version of the typography included within this repository.

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

Install using NPM

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

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.

Dependencies

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

Usage

By default the GEL Typography component does not output any markup but exposes a Sass Mixin which can be called within your Sass.

Example

.my-component {
    @include gel-typography('pica');
}

.my-component__title {
    @include gel-typography('canon');
}

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

Example:

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

@import "gel-typography/typography";

The following configurable options are available:

General Configuration

  • $gel-type-namespace: 'gel-'; - the default namespace applied to all typography classes
  • $gel-type-touch-class: 'no-touch'; - the class exposed used by your touch detection script applied when a non-touch interface is detected

Output Configuration

  • $gel-type-enable--markup-output: false; - output a collection of classes for each type group
  • $gel-type-enable--font-family: false; - output the correct font-family required by GEL Typography, required if the BBC's global header and footer, Barlesque, is not available.
  • $gel-type-enable--base-elements: false; - map the GEL Typography classes to the relevant HTML elements

Custom Font Configuration

If you're using another font-face other than Arial and need to make adjustments to any of the type settings you can do this by defining in a custom $gel-type-settings map.

For example: BBC News support many languages, some of which do not use latin based character sets which require custom font scripts. It is often the case that these custom fonts will require bespoke font-sizes or line-heights.

For example, the configuration for Burmese may look like:

$gel-type-settings: (
    'trafalgar': (
        'group-a': (
          'font-size': 22px,
          'line-height': 30px,
        ),
        'group-b': (
          'font-size': 26px,
          'line-height': 36px
        ),
        'group-c': (
          'font-size': 38px,
          'line-height': 50px
        ),
        'group-d': (
          'font-size': 32px,
          'line-height': 32px
        )
    ),
    'trafalgar-bold': (
       ...
    )
);

Touch Detection

We operate a touch-first approach to our Typography. Group C (touch) sizes are used from 600px by default and then detection should be used to get the Group D (non-touch) sizes.

We also understand that touch detection is not an absolute measure and does not guarantee a 'true or false' outcome - this is okay.

Why not just have Group C and remove Group D?

Products such as News & Sport require more densely packed, legacy-like font sizes for their 'desktop' experience. Eventually we aim to remove this group altogether.

How can you detect touch

There are a number of ways you can apply the touch detection. Modernizr, the common feature detection library offers some basic touch events detection. Alternatively, you could use your own bespoke detection script like this one used by BBC Sport.

Who is using this?

The following teams are currently using this component: GEL, News, Sport, Live, Homepage, Search, BBC Food, CBBC, CBeebies, BBC Three, MyBBC, K&L, Taster, Academy, Travel & Weather, BBC Music, BBC Subtitle Guidelines

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

Credits

Maintainers

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.

gel-typography's People

Contributors

craigkj avatar crouchygt avatar itsaljones avatar jcockerill86 avatar jucke avatar nigelmegitt avatar randombitsuk avatar shaunbent avatar simonsinclair avatar simonsmith avatar tsouk avatar willbamford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gel-typography's Issues

$gel-type-enable-base-elements should set font-size and line-height on p, ul and ol

Currently the base elements define font-size and line-height for p,ul and ol.

p, ul, ol {
    @extend %gel-pica;
}

IMO this should not be done as we should take advantage of the standard cascade of font-size and line-height. The above css should be removed and people should specify gel-pica on a parent element:

<div class="gel-pica">
    <p>blah</p>
    <p>blah</p>
</div>

This means that apps can constrain the gel styling to just their application container, not affecting the other page wrappers such as the ORB.

Update Pica & Create a new article 'Body copy' Definition.

We need to update gel-pica to have a tighter, more index suitable line-height across the groups as its been agreed that this will now be used only for indexing and not for the dual purpose of indexing & article body copy.

In addition, a new, more specific Article gel-body-copy class will be added to the groups. This allows us to have a more precise and suitable reading experience.

Will update with sizes shortly.

GEL Typography v2

Following agreements from the Responsive Working Group, we need to update some of the type sizes and line heights shortly to form the Typography v2 Guideline.

This will also update seamlessly to v2 on our website: http://www.bbc.co.uk/gel/guidelines/typography

  • Canon. sizes agreed by all products across all groups - 28/32 on A, 32/36 on B, 52/56 on C, 44/48 on D.
  • Group D (non touch) - Increased line-heights - Line-height changes: Trafalgar 32 to 36, Double pica 24 to 28, Great primer 20 to 24.
  • Group C - Double Pica reduced to 26/30 from 28/32, Great Primer reduced from 24/28 to 21/24, Long Primer reduced from 16/22 to 15/20.
  • Group B - Great Primer reduced from 20/24 to 18/22, Long Primer reduced from 16/20 to 15/18, Brevier line height increased 16 to 18.
  • Group A - Great Primer line height increased from 20 to 22.

Remove MQ dependancy checks

Would make sense to move this up the triangle and do a single check at the start instead of repeating this code over and over within each GEL component

Group D font sizes break without Javascript enabled

Group D font sizes make use of the .no-touch class normally appended to the HTML element by Modernizr or something similar. As a result, when Javascript is disabled, on desktop, Group C font sizes kick in.

The easy solution I could see to this, is to set a default 'no-touch' class to the HTML element. However, this is controlled by Barlesque and there is no way to control this.

I guess you know about this. How do you deal with it? I'm working on cards layouts with heights dictated by the images, so I get text overflows with the wrong font sizes. The only other solution is to hide content and start peppering my CSS with .js prefixes to then display it. Don't want to do this.

0.5.2 NPM package.json changes

Hey,

We're stuck on 0.5.2 currently and the probability of us getting time to update to 2.0 is unlikely at present.

However, we're upgrading to Node v4 and the package.json in a dependency of version 0.5.2 is malformed (I believe gel-tools 0.4.0 used an array for main[]).

Could I request a 0.5.3 release with an update to the package.json for gel-tools 0.4.2 so we can continue using 0.5.2 on node v4 until we get the change to update at a later stage?

Consistant Code GEL Introduction

We need a clear and consistant Code GEL Introduction across these repos, helping to increase awareness and knowledge of other repos. The intro should be quite high level for new starters, stakeholders etc.

Remove REM function

The currently bundled version of the REM function will now form part of a GEL tools package so can be removed from here.

Update dependancies

The new GEL abstractions will give this package some new dependancies which we'll need to add in to both the Bower and NPM package files.

Update variable names

Would be good if all our variables followed the same naming convention so lets update the typography variables to match the other GEL code abstractions.

Should define margins

As we currently only make a provision for font-size and line-height, and leave everything else up to the application, sections of continuous prose looks odd unless the application does some additional work.

Continuous prose looks odd as we don't specify the margin-bottom of pages which means by default the vertical-rhythm of multiple <p> tags breaks as the default margin-bottom is 1em, when IMO we should set it to be equal to the line-height of pica (which is the expected base-text size).

GEL Minion with accents on Windows

Affects

  • OS: Windows (doesn't seem to affect OSX)
  • Browsers: Seen intermittently on IE9-IE11 and consistently on Chrome. Not tested others.

Description

The current line-height: rem(16px); cuts off the top of accents when an overflow: hidden; style is applied (for use with text-overflow: ellipsis;). Adding line-height: rem(17px); fixes the issue and doesn't seem to cause layout issues across any of the mac browsers (for us anyway).

Screen shots

IE11 Current
gel-minion-ie-current

IE11 After Fix
gel-minion-ie-fix

Chrome Current
gel-minion-chrome-current

Chrome After Fix
gel-minion-chrome-fix

Mixins for Typography

Whilst we could advocate using the GEL Typography classes within markup is the most effective way of applying the typography to your codebase and offers complete separation of concerns. There are certain cases where we either can't use this or need to do something a little more bespoke.

To facilitate these edge cases we should expose some helper mixins so that typography can be applied consistent way. Something like this:

.some-component {
    @include gel-pica;
}

This should output the following:

.some-component {
      font-size: 15px;
      line-height: 20px;
}

@media all and (min-width: 20em) {
    .some-component {
       font-size: 16px;
       line-height: 22px;
    }
}

@media all and (min-width: 37.5em) {
    .some-component {
       font-size: 18px;
       line-height: 24px;
    }

    .no-touch .some-component {
       font-size: 16px;
       line-height: 22px;
    }
}

We should also investigate a way that you can output a specific typography group, thus allowing you to change the typography group at different breakpoints. Something like:

.some-component {
    @include gel-double-pica;

    @if $enhanced {
        @include mq($from: gel-bp-m) {
            @include gel-pica;
        }
    }
}

We would really need to think about this though as we need to ensure the output is correct. You might need to be able to specify the specific typography group size you want output. Maybe something like this:

.some-component {
    @include gel-double-pica(group-a);
}

We need to remember if you output group-c or group-d these two are always linked. If you output one you should always output the other.

Extends

You could achieve a similar thing with the existing codebase but this would involve using the Sass @extend feature which is probably not appropriate for this kind of relationship:

Whilst this will produce more output compared to the use of an @extend research has shown that compression will be more effective on this repeating data, thus negating the page weight of any additional output. Avoiding the use of @extend also stops any false relationships being forged between code elements.

Sample Page Fails Tests for gel-long-primer-bold

Our test rig looks for an element on the sample page with a class of .gel-long-primer-bold and then expects it to have a line-height of 18px at a viewport width of 321px. This test is failing because there are two elements on the Sample page with a class of .gel-long-primer-bold. The first element is a button with the text "Go to BBC GEL". This element is affected by the .button class which modifies the normal line-height. The test rig is mistakenly running tests on that button instead of the correct test element further down the page.

Please remove the button from that page, or give it a class other than .gel-long-primer-bold to make the test rig go green :)

Opt-in Display Sizes

We will be adding a new section of optional ‘Display type’ sizes to the Guideline. This will allow typography to be used for greater impact, offer sizes that are more visually balanced on wider grids and help to rationalise our use of type at sizes larger than ‘Canon’.

The new opt-in sizes to be added are:

Foolscap – Group A: 32/36, Group B: 40/44, Group C: 72/80, Group D: 56/60
Royal – Group A: 40/44, Group B: 52/60, Group C: 94/104, Group D: 76/84
Imperial – Group A: 50/54, Group B: 64/72, Group C: 124/136, Group D: 96/104
Elephant – Group A: 60/64, Group B: 78/84, Group C: 156/170, Group D: 116/124
Atlas – Group A: 78/84, Group B: 96/104, Group C: 192/208, Group D: 140/148

Font stack is inconsistent with Barlesque

If $gel-type-enable--font-family is enabled, the font stack produced by gel-typography is inconsistent with that in Barlesque/Orb

Compare:
https://github.com/bbc/gel-typography/blob/master/_typography.scss#L41

With:
https://github.com/bbc/nav-orbit/blob/master/static-sources/sass/global/_reset.scss#L251
and
https://github.com/bbc/nav-barlesque/blob/a44453ec49a5edb99390b523f4a354a500757103/static-sources/orb/sass/global/_reset.scss#L251

As most teams will not need to enable the font-family flag, the demo pages for this project are misleading, as they appear to have been built with this flag enabled

specificity issue with line-height

We have use-cases with the search card design where the default line-height needs over-riding. For some fonts this works fine, for others, the .no-touch specificity make this difficult.

e.g. to over-ride the line-height for 'minion', this works fine as it is only defined for group-a. However, for long-primer, as line-height is also defined for the other groups the .no-touch specificity issue arises.

So, our options are to either use .no-touch specificity to override the line-height on the desired element, or to use !important

Unable to find a suitable version for sass-mq

The version of sass-mq required by gel-typography and gel-layout are not same. If you install gel-layout then gel-typography you end up with Unable to find a suitable version for sass-mq.

$ bower install --save git+ssh://[email protected]/bbc/gel-typography.git
bower gel-typography#*          cached ssh://[email protected]/bbc/gel-typography.git#1.0.0
bower gel-typography#*        validate 1.0.0 against ssh://[email protected]/bbc/gel-typography.git#*
bower gel-sass-tools#^1.0.0     cached [email protected]:bbc/gel-sass-tools.git#1.1.0
bower gel-sass-tools#^1.0.0   validate 1.1.0 against [email protected]:bbc/gel-sass-tools.git#^1.0.0
bower sass-mq#^3.2.3            cached git://github.com/sass-mq/sass-mq.git#3.2.4
bower sass-mq#^3.2.3          validate 3.2.4 against git://github.com/sass-mq/sass-mq.git#^3.2.3

Unable to find a suitable version for sass-mq, please choose one:
    1) sass-mq#~3.1.2 which resolved to 3.1.2 and is required by gel-settings#0.3.0
    2) sass-mq#^3.2.3 which resolved to 3.2.4 and is required by gel-sass-tools#1.1.0

Prefix the choice with ! to persist it to bower.json

? Answer

Incorrect repo URL

Should be https://bbc.github.io/gel-typography/ instead of https://bbc-gel.github.io/gel-typography/.

Great news to see this code here :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.