Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Streamline templates #5

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions src/generators/asset-types/__tests__/__snapshots__/css.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,48 @@

exports[`\`CSS\` asset generator renders CSS correctly with \`selector\` option 1`] = `
"@font-face {
font-family: "test-font";
src: "::src-attr::";
font-display: block;
font-family: "test-font";
src: "::src-attr::";
}
.my-selector:before {
font-family: test-font !important;
font-style: normal;
font-weight: normal !important;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
.my-selector::before {
font-family: test-font !important;
font-style: normal;
font-weight: normal !important;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.my-selector.tf-my-icon:before {
content: "\\f101";
.my-selector.tf-my-icon::before {
content: "\\f101";
}
"
`;

exports[`\`CSS\` asset generator renders CSS correctly with prefix and tag name options 1`] = `
"@font-face {
font-family: "test-font";
src: "::src-attr::";
font-display: block;
font-family: "test-font";
src: "::src-attr::";
}
b[class^="tf-"]:before, b[class*=" tf-"]:before {
font-family: test-font !important;
font-style: normal;
font-weight: normal !important;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
b[class^="tf-"]::before, b[class*=" tf-"]::before {
font-family: test-font !important;
font-style: normal;
font-weight: normal !important;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.tf-my-icon:before {
content: "\\f101";
.tf-my-icon::before {
content: "\\f101";
}
"
`;
116 changes: 56 additions & 60 deletions src/generators/asset-types/__tests__/__snapshots__/html.ts.snap
Original file line number Diff line number Diff line change
@@ -1,73 +1,69 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`\`HTML\` asset generator renders HTML correctly with prefix and tag name options 1`] = `
"<!DOCTYPE html>
"<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test-font</title>
<meta charset="utf-8">
<title>test-font</title>

<style>
body {
font-family: sans-serif;
margin: 0;
padding: 10px 20px;
text-align: center;
}
.preview {
width: 100px;
display: inline-block;
margin: 10px;
}
.preview .inner {
display: inline-block;
width: 100%;
text-align: center;
background: #f5f5f5;
-webkit-border-radius: 3px 3px 0 0;
-moz-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0;
}
.preview .inner {
line-height: 85px;
font-size: 40px;
color: #333;
}
.label {
display: inline-block;
width: 100%;
box-sizing: border-box;
padding: 5px;
font-size: 10px;
font-family: Monaco, monospace;
color: #666;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
background: #ddd;
-webkit-border-radius: 0 0 3px 3px;
-moz-border-radius: 0 0 3px 3px;
border-radius: 0 0 3px 3px;
color: #666;
}
</style>
<style>
body {
font-family: sans-serif;
margin: 0;
padding: 10px 20px;
text-align: center;
}
.preview {
width: 100px;
display: inline-block;
margin: 10px;
}
.preview .inner {
display: inline-block;
width: 100%;
text-align: center;
background: #f5f5f5;
-webkit-border-radius: 3px 3px 0 0;
-moz-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0;
}
.preview .inner {
line-height: 85px;
font-size: 40px;
color: #333;
}
.label {
display: inline-block;
width: 100%;
box-sizing: border-box;
padding: 5px;
font-size: 10px;
font-family: Monaco, monospace;
color: #666;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
background: #ddd;
-webkit-border-radius: 0 0 3px 3px;
-moz-border-radius: 0 0 3px 3px;
border-radius: 0 0 3px 3px;
color: #666;
}
</style>

<link rel="stylesheet" type="text/css" href="test-font.css" />
<link rel="stylesheet" href="test-font.css">
</head>
<body>
<h1>test-font</h1>

<h1>test-font</h1>


<div class="preview">
<span class="inner">
<b class="tf tf-my-icon"></b>
</span>
<br>
<span class='label'>my-icon</span>
</div>


<div class="preview">
<span class="inner">
<b class="tf tf-my-icon"></b>
</span>
<br>
<span class="label">my-icon</span>
</div>
</body>
</html>
"
Expand Down
64 changes: 32 additions & 32 deletions src/generators/asset-types/__tests__/__snapshots__/sass.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,52 @@ exports[`\`SASS\` asset generator renders SASS correctly with \`selector\` optio
"$test-font: "test"
@font-face
font-family: $test-font
src: "::src-attr::"
.my-selector:before
font-family: test !important
font-style: normal
font-weight: normal !important
font-variant: normal
text-transform: none
line-height: 1
-webkit-font-smoothing: antialiased
-moz-osx-font-smoothing: grayscale
font-display: block
font-family: $test-font
src: "::src-attr::"
.my-selector::before
font-family: test !important
font-style: normal
font-weight: normal !important
font-variant: normal
text-transform: none
line-height: 1
-webkit-font-smoothing: antialiased
-moz-osx-font-smoothing: grayscale
$test-map: (
"my-icon": "\\f101",
"my-icon": "\\f101",
)
.my-selector.tf-my-icon:before
content: map-get($test-map, "my-icon")
.my-selector.tf-my-icon::before
content: map-get($test-map, "my-icon")
"
`;

