Skip to content

Commit

Permalink
feat(json template and template cache string): add json built-in temp…
Browse files Browse the repository at this point in the history
…late, and templateCacheString which defaults to unix timestamp.
  • Loading branch information
mpalpha committed Aug 27, 2019
1 parent 9106a13 commit 1e43bba
Show file tree
Hide file tree
Showing 21 changed files with 357 additions and 66 deletions.
115 changes: 115 additions & 0 deletions demo/webfont.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
@font-face {
font-family: "webfont";
font-style: normal;
font-weight: 400;
font-display: auto;
src: url("./webfont.eot?1565728069335");
src: url("./webfont.eot?#iefix") format("embedded-opentype"), url("./webfont.woff2?1565728069335") format("woff2"), url("./webfont.woff?1565728069335") format("woff"), url("./webfont.ttf?1565728069335") format("truetype"), url("./webfont.svg?1565728069335#webfont") format("svg");
}

.webfont {
display: inline-block;
font-family: "webfont";
font-weight: 400;
font-style: normal;
font-variant: normal;
text-rendering: auto;
line-height: 1;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}

.webfont-lg {
font-size: 1.33333em;
line-height: 0.75em;
vertical-align: -0.0667em;
}

.webfont-xs {
font-size: 0.75em;
}

.webfont-sm {
font-size: 0.875em;
}

.webfont-1x {
font-size: 1em;
}

.webfont-2x {
font-size: 2em;
}

.webfont-3x {
font-size: 3em;
}

.webfont-4x {
font-size: 4em;
}

.webfont-5x {
font-size: 5em;
}

.webfont-6x {
font-size: 6em;
}

.webfont-7x {
font-size: 7em;
}

.webfont-8x {
font-size: 8em;
}

.webfont-9x {
font-size: 9em;
}

.webfont-10x {
font-size: 10em;
}

.webfont-fw {
text-align: center;
width: 1.25em;
}

.webfont-border {
border: solid 0.08em #eee;
border-radius: 0.1em;
padding: 0.2em 0.25em 0.15em;
}

.webfont-pull-left {
float: left;
}

.webfont-pull-right {
float: right;
}

.webfont.webfont-pull-left {
margin-right: 0.3em;
}

.webfont.webfont-pull-right {
margin-left: 0.3em;
}


.webfont-avatar::before {
content: "\ea01";
}

.webfont-envelope::before {
content: "\ea02";
}

.webfont-phone-call::before {
content: "\ea03";
}

Binary file modified demo/webfont.eot
Binary file not shown.
4 changes: 2 additions & 2 deletions demo/webfont.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
font-style: normal;
font-weight: 400;
font-display: auto;
src: url("./webfont.eot");
src: url("./webfont.eot?#iefix") format("embedded-opentype"), url("./webfont.woff2") format("woff2"), url("./webfont.woff") format("woff"), url("./webfont.ttf") format("truetype"), url("./webfont.svg#webfont") format("svg");
src: url("./webfont.eot?1565728045067");
src: url("./webfont.eot?#iefix") format("embedded-opentype"), url("./webfont.woff2?1565728045067") format("woff2"), url("./webfont.woff?1565728045067") format("woff"), url("./webfont.ttf?1565728045067") format("truetype"), url("./webfont.svg?1565728045067#webfont") format("svg");
}

.webfont {
Expand Down
17 changes: 17 additions & 0 deletions demo/webfont.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"id": "avatar",
"name": "Avatar",
"unicode": ["ea01", "avatar"]
},
{
"id": "envelope",
"name": "Envelope",
"unicode": ["ea02", "envelope"]
},
{
"id": "phone-call",
"name": "Phone Call",
"unicode": ["ea03", "phone_call"]
}
]
127 changes: 127 additions & 0 deletions demo/webfont.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@

$webfont-avatar: "\ea01";

$webfont-envelope: "\ea02";

$webfont-phone-call: "\ea03";


@font-face {
font-family: "webfont";
font-style: normal;
font-weight: 400;
font-display: auto;
src: url("./webfont.eot?1565728077137");
src: url("./webfont.eot?#iefix") format("embedded-opentype"), url("./webfont.woff2?1565728077137") format("woff2"), url("./webfont.woff?1565728077137") format("woff"), url("./webfont.ttf?1565728077137") format("truetype"), url("./webfont.svg?1565728077137#webfont") format("svg");
}

%webfont {
display: inline-block;
font-family: "webfont";
font-weight: 400;
font-style: normal;
font-variant: normal;
text-rendering: auto;
line-height: 1;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}

.webfont {
@extend %webfont;
}

.webfont-lg {
font-size: 1.33333em;
line-height: 0.75em;
vertical-align: -0.0667em;
}

