Skip to content

Commit

Permalink
feat(STATFLO-1093): finish up widget playground
Browse files Browse the repository at this point in the history
  • Loading branch information
Emgem committed Oct 3, 2023
1 parent 2aedba7 commit 5ffbc12
Show file tree
Hide file tree
Showing 27 changed files with 2,783 additions and 93 deletions.
8 changes: 6 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "playground",
"version": "0.1.0",
"private": true,
"homepage": "https://statflo.github.io/widget-sdk",
"dependencies": {
"@faker-js/faker": "^8.0.2",
"@statflo/ui": "^0.0.14",
"@headlessui/react": "^1.7.17",
"@statflo/ui": "^0.0.19",
"@statflo/widget-sdk": "^0.4.8",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.5",
Expand Down Expand Up @@ -33,6 +34,8 @@
},
"scripts": {
"start": "react-scripts start",
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand All @@ -57,6 +60,7 @@
},
"devDependencies": {
"autoprefixer": "^10.4.15",
"gh-pages": "^6.0.0",
"postcss": "^8.4.28",
"tailwindcss": "^3.3.3"
}
Expand Down
40 changes: 40 additions & 0 deletions docs/public/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Single Page Apps for GitHub Pages</title>
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// MIT License
// https://github.com/rafgraph/spa-github-pages
// This script takes the current url and converts the path and query
// string into just a query string, and then redirects the browser
// to the new url with only a query string and hash fragment,
// e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
// https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
// Note: this 404.html file must be at least 512 bytes for it to work
// with Internet Explorer (it is currently > 512 bytes)

// If you're creating a Project Pages site and NOT using a custom domain,
// then set pathSegmentsToKeep to 1 (enterprise users may need to set it to > 1).
// This way the code will only replace the route part of the path, and not
// the real directory in which the app resides, for example:
// https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
// https://username.github.io/repo-name/?/one/two&a=b~and~c=d#qwe
// Otherwise, leave pathSegmentsToKeep as 0.
var pathSegmentsToKeep = 0;

var l = window.location;
l.replace(
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
l.hash
);

</script>
</head>
<body>
</body>
</html>
35 changes: 33 additions & 2 deletions docs/public/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en" class="dark">
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
Expand All @@ -25,7 +25,38 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Widget Playground</title>

<script type="text/javascript">
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
</script>

<script type="text/javascript">
// Single Page Apps for GitHub Pages
// MIT License
// https://github.com/rafgraph/spa-github-pages
// This script checks to see if a redirect is present in the query string,
// converts it back into the correct url and adds it to the
// browser's history using window.history.replaceState(...),
// which won't cause the browser to attempt to load the new url.
// When the single page app is loaded further down in this file,
// the correct url will be waiting in the browser's history for
// the single page app to route accordingly.
(function(l) {
if (l.search[1] === '/' ) {
var decoded = l.search.slice(1).split('&').map(function(s) {
return s.replace(/~and~/g, '&')
}).join('?');
window.history.replaceState(null, null,
l.pathname.slice(0, -1) + decoded + l.hash
);
}
}(window.location))
</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
4 changes: 3 additions & 1 deletion docs/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ import {
Routes,
} from "react-router-dom";
import WidgetManager from "./pages/WidgetManager";
import Settings from "./pages/Settings";

const App = () => {
return (
<ConversationProvider>
<WidgetProvider>
<Router>
<Router basename="/widget-sdk">
<div className="w-screen h-screen overflow-hidden flex">
<Navigation />
<div className="flex-1 block h-screen">
<Routes>
<Route path="/" element={<Navigate to="/conversations" />} />
<Route path="/conversations" element={<Conversations />} />
<Route path="/widget-manager" element={<WidgetManager />} />
<Route path="/settings" element={<Settings />} />
</Routes>
</div>
</div>
Expand Down
33 changes: 33 additions & 0 deletions docs/src/components/Placeholder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Icon } from "@statflo/ui";
import { useNavigate } from "react-router-dom";

type PlaceholderProps = {
location: string;
};

const Placeholder = ({ location }: PlaceholderProps) => {
const navigate = useNavigate();

return (
<div className="w-full p-8 rounded-lg border border-dashed border-blue-200 bg-blue-200/15 text-blue-400 dark:text-blue-200 flex flex-col items-center justify-center text-center">
<p>{location} Widgets will appear here.</p>
<p>
Go to the{" "}
<button
className="text-blue-500 hocus-not-disabled:text-blue-700 dark:text-blue-300 font-semibold dark:hocus-not-disabled:text-blue-400"
onClick={() => navigate("/widget-manager")}
>
Widget Manager{" "}
<Icon
className="inline mb-1"
color="current"
icon="application-setting"
/>
</button>{" "}
to add a new widget.
</p>
</div>
);
};

export default Placeholder;
Loading

0 comments on commit 5ffbc12

Please sign in to comment.