Skip to content

Commit 05373a6

Browse files
committed
Move search clear button to top of article
1 parent 23074b1 commit 05373a6

File tree

7 files changed

+62
-33
lines changed

7 files changed

+62
-33
lines changed

docs/_static/contributors.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
- header: "@bollwyvl"
22
image: https://avatars.githubusercontent.com/u/45380
3-
link: https://github.com/bollwyvl
3+
website: https://github.com/bollwyvl
44
- header: "@jarrodmillman"
55
image: https://avatars.githubusercontent.com/u/123428
6-
link: https://github.com/jarrodmillman
6+
website: https://github.com/jarrodmillman
77
- header: "@hoetmaaiers"
88
image: https://avatars.githubusercontent.com/u/468045
9-
link: https://github.com/hoetmaaiers
9+
website: https://github.com/hoetmaaiers
1010
- header: "@jorisvandenbossche"
1111
image: https://avatars.githubusercontent.com/u/1020496
12-
link: https://github.com/jorisvandenbossche
12+
website: https://github.com/jorisvandenbossche
1313
- header: "@damianavila"
1414
image: https://avatars.githubusercontent.com/u/1640669
15-
link: https://github.com/damianavila
15+
website: https://github.com/damianavila
1616
- header: "@drammock"
1717
image: https://avatars.githubusercontent.com/u/1810515
18-
link: https://github.com/drammock
18+
website: https://github.com/drammock
1919
- header: "@choldgraf"
2020
image: https://avatars.githubusercontent.com/u/1839645
21-
link: https://github.com/choldgraf
21+
website: https://github.com/choldgraf
2222
- header: "@12rambau"
2323
image: https://avatars.githubusercontent.com/u/12596392
24-
link: https://github.com/12rambau
24+
website: https://github.com/12rambau

docs/scripts/generate_collaborators_gallery.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{
2323
"header": f"@{collaborator['login']}",
2424
"image": f"https://avatars.githubusercontent.com/u/{collaborator['id']}",
25-
"link": collaborator["html_url"],
25+
"website": collaborator["html_url"],
2626
}
2727
)
2828

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* The 'Hide Search Matches' button.
3+
* This only shows up when a person lands on a page after clicking a search result.
4+
* Clicking it removes the highlighting of the search term from the page.
5+
* We want it to behave like a button.
6+
*/
7+
div#searchbox {
8+
// Leave `#searchbox` rules empty so that it doesn't show at all when it is empty
9+
p.highlight-link {
10+
margin: 1rem 0;
11+
width: fit-content;
12+
13+
// A bit more margin on wide screens to mimic article behavior
14+
@include media-breakpoint-up($breakpoint-sidebar-secondary) {
15+
margin-left: 2rem;
16+
}
17+
18+
// Put outer shadow on this one so that we can darken the link w/ an inner shadow
19+
@include box-shadow();
20+
21+
// Style the button to look like a Sphinx Design button
22+
a {
23+
border-radius: 0.25rem;
24+
font-size: 1.25rem;
25+
padding: 0.75rem;
26+
background-color: var(--pst-color-primary);
27+
// Button text is always white with Sphinx Design buttons
28+
color: white;
29+
30+
// The box shadow is inset so that it darkens the button on hover
31+
transition: box-shadow 0.25s ease-out;
32+
&:hover {
33+
box-shadow: inset 0px 0px 50px 50px rgba(0, 0, 0, 0.25);
34+
35+
// Remove underline for link
36+
text-decoration: none;
37+
}
38+
39+
// add icon via CSS because the link is created by javascript
40+
// match padding to .toc-item > i above
41+
&:before {
42+
content: var(--pst-icon-search-minus);
43+
color: unset;
44+
font-family: "Font Awesome 6 Free";
45+
font-weight: 900;
46+
margin-right: 0.5rem;
47+
}
48+
}
49+
}
50+
}

src/pydata_sphinx_theme/assets/styles/pydata-sphinx-theme.scss

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
@import "./components/navbar-links";
3838
@import "./components/prev-next";
3939
@import "./components/search";
40+
@import "./components/searchbox";
4041
@import "./components/switcher-theme";
4142
@import "./components/switcher-version";
4243
@import "./components/toc-inpage";

src/pydata_sphinx_theme/assets/styles/sections/_sidebar-secondary.scss

-20
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,3 @@
5353
padding-left: 1rem;
5454
}
5555
}
56-
57-
// The 'Hide Search Matches' link
58-
div#searchbox {
59-
p.highlight-link {
60-
// remove excess margin from p tag
61-
margin-bottom: 0px;
62-
a {
63-
// add icon via CSS because the link is created by javascript
64-
// match padding to .toc-item > i above
65-
&:before {
66-
content: var(--pst-icon-search-minus);
67-
color: unset; // make sure it uses the same color as the text
68-
font-family: "Font Awesome 6 Free";
69-
font-weight: 900;
70-
padding-right: 0.5rem;
71-
margin-right: 0;
72-
}
73-
}
74-
}
75-
}

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
<div class="bd-header-article">{% include "sections/header-article.html" %}</div>
9090
{# Article content #}
9191
{% block docs_body %}
92+
{# This is empty and only shows up if text has been highlighted by the URL #}
93+
{% include "components/searchbox.html" %}
9294
<article class="bd-article" role="main">
9395
{% block body %}{% endblock %}
9496
</article>

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/sidebar-primary.html

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
{% block docs_sidebar %}
2-
{# This is empty and only shows up if text has been highlighted by the URL #}
3-
{# We put it *both above and below the article* to be easier to find. #}
4-
{% include "components/searchbox.html" %}
5-
62
{# Header items that will be displayed in the sidebar on mobile #}
73
<div class="sidebar-header-items sidebar-primary__section">
84
{# The header center items #}

0 commit comments

Comments
 (0)