Skip to content

Commit

Permalink
Add createGlobalStyle keyword
Browse files Browse the repository at this point in the history
This commit adds support for the new keyword `createGlobalStyle` that
replaces `injectGlobal` in styled-components.

NOTE: The latter is kept as it's still part of the emotion API and also
      to be backwards compatible.
  • Loading branch information
fleischie committed Sep 5, 2018
1 parent 665ee8a commit f5a058f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion after/syntax/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ syn match cssError contained "{@<>"

" extend javascript matches to trigger styledDefinition highlighting
syn match jsTaggedTemplate extend
\ "\<css\>\|\<keyframes\>\|\<injectGlobal\>\|\<fontFace\>"
\ "\<css\>\|\<keyframes\>\|\<injectGlobal\>\|\<fontFace\>\|\<createGlobalStyle\>"
\ nextgroup=styledDefinition
syn match jsFuncCall "\<styled\>\s*(.\+)" transparent
\ nextgroup=styledDefinition
Expand Down
13 changes: 12 additions & 1 deletion examples/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const genericTemplateString = `
* Note: As glamor and emotion use similar APIs, only the extraneous APIs are
* mentioned later on.
*/
import styled, { css, keyframes, injectGlobal } from 'styled-components';
import styled, { css, keyframes, createGlobalStyle } from 'styled-components';

// match of styled.method api
// - unmatched cssTagName (note the double typoes and missing highlighting)
Expand Down Expand Up @@ -109,6 +109,17 @@ injectGlobal`
margin: 0;
}
`;
// - createGlobalStyle
createGlobalStyle`
@font-face {
font-family: 'Operator Mono';
src: url('../fonts/Operator-Mono.ttf');
}
body {
margin: 0;
}
`;

// class based stylings
class Container {
Expand Down

0 comments on commit f5a058f

Please sign in to comment.