Skip to content

Commit 1464935

Browse files
authored
Add Ask AI button in header & hero box (#1485)
* feat: add ask ai hero box * fix: prevent search scroll * feat: add search to header * chore: revert order * fix: tests * Change 'Platforms' to 'Deployments' in header
1 parent 484cabe commit 1464935

File tree

17 files changed

+467
-25
lines changed

17 files changed

+467
-25
lines changed

docs/source/examples/hero-box.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ The ``hero-box`` directive supports the following options:
8787
-
8888
-
8989
- If present, adds vertical padding suitable for content pages. By default (without this flag), the hero box is optimized for landing pages.
90+
* - ``ai_chatbot_id``
91+
- string
92+
-
93+
- my-chatbot-id
94+
- AI chatbot ID to use for the Ask AI button. Requires the ``search_box`` option to be present.
9095

9196
Link resolution
9297
---------------
@@ -220,6 +225,29 @@ Results in:
220225
:search_box:
221226
:content_page:
222227

228+
With custom AI chatbot ID
229+
..........................
230+
231+
Using:
232+
233+
.. code-block:: rst
234+
235+
.. hero-box::
236+
:title: Lorem Ipsum
237+
:text: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
238+
:search_box:
239+
:ai_chatbot_id: my-custom-chatbot-id
240+
:content_page:
241+
242+
Results in:
243+
244+
.. hero-box::
245+
:title: Lorem Ipsum
246+
:text: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
247+
:search_box:
248+
:ai_chatbot_id: ddfdo8m94k
249+
:content_page:
250+
223251
With bold button
224252
.................
225253

docs/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
.. hero-box::
1313
:button_icon: icon-github
1414
:button_style: bold
15-
:button_url: https://github.com/scylladb/sphinx-scylladb-theme
16-
:button_text: Source code
1715
:title: Welcome to ScyllaDB Sphinx Theme documentation
1816
:image: /_static/img/mascots-2/docs.svg
17+
:search_box:
18+
:ai_chatbot_id: ddfdo8m94k
1919

2020
The documentation toolchain for ScyllaDB projects.
2121

sphinx_scylladb_theme/extensions/hero_box.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class HeroBox(Directive):
2424
"button_text": directives.path,
2525
"search_box": directives.flag,
2626
"content_page": directives.flag,
27+
"ai_chatbot_id": directives.unchanged,
2728
}
2829

2930
def run(self):
@@ -88,18 +89,34 @@ def run(self):
8889
)
8990

