Skip to content

Commit a00a28e

Browse files
authored
Dark syntax highlighting (#320)
* Disable ember-code-snippets default styles * Ensure one version of ember-cli-clipboard * pin assign-polyfill
1 parent dfd71ae commit a00a28e

File tree

14 files changed

+207
-203
lines changed

14 files changed

+207
-203
lines changed

addon/components/docs-demo/template.hbs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="docs-rounded docs-border docs-my-8 {{class}}">
1+
<div class="docs-rounded docs-border docs-border-grey-lighter docs-my-8 {{class}}">
22

33
{{yield (hash
44
example=(component 'docs-demo/x-example')
@@ -7,13 +7,20 @@
77

88
<div>
99
{{#if (and snippets (gt snippets.length 1))}}
10-
<nav class="docs-demo__snippets-nav docs-py-2 docs-px-4 docs-font-medium docs-bg-grey-lighter docs-tracking-tight">
10+
<nav class="
11+
docs-demo__snippets-nav docs-py-2 docs-px-4 docs-font-medium
12+
docs-bg-black docs-tracking-tight docs-border-b
13+
docs-border-grey-darkest
14+
">
1115
{{#each snippets as |snippet|}}
1216
<button {{action 'selectSnippet' snippet}}
1317
class='
1418
docs-mr-4 docs-text-xs docs-no-underline outline-none
15-
hover:docs-text-grey-darkest
16-
{{if snippet.isActive 'docs-text-grey-darkest' 'docs-text-grey-dark'}}
19+
hover:docs-text-grey-lighter
20+
{{if snippet.isActive
21+
'docs-text-grey-lighter'
22+
'docs-text-grey-dark'
23+
}}
1724
'
1825
>
1926
{{snippet.label}}
@@ -24,7 +31,9 @@
2431

2532
{{#each snippets as |snippet|}}
2633
{{#if snippet.isActive}}
27-
<div class="docs-demo__snippet-wrapper {{if (lte snippets.length 1) 'docs-border-t docs-border-grey-lighter'}}">
34+
<div class="
35+
docs-demo__snippet-wrapper docs-bg-code-base docs-rounded-b
36+
">
2837
{{docs-snippet name=snippet.name unindent=true language=snippet.language}}
2938
</div>
3039
{{/if}}

addon/components/docs-snippet/template.hbs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
{{#if title}}
2-
<div class='docs-bg-grey-lighter docs-text-xs docs-text-grey-darkest
3-
docs-font-medium docs-py-2 docs-px-4'>
2+
<div class='
3+
docs-bg-black docs-text-grey-lighter docs-text-xs
4+
docs-font-medium docs-py-2 docs-px-4 docs-rounded-t
5+
docs-border-b docs-border-grey-darkest
6+
'>
47
{{title}}
58
</div>
69
{{/if}}
710

8-
<div class='docs-text-xs docs-p-4 docs-bg-grey-lightest docs-relative' data-test-id={{name}}>
11+
<div class='
12+
docs-text-sm docs-px-2 docs-py-1 docs-bg-code-base docs-relative
13+
{{if title "docs-rounded-b" "docs-rounded"}}
14+
'
15+
data-test-id={{name}}
16+
>
917
{{#if showCopy}}
1018
{{#copy-button
1119
clipboardText=snippetText
1220
title='copy to clipboard'
1321
class='
1422
docs-absolute docs-pin-t docs-pin-r docs-bg-transparent hover:docs-bg-transparent
15-
docs-border-none docs-opacity-50 hover:docs-opacity-100 docs-p-3
23+
docs-border-none docs-opacity-50 hover:docs-opacity-100 docs-p-3 docs-text-white
1624
'
1725
}}
1826
Copy

addon/styles/addon.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
$site-container: 1400px;
33

44
@import 'tailwind';
5-
@import 'syntax';
65
@import 'pod-styles.scss';
6+
@import 'syntax';
77

88
// Figure out how to do this in tailwind
99
.docs-fill-current {

addon/styles/syntax.scss

Lines changed: 58 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
1+
/*
2+
3+
Original: Atom One Dark by Daniel Gamage
4+
Original One Dark Syntax theme from https://github.com/atom/one-dark-syntax
5+
6+
Modified for AddonDocs.
7+
*/
8+
9+
$base: #282c34;
10+
$mono-1: #abb2bf;
11+
$mono-2: #818896;
12+
$mono-3: #5c6370;
13+
$hue-1: #56b6c2;
14+
$hue-2: #61aeee;
15+
$hue-3: #c678dd;
16+
$hue-4: #98c379;
17+
$hue-5: #e06c75;
18+
$hue-5-2: #be5046;
19+
$hue-6: #e06c75; // original #d19a66
20+
$hue-6-2: #e6c07b;
21+
122
.hljs {
223
display: block;
324
overflow-x: auto;
425
padding: 0.5em;
5-
color: #333;
6-
background: inherit;
26+
color: $mono-1;
27+
background: $base;
728
}
829

930
.hljs-comment,
1031
.hljs-quote {
11-
color: #8795A1;
32+
color: $mono-3;
1233
font-style: italic;
1334
}
1435

36+
.hljs-doctag,
1537
.hljs-keyword,
16-
.hljs-selector-tag,
17-
.hljs-subst {
18-
color: #333;
19-
font-weight: bold;
20-
}
21-
22-
.hljs-number,
23-
.hljs-literal,
24-
.hljs-variable,
25-
.hljs-template-variable,
26-
.hljs-tag .hljs-attr {
27-
color: #008080;
28-
}
29-
30-
.hljs-string,
31-
.hljs-doctag {
32-
color: #d14;
38+
.hljs-formula {
39+
color: $hue-3;
3340
}
3441

35-
.hljs-title,
3642
.hljs-section,
37-
.hljs-selector-id {
38-
color: #900;
39-
font-weight: bold;
40-
}
41-
43+
.hljs-name,
44+
.hljs-selector-tag,
45+
.hljs-deletion,
4246
.hljs-subst {
43-
font-weight: normal;
47+
color: $hue-5;
4448
}
4549

46-
.hljs-type,
47-
.hljs-class .hljs-title {
48-
color: #458;
49-
font-weight: bold;
50-
}
51-
52-
.hljs-tag,
53-
.hljs-name,
54-
.hljs-attribute {
55-
color: #333;
56-
font-weight: normal;
50+
.hljs-literal {
51+
color: $hue-1;
5752
}
5853

54+
.hljs-string,
5955
.hljs-regexp,
60-
.hljs-link {
61-
color: #009926;
62-
}
63-
64-
.hljs-symbol,
65-
.hljs-bullet {
66-
color: #990073;
56+
.hljs-addition,
57+
.hljs-attribute,
58+
.hljs-meta-string {
59+
color: $hue-4;
6760
}
6861

6962
.hljs-built_in,
70-
.hljs-builtin-name {
71-
color: #0086b3;
72-
}
73-
74-
.hljs-meta {
75-
color: #8795A1;
76-
font-weight: bold;
63+
.hljs-class .hljs-title {
64+
color: $hue-6-2;
7765
}
7866

79-
.hljs-deletion {
80-
background: #fdd;
67+
.hljs-attr,
68+
.hljs-variable,
69+
.hljs-template-variable,
70+
.hljs-type,
71+
.hljs-selector-class,
72+
.hljs-selector-attr,
73+
.hljs-selector-pseudo,
74+
.hljs-number {
75+
color: $hue-6;
8176
}
8277

83-
.hljs-addition {
84-
background: #dfd;
78+
.hljs-symbol,
79+
.hljs-bullet,
80+
.hljs-link,
81+
.hljs-meta,
82+
.hljs-selector-id,
83+
.hljs-title {
84+
color: $hue-2;
8585
}
8686

8787
.hljs-emphasis {
@@ -92,30 +92,6 @@
9292
font-weight: bold;
9393
}
9494

95-
96-
/* My customizations*/
97-
.hljs-tag {
98-
.hljs-name {
99-
color: #22863a;
100-
}
101-
.hljs-attr {
102-
color: #6f42c1;
103-
}
104-
}
105-
.hljs-template-variable {
106-
color: #005cc5;
107-
}
108-
.hljs-template-tag {
109-
color: #005cc5;
110-
111-
.hljs-attr {
112-
color: #e36209;
113-
}
114-
}
115-
116-
.hljs-string {
117-
color: #032f62;
118-
}
119-
.hljs-name {
120-
color: #005cc5;
95+
.hljs-link {
96+
text-decoration: underline;
12197
}

addon/tailwind/components/docs-md.css

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,22 @@
3939
@apply docs-mb-4 docs-mt-6 docs-bg-grey-lightest docs-italic docs-px-4 docs-py-3 docs-text-xs;
4040
}
4141

42-
/* mb-4 on pre interferes with docs-snippet and others, really want Renderer
43-
to generate its own class...
44-
pre {
45-
@apply .docs-mb-4;
46-
} */
47-
4842
.docs-md__blockquote {
4943
@apply docs-pl-4 docs-text-grey-dark docs-border-l-4;
5044
}
5145

46+
/* Applied to inline code in compiled markdown */
47+
.docs-md :not(pre) > code {
48+
@apply docs-bg-grey-lighter docs-px-1;
49+
}
50+
5251
/* Applied to fenced code in compiled markdown */
5352
.docs-md__code {
54-
@apply docs-bg-grey-lightest docs-my-8 docs-p-6 docs-overflow-x-scroll docs-text-xs;
53+
@apply docs-my-8 docs-px-4 docs-py-3 docs-overflow-x-scroll docs-text-sm docs-rounded;
54+
55+
/* These values are copied from atom-one-dark theme, imported from highlight.js */
56+
background: #282c34;
57+
color: #abb2bf;
5558
}
5659

5760
.docs-md__a {

addon/tailwind/config/colors.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export default {
3535

3636
'yellow': '#ffed4a',
3737

38-
// See the ntoe in tailwind/compnents/docs-brand-colors.css
38+
'code-base': '#282c34',
39+
40+
// See the note in tailwind/compnents/docs-brand-colors.css
3941
'brand-var': 'var(--brand-primary, #E04E39)'
4042

4143
};

config/dependency-lint.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = {
4+
5+
};

index.js

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ module.exports = {
1818
LATEST_VERSION_NAME,
1919

2020
options: {
21-
nodeAssets: {
22-
'highlight.js': {
23-
public: {
24-
include: [ 'styles/monokai.css' ]
25-
},
26-
vendor: {
27-
include: [ 'styles/monokai.css' ]
28-
}
29-
}
30-
},
3121
svgJar: {
3222
sourceDirs: [
3323
'public',
@@ -91,6 +81,17 @@ module.exports = {
9181
throw new Error(`ember-cli-addon-docs only currently works with addons, not applications`);
9282
}
9383

84+
includer.options.includeFileExtensionInSnippetNames = includer.options.includeFileExtensionInSnippetNames || false;
85+
includer.options.snippetSearchPaths = includer.options.snippetSearchPaths || ['tests/dummy/app'];
86+
includer.options.snippetRegexes = Object.assign({}, {
87+
begin: /{{#(?:docs-snippet|demo.example)\sname=(?:"|')(\S+)(?:"|')/,
88+
end: /{{\/(?:docs-snippet|demo.example)}}/,
89+
}, includer.options.snippetRegexes);
90+
includer.options.includehighlightJS = false;
91+
includer.options.includeHighlightStyle = false;
92+
includer.options.snippetExtensions = ['js', 'css', 'scss', 'hbs', 'md', 'text', 'json', 'handlebars', 'htmlbars', 'html', 'diff'];
93+
94+
// This must come after we add our own options above, or else other addons won't see them.
9495
this._super.included.apply(this, arguments);
9596

9697
const hasPlugins = this.project.addons.some(function(addon) {
@@ -106,23 +107,11 @@ module.exports = {
106107
this.addonOptions = Object.assign({}, includer.options['ember-cli-addon-docs']);
107108
this.addonOptions.projects = Object.assign({}, this.addonOptions.projects);
108109

109-
includer.options.includeFileExtensionInSnippetNames = includer.options.includeFileExtensionInSnippetNames || false;
110-
includer.options.snippetSearchPaths = includer.options.snippetSearchPaths || ['tests/dummy/app'];
111-
includer.options.snippetRegexes = Object.assign({}, {
112-
begin: /{{#(?:docs-snippet|demo.example)\sname=(?:"|')(\S+)(?:"|')/,
113-
end: /{{\/(?:docs-snippet|demo.example)}}/,
114-
}, includer.options.snippetRegexes);
115-
116110
let importer = findImporter(this);
117111

118112
importer.import('vendor/lunr/lunr.js', {
119113
using: [{ transformation: 'amd', as: 'lunr' }]
120114
});
121-
122-
// importer.import('vendor/highlightjs-styles/default.css');
123-
// importer.import('vendor/styles/highlightjs-styles/default.css');
124-
// importer.import('vendor/highlight.js/styles/monokai.css');
125-
// importer.import('vendor/highlightjs-styles/github.css');
126115
},
127116

128117
createDeployPlugin() {
@@ -180,7 +169,7 @@ module.exports = {
180169
treeForVendor(vendor) {
181170
return new MergeTrees([
182171
vendor,
183-
this._highlightJSTree(),
172+
// this._highlightJSTree(),
184173
this._lunrTree()
185174
].filter(Boolean));
186175
},

0 commit comments

Comments
 (0)