Skip to content

Commit 4497439

Browse files
committed
Go with a simpler CSS class / data-attribute
1 parent e76fdc0 commit 4497439

File tree

9 files changed

+19
-18
lines changed

9 files changed

+19
-18
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
* The `ui.Chat()` component now supports input suggestion links. This feature is useful for providing users with clickable suggestions that can be used to quickly input text into the chat. This can be done in 2
1515
different ways (see #1845 for more details):
16-
* By adding a `.chat-input-suggestion` CSS class to an HTML element (e.g., `<span class="chat-input-suggestion">A suggestion</span>`)
17-
* Add a `data-input-suggestion` attribute to an HTML element, and set the value to the input suggestion text (e.g., `<span data-input-suggestion="Suggestion value">Suggestion link</span>`)
16+
* By adding a `.suggestion` CSS class to an HTML element (e.g., `<span class="suggestion">A suggestion</span>`)
17+
* Add a `data-suggestion` attribute to an HTML element, and set the value to the input suggestion text (e.g., `<span data-suggestion="Suggestion value">Suggestion link</span>`)
1818

1919
* Added a new `.add_sass_layer_file()` method to `ui.Theme` that supports reading a Sass file with layer boundary comments, e.g. `/*-- scss:defaults --*/`. This format [is supported by Quarto](https://quarto.org/docs/output-formats/html-themes-more.html#bootstrap-bootswatch-layering) and makes it easier to store Sass rules and declarations that need to be woven into Shiny's Sass Bootstrap files. (#1790)
2020

js/chat/chat.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ shiny-chat-container {
1313
margin-bottom: 0;
1414
}
1515

16-
.chat-input-suggestion, [data-input-suggestion] {
16+
.suggestion,
17+
[data-suggestion] {
1718
text-decoration: underline;
1819
text-decoration-style: dotted;
1920
text-decoration-color: var(--bs-link-color, #007bc2);

js/chat/chat.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,14 @@ class ChatContainer extends LightElement {
339339
if (!(target instanceof HTMLElement)) return;
340340

341341
const isSuggestion =
342-
target.classList.contains("chat-input-suggestion") ||
343-
target.dataset.inputSuggestion !== undefined;
342+
target.classList.contains("suggestion") ||
343+
target.dataset.suggestion !== undefined;
344344

345345
if (!isSuggestion) return;
346346

347347
e.preventDefault();
348348

349-
const suggestion = target.dataset.inputSuggestion || target.textContent;
349+
const suggestion = target.dataset.suggestion || target.textContent;
350350
if (suggestion) {
351351
this.input.setInputValue(suggestion);
352352
}

shiny/www/py-shiny/chat/chat.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.

shiny/www/py-shiny/chat/chat.css.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shiny/www/py-shiny/chat/chat.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.

shiny/www/py-shiny/chat/chat.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/playwright/shiny/components/chat/input-suggestion/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
welcome = ui.HTML(
44
"""
5-
Here is the <span class='chat-input-suggestion'>1st input suggestion</span>.
6-
And here is a <span data-input-suggestion='The actual suggestion'>2nd suggestion</span>.
7-
Finally, a <img data-input-suggestion='A 3rd, image-based, suggestion' src='shiny-hex.svg' height="50px" alt='Shiny logo'> image suggestion.
5+
Here is the <span class='suggestion'>1st input suggestion</span>.
6+
And here is a <span data-suggestion='The actual suggestion'>2nd suggestion</span>.
7+
Finally, a <img data-suggestion='A 3rd, image-based, suggestion' src='shiny-hex.svg' height="50px" alt='Shiny logo'> image suggestion.
88
"""
99
)
1010

0 commit comments

Comments
 (0)