9091
has_search_box = "search_box" in self.options
91-
search_box = (
92-
generate_template(
92+
93+
ai_chatbot_id = self.options.get("ai_chatbot_id")
94+
95+
ask_ai_section = ""
96+
if ai_chatbot_id:
97+
ask_ai_section = """
98+
<div class="{class_name}__ask-ai">
99+
<biel-button project="{ai_chatbot_id}"
100+
header-title="ScyllaDB chatbot (beta)"
101+
button-position="default"
102+
modal-position="bottom-right"
103+
button-style="dark">Ask AI</biel-button>
104+
</div>""".format(class_name=class_name, ai_chatbot_id=ai_chatbot_id)
105+
106+
if has_search_box:
107+
search_box = generate_template(
93108
"""
94-
<div class="{class_name}__search-box search-box search-box--hero">
95-
<ci-search></ci-search>
109+
<div class="{class_name}__search-wrapper">
110+
<div class="{class_name}__search-box search-box search-box--hero">
111+
<ci-search></ci-search>
112+
</div>{ask_ai_section}
96113
</div>
97114
""",
98115
class_name=class_name,
116+
ask_ai_section=ask_ai_section,
99117
)
100-
if has_search_box
101-
else ""
102-
)
118+
else:
119+
search_box = ""
103120

104121
html_tag_open = generate_template(
105122
"""

sphinx_scylladb_theme/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
</div>
5959
</div>
6060
{% if theme_hide_ai_chatbot|lower != 'true' %}
61-
<biel-button project="{{theme_ai_chatbot_id}}"
61+
<biel-button class="footer-ask-ai" project="{{theme_ai_chatbot_id}}"
6262
header-title="ScyllaDB chatbot (beta)"
6363
button-position="bottom-right"
6464
modal-position="bottom-right"

sphinx_scylladb_theme/header.html

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@
1111
<div class="header-navigation">
1212
<ul class="dropdown menu scylla-dropdown scylla-dropdown--header" data-dropdown-menu>
1313
<li class="scylla-dropdown__item">
14-
<a href="https://docs.scylladb.com/manual/" class="scylla-dropdown__title">Server</a>
15-
</li>
16-
<li class="scylla-dropdown__item">
17-
<a href="https://docs.scylladb.com/scylla-cloud/" class="scylla-dropdown__title">Cloud</a>
14+
<a href="#" class="scylla-dropdown__title">Deployments <i class="chevron icon-arrow-dropdown"></i></a>
15+
<ul class="menu scylla-dropdown__content">
16+
<li>
17+
<a href="https://docs.scylladb.com/scylla-cloud/">
18+
<i class="icon-docs-cloud"></i>Cloud</a>
19+
</li>
20+
<li>
21+
<a href="https://docs.scylladb.com/manual/">
22+
<i class="icon-server"></i>Server</a>
23+
</li>
24+
</ul>
1825
</li>
1926
<li class="scylla-dropdown__item">
2027
<a href="#" class="scylla-dropdown__title">Tools <i class="chevron icon-arrow-dropdown"></i></a>
@@ -84,6 +91,15 @@
8491
<div class="search-box">
8592
<ci-search></ci-search>
8693
</div>
94+
{% if theme_hide_ai_chatbot|lower != 'true' %}
95+
<biel-button class="header-ask-ai" project="{{theme_ai_chatbot_id}}"
96+
header-title="ScyllaDB chatbot (beta)"
97+
button-position="default"
98+
modal-position="bottom-right"
99+
button-style="dark">
100+
Ask AI
101+
</biel-button>
102+
{% endif %}
87103
</div>
88104
{% include 'side-nav-toggle.html' %}
89105
</header>

sphinx_scylladb_theme/static/css/main.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sphinx_scylladb_theme/static/js/main.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/css/base/_variables.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ $product-title-height: $spacer-md;
185185
--brand-self-hosted: #{$brand-self-hosted};
186186

187187
--biel-primary-color: #{$link-color};
188+
--biel-button-dark-bg-color: #{$link-color};
189+
--biel-input-button-bg-color: #{$link-color};
190+
--biel-button-border-radius: 4px;
191+
--biel-button-padding: 12px 15px;
192+
--biel-font-family: "Roboto", sans-serif;
188193
}
189194

190195
.dark {
@@ -218,6 +223,8 @@ $product-title-height: $spacer-md;
218223
--brand-text: #{$gray-100};
219224

220225
--biel-primary-color: #{$primary};
226+
--biel-button-dark-bg-color: #{$primary};
227+
--biel-input-button-bg-color: #{$primary};
221228
}
222229

223230
@each $key, $styles in $brand-colors {

src/css/components/_footer.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
}
105105
}
106106

107+
.footer-ask-ai {
108+
display: block;
109+
}
107110

108111
@media screen and (min-width: $large) {
109112
.footer {
@@ -145,3 +148,9 @@
145148
}
146149
}
147150
}
151+
152+
@media screen and (min-width: $xlarge) {
153+
.footer-ask-ai {
154+
display: none;
155+
}
156+
}

src/css/components/_header.scss

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,27 @@
6868
.header-search-box {
6969
display: none;
7070
width: 200px;
71+
align-items: center;
72+
gap: 15px;
73+
74+
.search-box {
75+
flex: 1;
76+
width: 160px;
77+
transition: width 0.2s ease;
78+
79+
ci-search {
80+
width: 100%;
81+
display: block;
82+
}
83+
}
84+
85+
.header-ask-ai {
86+
white-space: nowrap;
87+
display: none;
88+
width: 100.56px;
89+
flex-shrink: 0;
90+
text-align: center;
91+
}
7192
}
7293

7394
.scylla-dropdown__content {
@@ -119,19 +140,38 @@
119140
flex-direction: row;
120141
align-items: center;
121142
gap: 20px;
143+
max-width: 180px;
144+
width: 180px;
145+
}
146+
}
147+
148+
// Intermediate screen sizes - optimize for space efficiency
149+
@media screen and (min-width: $large) and (max-width: 1199px) {
150+
.header-search-box {
151+
gap: 15px; // Reduce gap between elements
152+
max-width: 160px; // Make even smaller to prevent wrapping
153+
width: 160px;
122154
}
123155
}
124156

125157
@media screen and (min-width: $xlarge) {
126158
.header-logo {
127-
width: $side-nav-width - $spacer;
159+
width: auto;
128160
}
129161

130162
.header-search-box {
131-
max-width: 20%;
132-
width: $search-box-width;
163+
max-width: 25%;
164+
width: auto;
165+
min-width: 300px;
166+
gap: 20px;
167+
168+
.header-ask-ai {
169+
display: block;
170+
}
133171
}
172+
}
134173

174+
@media screen and (min-width: 1320px) {
135175
.header-button {
136176
display: block;
137177
}

0 commit comments

Comments
 (0)