From 3b8d792f1377dba02e83d243478e220d55d13c0a Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Mon, 10 Mar 2025 16:28:47 -0700 Subject: [PATCH 1/8] Replace Kapa.ai with Streamlit app using Cortex. Add script to prep data for Cortex. --- components/layouts/globalTemplate.js | 4 +- components/navigation/chatSticky.js | 17 --- components/navigation/chatSticky.module.css | 11 -- components/navigation/footer.js | 2 +- components/navigation/footer.module.css | 7 + components/utilities/Modal.js | 47 +++++++ components/utilities/Modal.module.css | 29 ++++ components/utilities/assistant.js | 40 ++++++ .../{kapa.module.css => assistant.module.css} | 16 +-- components/utilities/cookieSettingsModal.js | 98 ++++++-------- .../utilities/cookieSettingsModal.module.css | 4 + components/utilities/kapa.js | 67 --------- components/utilities/kapaModal.css | 128 ------------------ content/cookie-settings.md | 2 - netlify.toml | 5 - next.config.js | 10 -- pages/_app.js | 1 - 17 files changed, 180 insertions(+), 308 deletions(-) delete mode 100644 components/navigation/chatSticky.js delete mode 100644 components/navigation/chatSticky.module.css create mode 100644 components/utilities/Modal.js create mode 100644 components/utilities/Modal.module.css create mode 100644 components/utilities/assistant.js rename components/utilities/{kapa.module.css => assistant.module.css} (82%) delete mode 100644 components/utilities/kapa.js delete mode 100644 components/utilities/kapaModal.css diff --git a/components/layouts/globalTemplate.js b/components/layouts/globalTemplate.js index 12361fe1a..2eb1a2e44 100644 --- a/components/layouts/globalTemplate.js +++ b/components/layouts/globalTemplate.js @@ -1,6 +1,6 @@ import React, { useState, useEffect } from "react"; import Header from "../navigation/header"; -import ChatSticky from "../navigation/chatSticky"; +import Assistant from "../utilities/assistant"; import styles from "./globalTemplate.module.css"; @@ -26,7 +26,7 @@ const Layout = ({ children }) => {
{children}
- + ); }; diff --git a/components/navigation/chatSticky.js b/components/navigation/chatSticky.js deleted file mode 100644 index 358d805ce..000000000 --- a/components/navigation/chatSticky.js +++ /dev/null @@ -1,17 +0,0 @@ -import classNames from "classnames"; -import Kapa from "../utilities/kapa"; -import styles from "./chatSticky.module.css"; - -const ChatSticky = () => { - return ( -
- -
- ); -}; - -export default ChatSticky; diff --git a/components/navigation/chatSticky.module.css b/components/navigation/chatSticky.module.css deleted file mode 100644 index 37b42c0ce..000000000 --- a/components/navigation/chatSticky.module.css +++ /dev/null @@ -1,11 +0,0 @@ -.Container { - @apply fixed bottom-[30px] w-full z-10; -} - -.Navigation { - @apply container px-2 xl:px-4 flex items-center justify-between relative transition-all mx-auto h-full left-auto; -} - -.NavigationContainer { - @apply flex flex-auto justify-end; -} diff --git a/components/navigation/footer.js b/components/navigation/footer.js index 474b8e874..1f4273704 100644 --- a/components/navigation/footer.js +++ b/components/navigation/footer.js @@ -182,7 +182,7 @@ const Footer = ({ setIsTelemetryModalVisible }) => {
© {new Date().getFullYear()} Snowflake Inc. + + +
+ {children} +
+ +
+ ); +} diff --git a/components/utilities/Modal.module.css b/components/utilities/Modal.module.css new file mode 100644 index 000000000..47cac1d66 --- /dev/null +++ b/components/utilities/Modal.module.css @@ -0,0 +1,29 @@ +.Shim { + @apply fixed inset-0 z-40; + @apply bg-gray-90 bg-opacity-90; + @apply flex items-center justify-center; +} + +.Modal { + @apply relative; + @apply bg-white sm:rounded-xl; + @apply p-8 md:p-12; + @apply overscroll-none; + @apply h-full sm:max-h-[90vh]; + @apply w-full sm:max-w-4xl; + @apply flex flex-col; + @apply gap-4; +} + +.Header { + @apply flex flex-row w-full items-center z-10; +} + +.Content { + @apply overflow-y-auto; + @apply flex-1; +} + +.Title { + @apply flex-1; +} diff --git a/components/utilities/assistant.js b/components/utilities/assistant.js new file mode 100644 index 000000000..383c6706b --- /dev/null +++ b/components/utilities/assistant.js @@ -0,0 +1,40 @@ +import React, { useState, useCallback, useEffect } from "react"; +import styles from "./assistant.module.css"; + +import Modal from "./Modal"; + +const Assistant = () => { + const [assistantVisible, setAssistantVisible] = useState(false); + + const showAssistant = useCallback(() => { + setAssistantVisible(true); + }, []); + + const hideAssistant = useCallback(() => { + setAssistantVisible(false); + }, []); + + return ( + <> +
+ +
+ + {assistantVisible && ( + + + + )} + + ); +}; + +export default Assistant; diff --git a/components/utilities/kapa.module.css b/components/utilities/assistant.module.css similarity index 82% rename from components/utilities/kapa.module.css rename to components/utilities/assistant.module.css index 63fcc5b19..bf8c8423f 100644 --- a/components/utilities/kapa.module.css +++ b/components/utilities/assistant.module.css @@ -24,6 +24,7 @@ .AskButtonContainer { @apply flex justify-end; + @apply fixed bottom-6 right-6 z-40; } .AskButton { @@ -53,14 +54,13 @@ @apply text-gray-100 !important; } -.Tooltip { - @apply hidden absolute top-20 right-[4.5rem] h-8 px-2 pt-0.5 rounded-md bg-gray-20; +.IframeWrapper { + @apply flex-1; + @apply flex; + @apply -mx-8 -mb-8 sm:-mx-12 sm:-mt-12 sm:-mb-4 sm:rounded-b-xl sm:z-0; } -.Tooltip p { - @apply text-gray-70; -} - -:global(.dark) .Tooltip { - @apply bg-gray-90; +.Iframe { + @apply flex-1; + @apply p-0; } diff --git a/components/utilities/cookieSettingsModal.js b/components/utilities/cookieSettingsModal.js index 25536dfae..fa9432a50 100644 --- a/components/utilities/cookieSettingsModal.js +++ b/components/utilities/cookieSettingsModal.js @@ -3,71 +3,57 @@ import classNames from "classnames"; import content from "../../content/cookie-settings.md"; import styles from "./cookieSettingsModal.module.css"; +import Modal from "./Modal"; +import { useCallback } from "react"; export default function CookieSettingsModal({ setIsTelemetryModalVisible, declineTelemetryAndCloseBanner, allowTelemetryAndCloseBanner, }) { + const closeDialog = useCallback(() => { + setIsTelemetryModalVisible(false); + }, []); + return ( -
-
+
+ + -
- - -
-
+ Accept all + + ); } diff --git a/components/utilities/cookieSettingsModal.module.css b/components/utilities/cookieSettingsModal.module.css index 825ba029a..0bc9feebb 100644 --- a/components/utilities/cookieSettingsModal.module.css +++ b/components/utilities/cookieSettingsModal.module.css @@ -2,6 +2,10 @@ @apply text-gray-90 grid grid-cols-1 gap-4 text-base leading-loose; } +.Content { + @apply overflow-y-auto; +} + .Container h1, .Container h2, .Container h3, diff --git a/components/utilities/kapa.js b/components/utilities/kapa.js deleted file mode 100644 index 31ebafe8e..000000000 --- a/components/utilities/kapa.js +++ /dev/null @@ -1,67 +0,0 @@ -import styles from "./kapa.module.css"; - -const Kapa = () => { - const showTooltip = () => { - let tips = document.getElementsByClassName(styles.Tooltip); - if (tips.length > 0) { - tips[0].style.display = "block"; - } - }; - - const hideTooltip = () => { - let tips = document.getElementsByClassName(styles.Tooltip); - if (tips.length > 0) { - tips[0].style.display = "none"; - } - }; - let kapaWidget = ( -
-
- - {/*
-

Try our new docs assistant!

-
*/} - -
-
- ); - - return kapaWidget; -}; - -export default Kapa; diff --git a/components/utilities/kapaModal.css b/components/utilities/kapaModal.css deleted file mode 100644 index ed2d91488..000000000 --- a/components/utilities/kapaModal.css +++ /dev/null @@ -1,128 +0,0 @@ -.mantine-Modal-overlay { - background-color: rgba(166, 168, 184, 0.6) !important; -} - -.mantine-Paper-root { - @apply bg-white dark:bg-gray-90; -} - -.mantine-Modal-header, -.mantine-Modal-header h3 { - @apply bg-white dark:bg-gray-90 text-gray-90 dark:text-gray-40 border-b-0 font-normal tracking-wide; -} - -.mantine-Modal-header > .mantine-Group-root:first-child .mantine-Image-root { - @apply hidden; -} - -.mantine-Modal-body, -.mantine-Modal-body a, -.mantine-Modal-body .mantine-List-root, -.mantine-Modal-body .mantine-List-item { - @apply bg-white dark:bg-gray-90; - @apply text-gray-90 dark:text-gray-40; -} - -.mantine-Paper-root - > .mantine-Modal-body - > .mantine-Modal-body - > div:first-child - > div:first-child:has(.mantine-Text-root) { - @apply bg-gray-20 dark:bg-gray-80; -} - -.mantine-Paper-root - > .mantine-Modal-body - > .mantine-Modal-body - > div:first-child - > div:first-child - .mantine-Text-root { - @apply text-gray-70 dark:text-gray-50; -} - -.mantine-Group-root button { - @apply text-gray-70; -} - -.mantine-Group-root button:hover { - @apply bg-gray-20 dark:bg-gray-80; -} - -.mantine-Input-input { - @apply bg-white dark:bg-gray-90 border-gray-70 focus:border-orange-70 text-gray-90 dark:text-gray-40; -} - -.mantine-Input-rightSection > .mantine-Group-root > .mantine-ActionIcon-root { - @apply bg-white dark:bg-gray-90 border-none text-orange-70 !important; -} - -.mantine-Input-rightSection - > .mantine-Group-root - > .mantine-ActionIcon-root - svg { - @apply scale-150 hover:scale-[1.6]; -} - -.mantine-Code-root { - @apply bg-transparent border border-gray-40 dark:border-gray-80 rounded-md text-red-70 px-1 mx-1; -} - -.mantine-Grid-root .mantine-Grid-col a { - @apply border-gray-20 dark:border-gray-80 bg-transparent; -} - -.mantine-Grid-root .mantine-Grid-col a:hover { - @apply bg-gray-20 dark:bg-gray-80; -} - -.mantine-Grid-root .mantine-Grid-col div { - @apply text-gray-90 dark:text-gray-40; -} - -.mantine-Grid-root .mantine-Grid-col div.mantine-Tooltip-tooltip { - @apply bg-gray-80 dark:bg-gray-20 text-gray-50 dark:text-gray-70; -} - -.mantine-Popover-dropdown, -.mantine-Popover-arrow { - @apply bg-white dark:bg-gray-90 text-gray-90 dark:text-gray-40; -} - -.mantine-Popover-dropdown .mantine-Button-root { - @apply text-white; -} - -.mantine-Popover-dropdown h5 { - @apply text-gray-90 dark:text-gray-40; -} - -.mantine-Checkbox-input { - @apply bg-gray-20 dark:bg-gray-80 border-gray-70; -} - -.mantine-Checkbox-label { - @apply text-gray-90 dark:text-gray-40; -} - -.mantine-Paper-root - > .mantine-Modal-body - > .mantine-Modal-body - > div:last-child { - @apply text-gray-70; -} - -.mantine-Paper-root - > .mantine-Modal-body - > .mantine-Modal-body - > div:last-child - a { - @apply text-gray-70; -} - -.mantine-Button-icon:has(.tabler-icon-player-stop) { - @apply hidden; -} - -.mantine-Button-root:has(.tabler-icon-player-stop) { - @apply py-0 px-4; -} diff --git a/content/cookie-settings.md b/content/cookie-settings.md index b422adc73..94268f1df 100644 --- a/content/cookie-settings.md +++ b/content/cookie-settings.md @@ -2,8 +2,6 @@ visible: false --- -### Cookie settings - ##### Strictly necessary cookies These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. diff --git a/netlify.toml b/netlify.toml index 287030946..9222f6e4a 100644 --- a/netlify.toml +++ b/netlify.toml @@ -25,7 +25,6 @@ connect-src \ https://px.ads.linkedin.com/ \ https://*.algolia.net/ \ https://*.algolianet.com/ \ - https://kapa-widget-proxy-la7dkmplpq-uc.a.run.app/ \ ; \ default-src 'none' ; \ font-src 'self' ; \ @@ -54,10 +53,6 @@ script-src \ https://connect.facebook.net/ \ https://*.algolia.net/ \ https://*.algolianet.com/ \ - https://widget.kapa.ai/kapa-widget.bundle.js \ - https://www.google.com/recaptcha/api.js \ - https://www.gstatic.com/recaptcha/releases/ \ - https://www.google.com/recaptcha/enterprise.js \ ; \ style-src \ 'self' \ diff --git a/next.config.js b/next.config.js index 525b6f3ab..fb02f707b 100644 --- a/next.config.js +++ b/next.config.js @@ -23,11 +23,6 @@ const CSP_HEADER = [ "https://px.ads.linkedin.com/", // LinkedIn ad pixel "https://*.algolia.net/", // Search "https://*.algolianet.com/", // Search - "https://widget.kapa.ai/kapa-widget.bundle.js", // Kapa.ai - "https://kapa-widget-proxy-la7dkmplpq-uc.a.run.app/", // Kapa.ai - "https://www.google.com/recaptcha/api.js", // Recaptcha for Kapa.ai - "https://www.gstatic.com/recaptcha/releases/", // Recaptchas for Kapa.ai - "https://www.google.com/recaptcha/enterprise.js", // Recaptchas for Kapa.ai ";", "default-src 'none';", "font-src 'self';", @@ -56,11 +51,6 @@ const CSP_HEADER = [ "https://connect.facebook.net/", // Facebook ad pixel "https://*.algolia.net/", // Search "https://*.algolianet.com/", // Search - "https://widget.kapa.ai/kapa-widget.bundle.js", // Kapa.ai - "https://kapa-widget-proxy-la7dkmplpq-uc.a.run.app/", // Kapa.ai - "https://www.google.com/recaptcha/api.js", // Recaptcha for Kapa.ai - "https://www.gstatic.com/recaptcha/releases/", // Recaptchas for Kapa.ai - "https://www.google.com/recaptcha/enterprise.js", // Recaptchas for Kapa.ai ";", "style-src", "'self'", diff --git a/pages/_app.js b/pages/_app.js index 0eb7a1725..924745a84 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -2,7 +2,6 @@ import { debounce } from "lodash"; import "../styles/globals.css"; import "../components/utilities/searchModal.css"; -import "../components/utilities/kapaModal.css"; import "../styles/main.scss"; import "../public/fonts/styles.css"; From cd4b5cb7b26564e4cc9596990fc0d3317039e86c Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Tue, 11 Mar 2025 11:42:37 -0700 Subject: [PATCH 2/8] Adjust FAB CSS --- components/utilities/assistant.module.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/utilities/assistant.module.css b/components/utilities/assistant.module.css index bf8c8423f..e16ba08fc 100644 --- a/components/utilities/assistant.module.css +++ b/components/utilities/assistant.module.css @@ -24,7 +24,7 @@ .AskButtonContainer { @apply flex justify-end; - @apply fixed bottom-6 right-6 z-40; + @apply fixed bottom-4 right-4 sm:bottom-12 sm:right-12 z-40; } .AskButton { From 0e0d1e7bac25e17a4edd59c7d92720768b765bc7 Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Tue, 11 Mar 2025 12:25:29 -0700 Subject: [PATCH 3/8] Set cpu=1 in next.config.js --- next.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/next.config.js b/next.config.js index 525b6f3ab..cae0abb34 100644 --- a/next.config.js +++ b/next.config.js @@ -75,6 +75,11 @@ const CSP_HEADER = [ module.exports = { output: "export", + experimental: { + //workerThreads: false, // Not sure if this does anything when cpu=1 + cpus: 1, + }, + webpack: (configuration) => { // Don't try to polyfill the fs module. configuration.resolve.fallback = { fs: false }; From 8980d1d361f22c9d6c5eee6fbfee5764a9702375 Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Tue, 11 Mar 2025 13:07:11 -0700 Subject: [PATCH 4/8] Try to improve build speed a little using worker threads. --- next.config.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index cae0abb34..f97fcd3c9 100644 --- a/next.config.js +++ b/next.config.js @@ -76,8 +76,9 @@ module.exports = { output: "export", experimental: { - //workerThreads: false, // Not sure if this does anything when cpu=1 - cpus: 1, + workerThreads: true, + cpus: 2, + sharedPool: true, }, webpack: (configuration) => { From d95c4f5630f8f17e933602d8b91710d34a85641d Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Tue, 11 Mar 2025 13:19:28 -0700 Subject: [PATCH 5/8] Make this run on prod only --- next.config.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/next.config.js b/next.config.js index f97fcd3c9..b074155b9 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,15 @@ const IS_DEV = process.env.NODE_ENV === "development"; +const PROD_OPTIMIZATIONS = IS_DEV + ? {} + : { + experimental: { + workerThreads: true, + cpus: 2, + sharedPool: true, + }, + }; + // IMPORTANT: Keep this in sync with netlify.toml // prettier-ignore const CSP_HEADER = [ @@ -75,11 +85,7 @@ const CSP_HEADER = [ module.exports = { output: "export", - experimental: { - workerThreads: true, - cpus: 2, - sharedPool: true, - }, + ...PROD_OPTIMIZATIONS, webpack: (configuration) => { // Don't try to polyfill the fs module. From 59be5d5b34e0a53c40ce502002bc9c0c9eedee8f Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Tue, 11 Mar 2025 13:39:00 -0700 Subject: [PATCH 6/8] CSS tweak. --- components/utilities/assistant.module.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/utilities/assistant.module.css b/components/utilities/assistant.module.css index e16ba08fc..823fd7013 100644 --- a/components/utilities/assistant.module.css +++ b/components/utilities/assistant.module.css @@ -57,7 +57,7 @@ .IframeWrapper { @apply flex-1; @apply flex; - @apply -mx-8 -mb-8 sm:-mx-12 sm:-mt-12 sm:-mb-4 sm:rounded-b-xl sm:z-0; + @apply -mx-8 -mb-8 sm:-mx-12 sm:-mt-12 sm:-mb-4 sm:z-0; } .Iframe { From 9598e9fe6bfd7d329fc5bbc315651db8cf1a8e58 Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Tue, 11 Mar 2025 15:31:57 -0700 Subject: [PATCH 7/8] Make GDPR banner float above AI button --- components/utilities/gdpr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/utilities/gdpr.js b/components/utilities/gdpr.js index 110ab94f1..cdd5c57ee 100644 --- a/components/utilities/gdpr.js +++ b/components/utilities/gdpr.js @@ -84,7 +84,7 @@ export default function GDPRBanner({
From 071b2315de7794fc1efa1a285a9e179fda26f85c Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Tue, 11 Mar 2025 15:36:04 -0700 Subject: [PATCH 8/8] Fix z-indices all around --- components/utilities/assistant.module.css | 2 +- components/utilities/gdpr.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/utilities/assistant.module.css b/components/utilities/assistant.module.css index 823fd7013..fdb5e1fa6 100644 --- a/components/utilities/assistant.module.css +++ b/components/utilities/assistant.module.css @@ -24,7 +24,7 @@ .AskButtonContainer { @apply flex justify-end; - @apply fixed bottom-4 right-4 sm:bottom-12 sm:right-12 z-40; + @apply fixed bottom-4 right-4 sm:bottom-12 sm:right-12 z-20; } .AskButton { diff --git a/components/utilities/gdpr.js b/components/utilities/gdpr.js index cdd5c57ee..110ab94f1 100644 --- a/components/utilities/gdpr.js +++ b/components/utilities/gdpr.js @@ -84,7 +84,7 @@ export default function GDPRBanner({