Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
99 lines (85 sloc) 4.36 KB
import React, { Fragment, useEffect, useState } from 'react';
import './Widget.css';
import { MediumContent, LargeContent, useTextKitWidget, WidgetViewSize } from '@statflo/textkit-widget-sdk-react'
const Widget = () => {
const [hasMounted, setHasMounted] = useState(false);
const [theme, setTheme] = useState(false);
useEffect(() => {
}, []);
const { state, setHeader, setSize } = hasMounted && useTextKitWidget();
const [headerReplaced, setHeaderReplaced] = useState<boolean>(false);
useEffect(() => {
if (state && && theme !== {'--background',;'--background--highlight',;'--primary',;'--primary-text',;'--primary--active',;'--primary--hover',;'--text',;
}, [state]);
const swapHeader = () => {
if (headerReplaced) {
setHeader('Your Standard Widget');
} else {
setHeader('My New Header');
const closeWidget = () => {
return (
<div className='widget-container transition-opacity'>
<h1 className='widget-title'>
This is a Standard Widget.
<p className='widget-copy'></p>
<a href='' rel='noreferrer' target="_blank" className='widget-link widget-link__doc'>Read our docs to learn more.</a>
<p className='widget-more'>Click show more to enlarge this widget</p>
<div className='widget-container' style={{ height: state ? state?.maxHeight : 100 }}>
<div className='widget-flex-container'>
<h1 className='widget-title'>
This is the large view of a Standard Widget
<div className='widget-flex-container'>
{state && state.context && (
<><div className="widget-spacer">
<div className="widget-spacer">
<div className="widget-spacer">
<div className="widget-spacer">
<div className='widget-action-bar'>
<button onClick={closeWidget} className='widget-cancel'>Cancel</button>
<button onClick={swapHeader} className='widget-button widget-button-wide'>Change Header</button>
export default Widget;