import { whisper } from "@oliveai/ldk"
import {
NewWhisper,
OpenDirection,
Size,
UpdateWhisper,
Whisper,
WhisperComponentType
} from "@oliveai/ldk/dist/whisper"
const collapseBoxExampleConfig = ((collapseBoxLabel: string, isOpen: boolean): NewWhisper | UpdateWhisper => {
return {
label: "Collapse Box Example",
components: [
{
type: WhisperComponentType.CollapseBox,
label: collapseBoxLabel,
open: isOpen,
previewHeight: Size.Small,
openDirection: OpenDirection.Bottom,
onClick: async (error: Error, params: boolean, whisper: Whisper) => {
if ( error ) {
console.debug(error);
}
console.log(`CollapseBox params: ${params}`);
if (params) {
whisper.update(collapseBoxExampleConfig("Hide Collapse Box Content", params) as UpdateWhisper);
} else {
whisper.update(collapseBoxExampleConfig("Show Collapse Box Content", params) as UpdateWhisper);
}
},
children: [
{
type: WhisperComponentType.Markdown,
body: "Collapse Box Contents 1"
},
{
type: WhisperComponentType.Markdown,
body: "Collapse Box Contents 2"
},
{
type: WhisperComponentType.Markdown,
body: "Collapse Box Contents 3"
},
{
type: WhisperComponentType.Markdown,
body: "Collapse Box Contents 4"
},
{
type: WhisperComponentType.Markdown,
body: "Collapse Box Contents 5"
},
],
},
]
}
});
const collapseBoxExample = (async () => {
await whisper.create(collapseBoxExampleConfig("Hide Collapse Box Content", true) as NewWhisper);
})
collapseBoxExample();