-
Notifications
You must be signed in to change notification settings - Fork 4
POC: Ask AI button and Kapa widget #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // (C) 2026 GoodData Corporation | ||
| @import "variables/variables"; | ||
|
|
||
| // "Ask AI" button — opens the Kapa AI widget. The outlined button appearance | ||
| // comes from the shared .gd-docs-header-nav__secondary styles; this file only | ||
| // owns the container layout and icon sizing. Rendered only when | ||
| // Site.Params.askAI.websiteId is configured (see partials/ask-ai-button.html). | ||
| .ask-ai-button-container { | ||
| display: flex; | ||
| margin-left: 20px; | ||
| justify-content: flex-start; | ||
|
|
||
| button { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 5px; | ||
|
|
||
| &:disabled { | ||
| cursor: not-allowed; | ||
| opacity: 0.2; | ||
|
|
||
| &:hover, | ||
| &:focus, | ||
| &:active { | ||
| color: inherit; | ||
| border-color: inherit; | ||
| } | ||
|
|
||
| &:focus { | ||
| box-shadow: inherit; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .ask-ai-icon { | ||
| display: flex; | ||
| width: fit-content; | ||
|
|
||
| svg { | ||
| width: 15px; | ||
| height: 15px; | ||
| margin: 0; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| {{/* (C) 2026 GoodData Corporation */}} | ||
| {{/* "Ask AI" button — opens the Kapa AI widget (loaded by ask-ai-widget.html). | ||
| Rendered only when Site.Params.askAI.websiteId is configured. The widget is | ||
| triggered via the `open-kapa-widget` override class. */}} | ||
| {{- with .Site.Params.askAI }} | ||
| {{- if .websiteId }} | ||
| <div class="ask-ai-button-container"> | ||
| <button | ||
| class="gd-docs-header-nav__cta gd-docs-header-nav__secondary open-kapa-widget ask-ai-button" | ||
| aria-expanded="false" | ||
| aria-haspopup="dialog" | ||
| aria-controls="kapa-modal-content" | ||
| id="ask-ai-button" | ||
| > | ||
| {{ .buttonText | default "Ask AI" }} | ||
| <div class="ask-ai-icon"> | ||
| {{ with resources.Get "icons/ai.svg" }}{{ ( . | minify).Content | safeHTML }}{{ end }} | ||
| </div> | ||
| </button> | ||
| </div> | ||
| {{- end }} | ||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| {{/* (C) 2026 GoodData Corporation */}} | ||
| {{/* Loads the Kapa AI widget bundle. Rendered only when Site.Params.askAI.websiteId | ||
| is configured. Pair with partials/ask-ai-button.html, which provides the | ||
| trigger button (data-button-hide keeps Kapa's own launcher hidden). | ||
|
|
||
| Configure in site params, e.g.: | ||
| [params.askAI] | ||
| websiteId = "..." # required | ||
| projectName = "GoodData" | ||
| projectColor = "#ED26B7" | ||
| projectLogo = "https://www.gooddata.ai/img/generic/logo-g.svg" | ||
| modalDisclaimerTextColor = "#ED26B7" | ||
| modalTitleColor = "#1c0d3f" | ||
| modalTitleFontFamily = "bca6d3310b5c9dae1dae416e8abc8405,helvetica,arial,sans-serif" | ||
| */}} | ||
| {{- with .Site.Params.askAI }} | ||
| {{- if .websiteId }} | ||
| <script | ||
| async | ||
| src="https://widget.kapa.ai/kapa-widget.bundle.js" | ||
| data-website-id="{{ .websiteId }}" | ||
| data-project-name="{{ .projectName | default "GoodData" }}" | ||
| data-project-color="{{ .projectColor | default "#ED26B7" }}" | ||
| data-project-logo="{{ .projectLogo | default "https://www.gooddata.ai/img/generic/logo-g.svg" }}" | ||
| data-button-hide="true" | ||
| data-modal-disclaimer-text-color="{{ .modalDisclaimerTextColor | default "#ED26B7" }}" | ||
| data-modal-override-open-class="open-kapa-widget" | ||
| data-modal-open-on-command-k="true" | ||
| data-modal-y-offset="20vh" | ||
| data-modal-title-color="{{ .modalTitleColor | default "#1c0d3f" }}" | ||
| data-modal-title-font-family="{{ .modalTitleFontFamily | default "bca6d3310b5c9dae1dae416e8abc8405,helvetica,arial,sans-serif" }}" | ||
| ></script> | ||
| {{- end }} | ||
| {{- end }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ | |
| <script src="/js/prism-accessibility.js"></script> | ||
| {{ $themeSwitcherJS := resources.Get "js/theme-switcher.js" | minify | fingerprint }} | ||
| <script src="{{ $themeSwitcherJS.RelPermalink }}" integrity="{{ $themeSwitcherJS.Data.integrity }}" defer></script> | ||
| {{ partial "ask-ai-widget.html" . }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Search for where ask-ai-accessibility.js is loaded in the codebase.
rg -n "ask-ai-accessibility" --type=html --type=mdRepository: gooddata/gooddata-docs-theme Length of output: 166 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== references to ask-ai =="
rg -n --hidden --glob '!**/.git/**' "ask-ai-accessibility|ask-ai-button|ask-ai-widget" .
echo
echo "== relevant template files =="
git ls-files 'layouts/**' 'static/js/**' | rg 'body-end|ask-ai|hooks|partials|js'
echo
echo "== body-end template =="
sed -n '1,220p' layouts/partials/hooks/body-end.htmlRepository: gooddata/gooddata-docs-theme Length of output: 3405 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== ask-ai-widget partial =="
sed -n '1,220p' layouts/partials/ask-ai-widget.html
echo
echo "== custom-scripts partial =="
sed -n '1,220p' layouts/partials/custom-scripts.html
echo
echo "== any direct include of ask-ai-accessibility.js =="
rg -n "/js/ask-ai-accessibility\.js|ask-ai-accessibility\.js" layouts static assetsRepository: gooddata/gooddata-docs-theme Length of output: 2308 Load 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Remove static
aria-controls— the controlled element doesn't exist on initial load.aria-controls="kapa-modal-content"is set in the HTML, but thekapa-modal-contentelement lives inside the Kapa widget's shadow DOM and won't exist until the async script loads and the user opens the modal. The accessibility JS instatic/js/ask-ai-accessibility.jsalready addsaria-controlswhen the modal appears and removes it when it disappears. The static value is redundant and incorrectly references a non-existent element on initial page load, which can confuse screen readers.♿ Proposed fix
aria-expanded="false" aria-haspopup="dialog" - aria-controls="kapa-modal-content" id="ask-ai-button"📝 Committable suggestion
🤖 Prompt for AI Agents