-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(css): Allow
@import
in css examples (#1129)
* feat(css): Allow `@import` in css examples * Make it work also in `cssHiddenSrc` * Correct test file extension * Add types
- Loading branch information
1 parent
ceb3658
commit 4949ded
Showing
7 changed files
with
115 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import fse from "fs-extra"; | ||
import getConfig from "../lib/config.js"; | ||
|
||
const config = getConfig(); | ||
|
||
describe("example", () => { | ||
describe("font-stretch", () => { | ||
it("should have content of @import directly in css", () => { | ||
const path = "live-examples/css-examples/fonts/font-stretch.css"; | ||
const content = fse.readFileSync(config.baseDir + path, "utf8"); | ||
|
||
const expectedOutput = | ||
'@font-face{font-family:molot;src:url("/media/fonts/molot.woff2") format("woff2")}#output section{font-size:1.2em;font-family:molot,sans-serif}'; | ||
|
||
expect(content).toBe(expectedOutput); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@import "../../fonts/molot.css"; | ||
|
||
#output section { | ||
font-size: 1.2em; | ||
font-family: molot, sans-serif; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<section | ||
id="example-choice-list" | ||
class="example-choice-list" | ||
data-property="font-stretch" | ||
> | ||
<div class="example-choice" initial-choice="true"> | ||
<pre><code class="language-css">font-stretch: condensed;</code></pre> | ||
<button type="button" class="copy hidden" aria-hidden="true"> | ||
<span class="visually-hidden">Copy to Clipboard</span> | ||
</button> | ||
</div> | ||
<div class="example-choice"> | ||
<pre><code class="language-css">font-stretch: expanded;</code></pre> | ||
<button type="button" class="copy hidden" aria-hidden="true"> | ||
<span class="visually-hidden">Copy to Clipboard</span> | ||
</button> | ||
</div> | ||
<div class="example-choice"> | ||
<pre><code class="language-css">font-stretch: ultra-expanded;</code></pre> | ||
<button type="button" class="copy hidden" aria-hidden="true"> | ||
<span class="visually-hidden">Copy to Clipboard</span> | ||
</button> | ||
</div> | ||
<div class="example-choice"> | ||
<pre><code class="language-css">font-stretch: 50%;</code></pre> | ||
<button type="button" class="copy hidden" aria-hidden="true"> | ||
<span class="visually-hidden">Copy to Clipboard</span> | ||
</button> | ||
</div> | ||
<div class="example-choice"> | ||
<pre><code class="language-css">font-stretch: 100%;</code></pre> | ||
<button type="button" class="copy hidden" aria-hidden="true"> | ||
<span class="visually-hidden">Copy to Clipboard</span> | ||
</button> | ||
</div> | ||
<div class="example-choice"> | ||
<pre><code class="language-css">font-stretch: 150%;</code></pre> | ||
<button type="button" class="copy hidden" aria-hidden="true"> | ||
<span class="visually-hidden">Copy to Clipboard</span> | ||
</button> | ||
</div> | ||
</section> | ||
|
||
<div id="output" class="output hidden"> | ||
<section id="default-example" class="default-example"> | ||
<p id="example-element" class="transition-all"> | ||
London. Michaelmas term lately over, and the Lord Chancellor sitting in | ||
Lincoln's Inn Hall. Implacable November weather. As much mud in the | ||
streets as if the waters had but newly retired from the face of the earth, | ||
and it would not be wonderful to meet a Megalosaurus, forty feet long or | ||
so, waddling like an elephantine lizard up Holborn Hill. | ||
</p> | ||
</section> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"pages": { | ||
"fontStretch": { | ||
"cssExampleSrc": "./live-examples/css-examples/fonts/font-stretch.css", | ||
"exampleCode": "./live-examples/css-examples/fonts/font-stretch.html", | ||
"fileName": "font-stretch.html", | ||
"title": "CSS Demo: font-stretch", | ||
"type": "css" | ||
} | ||
} | ||
} |
Binary file not shown.