Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Website global search feature #18288

Merged
merged 30 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ab2f571
init global search ui
May 5, 2020
5a47a65
add hover effect to icon and refactor js
May 5, 2020
e3e2eca
add search bar ui styles
May 5, 2020
f7ace01
fix search UI's effect on navbar height
May 6, 2020
1356605
add fade in/out effect to search ui and navbar
May 6, 2020
67c23f8
update search trigger to click and add x button for close
ys2843 May 7, 2020
ce0f54c
add version select for search
ys2843 May 7, 2020
eeb4cc9
fix version typo
ys2843 May 7, 2020
0294488
update dropdown
ys2843 May 7, 2020
63113dd
fix hitsperpage reset after change version
ys2843 May 7, 2020
96a10f4
fix nav trigger not show
ys2843 May 7, 2020
b36f0c0
update search border css class name
ys2843 May 7, 2020
592a9f1
make dropdown style consistent
ys2843 May 7, 2020
9d815bf
global search mobile&tablet UI
ys2843 May 11, 2020
bb2c0b6
adjust mobile search result width
ys2843 May 11, 2020
e51b2b5
extract global search related styles to a seperate scss
ys2843 May 12, 2020
4a869d9
restore formatting to existing code
ys2843 May 12, 2020
d2a9981
format & coding style
ys2843 May 12, 2020
aa0430f
fix caret height bug
ys2843 May 12, 2020
cff1da4
add mobile compatible UI
ys2843 May 12, 2020
5164f6f
add license header to js files and update dropdown width
ys2843 May 12, 2020
60d0715
put docsearch css before main to overrides
ys2843 May 12, 2020
4d97ac8
update search result panel height
ys2843 May 13, 2020
e588283
dynamically generate version dropdown
ys2843 May 13, 2020
20628b4
use more accurate selector over search result
ys2843 May 13, 2020
d58ce1f
use vh for height
ys2843 May 13, 2020
8ca1c10
add comments to scss
ys2843 May 14, 2020
34709c4
move versions to Jekyll global variable
ys2843 May 15, 2020
4693954
remove redundant version key
ys2843 May 18, 2020
f038f5e
make global search default version the same as website version
ys2843 May 18, 2020
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
11 changes: 11 additions & 0 deletions docs/static_site/src/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ description: >- # this means to ignore newlines until "baseurl:"
twitter_username: apachemxnet
github_username: apache/incubator-mxnet
youtube_username: apachemxnet
versions:
- master
- 1.6
- 1.5.0
- 1.4.1
- 1.3.1
- 1.2.1
- 1.1.0
- 1.0.0
- 0.12.1
- 0.11.0

# Build settings
markdown: kramdown
Expand Down
13 changes: 12 additions & 1 deletion docs/static_site/src/_config_beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ url: https://thomasdelteil.github.io
twitter_username: apachemxnet
github_username: apache/incubator-mxnet
youtube_username: apachemxnet

versions:
- master
- 1.6
- 1.5.0
- 1.4.1
- 1.3.1
- 1.2.1
- 1.1.0
- 1.0.0
- 0.12.1
- 0.11.0

# Build settings
markdown: kramdown
plugins:
Expand Down
13 changes: 12 additions & 1 deletion docs/static_site/src/_config_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ twitter_username: apachemxnet
github_username: apache/incubator-mxnet
youtube_username: apachemxnet
google_analytics: UA-96378503-1

versions:
- master
- 1.6
- 1.5.0
- 1.4.1
- 1.3.1
- 1.2.1
- 1.1.0
- 1.0.0
- 0.12.1
- 0.11.0

# Build settings
markdown: kramdown
plugins:
Expand Down
9 changes: 7 additions & 2 deletions docs/static_site/src/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
<link href="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-icon.png" rel="icon" type="image/png">
{%- seo -%}
<script src="https://medium-widget.pixelpoint.io/widget.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
<link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}">
{%- feed_meta -%}
{%- if jekyll.environment == 'production' and site.google_analytics -%}
{%- include google-analytics.html -%}
{%- endif -%}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
ys2843 marked this conversation as resolved.
Show resolved Hide resolved
<script src="{{'/assets/js/globalSearch.js'|relative_url}}"></script>
<script src="{{'/assets/js/clipboard.js'|relative_url}}"></script>
<script src="{{'/assets/js/copycode.js'|relative_url}}"></script>
<style>
Expand Down Expand Up @@ -50,6 +51,10 @@
width: 18px;
}

.trigger .dropdown-caret {
height: 57px;
}

.dropdown-caret-path {
fill: #FFFFFF;
}
Expand Down
45 changes: 44 additions & 1 deletion docs/static_site/src/_includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,51 @@
</svg>
</span>
</label>

<div class="gs-search-border">
<div id="gs-search-icon"></div>
<form id="global-search-form">
<input id="global-search" type="text" title="Search" placeholder="Search" />
<div id="global-search-dropdown-container">
<button class="gs-current-version btn" type="button" data-toggle="dropdown">
<span id="gs-current-version-label">{{site.versions[0]}}</span>
<svg class="gs-dropdown-caret" viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true">
<path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path>
</svg>
</button>
<ul class="gs-opt-group gs-version-dropdown">
{% for version in site.versions %}
{% if version == site.versions[0] %}
<li class="gs-opt gs-versions active">{{version}}</li>
{% else %}
<li class="gs-opt gs-versions">{{version}}</li>
{% endif %}
{% endfor %}
</ul>
</div>
<span id="global-search-close">x</span>
</form>
</div>
<div class="trigger">
<div id="global-search-mobile-border">
<div id="gs-search-icon-mobile"></div>
<input id="global-search-mobile" placeholder="Search..." type="text"/>
<div id="global-search-dropdown-container-mobile">
<button class="gs-current-version-mobile btn" type="button" data-toggle="dropdown">
<svg class="gs-dropdown-caret" viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true">
<path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path>
</svg>
</button>
<ul class="gs-opt-group gs-version-dropdown-mobile">
{% for version in site.versions %}
{% if version == site.versions[0] %}
<li class="gs-opt gs-versions active">{{version}}</li>
{% else %}
<li class="gs-opt gs-versions">{{version}}</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
<a class="page-link" href="{{'/get_started' | relative_url }}">Get Started</a>
<a class="page-link" href="{{'/blog' | relative_url }}">Blog</a>
<a class="page-link" href="{{'/features' | relative_url }}">Features</a>
Expand Down
217 changes: 217 additions & 0 deletions docs/static_site/src/_sass/globalSearch.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
.trigger {
float: right;
}

