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

[docs] Add a search box #464

Merged
merged 4 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
37 changes: 35 additions & 2 deletions docs/_api/theme/layouts/default.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
<link rel="stylesheet" href="{{relativeURL "../css/main.css"}}">
<link rel="stylesheet" href="{{relativeURL "../css/pygments.css"}}">
<link rel="stylesheet" href="{{relativeURL "../css/theme.css"}}">

{{!-- Add margin-top to offset our custom fixed top nav. --}}
<style>
body {
position: relative;
margin-top: 60px;
}
@media screen and (max-width: 640px) {
body {
margin-top: 56px;
}
}
</style>
</head>
<body>

Expand All @@ -20,12 +33,17 @@
<a class="nav-item" href="{{relativeURL "../try"}}">Try</a>
<a class="nav-item" href="{{relativeURL "../guide"}}">Guide</a>
<a class="nav-item" href="{{relativeURL "../api/index.html"}}">API</a>

<a class="icon-github" href="https://github.com/polymer/lit-element" title="GitHub">
<a class="icon" href="https://github.com/polymer/lit-element" title="GitHub">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentcolor">
<path d="M12,2C6.48,2,2,6.59,2,12.25c0,4.53,2.87,8.37,6.84,9.73c0.5,0.09,0.68-0.22,0.68-0.49c0-0.24-0.01-0.89-0.01-1.74c-2.78,0.62-3.37-1.37-3.37-1.37c-0.45-1.18-1.11-1.5-1.11-1.5c-0.91-0.64,0.07-0.62,0.07-0.62c1,0.07,1.53,1.06,1.53,1.06c0.89,1.57,2.34,1.11,2.91,0.85c0.09-0.66,0.35-1.11,0.63-1.37c-2.22-0.26-4.56-1.14-4.56-5.07c0-1.12,0.39-2.03,1.03-2.75c-0.1-0.26-0.45-1.3,0.1-2.71c0,0,0.84-0.28,2.75,1.05c0.8-0.23,1.65-0.34,2.5-0.34c0.85,0,1.7,0.12,2.5,0.34c1.91-1.33,2.75-1.05,2.75-1.05c0.55,1.41,0.2,2.45,0.1,2.71c0.64,0.72,1.03,1.63,1.03,2.75c0,3.94-2.34,4.81-4.57,5.06c0.36,0.32,0.68,0.94,0.68,1.9c0,1.37-0.01,2.48-0.01,2.81c0,0.27,0.18,0.59,0.69,0.49c3.97-1.36,6.83-5.2,6.83-9.73C22,6.59,17.52,2,12,2"/>
</svg>
</a>
<a class="icon" href="javascript:searchBox.focus()" title="Search">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentcolor">
<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
</svg>
</a>
<input id="searchBox" type="search" class="search-box" placeholder="Search" aria-label="Search">
</nav>

{{> header}}
Expand Down Expand Up @@ -60,6 +78,21 @@
<div class="overlay"></div>
<script src="{{relativeURL "assets/js/main.js"}}"></script>
<script>if (location.protocol == 'file:') document.write('<script src="{{relativeURL "assets/js/search.js"}}"><' + '/script>');</script>
<script>
searchBox.addEventListener('keypress', function(event) {
if (event.keyCode === 13 /* enter */) {
const site = window.location.hostname;
const query = searchBox.value;
window.location = 'https://www.google.com/search?q=site%3A'+site+'+'+query;
event.preventDefault();
}
});
// TypeDoc's main.js installs a `keydown` handler on `body` for its own
// search functionality - stop our search box from triggering that.
searchBox.addEventListener('keydown', function(event) {
event.stopPropagation();
});
</script>

{{> analytics}}

Expand Down
9 changes: 7 additions & 2 deletions docs/_includes/topnav.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
<a class="nav-item" href="{{ site.baseurl }}/try/">Try</a>
<a class="nav-item" href="{{ site.baseurl }}/guide/">Guide</a>
<a class="nav-item" href="{{ site.baseurl }}/api/index.html">API</a>

