Skip to content
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

feat: vica integration #982

Merged
merged 5 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions packages/components/src/interfaces/internal/Vica.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { ScriptComponentType } from "~/types"

// NOTE: not all props will be used even if we passed them in
// as we will override some of them with Isomer's configuration e.g. font-family
// Nevertheless, keeping them here for reference
interface VicaWidgetProps {
Comment on lines +3 to +6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abit confused - how will we override? i'm assuming the compiled css will have font-family but how will vica pick it up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can override directly in

<div
id="webchat"
{...props}
app-font-family="Inter, system-ui, sans-serif"
// NOTE: Clarifying with VICA regarding color scheme
// Once confirmed, will override with site's color scheme for consistency
/>

once VICA got back to me, we also ideally want to use the site's color to prefill this. For now the only props we know we will override what's passed in is font family

// UI Theme
"app-id": string
"app-name": string
"app-icon"?: string
"app-subtitle"?: string // configuration disabled (according to docs)
"app-welcome-message"?: string
"app-font-family"?: string
"app-base-font-size"?: string
// General Color
"app-color"?: string
"app-foreground-color1"?: string
"app-background-color2"?: string
"app-foreground-color2"?: string
"app-canvas-background-color"?: string
"app-button-border-color"?: string
"app-quick-reply-button-background-color"?: string
// Autocomplete
"app-enable-auto-complete"?: boolean
"app-auto-complete-background-color"?: string
"app-auto-complete-foreground-color"?: string
"app-auto-complete-hover-color"?: string
"app-auto-complete-divider-color"?: string
// Recommendations
"app-enable-recommendations"?: boolean
"app-recommendations-background-color"?: string
"app-recommendations-foreground-color"?: string
"app-recommendations-hover-color"?: string
// UI Behaviours
"app-orchestrator-timeout"?: number
"app-alternate-copy-vault"?: string
"app-auto-launch"?: boolean
"app-launched-animation-iteration"?: number
"app-disable-csat"?: boolean
// Chatbot Behaviours
"app-quick-launch-event"?: string
"app-quick-launch-event-force-trigger"?: boolean
"app-bot-response-trigger-event"?: string
"app-environment-override"?: string
"app-translation-languages"?: string
"app-enable-hide-translation"?: boolean
}

export interface VicaProps extends VicaWidgetProps {
ScriptComponent?: ScriptComponentType
}
1 change: 1 addition & 0 deletions packages/components/src/interfaces/internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type { SiderailProps } from "./Siderail"
export type { SkipToContentProps } from "./SkipToContent"
export type { TableOfContentsProps } from "./TableOfContents"
export type { WogaaProps } from "./Wogaa"
export type { VicaProps } from "./Vica"
export type {
GoogleTagManagerHeaderScriptProps,
GoogleTagManagerHeaderProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { VicaProps } from "~/interfaces"

export const VicaStylesheet = () => {
return (
<>
<link
href="https://webchat.vica.gov.sg/static/css/chat.css"
referrerPolicy="origin"
rel="stylesheet"
/>
</>
)
}

export const VicaWidget = ({
ScriptComponent = "script",
...props
}: VicaProps) => {
return (
<>
<ScriptComponent
async
type="text/javascript"
src="https://webchat.vica.gov.sg/static/js/chat.js"
referrerPolicy="origin"
// 'lazyOnload' is recommended by Next.js for chat widgets
// Reference: https://nextjs.org/docs/pages/api-reference/components/script#lazyonload
strategy="lazyOnload"
/>
<div
id="webchat"
{...props}
app-font-family="Inter, system-ui, sans-serif"
// NOTE: Clarifying with VICA regarding color scheme
// Once confirmed, will override with site's color scheme for consistency
/>
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Vica"
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export { SkipToContent } from "./SkipToContent"
export { default as TableOfContents } from "./TableOfContents"
export { default as UnsupportedBrowserBanner } from "./UnsupportedBrowserBanner"
export { Wogaa } from "./Wogaa"
export { VicaStylesheet, VicaWidget } from "./Vica"
export { BackToTopLink } from "./BackToTopLink"
export {
GoogleTagManagerHeader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
Notification,
SkipToContent,
UnsupportedBrowserBanner,
VicaStylesheet,
VicaWidget,
Wogaa,
} from "../../components/internal"
import { SKIP_TO_CONTENT_ANCHOR_ID } from "../../constants"
Expand Down Expand Up @@ -48,6 +50,8 @@ export const Skeleton = ({

{!isStaging && <DatadogRum />}

{site.vica && <VicaStylesheet />}

<header>
<SkipToContent LinkComponent={LinkComponent} />

Expand Down Expand Up @@ -92,13 +96,15 @@ export const Skeleton = ({
{...site.footerItems}
/>

{/* needs to be the last element in the body */}
{shouldIncludeGTM && (
<GoogleTagManagerBody
siteGtmId={site.siteGtmId}
isomerGtmId={site.isomerGtmId}
/>
)}

{/* Ensures that the webchat widget only loads after the page has loaded */}
{site.vica && <VicaWidget {...site.vica} />}
</>
)
}
3 changes: 2 additions & 1 deletion packages/components/src/types/site.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IsomerSitemap } from "./sitemap"
import type { NavbarProps, NotificationProps } from "~/interfaces"
import type { NavbarProps, NotificationProps, VicaProps } from "~/interfaces"
import type { SiteConfigFooterProps } from "~/interfaces/internal/Footer"

export interface IsomerGeneratedSiteProps {
Expand All @@ -26,6 +26,7 @@ export interface IsomerSiteConfigProps {
search: NavbarProps["search"]
notification?: Omit<NotificationProps, "LinkComponent" | "site">
siteGtmId?: string
vica?: VicaProps
}

export type IsomerSiteProps = IsomerGeneratedSiteProps &
Expand Down
Loading