/* Search bar - wide screen */
.gs-search-border {
padding-left: 25px;
float: right;
}

#global-search {
width: 0px;
border: 0px;
background-color: transparent;
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
outline: none;
font-size: 1em;
color: #ffffff;
display: inline-block;
margin-bottom: 19px;
}

#gs-search-icon {
background: url(/assets/img/search-icon.svg) center no-repeat;
background-size: 1em;
height: 30px;
width: 30px;
position: relative;
top: 10px;
cursor: pointer;
display: inline-block;
}

#global-search-form {
display: none;
padding: 5px;
line-height: 1em;
}

#global-search-close {
cursor: pointer;
}

#global-search-dropdown-container {
display: inline-block;
position: relative;
}

#global-search-dropdown-container button {
background-color: inherit;
color: white;
font-size: 17px;
margin: 0px;
border: none;
min-width: 100%;
outline: 0;
height: 37px;
width: 90px;
padding: 0px;
cursor: pointer;
}

#global-search-dropdown-container-mobile
.gs-current-version-mobile
.gs-dropdown-caret,
#global-search-dropdown-container .gs-current-version .gs-dropdown-caret {
position: relative;
top: 4px;
height: 18px;
}

ul.gs-version-dropdown {
display: none;
position: absolute;
text-align: center;
background-color: whitesmoke;
box-shadow: none;
z-index: 1;
margin: 0px;
padding: 0px;
list-style-type: none;
}

li.gs-opt.gs-versions {
padding: 10px;
cursor: pointer;
}

.gs-version-dropdown li:hover {
color: #ff4500 !important;
}

/* Search bar - mobile */
#global-search-mobile {
width: 120px;
margin-right: 10px;
background-color: transparent;
border: 0px;
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
outline: none;
font-size: 1em;
color: white;
}

#gs-search-icon-mobile {
background: url(/assets/img/search-icon.svg) center no-repeat;
background-size: 1em;
height: 30px;
width: 30px;
position: relative;
top: 10px;
cursor: pointer;
display: inline-block;
}

#global-search-dropdown-container-mobile {
display: inline-block;
position: absolute;
right: 10px;
}

#global-search-dropdown-container-mobile button {
background-color: inherit;
margin: 0px;
border: none;
outline: 0;
height: 37px;
padding: 0px;
cursor: pointer;
}

.gs-version-dropdown-mobile {
display: none;
position: absolute;
text-align: center;
background-color: whitesmoke;
box-shadow: none;
z-index: 1;
margin: 0px;
padding: 0px;
left: -50px;
list-style-type: none;
width: 166px;
left: -138px;
}

#global-search-mobile-border {
line-height: 25px;
}

#global-search-mobile::placeholder,
#global-search::placeholder {
color: #eeeeee;
}

.gs-version-dropdown-mobile li.active,
.gs-version-dropdown li.active {
color: #ff4500 !important;
font-weight: lighter;
}

.gs-version-dropdown-mobile li,
.gs-version-dropdown li {
color: #424242;
text-decoration: none;
display: block;
padding-left: 5px;
padding-right: 5px;
font-size: 17px;
}

/* Main dropdown wrapper */
.algolia-autocomplete .ds-dropdown-menu > div {
max-height: 60vh;
overflow-y: scroll;
}

#global-search-mobile-border .algolia-autocomplete .ds-dropdown-menu {
min-width: 80vw;
}

#global-search-mobile-border .algolia-autocomplete .ds-dropdown-menu > div {
min-width: 80vw;
max-height: 90vh;
}

.gs-search-border .algolia-autocomplete .ds-dropdown-menu {
min-width: 680px;
}

/* Main category */
.algolia-autocomplete .algolia-docsearch-suggestion--category-header {
color: #000000;
text-align: center;
}

/* Category */
.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column {
color: gray;
}

/* Title */
.algolia-autocomplete .algolia-docsearch-suggestion--title {
color: black;
font-weight: 300;
}

/* Description description */
.algolia-autocomplete .algolia-docsearch-suggestion--text {
font-size: 0.8rem;
color: gray;
}

/* Highlighted text */
.algolia-autocomplete .algolia-docsearch-suggestion--highlight {
color: blue;
}
16 changes: 16 additions & 0 deletions docs/static_site/src/_sass/minima/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
.nav-trigger {
display: none;
}

#global-search-mobile-border {
display: none;
}

.gs-search-border {
display: inline-block;
}

.menu-icon {
display: none;
Expand Down Expand Up @@ -81,6 +89,14 @@
cursor: pointer;
}

.gs-search-border {
display: none;
}

#global-search-mobile-border {
display: block;
}

.menu-icon {
display: block;
float: right;
Expand Down
3 changes: 3 additions & 0 deletions docs/static_site/src/assets/img/search-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading