Skip to content

Commit 8673840

Browse files
Revathyvenugopal162pyansys-ci-botjorgepiloto
authored
maint: styles for dark theme search bar (#511)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Jorge Martínez <[email protected]>
1 parent 5159d3b commit 8673840

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

doc/changelog.d/511.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
maint: styles for dark theme search bar

src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/ast-search-button.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44

55
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
66

7+
{% if theme_static_search %}
8+
79
{% set theme_static_search = theme_static_search | default({}) %}
10+
{% else %}
11+
{% set theme_static_search = {'keys': ['title', 'text'], 'threshold': 0.5, 'shouldSort': 'True', 'ignoreLocation': 'False', 'useExtendedSearch': 'True'} %}
12+
{% endif %}
13+
814
{% set theme_limit = theme_static_search.limit | default(10) %}
915
{% set min_chars_for_search = theme_static_search.min_chars_for_search | default(1) %}
1016

src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/ansys-sphinx-theme-variable.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ html[data-theme="light"] {
220220
--ast-catagory-header-text: #353535;
221221
--ast-catagory-suggestion-text: #8e8e8e;
222222
--ast-suggestion-text-color: #000000;
223+
--ast-hover-suggestion-text-background: #ececec;
223224

224225
/**
225226
* dropdown header
@@ -375,6 +376,7 @@ html[data-theme="dark"] {
375376
--ast-catagory-header-text: #ececec;
376377
--ast-catagory-suggestion-text: #686868;
377378
--ast-suggestion-text-color: #ffffff;
379+
--ast-hover-suggestion-text-background: #3d3d3d;
378380

379381
/**
380382
* dropdown header

src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/fuse-search.css

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
@import "ansys-sphinx-theme-variable.css";
12
.results {
23
display: flex;
34
flex-direction: column;
45
align-content: flex-start;
56
justify-content: center;
67
position: absolute;
7-
background-color: white;
8+
background-color: var(--ast-search-bar-enable-background);
89
width: 700px;
910
padding: 10px;
10-
border: 1px solid #ddd; /* Optional: Add border for better visibility */
11-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Optional: Add shadow for better visibility */
11+
border: 1px solid var(--ast-search-bar-enable-border);
12+
box-shadow: var(--ast-box-shadow-active);
1213
overflow: auto;
1314
height: 500px;
1415
}
@@ -24,8 +25,9 @@
2425
.result-title {
2526
font-size: 1em;
2627
font-weight: bold;
27-
background-color: #f3f4f5;
28+
background-color: var(--ast-suggestion-header-background);
2829
font-family: "Open Sans", sans-serif;
30+
color: var(--ast-catagory-header-text);
2931
}
3032

3133
.result-title:focus,
@@ -55,18 +57,17 @@
5557

5658
.result-item:hover {
5759
background-color: var(
58-
--ast-color-hover-card-background
60+
--ast-hover-suggestion-text-background
5961
); /* Background when hovered */
6062
}
6163

6264
.no-results {
6365
font-style: italic;
64-
color: #777;
66+
color: var(--ast-color-text);
6567
font-family: "Open Sans", sans-serif;
6668
}
6769

6870
html[data-theme="light"] .highlight {
69-
background-color: #ececec;
7071
color: var(--ast-highlight-color);
7172
}
7273

@@ -160,3 +161,8 @@ html[data-theme="light"] .highlight {
160161
.search-icon {
161162
cursor: pointer;
162163
}
164+
165+
.bd-main.blurred {
166+
opacity: 0.5;
167+
transition: opacity 0.3s ease;
168+
}

src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/fuse_extension.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const searchBar = document.getElementById("search-bar");
22
const searchBarBox = searchBar.querySelector(".bd-search input");
33
resultsContainer = document.getElementById("results");
4+
const content = document.querySelector(".bd-main");
45

56
// Function to expand the search bar and display results
67
function expandSearchBox() {
78
searchBarBox.classList.add("expanded");
9+
content.classList.add("blurred");
810
searchBarBox.focus();
911

1012
if (searchBarBox.value.trim().length >= parseInt(min_chars_for_search)) {
@@ -26,6 +28,7 @@ document.addEventListener("keydown", function (event) {
2628
case "Escape":
2729
resultsContainer.style.display = "none";
2830
searchBarBox.classList.remove("expanded");
31+
content.classList.remove("blurred");
2932
break;
3033
}
3134
});
@@ -38,5 +41,6 @@ document.addEventListener("click", function (event) {
3841
) {
3942
resultsContainer.style.display = "none";
4043
searchBarBox.classList.remove("expanded");
44+
content.classList.remove("blurred");
4145
}
4246
});

0 commit comments

Comments
 (0)