exports[`\`SASS\` asset generator renders SASS correctly with prefix and tag name options 1`] = `
"$test-font: "test"
@font-face
font-family: $test-font
src: "::src-attr::"
b[class^="tf-"]:before, b[class*=" tf-"]:before
font-family: test !important
font-style: normal
font-weight: normal !important
font-variant: normal
text-transform: none
line-height: 1
-webkit-font-smoothing: antialiased
-moz-osx-font-smoothing: grayscale
font-display: block
font-family: $test-font
src: "::src-attr::"
b[class^="tf-"]::before, b[class*=" tf-"]::before
font-family: test !important
font-style: normal
font-weight: normal !important
font-variant: normal
text-transform: none
line-height: 1
-webkit-font-smoothing: antialiased
-moz-osx-font-smoothing: grayscale
$test-map: (
"my-icon": "\\f101",
"my-icon": "\\f101",
)
.tf-my-icon:before
content: map-get($test-map, "my-icon")
.tf-my-icon::before
content: map-get($test-map, "my-icon")
"
`;
58 changes: 30 additions & 28 deletions src/generators/asset-types/__tests__/__snapshots__/scss.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@ exports[`\`SCSS\` asset generator renders SCSS correctly with \`selector\` optio
"$test-font: "test";
@font-face {
font-family: $test-font;
src: "::src-attr::";
font-display: block;
font-family: $test-font;
src: "::src-attr::";
}
.my-selector:before {
font-family: test !important;
font-style: normal;
font-weight: normal !important;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
.my-selector::before {
font-family: test !important;
font-style: normal;
font-weight: normal !important;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
$test-map: (
"my-icon": "\\f101",
"my-icon": "\\f101",
);
.my-selector.tf-my-icon:before {
content: map-get($test-map, "my-icon");
.my-selector.tf-my-icon::before {
content: map-get($test-map, "my-icon");
}
"
`;
Expand All @@ -33,27 +34,28 @@ exports[`\`SCSS\` asset generator renders SCSS correctly with prefix and tag nam
"$test-font: "test";
@font-face {
font-family: $test-font;
src: "::src-attr::";
font-display: block;
font-family: $test-font;
src: "::src-attr::";
}
b[class^="tf-"]:before, b[class*=" tf-"]:before {
font-family: test !important;
font-style: normal;
font-weight: normal !important;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
b[class^="tf-"]::before, b[class*=" tf-"]::before {
font-family: test !important;
font-style: normal;
font-weight: normal !important;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
$test-map: (
"my-icon": "\\f101",
"my-icon": "\\f101",
);
.tf-my-icon:before {
content: map-get($test-map, "my-icon");
.tf-my-icon::before {
content: map-get($test-map, "my-icon");
}
"
`;
10 changes: 6 additions & 4 deletions src/generators/asset-types/__tests__/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ describe('`CSS` asset generator', () => {
test('renders expected selector blocks', async () => {
const css = await cssGen.generate(mockOptions, Buffer.from(''));

expect(css).toContain('b[class^="tf-"]:before, b[class*=" tf-"]:before {');
expect(css).toContain('.tf-my-icon:before {');
expect(css).toContain(
'b[class^="tf-"]::before, b[class*=" tf-"]::before {'
);
expect(css).toContain('.tf-my-icon::before {');
});

test('renders expected selector blocks with `selector` option', async () => {
Expand All @@ -62,7 +64,7 @@ describe('`CSS` asset generator', () => {
Buffer.from('')
);

expect(css).toContain('.my-selector:before {');
expect(css).toContain('.my-selector.tf-my-icon:before {');
expect(css).toContain('.my-selector::before {');
expect(css).toContain('.my-selector.tf-my-icon::before {');
});
});
Loading