-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
325 lines (298 loc) · 7.75 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<!DOCTYPE html>
<html lang="en">
<head>
<title>Spindle syntax themes</title>
<meta name="viewport" content="width=device-width">
<meta charset="utf-8">
<meta name="description" content="Check the Spindle code syntax with some languages.">
<link rel="stylesheet" href="https://unpkg.com/ameba-color-palette.css">
<link rel="stylesheet" href="./highlightjs-light.css">
<link rel="stylesheet" href="./highlightjs-dark.css" disabled>
<link rel="stylesheet" href="https://unpkg.com/@openameba/spindle-ui/Form/DropDown.css">
<link rel="icon" href="./favicon.ico" type="image/x-icon">
<style>
body {
background: var(--color-surface-primary);
color: var(--color-text-medium-emphasis);
font-family: sans-serif;
margin: 0;
}
h1,
section {
margin: 2rem;
}
.select-theme {
background: var(--color-surface-primary);
padding: 2rem;
position: sticky;
top: 0;
}
.spui-DropDown-visual {
text-transform: capitalize;
}
</style>
</head>
<body>
<h1>Spindle syntax themes for highlight.js</h1>
<div class="select-theme">
<label class="spui-DropDown-label is-active">
<span class="spui-DropDown-visual" id="js-select-visual">Light</span>
<span class="spui-DropDown-icon">
<svg width="1em" height="1em" viewBox="0 0 24 24" fill="currentColor" role="img" aria-hidden="true"><path d="M2.55 9.45c0-.38.15-.77.44-1.06a1.49 1.49 0 012.12 0l6.94 6.94 6.94-6.94a1.49 1.49 0 012.12 0c.58.59.59 1.54 0 2.12l-7.29 7.29c-.97.97-2.56.97-3.54 0l-7.29-7.29c-.29-.29-.44-.67-.44-1.06z"></path></svg>
</span>
<select aria-label="Theme" class="spui-DropDown-select" name="theme">
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
<span class="spui-DropDown-outline"></span>
</label>
</div>
<section>
<h2>HTML, XML</h2>
<pre>
<code class="language-html">
<!DOCTYPE html>
<title>Title</title>
<style>body {width: 500px;}</style>
<script type="application/javascript">
function $init() {return true;}
</script>
<body>
<p checked class="title" id='title'>Title</p>
<!-- here goes the rest of the page -->
</body>
</code>
</pre>
</section>
<section>
<h2>CSS</h2>
<pre>
<code class="language-css">
@font-face {
font-family: Chunkfive; src: url('Chunkfive.otf');
}
body, .usertext {
color: #F0F0F0; background: #600;
font-family: Chunkfive, sans;
--heading-1: 30px/32px Helvetica, sans-serif;
}
@import url(print.css);
@media print {
a[href^=http]::after {
content: attr(href)
}
}
</code>
</pre>
</section>
<section>
<h2>JavaScript</h2>
<pre>
<code class="language-javascript">
function $initHighlight(block, cls) {
try {
if (cls.search(/\bno\-highlight\b/) != -1)
return process(block, true, 0x0F) +
` class="${cls}"`;
} catch (e) {
/* handle exception */
}
for (var i = 0 / 2; i < classes.length; i++) {
if (checkCondition(classes[i]) === undefined)
console.log('undefined');
}
return (
<div>
<web-component>{block}</web-component>
</div>
)
}
export $initHighlight;
</code>
</pre>
</section>
<section>
<h2>TypeScript</h2>
<pre>
<code class="language-typescript">
class MyClass {
public static myValue: string;
constructor(init: string) {
this.myValue = init;
}
}
import fs = require("fs");
module MyModule {
export interface MyInterface extends Other {
myProperty: any;
}
}
declare magicNumber number;
</code>
</pre>
</section>
<section>
<h2>JSON</h2>
<pre>
<code class="language-json">
[
{
"title": "apples",
"count": [12000, 20000],
"description": {"text": "...", "sensitive": false}
},
{
"title": "oranges",
"count": [17500, null],
"description": {"text": "...", "sensitive": false}
}
]
</code>
</pre>
</section>
<section>
<h2>Kotlin</h2>
<pre>
<code class="language-kotlin">
import kotlin.lang.test
interface A {
fun x()
}
fun xxx(): Int {
return 888
}
public fun main(args: Array<String>) {
}
</code>
</pre>
</section>
<section>
<h2>Java</h2>
<pre>
<code class="language-java">
/**
* @author John Smith <[email protected]>
*/
package l2f.gameserver.model;
public abstract strictfp class L2Char extends L2Object {
public static final Short ERROR = 0x0001;
public void moveTo(int x, int y, int z) {
_ai = null;
log("Should not be called");
if (1 > 5) { // wtf!?
return;
}
}
}
</code>
</pre>
</section>
<section>
<h2>Swift</h2>
<pre>
<code class="language-swift">
import Foundation
@objc class Person: Entity {
var name: String!
var age: Int!
init(name: String, age: Int) {
/* /* ... */ */
}
// Return a descriptive string for this person
func description(offset: Int = 0) -> String {
return "\(name) is \(age + offset) years old"
}
}
</code>
</pre>
</section>
<section>
<h2>Objective-C</h2>
<pre>
<code class="language-objectivec">
#import <UIKit/UIKit.h>
#import "Dependency.h"
@protocol WorldDataSource
@optional
- (NSString*)worldName;
@required
- (BOOL)allowsToLive;
@end
@property (nonatomic, readonly) NSString *title;
- (IBAction) show;
@end
</code>
</pre>
</section>
<section>
<h2>YAML</h2>
<pre>
<code class="language-yaml">
---
# comment
string_1: "Bar"
string_2: 'bar'
string_3: bar
inline_keys_ignored: sompath/name/file.jpg
keywords_in_yaml:
- true
- false
- TRUE
- FALSE
- 21
- 21.0
- !!str 123
"quoted_key": &foobar
bar: foo
foo:
"foo": bar
reference: *foobar
multiline_1: |
Multiline
String
multiline_2: >
Multiline
String
multiline_3: "
Multiline string
"
ansible_variables: "foo {{variable}}"
array_nested:
- a
- b: 1
c: 2
- b
- comment
</code>
</pre>
</section>
<script src="https://unpkg.com/@highlightjs/[email protected]/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
<script type="module">
const lightCss = document.querySelector('link[href*="highlightjs-light.css"]');
const darkCss = document.querySelector('link[href*="highlightjs-dark.css"]');
const selectEl = document.querySelector('select[name="theme"]');
const selectVisualEl = document.querySelector('#js-select-visual');
function applyTheme(theme) {
selectVisualEl.innerText = theme;
if (theme === 'dark') {
lightCss.disabled = true;
darkCss.disabled = false;
} else {
lightCss.disabled = false;
darkCss.disabled = true;
}
}
window.addEventListener('DOMContentLoaded', () => {
const url = new URL(location.href);
const theme = url.searchParams.get('theme') === 'dark' ? 'dark' : 'light';
selectEl.value = theme;
applyTheme(theme);
});
selectEl.addEventListener('change', (event) => {
const { value } = event.target;
applyTheme(value);
}, false);
</script>
</body>
</html>