TIL about PostCSS mixins

A presentation at Tech Talk @ Tagesspiegel in December 2019 in Berlin, Germany by Gunnar Bittersmann

Slide 1

Slide 1

TIL about PostCSS mixins

Slide 2

Slide 2

&!—right-inline .metainfo!__text:first-child { @media (!—media-sm-down) { > * { display: inline; } !/* and when there’s slot content, put a separator after author credits !/ .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } } } !/ when there’s no author image, render metainfo text content inline !/ &!—inline .metainfo!__text:first-child { &, > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !*/ .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } }

Slide 3

Slide 3

@define-mixin metainfo-separator { content: ‘|’; padding: 0 0.25em; font-weight: normal; } &!—right-inline .metainfo!__text:first-child { @media (!—media-sm-down) { > * { display: inline; } !/* and when there’s slot content, put a separator after author credits !/ .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } } } !/ when there’s no author image, render metainfo text content inline !/ &!—inline .metainfo!__text:first-child { &, > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !*/ .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } }

Slide 4

Slide 4

@define-mixin metainfo-separator { content: ‘|’; padding: 0 0.25em; font-weight: normal; } &!—right-inline .metainfo!__text:first-child { @media (!—media-sm-down) { > * { display: inline; } !/* and when there’s slot content, put a separator after author credits !/ .metainfo!__credits:not(:last-child)!::after { @mixin metainfo-separator } } } !/ when there’s no author image, render metainfo text content inline !/ &!—inline .metainfo!__text:first-child { &, > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !*/ .metainfo!__credits:not(:last-child)!::after { @mixin metainfo-separator } } }

Slide 5

Slide 5

@define-mixin metainfo-separator { content: ‘|’; padding: 0 0.25em; font-weight: normal; } &!—right-inline .metainfo!__text:first-child { @media (!—media-sm-down) { > * { display: inline; } !/* and when there’s slot content, put a separator after author credits !/ .metainfo!__credits:not(:last-child)!::after { @mixin metainfo-separator } } } !/ when there’s no author image, render metainfo text content inline !/ &!—inline .metainfo!__text:first-child { &, > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !*/ .metainfo!__credits:not(:last-child)!::after { @mixin metainfo-separator } } }

Slide 6

Slide 6

@define-mixin metainfo-separator { .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } &!—right-inline .metainfo!__text:first-child { @media (!—media-sm-down) { > * { display: inline; } !/* and when there’s slot content, put a separator after author credits !/ @mixin metainfo-separator } } } !/ when there’s no author image, render metainfo text content inline !/ &!—inline .metainfo!__text:first-child { &, > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !*/ @mixin metainfo-separator }

Slide 7

Slide 7

@define-mixin metainfo-separator { .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } &!—right-inline .metainfo!__text:first-child { @media (!—media-sm-down) { > * { display: inline; } !/* and when there’s slot content, put a separator after author credits !/ @mixin metainfo-separator } } } !/ when there’s no author image, render metainfo text content inline !/ &!—inline .metainfo!__text:first-child { &, > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !*/ @mixin metainfo-separator }

Slide 8

Slide 8

@define-mixin metainfo-separator { .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } &!—right-inline .metainfo!__text:first-child { @media (!—media-sm-down) { > * { display: inline; } !/* and when there’s slot content, put a separator after author credits !/ @mixin metainfo-separator } } } !/ when there’s no author image, render metainfo text content inline !/ &!—inline .metainfo!__text:first-child { & { display: inline; } > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !*/ @mixin metainfo-separator }

Slide 9

Slide 9

@define-mixin metainfo-separator { !/* when there’s no author image, render metainfo text content inline !/ > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !/ .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } &!—right-inline .metainfo!__text:first-child { @media (!—media-sm-down) { @mixin metainfo-separator } } } !/ when there’s no author image, render metainfo text content inline !*/ &!—inline .metainfo!__text:first-child { & { display: inline; } @mixin metainfo-separator }

Slide 10

Slide 10

@define-mixin metainfo-separator { !/* when there’s no author image, render metainfo text content inline !/ > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !/ .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } &!—right-inline .metainfo!__text:first-child { @media (!—media-sm-down) { @mixin metainfo-separator } } } !/ when there’s no author image, render metainfo text content inline !*/ &!—inline .metainfo!__text:first-child { & { display: inline; } @mixin metainfo-separator }

Slide 11

Slide 11

@define-mixin metainfo-separator { !/* when there’s no author image, render metainfo text content inline !/ > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !/ .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } &!—right-inline { @media (!—media-sm-down) { .metainfo!__text:first-child { @mixin metainfo-separator } } } } !/ when there’s no author image, render metainfo text content inline !*/ &!—inline .metainfo!__text:first-child { display: inline; } .metainfo!__text:first-child { @mixin metainfo-separator } }

Slide 12

Slide 12

@define-mixin metainfo-separator { !/* when there’s no author image, render metainfo text content inline !/ .metainfo!__text:first-child { > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !/ .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } } &!—right-inline { @media (!—media-sm-down) { @mixin metainfo-separator } } !/ when there’s no author image, render metainfo text content inline !*/ &!—inline .metainfo!__text:first-child { display: inline; } } } @mixin metainfo-separator

Slide 13

Slide 13

@define-mixin metainfo-separator { !/* when there’s no author image, render metainfo text content inline !/ .metainfo!__text:first-child { > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !/ .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } } &!—right-inline { @media (!—media-sm-down) { @mixin metainfo-separator } } !/ when there’s no author image, render metainfo text content inline !*/ &!—inline .metainfo!__text:first-child { display: inline; } } } @mixin metainfo-separator

Slide 14

Slide 14

@define-mixin metainfo-inline { !/* when there’s no author image, render metainfo text content inline !/ .metainfo!__text:first-child { > * { display: inline; } !/ and when there’s slot content, put a separator after author credits !/ .metainfo!__credits:not(:last-child)!::after { content: ‘|’; padding: 0 0.25em; font-weight: normal; } } } &!—right-inline { @media (!—media-sm-down) { @mixin metainfo-inline } } !/ when there’s no author image, render metainfo text content inline !*/ &!—inline .metainfo!__text:first-child { display: inline; } } } @mixin metainfo-inline