Skip to content

Commit 9bfefa7

Browse files
add canny.io (CodingCatDev#520)
* add canny * update button --------- Co-authored-by: Alex Patterson <alex.patterson@fusionauth.io>
1 parent 72780fc commit 9bfefa7

File tree

6 files changed

+92
-1
lines changed

6 files changed

+92
-1
lines changed

apps/codingcatdev/src/lib/components/global/icons/ThemeToggle.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { onMount } from 'svelte/types/runtime/internal/lifecycle';
2+
import { onMount } from 'svelte';
33
44
enum themeType {
55
dark = 'dark',
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<script lang="ts">
2+
import { afterUpdate, onDestroy, onMount } from 'svelte';
3+
import { modeCurrent } from '@skeletonlabs/skeleton';
4+
import type { Unsubscriber } from 'svelte/store';
5+
6+
let container: HTMLDivElement;
7+
let modeUnsubscribe: Unsubscriber;
8+
onMount(async () => {
9+
modeUnsubscribe = modeCurrent.subscribe((m) => {
10+
container.style.backgroundColor = m ? 'white' : '#121212';
11+
});
12+
13+
// @ts-ignore
14+
!(function (w, d, i, s) {
15+
function l() {
16+
if (!d.getElementById(i)) {
17+
var f = d.getElementsByTagName(s)[0],
18+
e = d.createElement(s);
19+
// @ts-ignore
20+
(e.type = 'text/javascript'),
21+
// @ts-ignore
22+
(e.async = !0),
23+
// @ts-ignore
24+
(e.src = 'https://canny.io/sdk.js'),
25+
// @ts-ignore
26+
f.parentNode.insertBefore(e, f);
27+
}
28+
}
29+
// @ts-ignore
30+
if ('function' != typeof w.Canny) {
31+
var c = function () {
32+
// @ts-ignore
33+
c.q.push(arguments);
34+
};
35+
// @ts-ignore
36+
(c.q = []),
37+
// @ts-ignore
38+
(w.Canny = c),
39+
'complete' === d.readyState
40+
? l()
41+
: // @ts-ignore
42+
w.attachEvent
43+
? // @ts-ignore
44+
w.attachEvent('onload', l)
45+
: w.addEventListener('load', l, !1);
46+
}
47+
})(window, document, 'canny-jssdk', 'script');
48+
});
49+
afterUpdate(() => {
50+
// @ts-ignore
51+
if ('function' === typeof window.Canny) {
52+
// @ts-ignore
53+
Canny('render', {
54+
boardToken: '185218a5-57c7-2354-9eba-30105a9da7bd',
55+
basePath: '/feedback', // See step 2
56+
ssoToken: null, // See step 3,
57+
theme: $modeCurrent ? 'light' : 'dark'
58+
});
59+
}
60+
});
61+
onDestroy(() => {
62+
if (modeUnsubscribe) modeUnsubscribe();
63+
});
64+
</script>
65+
66+
<div class="flex justify-center h-full w-full" bind:this={container}>
67+
<div class="w-full h-full max-w-5xl p-8" data-canny></div>
68+
</div>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script lang="ts">
2+
import { Icon } from '@steeze-ui/svelte-icon';
3+
import { ChatBubbleLeft } from '@steeze-ui/heroicons';
4+
</script>
5+
6+
<div class="fixed bottom-8 right-8 z-50">
7+
<a href="/feedback" class="btn variant-filled-primary flex flex-col">
8+
<span class="hidden md:block">Feedback</span>
9+
<div><Icon src={ChatBubbleLeft} theme="solid" class="w-8 md:w-12" /></div></a
10+
>
11+
</div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
import Canny from '../Canny.svelte';
3+
</script>
4+
5+
<Canny />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
import Canny from '../../Canny.svelte';
3+
</script>
4+
5+
<Canny />

apps/codingcatdev/src/routes/+layout.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import CcdFooter from './(layout-partials)/CcdFooter.svelte';
3131
import type { Author, Content } from '$lib/types';
3232
import { analyticsLogPageView } from '$lib/client/firebase';
33+
import CannyButton from './(feedback)/CannyButton.svelte';
3334
3435
// Scroll heading into view
3536
function scrollHeadingIntoView(): void {
@@ -165,6 +166,7 @@
165166
<CcdDrawer />
166167
<Modal />
167168
<Toast />
169+
<CannyButton />
168170

169171
{#if data?.preview}
170172
<div

0 commit comments

Comments
 (0)