Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Merge pull request #529 from openchatai/docs/update-docs
Browse files Browse the repository at this point in the history
Update the Docs to include the latest api changes.
  • Loading branch information
gharbat authored Feb 15, 2024
2 parents 7d6ec35 + dbf8b08 commit bfc16f9
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 20 deletions.
64 changes: 64 additions & 0 deletions dashboard/components/ui/callout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Callouts (Alerts, Notes, Warning,Danger, Success, Info)
import { cn } from "@/lib/utils";
import { cva } from "class-variance-authority";
import React, { forwardRef } from "react";

import {
AlertCircle,
AlertTriangle,
CheckCircle,
Info,
XCircle,
XOctagon,
} from 'lucide-react'

type CalloutType = "alert" | "note" | "warning" | "danger" | "success" | "info";

type CalloutProps = {
type: CalloutType;
} & React.HTMLAttributes<HTMLDivElement>;

function getIcon(type: CalloutType) {
switch (type) {
case "alert":
return AlertCircle
case "note":
return Info
case "warning":
return AlertTriangle
case "danger":
return XOctagon
case "success":
return CheckCircle
case "info":
return Info
default:
return XCircle
}
}

const alertVariants = cva("rounded-lg p-2", {
variants: {
type: {
alert: "bg-blue-100 border-blue-500 [&>p]:text-blue-700 [&>span]:text-blue-500",
note: "bg-blue-100 border-blue-500 [&>p]:text-blue-700 [&>span]:text-blue-500",
warning: "bg-yellow-100 border-yellow-500 [&>p]:text-yellow-700 [&>span]:text-yellow-500",
danger: "bg-red-100 border-red-500 [&>p]:text-red-700 [&>span]:text-red-500",
success: "bg-green-100 border-green-500 [&>p]:text-green-700 [&>span]:text-green-500",
info: "bg-gray-100 border-gray-500 [&>p]:text-gray-700 [&>span]:text-gray-500",
}
}
});

const Alert = forwardRef<HTMLDivElement, CalloutProps>(({ className, children, type, ...oprops }, ref) => {
const Icon = getIcon(type);
return <div ref={ref} className={cn(alertVariants({ type }), className)} {...oprops}>
<span>
{<Icon className="size-4" />}
</span>
<p className="">
{children}
</p>
</div>
});
Alert.displayName = "Alert";
2 changes: 1 addition & 1 deletion docs/ai-copilots.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Watch this video from Shopify to understand what a Copilot (AKA sidekick) is:
title="YouTube video player"
frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
allowFullScreen
></iframe>
(OpenCopilot is inspired by Shopify's sidekick and is not affiliated with Shopify.)

Expand Down
6 changes: 3 additions & 3 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
{
"group": "Copilot widget",
"pages": [
"widget/embed"
],
"icon": "chat"
"widget/embed",
"widget/styling"
]
},
{
"group": "Managing copilots via API",
Expand Down
52 changes: 36 additions & 16 deletions docs/widget/embed.mdx
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
---
title: "Embedding the copilot"
title: "How to embed the widget"
description: "Learn how to embed the copilot in your app"
icon: "message"
---
the chat widget enables you to interact with the Copilot from your dashboard and see the changes in realtime.
OpenCopilot is a react web app that you can embed in your app.

## How to embed the copilot in your app

there are several ways you can integrate the Copilot Chat widget into your application/webpage
<CardGroup cols={2}>
<Card title="As a JavaScript File" icon="js">
<Card title="As a JavaScript File" href='#using-simple-js-script-recommended' icon="js">
</Card>
<Card title='As a React Component (via npm)' icon='react'>
<Card title='As a React Component (via npm)' href='#as-a-react-component' icon='react'>
</Card>
</CardGroup>

Expand Down Expand Up @@ -116,35 +113,58 @@ function Widget(){
}
```

## Options

<ResponseField name="Options" type="Object">
<Expandable title="properties">
<ResponseField name="initialMessage" type="string">
The message that will be first present when the copilot is initialized
</ResponseField>
<ResponseField name="token" type="string">
Your copilot token
</ResponseField>
<ResponseField name="triggerSelector" type="string">
The selector of the element that will trigger the copilot when clicked
</ResponseField>
<ResponseField name="apiUrl" type="string">
the url of the copilot api.
</ResponseField>
<ResponseField name="headers" type="Object">
An object of headers that will be sent with every request (can be used to authenticate your api requests)
</ResponseField>
<ResponseField name="containerProps" type="Object">
An object of props that will be passed to the container div
</ResponseField>
<ResponseField name="socketUrl" type="string">
The url of the socket url that will be used to send and receive messages
</ResponseField>
</Expandable>
</ResponseField>


## Available options

| Option | Description | type |
| ----------------- | --------------------------------------------------------------------------------------------------------- | ----------------------- |
| `initialMessage` | An array of messages that will be sent to the copilot when it's initialized | `string` |
| `initialMessage` | The message that will be first present when the copilot is initialized | `string` |
| `token` | Your copilot token | `string` |
| `triggerSelector` | The selector of the element that will trigger the copilot when clicked | `string` |
| `apiUrl` | the url of the copilot api. | `string` |
| `headers` | An object of headers that will be sent with every request (can be used to authenticate your api requests) | `Record<string,string>` |
| `containerProps` | An object of props that will be passed to the container div | `Record<string,string>` |
| `socketUrl` | The url of the socket url that will be used to send and receive messages | `string` |

## FAQ

<AccordionGroup>
<Accordion title="I have a style conflict with the widget">
The copilot is styled using
[tailwindcss](https://tailwindcss.com/) and all the classes are prefixed so it should not conflict with your
exising style, however, if so, please feel free to [open an issue on our GitHub repo](https://github.com/openchatai/OpenCopilot/issues/new)
</Accordion>

<Accordion title="The copilot widget is not showing up">
Make sure that the `triggerSelector` is correct and the element exists in
the dom, if that did not work, please [open an issue on our GitHub repo](https://github.com/openchatai/OpenCopilot/issues/new)
the dom,instead you can set `defaultOpen` to `true` to make the copilot open by default.
if that did not work, please [open an issue on our GitHub repo](https://github.com/openchatai/OpenCopilot/issues/new)
</Accordion>

<Accordion title="The copilot widget is so small">
The copilot widget is responsive and it's width is set to 100% by default, you can change that by passing the
The copilot widget is responsive and it's width is set to 100% by default of the container, you can change that by passing the
`containerProps` option and setting the width to whatever you want.
</Accordion>
</AccordionGroup>
</AccordionGroup>
14 changes: 14 additions & 0 deletions docs/widget/styling.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "Styling the widget"
description: "few notes on how to style the widget."
---
The widget is styled using tailwindcss.
so it is hard to overwrite the styles of let's say the basic elements such as buttons, inputs, etc.
but when it comes to placing the widget we provided an easy way to manage this via `containerProps` prop(if you are using the standalone) or option if you are using the pre-built script.

## The Default Widget Container Styles
the widget is fluid by default and it will take the full width of the parent container.

## containerProps
`containerProps` is an object that you can pass to the widget to style the container of the widget.
it can accept any valid html attributes such as `className`, `id`, `style`, etc.

0 comments on commit bfc16f9

Please sign in to comment.