-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
153 lines (153 loc) · 9.59 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
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<title>RAW JS | ⛓ Utility Chain</title>
<base target="_blank">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="A design system starter for evergreen browsers">
<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACAAQMAAAD58POIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAGUExURR0dHf/dRNuTfs0AAAArSURBVEjHY/iPBhhGBYaOAAMUjArABKBhwzAqMJocRtPHqABpAqP1C70FAM5nOhvMJUGgAAAAAElFTkSuQmCC">
<link rel="stylesheet" href="//vbrajon.github.io/rawcss/raw.css">
<style>
* { border-radius: 0; }
html.dark { background: rgb(40, 44, 52); }
main { margin: -1px 0 -1px 300px; }
aside { position: fixed;top: 0;left: 0;width: 300px;height: 100vh;padding: 20px;border-right: 1px solid var(--gray2); }
.github { margin: 8px -4px -8px; }
.github > span { display: flex;margin: 0 4px; }
.tags code, .fn code { padding-bottom: 2px;font-size: 60%; }
h1 { background: linear-gradient(to right, #f34, #fd0);font-variant: small-caps;letter-spacing: -0.04em;-webkit-background-clip: text;-webkit-text-fill-color: transparent; }
[type="search"] { flex-shrink: 0;text-transform: uppercase; }
[type="search"]:focus { box-shadow: 0 0 0 1px #fa3 inset; }
.tags { margin: 20px 0;text-transform: uppercase;user-select: none; }
.fns { overflow: auto;flex: 1;margin: 0 -20px;user-select: none; }
.fn { display: flex;flex-direction: row;align-items: center;cursor: pointer;height: 30px;padding: 0 20px;font-variant: small-caps; }
.fn:hover { background: var(--gray1); }
.fn .primitive { color: var(--text); }
.fn code { margin-left: 10px;color: var(--text);text-transform: uppercase; }
.fn.prim.prop, .prim.prop .fn { background: var(--gray2)!important;font-weight: 800; }
section { padding: 40px;border-top: 1px solid var(--gray2); }
.markdown { width: 100%;font-size: 18px; }
.markdown > :first-child { margin: 20px 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown ul, .markdown pre { margin-bottom: 30px; }
/* Prism - Raw theme */
:root { --gray05: rgb(0,0,0, .25);--gray1: rgb(0,0,0, .35);--gray2: rgb(0,0,0, .4);--gray3: rgb(0,0,0, .5); }
pre, :not(pre) > code { color: #def;background: rgba(0, 0, 0, 0.25); }
pre { position: relative; }
code[class*="language-"]::before { position: absolute;top: 6px;right: 6px;font-size: 60%;font-weight: 800; }
code.language-javascript::before { content: "JS"; }
pre { width: 100%;overflow: auto;margin: 0.5em 0;padding: 1em; }
pre, code[class*="language-"] { border-radius: 0.3em;font: 400 1em/1.5 Menlo, monospace;white-space: pre;hyphens: none;tab-size: 2; }
:not(pre) > code[class*="language-"] { padding: 0.1em; }
.token.comment { color: #555; }
.token.class-name { color: #fd0; }
.token.keyword { color: #f6e; }
.token.property-access, .token.tag { color: #f34; }
.token.boolean, .token.number, .token.attr-name { color: #fa3; }
.token.string, .token.regex, .token.attr-value { color: #7d0; }
.token.function, .token.method { color: #39f; }
.token.operator { color: #3df; }
/* Primitive colors */
.Object { color: #f34!important; }
.Array { color: #fd0!important; }
.Function { color: #39f!important; }
.String { color: #7d0!important; }
.Number { color: #fa3!important; }
.Date { color: #f6e!important; }
.RegExp { color: #3df!important; }
</style>
</head>
<body>
<main>
<aside class="column nowrap">
<div class="row"><h1 @click.prevent="pname = fname = '';window.scrollTo(0, 0)">rawjs</h1><!--<code style="margin: auto 0 auto auto">{{ Object.extend.version }}</code>--></div>
<input type="search" v-model="search">
<div class="tags row center"><code :style="search === tag && 'background: rgb(255, 255, 255, .2);'" @click="search = search === tag ? '' : tag" v-for="tag in ['core', 'native', 'shortcut', 'notag']">{{ tag }}</code></div>
<div class="fns">
<div class="fn" :class="[item[0], item[1], { prim: pname === item[0], prop: fname === item[1] }]" @click="pname = item[0];fname = item[1];window.$('#' + item[0] + '-' + item[1]).scrollIntoView()" v-for="item in list">
<span class="primitive">{{ item[0] }}.</span>
<span class="function">{{ item[1] }}</span>
<code :style="search === tag && 'background: rgb(255, 255, 255, .2);'" v-for="tag in item.slice(2)">{{ tag }}</code>
</div>
</div>
<div class="github row">
<a class="github-button" href="https://github.com/vbrajon" aria-label="Follow @vbrajon on GitHub">Follow @vbrajon</a>
<a class="github-button" href="https://github.com/vbrajon/rawjs" data-show-count="true" aria-label="Star vbrajon/rawjs on GitHub">Star</a>
</div>
</aside>
<section id="readme" v-if="!search"><markdown :data="readme"></markdown></section>
<section class="column" :id="item.slice(0, 2).join('-')" class="row center left" :class="{ prim: pname === item[0], prop: fname === item[1] }" @click="pname = item[0];fname = item[1]" v-for="item in list">
<div class="fn row nowrap center left">
<span class="primitive">{{ item[0] }}.</span>
<span class="function" :class="[item[0], item[1]]">{{ item[1] }}</span>
<span class="signature">{{ signatures[item.slice(0, 2).join('-')] }}</span>
</div>
<markdown :data="docs[item.slice(0, 2).join('-')]"></markdown>
<div class="tags row">
<code :style="toggle === item.slice(0, 2).join('-') + '-source' && 'background: rgb(255, 255, 255, .2);'" @click="toggle = toggle === item.slice(0, 2).join('-') + '-source' ? '' : item.slice(0, 2).join('-') + '-source'" v-if="!item.includes('native')">source</code>
<code :style="toggle === item.slice(0, 2).join('-') + '-shortcut' && 'background: rgb(255, 255, 255, .2);'" @click="toggle = toggle === item.slice(0, 2).join('-') + '-shortcut' ? '' : item.slice(0, 2).join('-') + '-shortcut'" v-if="item.includes('shortcut')">shortcut</code>
</div>
<pre class="source" v-if="toggle === item.slice(0, 2).join('-') + '-source'"><code class="language-js" v-html="highlight(window[item[0]][item[1]].fn || window[item[0]][item[1]])"></code></pre>
<pre class="shortcut" v-if="toggle === item.slice(0, 2).join('-') + '-shortcut'"><code class="language-js" v-html="highlight(window[item[0]][item[1]].wrap)"></code></pre>
</section>
</main>
<script src="raw.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/[email protected]/lib/marked.js"></script>
<script src="https://unpkg.com/[email protected]/prism.js"></script>
<script src="https://unpkg.com/[email protected]/components/prism-markdown.js"></script>
<script src="https://unpkg.com/[email protected]/components/prism-js-extras.js"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
<script>
Object.extend()
window.$ = (s, start = document) => start.querySelector(s)
window.$$ = (s, start = document) => Array.from(start.querySelectorAll(s))
window.key = (letter, fn) => addEventListener('keydown', e => e.key.toLowerCase() === letter && fn(e))
addEventListener('keydown', e => !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && $('[type=search]').focus())
Vue.prototype.window = window
Vue.prototype.highlight = window.highlight = (code, lang = 'js') => Prism.highlight(String(code), Prism.languages[lang], lang)
marked.setOptions({ highlight })
Vue.component('markdown', {
props: ['data'],
render(h) {
return this.data && h({ template: '<div class="markdown">' + marked(this.data) + '</div>' })
},
})
window.$root = new Vue({
el: 'main',
data() {
const [pname, fname] = location.hash.slice(1).split('.')
fetch('README.md').then(r => r.text()).then(r => this.readme = r)
fetch('doc.md').then(r => r.text()).then(r => this.docs = r.split('### ').filter().reduce((acc, v) => (acc[v.split('\n')[0].replace('.', '-')] = v.split('\n').slice(1).join('\n').trim(), acc), {}))
return {
search: '',
pname,
fname,
toggle: '',
readme: '',
signatures: {},
docs: {},
}
},
computed: {
list() {
if (this.search === 'notag') return Object.extend().filter(v => !v.includes('#')).map(v => v.split(/[.#]/)).sort((a, b) => a[0] !== b[0] ? 0 : a[1] > b[1] ? 1 : -1)
return Object.extend().filter(v => RegExp(this.search.replace(/ /g, '.'), 'i').test(v)).map(v => v.split(/[.#]/)).sort((a, b) => a[0] !== b[0] ? 0 : a[1] > b[1] ? 1 : -1)
},
},
created() {
addEventListener('scroll', e => {
const el = $$('section').find(el => el.offsetTop + 70 > document.documentElement.scrollTop)
const menu = $('.' + el.id.replace('-', '.'))
this.pname = el.id.split('-')[0]
this.fname = el.id.split('-')[1]
if (menu) Array(3).fill().reduce(acc => acc.previousSibling || acc, menu).scrollIntoView({ top: 100 })
})
key('/', e => (e.preventDefault(), this.search = ''))
this.$watch(() => '#' + [this.pname, this.fname].filter().join('-'), id => window.history.replaceState({}, null, id === '#' ? ' ' : id))
},
})
</script>
</body>
</html>