.webfont-xs {
font-size: 0.75em;
}

.webfont-sm {
font-size: 0.875em;
}

.webfont-1x {
font-size: 1em;
}

.webfont-2x {
font-size: 2em;
}

.webfont-3x {
font-size: 3em;
}

.webfont-4x {
font-size: 4em;
}

.webfont-5x {
font-size: 5em;
}

.webfont-6x {
font-size: 6em;
}

.webfont-7x {
font-size: 7em;
}

.webfont-8x {
font-size: 8em;
}

.webfont-9x {
font-size: 9em;
}

.webfont-10x {
font-size: 10em;
}

.webfont-fw {
text-align: center;
width: 1.25em;
}

.webfont-border {
border: solid 0.08em #eee;
border-radius: 0.1em;
padding: 0.2em 0.25em 0.15em;
}

.webfont-pull-left {
float: left;
}

.webfont-pull-right {
float: right;
}

.webfont.webfont-pull-left {
margin-right: 0.3em;
}

.webfont.webfont-pull-right {
margin-left: 0.3em;
}


.webfont-avatar::before {
content: "\ea01";
}

.webfont-envelope::before {
content: "\ea02";
}

.webfont-phone-call::before {
content: "\ea03";
}

16 changes: 8 additions & 8 deletions demo/webfont.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/webfont.ttf
Binary file not shown.
Binary file modified demo/webfont.woff
Binary file not shown.
Binary file modified demo/webfont.woff2
Binary file not shown.
46 changes: 23 additions & 23 deletions src/__tests__/__snapshots__/standalone.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`standalone should create css selectors with transform titles through fu
font-style: normal;
font-weight: 400;
font-display: auto;
src: url(\\"./webfont.eot\\");
src: url(\\"./webfont.eot?test\\");
src: url(\\"./webfont.eot?#iefix\\") format(\\"embedded-opentype\\");
}
Expand Down Expand Up @@ -125,8 +125,8 @@ exports[`standalone should generate all fonts with build-in template 1`] = `
font-style: normal;
font-weight: 400;
font-display: auto;
src: url(\\"./webfont.eot\\");
src: url(\\"./webfont.eot?#iefix\\") format(\\"embedded-opentype\\"), url(\\"./webfont.woff2\\") format(\\"woff2\\"), url(\\"./webfont.woff\\") format(\\"woff\\"), url(\\"./webfont.ttf\\") format(\\"truetype\\"), url(\\"./webfont.svg#webfont\\") format(\\"svg\\");
src: url(\\"./webfont.eot?test\\");
src: url(\\"./webfont.eot?#iefix\\") format(\\"embedded-opentype\\"), url(\\"./webfont.woff2?test\\") format(\\"woff2\\"), url(\\"./webfont.woff?test\\") format(\\"woff\\"), url(\\"./webfont.ttf?test\\") format(\\"truetype\\"), url(\\"./webfont.svg?test#webfont\\") format(\\"svg\\");
}
.webfont {
Expand Down Expand Up @@ -242,13 +242,13 @@ exports[`standalone should generate all fonts with custom \`template\` with abso
"/* custom template */
@font-face {
font-family: webfont;
src: url(\\"./webfont.eot\\");
src: url(\\"./webfont.eot?test\\");
src:
url(\\"./webfont.eot?#iefix\\") format(\\"embedded-opentype\\"),
url(\\"./webfont.woff2\\") format(\\"woff2\\"),
url(\\"./webfont.woff\\") format(\\"woff\\"),
url(\\"./webfont.ttf\\") format(\\"truetype\\"),
url(\\"./webfont.svg#webfont\\") format(\\"svg\\");
url(\\"./webfont.woff2?test\\") format(\\"woff2\\"),
url(\\"./webfont.woff?test\\") format(\\"woff\\"),
url(\\"./webfont.ttf?test\\") format(\\"truetype\\"),
url(\\"./webfont.svg?test#webfont\\") format(\\"svg\\");
font-style: normal;
font-weight: 400;
}
Expand Down Expand Up @@ -308,13 +308,13 @@ exports[`standalone should generate all fonts with custom \`template\` with rela
"/* custom template */
@font-face {
font-family: webfont;
src: url(\\"./webfont.eot\\");
src: url(\\"./webfont.eot?test\\");
src:
url(\\"./webfont.eot?#iefix\\") format(\\"embedded-opentype\\"),
url(\\"./webfont.woff2\\") format(\\"woff2\\"),
url(\\"./webfont.woff\\") format(\\"woff\\"),
url(\\"./webfont.ttf\\") format(\\"truetype\\"),
url(\\"./webfont.svg#webfont\\") format(\\"svg\\");
url(\\"./webfont.woff2?test\\") format(\\"woff2\\"),
url(\\"./webfont.woff?test\\") format(\\"woff\\"),
url(\\"./webfont.ttf?test\\") format(\\"truetype\\"),
url(\\"./webfont.svg?test#webfont\\") format(\\"svg\\");
font-style: normal;
font-weight: 400;
}
Expand Down Expand Up @@ -377,7 +377,7 @@ exports[`standalone should generate only \`woff\` and \`woff2\` fonts with build
font-weight: 400;
font-display: auto;
src: url(\\"./webfont.woff2\\") format(\\"woff2\\"), url(\\"./webfont.woff\\") format(\\"woff\\");
src: url(\\"./webfont.woff2?test\\") format(\\"woff2\\"), url(\\"./webfont.woff?test\\") format(\\"woff\\");
}
.webfont {
Expand Down Expand Up @@ -503,8 +503,8 @@ exports[`standalone should load config and respect \`template\` option with buil
font-style: normal;
font-weight: 400;
font-display: auto;
src: url(\\"./webfont.eot\\");
src: url(\\"./webfont.eot?#iefix\\") format(\\"embedded-opentype\\"), url(\\"./webfont.woff2\\") format(\\"woff2\\"), url(\\"./webfont.woff\\") format(\\"woff\\"), url(\\"./webfont.ttf\\") format(\\"truetype\\"), url(\\"./webfont.svg#webfont\\") format(\\"svg\\");
src: url(\\"./webfont.eot?test\\");
src: url(\\"./webfont.eot?#iefix\\") format(\\"embedded-opentype\\"), url(\\"./webfont.woff2?test\\") format(\\"woff2\\"), url(\\"./webfont.woff?test\\") format(\\"woff\\"), url(\\"./webfont.ttf?test\\") format(\\"truetype\\"), url(\\"./webfont.svg?test#webfont\\") format(\\"svg\\");
}
%webfont {
Expand Down Expand Up @@ -624,13 +624,13 @@ exports[`standalone should load config and respect \`template\` option with exte
"/* custom template */
@font-face {
font-family: webfont;
src: url(\\"./webfont.eot\\");
src: url(\\"./webfont.eot?test\\");
src:
url(\\"./webfont.eot?#iefix\\") format(\\"embedded-opentype\\"),
url(\\"./webfont.woff2\\") format(\\"woff2\\"),
url(\\"./webfont.woff\\") format(\\"woff\\"),
url(\\"./webfont.ttf\\") format(\\"truetype\\"),
url(\\"./webfont.svg#webfont\\") format(\\"svg\\");
url(\\"./webfont.woff2?test\\") format(\\"woff2\\"),
url(\\"./webfont.woff?test\\") format(\\"woff\\"),
url(\\"./webfont.ttf?test\\") format(\\"truetype\\"),
url(\\"./webfont.svg?test#webfont\\") format(\\"svg\\");
font-style: normal;
font-weight: 400;
}
Expand Down Expand Up @@ -692,8 +692,8 @@ exports[`standalone should respect \`template\` options 1`] = `
font-style: normal;
font-weight: 400;
font-display: auto;
src: url(\\"./foo-bar/bar.eot\\");
src: url(\\"./foo-bar/bar.eot?#iefix\\") format(\\"embedded-opentype\\"), url(\\"./foo-bar/bar.woff2\\") format(\\"woff2\\"), url(\\"./foo-bar/bar.woff\\") format(\\"woff\\"), url(\\"./foo-bar/bar.ttf\\") format(\\"truetype\\"), url(\\"./foo-bar/bar.svg#bar\\") format(\\"svg\\");
src: url(\\"./foo-bar/bar.eot?test\\");
src: url(\\"./foo-bar/bar.eot?#iefix\\") format(\\"embedded-opentype\\"), url(\\"./foo-bar/bar.woff2?test\\") format(\\"woff2\\"), url(\\"./foo-bar/bar.woff?test\\") format(\\"woff\\"), url(\\"./foo-bar/bar.ttf?test\\") format(\\"truetype\\"), url(\\"./foo-bar/bar.svg?test#bar\\") format(\\"svg\\");
}
.foo {
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/fixtures/configs/.webfontrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"normalize": true,
"foo": "bar"
"foo": "bar",
"templateCacheString": "test"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"template": "scss"
"template": "scss",
"templateCacheString": "test"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"template": "src/__tests__/fixtures/templates/template.css"
"template": "src/__tests__/fixtures/templates/template.css",
"templateCacheString": "test"
}
Loading

0 comments on commit 1e43bba

Please sign in to comment.