<a class="icon-github" href="https://github.com/polymer/lit-element" title="GitHub">
<a class="icon" href="https://github.com/polymer/lit-element" title="GitHub">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentcolor">
<path d="M12,2C6.48,2,2,6.59,2,12.25c0,4.53,2.87,8.37,6.84,9.73c0.5,0.09,0.68-0.22,0.68-0.49c0-0.24-0.01-0.89-0.01-1.74c-2.78,0.62-3.37-1.37-3.37-1.37c-0.45-1.18-1.11-1.5-1.11-1.5c-0.91-0.64,0.07-0.62,0.07-0.62c1,0.07,1.53,1.06,1.53,1.06c0.89,1.57,2.34,1.11,2.91,0.85c0.09-0.66,0.35-1.11,0.63-1.37c-2.22-0.26-4.56-1.14-4.56-5.07c0-1.12,0.39-2.03,1.03-2.75c-0.1-0.26-0.45-1.3,0.1-2.71c0,0,0.84-0.28,2.75,1.05c0.8-0.23,1.65-0.34,2.5-0.34c0.85,0,1.7,0.12,2.5,0.34c1.91-1.33,2.75-1.05,2.75-1.05c0.55,1.41,0.2,2.45,0.1,2.71c0.64,0.72,1.03,1.63,1.03,2.75c0,3.94-2.34,4.81-4.57,5.06c0.36,0.32,0.68,0.94,0.68,1.9c0,1.37-0.01,2.48-0.01,2.81c0,0.27,0.18,0.59,0.69,0.49c3.97-1.36,6.83-5.2,6.83-9.73C22,6.59,17.52,2,12,2"/>
</svg>
</a>
<a class="icon" href="javascript:searchBox.focus()" title="Search">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentcolor">
<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
</svg>
</a>
<input id="searchBox" type="search" class="search-box" placeholder="Search" aria-label="Search">
</nav>
10 changes: 10 additions & 0 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,15 @@
</div>
</footer>

<script>
searchBox.addEventListener('keypress', function(event) {
if (event.keyCode === 13 /* enter */) {
const site = window.location.hostname;
const query = searchBox.value;
window.location = 'https://www.google.com/search?q=site%3A'+site+'+'+query;
event.preventDefault();
}
});
</script>
</body>
</html>
4 changes: 2 additions & 2 deletions docs/api/assets/js/search.js

Large diffs are not rendered by default.

