Financial-Times / o-typography

Typography and vertical rhythm styles for FT branding
http://registry.origami.ft.com/components/o-typography
10 stars 2 forks source link

Multiple scales and custom fonts. #163

Closed notlee closed 6 years ago

notlee commented 6 years ago

👇 This is where we started. See comments for final outcome.

Goals

Progress

Scale per font

Fonts outside of sans/serif/display.

To show how this works existing typography mixins wrap these e.g. oTypographySerif, oTypographyDisplay, oTypographyDisplayBold:

@mixin oTypographySerif($scale: false, $line-height: false, $progressive: true) {
    @include oTypography($o-typography-serif, $opts: (
        'family': true,
        'scale': $scale,
        'custom-line-height': $line-height,
        'progressive': $progressive
    ));
}

In a future major these mixins may be trimmed down, e.g. oTypographyDisplayBold could be removed and replaced with just oTypographyDisplay and an opts param:

@mixin oTypographyDisplay($opts) {
    @include oTypography($o-typography-display, $opts));
}

@include oTypographyDisplay(($scale: 1, $weight: 'bold'));

Other

Potential Future Direction

Brain dump:

// Keep
oTypography // new, output custom fonts
oTypographySerif
oTypographyDisplay
oTypographySans
oTypographyLink (accepts theme, external flag)
oTypographyWrapper
oTypographyBody
oTypographyCaption
oTypographyFooter
oTypographySub
oTypographySuper
oTypographyBlockquote
oTypographyHeadingLevel1 // new
oTypographyHeadingLevel2
oTypographyHeadingLevel3
oTypographyHeadingLevel4
oTypographyHeadingLevel5
oTypographyListOrdered
oTypographyListUnordered

// Remove
oTypographySize // replace with opts
oTypographyBold // replace with opts
oTypographyDisplayBold // replace with opts
oTypographySansBold // replace with opts
oTypographySerifBold // replace with opts
oTypographySerifItalic // replace with opts
oTypographyLinkCustom // replace with theme
oTypographyProgressiveFontFallback // why public?
oTypographyMargin // just use spacing?
oTypographyPadding // just use spacing?
oTypographyList // use ordered or unordered
oTypographyLinkExternal // replace with flag
oTypographyLinkExternalIcon // why public?
oTypographyItalic // replace with opts
oTypographyProductHeadingLevel1 // "product" headings default
oTypographyProductHeadingLevel2 // "product" headings default
oTypographyProductHeadingLevel3 // "product" headings default
oTypographyProductHeadingLevel4 // "product" headings default
oTypographyProductHeadingLevel5 // "product" headings default
oTypographyProductHeadingLevel6 // "product" headings default
oTypographyProductHeadingLevel7 // "product" headings default
oTypographyProductHeadingLevel8 // "product" headings default

// Break out article specific
oTypographyTimestamp
oTypographyStandfirst
oTypographyTag
oTypographyAuthor
oTypographyTopic
oTypographyReadNext
oTypographyBigNumber
oTypographyCollectionHeader
oTypographyHeadline // should oTypographyArticalHeadingLevel1 exist?
oTypographyHeadlineLarge // should oTypographyArticalHeadingLevel1 exist?
oTypographyArticalHeadingLevel1 // new, with product headings default
oTypographyArticalHeadingLevel2 // new, with product headings default
oTypographyArticalHeadingLevel3 // new, with product headings default
oTypographyArticalHeadingLevel4 // new, with product headings default
oTypographyArticalHeadingLevel5 // new, with product headings default
oTypographyArticalHeadingLevel6 // new, with product headings default
oTypographyArticalHeadingLevel7 // new, with product headings default
oTypographyArticalHeadingLevel8 // new, with product headings default
notlee commented 6 years ago

Why register a custom font with o-fonts? Component implementations should be able to call oFontsVariantExists and get a reliable result. Else breaking changes might creep in for whitelabel users without us noticing.

notlee commented 6 years ago

Thanks for the feedback! I'm going to make this real and not a proof of concept. Ignore the branch name 😬

notlee commented 6 years ago

@Financial-Times/origami-core This is ready for review. I'm going to merge this into a base branch which will include branding work, just in case branding gives me reason to change the interface of the new oTypographyFor mixin.

This PR

Features:

Implementation:

Up Next

notlee commented 6 years ago

Based on feedback from @gvonkoss I added a helper mixin oTypographySetCustomFont for setting a custom font. I've also made oTypographyFor private, as access to that mixin isn't needed by consumers yet.