Skip to content

Commit 54ae035

Browse files
committed
fix(create-config): append code-fence button if disableDefaultCSS is false
1 parent 755306c commit 54ae035

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

src/createConfig.ts

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import fs from "fs-extra";
77
import path from "path";
88
import { createHash } from "crypto";
99
import htmlminifier from "html-minifier";
10-
import { css } from "./style";
10+
import { css as github_styles } from "./style";
1111
import { Plugin, OutputOptions, InputOptions } from "rollup";
1212
import { PreprocessorGroup } from "svelte/types/compiler/preprocess";
1313

@@ -78,32 +78,7 @@ const custom_css = `
7878
main { padding: 15px; }
7979
}
8080
81-
/**
82-
* GitHub Primer button CSS
83-
* https://primer.style/css/components/buttons
84-
**/
85-
.code-fence button {
86-
font-family: inherit;
87-
text-transform: none;
88-
position: relative;
89-
display: inline-block;
90-
padding: 5px 16px;
91-
font-size: 14px;
92-
font-weight: 500;
93-
line-height: 20px;
94-
white-space: nowrap;
95-
vertical-align: middle;
96-
cursor: pointer;
97-
user-select: none;
98-
border: 1px solid;
99-
border-radius: 6px;
100-
appearance: none;
101-
color: #24292e;
102-
background-color: #fafbfc;
103-
border-color: rgba(27,31,35,0.15);
104-
box-shadow: 0 1px 0 rgba(27,31,35,0.04), inset 0 1px 0 rgba(255,255,255,0.25);
105-
transition: background-color 0.2s cubic-bezier(0.3, 0, 0.5, 1);
106-
}
81+
10782
`;
10883

10984
interface CreateConfigOptions {
@@ -189,6 +164,37 @@ export default function createConfig(opts: Partial<CreateConfigOptions> = {}): I
189164
console.log("svelte:", svelte);
190165
console.groupEnd();
191166

167+
let css = github_styles;
168+
169+
if (!opts.disableDefaultCSS) {
170+
css += `/**
171+
* GitHub Primer button CSS
172+
* https://primer.style/css/components/buttons
173+
**/
174+
.code-fence button {
175+
font-family: inherit;
176+
text-transform: none;
177+
position: relative;
178+
display: inline-block;
179+
padding: 5px 16px;
180+
font-size: 14px;
181+
font-weight: 500;
182+
line-height: 20px;
183+
white-space: nowrap;
184+
vertical-align: middle;
185+
cursor: pointer;
186+
user-select: none;
187+
border: 1px solid;
188+
border-radius: 6px;
189+
appearance: none;
190+
color: #24292e;
191+
background-color: #fafbfc;
192+
border-color: rgba(27,31,35,0.15);
193+
box-shadow: 0 1px 0 rgba(27,31,35,0.04), inset 0 1px 0 rgba(255,255,255,0.25);
194+
transition: background-color 0.2s cubic-bezier(0.3, 0, 0.5, 1);
195+
}`;
196+
}
197+
192198
const template = `
193199
<!DOCTYPE html>
194200
<html lang="en">

src/style.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,4 @@ pre code {
509509
background-color: initial;
510510
border: 0;
511511
}
512-
`;
512+
`;

0 commit comments

Comments
 (0)