57 changes: 37 additions & 20 deletions docs/api/classes/_lib_css_tag_.cssresult.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
<link rel="stylesheet" href="../../css/main.css">
<link rel="stylesheet" href="../../css/pygments.css">
<link rel="stylesheet" href="../../css/theme.css">
<style>
body {
position: relative;
margin-top: 60px;
}
@media screen and (max-width: 640px) {
body {
margin-top: 56px;
}
}
</style>
</head>
<body>
<nav class="main-nav" markdown="0">
Expand All @@ -18,11 +29,17 @@
<a class="nav-item" href="../../try">Try</a>
<a class="nav-item" href="../../guide">Guide</a>
<a class="nav-item" href="../../api/index.html">API</a>
<a class="icon-github" href="https://github.com/polymer/lit-element" title="GitHub">
<a class="icon" href="https://github.com/polymer/lit-element" title="GitHub">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentcolor">
<path d="M12,2C6.48,2,2,6.59,2,12.25c0,4.53,2.87,8.37,6.84,9.73c0.5,0.09,0.68-0.22,0.68-0.49c0-0.24-0.01-0.89-0.01-1.74c-2.78,0.62-3.37-1.37-3.37-1.37c-0.45-1.18-1.11-1.5-1.11-1.5c-0.91-0.64,0.07-0.62,0.07-0.62c1,0.07,1.53,1.06,1.53,1.06c0.89,1.57,2.34,1.11,2.91,0.85c0.09-0.66,0.35-1.11,0.63-1.37c-2.22-0.26-4.56-1.14-4.56-5.07c0-1.12,0.39-2.03,1.03-2.75c-0.1-0.26-0.45-1.3,0.1-2.71c0,0,0.84-0.28,2.75,1.05c0.8-0.23,1.65-0.34,2.5-0.34c0.85,0,1.7,0.12,2.5,0.34c1.91-1.33,2.75-1.05,2.75-1.05c0.55,1.41,0.2,2.45,0.1,2.71c0.64,0.72,1.03,1.63,1.03,2.75c0,3.94-2.34,4.81-4.57,5.06c0.36,0.32,0.68,0.94,0.68,1.9c0,1.37-0.01,2.48-0.01,2.81c0,0.27,0.18,0.59,0.69,0.49c3.97-1.36,6.83-5.2,6.83-9.73C22,6.59,17.52,2,12,2"/>
</svg>
</a>
<a class="icon" href="javascript:searchBox.focus()" title="Search">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentcolor">
<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
</svg>
</a>
<input id="searchBox" type="search" class="search-box" placeholder="Search" aria-label="Search">
</nav>
<header>
<div class="tsd-page-toolbar">
Expand Down Expand Up @@ -128,7 +145,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/Polymer/lit-element/blob/5526560/src/lib/css-tag.ts#L19">lib/css-tag.ts:19</a></li>
<li>Defined in <a href="https://github.com/Polymer/lit-element/blob/0dce05f/src/lib/css-tag.ts#L19">lib/css-tag.ts:19</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -150,7 +167,7 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> _style<wbr>Sheet</h3>
<div class="tsd-signature tsd-kind-icon">_style<wbr>Sheet<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">CSSStyleSheet</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/Polymer/lit-element/blob/5526560/src/lib/css-tag.ts#L17">lib/css-tag.ts:17</a></li>
<li>Defined in <a href="https://github.com/Polymer/lit-element/blob/0dce05f/src/lib/css-tag.ts#L17">lib/css-tag.ts:17</a></li>
</ul>
</aside>
</section>
Expand All @@ -160,7 +177,7 @@ <h3>css<wbr>Text</h3>
<div class="tsd-signature tsd-kind-icon">css<wbr>Text<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/Polymer/lit-element/blob/5526560/src/lib/css-tag.ts#L19">lib/css-tag.ts:19</a></li>
<li>Defined in <a href="https://github.com/Polymer/lit-element/blob/0dce05f/src/lib/css-tag.ts#L19">lib/css-tag.ts:19</a></li>
</ul>
</aside>
</section>
Expand All @@ -177,7 +194,7 @@ <h3>style<wbr>Sheet</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/Polymer/lit-element/blob/5526560/src/lib/css-tag.ts#L25">lib/css-tag.ts:25</a></li>
<li>Defined in <a href="https://github.com/Polymer/lit-element/blob/0dce05f/src/lib/css-tag.ts#L25">lib/css-tag.ts:25</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">CSSStyleSheet</span>
Expand All @@ -195,9 +212,6 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">CSSStyleS
<li class="globals ">
<a href="../globals.html"><em>Globals</em></a>
</li>
<li class="label tsd-is-external">
<span>Internals</span>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/_demo_ts_element_.html">"demo/ts-<wbr>element"</a>
</li>
Expand All @@ -211,18 +225,6 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">CSSStyleS
<a href="../modules/_lib_updating_element_.html">"lib/updating-<wbr>element"</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/_test_lit_element_styling_test_.html">"test/lit-<wbr>element_<wbr>styling_<wbr>test"</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/_test_lit_element_test_.html">"test/lit-<wbr>element_<wbr>test"</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/_test_test_helpers_.html">"test/test-<wbr>helpers"</a>
</li>
<li class="label tsd-is-external">
<span>Externals</span>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/_lit_element_.html">"lit-<wbr>element"</a>
</li>
</ul>
Expand Down Expand Up @@ -326,5 +328,20 @@ <h2>Legend</h2>
<div class="overlay"></div>
<script src="../assets/js/main.js"></script>
<script>if (location.protocol == 'file:') document.write('<script src="../assets/js/search.js"><' + '/script>');</script>
<script>
searchBox.addEventListener('keypress', function(event) {
if (event.keyCode === 13 /* enter */) {
const site = window.location.hostname;
const query = searchBox.value;
window.location = 'https://www.google.com/search?q=site%3A'+site+'+'+query;
event.preventDefault();
}
});
// TypeDoc's main.js installs a `keydown` handler on `body` for its own
// search functionality - stop our search box from triggering that.
searchBox.addEventListener('keydown', function(event) {
event.stopPropagation();
});
</script>
</body>
</html>
Loading