@squeletteapp/widget 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ declare let SqueletteWidgetButton: typeof HTMLElement | null;
2
+ export { SqueletteWidgetButton };
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SqueletteWidgetButton = void 0;
4
+ const svgIcon = `
5
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-gift-icon lucide-gift"><rect x="3" y="8" width="18" height="4" rx="1"/><path d="M12 8v13"/><path d="M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7"/><path d="M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5"/></svg>
6
+ `;
7
+ // Define the class only in browser environment
8
+ let SqueletteWidgetButton = null;
9
+ exports.SqueletteWidgetButton = SqueletteWidgetButton;
10
+ if (typeof window !== "undefined" && typeof HTMLElement !== "undefined") {
11
+ exports.SqueletteWidgetButton = SqueletteWidgetButton = class extends HTMLElement {
12
+ constructor() {
13
+ super();
14
+ this.isOpen = false;
15
+ this.attachShadow({ mode: "open" });
16
+ }
17
+ connectedCallback() {
18
+ this.render();
19
+ this.setupEventListeners();
20
+ }
21
+ disconnectedCallback() {
22
+ // Cleanup if needed
23
+ }
24
+ static get observedAttributes() {
25
+ return ["data-open"];
26
+ }
27
+ attributeChangedCallback(name, oldValue, newValue) {
28
+ if (name === "data-open") {
29
+ this.isOpen = newValue === "true";
30
+ this.updateButtonText();
31
+ }
32
+ }
33
+ setToggleHandler(handler) {
34
+ this.onToggle = handler;
35
+ }
36
+ toggle() {
37
+ this.isOpen = !this.isOpen;
38
+ this.setAttribute("data-open", this.isOpen.toString());
39
+ this.updateButtonText();
40
+ this.onToggle?.(this.isOpen);
41
+ }
42
+ render() {
43
+ if (!this.shadowRoot)
44
+ return;
45
+ // Create style element
46
+ const style = document.createElement("style");
47
+ style.textContent = `
48
+ @keyframes slideInFromBottom {
49
+ from {
50
+ transform: translateY(100px);
51
+ opacity: 0;
52
+ }
53
+ to {
54
+ transform: translateY(0);
55
+ opacity: 1;
56
+ }
57
+ }
58
+
59
+ :host {
60
+ position: fixed;
61
+ bottom: 20px;
62
+ right: 20px;
63
+ z-index: 9998;
64
+ animation: slideInFromBottom 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
65
+ }
66
+
67
+ .widget-button {
68
+ border-radius: 9999px;
69
+ height: 36px;
70
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
71
+ border: 1px solid #e5e7eb;
72
+ font-size: 14px;
73
+ display: flex;
74
+ align-items: center;
75
+ background-color: #1f2937;
76
+ color: white;
77
+ justify-content: center;
78
+ transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
79
+ padding-left: 12px;
80
+ padding-right: 12px;
81
+ gap: 4px;
82
+ font-weight: 500;
83
+ cursor: pointer;
84
+ font-family: system-ui, -apple-system, sans-serif;
85
+ }
86
+
87
+ .widget-button:hover {
88
+ background-color: #374151;
89
+ transform: scale(1.05);
90
+ box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.15);
91
+ }
92
+
93
+ .widget-button:active {
94
+ transform: scale(0.98);
95
+ }
96
+
97
+ .widget-button-icon {
98
+ display: inline-flex;
99
+ align-items: center;
100
+ width: 16px;
101
+ height: 16px;
102
+ flex-shrink: 0;
103
+ }
104
+
105
+ .widget-button-text {
106
+ display: inline-flex;
107
+ align-items: center;
108
+ transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
109
+ overflow: hidden;
110
+ white-space: nowrap;
111
+ max-width: 288px;
112
+ }
113
+ `;
114
+ // Create button element
115
+ const button = document.createElement("button");
116
+ button.className = "widget-button";
117
+ button.setAttribute("aria-label", "Toggle feedback widget");
118
+ const iconDiv = document.createElement("div");
119
+ iconDiv.className = "widget-button-icon";
120
+ iconDiv.innerHTML = svgIcon;
121
+ const span = document.createElement("span");
122
+ span.className = "widget-button-text";
123
+ span.textContent = "What's new ?";
124
+ button.appendChild(iconDiv);
125
+ button.appendChild(span);
126
+ this.shadowRoot.appendChild(style);
127
+ this.shadowRoot.appendChild(button);
128
+ }
129
+ setupEventListeners() {
130
+ const button = this.shadowRoot?.querySelector(".widget-button");
131
+ if (button) {
132
+ button.addEventListener("click", () => this.toggle());
133
+ }
134
+ }
135
+ updateButtonText() {
136
+ const span = this.shadowRoot?.querySelector(".widget-button-text");
137
+ const iconDiv = this.shadowRoot?.querySelector(".widget-button-icon");
138
+ if (span && iconDiv) {
139
+ if (this.isOpen) {
140
+ span.textContent = "✕";
141
+ iconDiv.style.display = "none";
142
+ }
143
+ else {
144
+ span.textContent = "What's new ?";
145
+ iconDiv.style.display = "inline-block";
146
+ }
147
+ }
148
+ }
149
+ };
150
+ }
151
+ // Register the custom element only in browser environment
152
+ if (typeof window !== "undefined" &&
153
+ typeof customElements !== "undefined" &&
154
+ SqueletteWidgetButton) {
155
+ if (!customElements.get("squelette-widget-button")) {
156
+ customElements.define("squelette-widget-button", SqueletteWidgetButton);
157
+ }
158
+ }
@@ -0,0 +1,26 @@
1
+ interface WidgetOptions {
2
+ url: string;
3
+ buttonSelector: string;
4
+ position?: 'top' | 'bottom' | 'left' | 'right';
5
+ onLoad?: () => void;
6
+ onOpenChange?: (isOpen: boolean) => void;
7
+ }
8
+ export declare function createRoadmapWidget(workspaceSlug: string, boardSlug: string, options: Omit<WidgetOptions, 'url'> & {
9
+ theme?: string;
10
+ }): {
11
+ destroy: () => void;
12
+ };
13
+ export declare function createChangelogWidget(workspaceSlug: string, options: Omit<WidgetOptions, 'url'> & {
14
+ theme?: string;
15
+ }): {
16
+ destroy: () => void;
17
+ };
18
+ export declare function createFeedbackWidget(workspaceSlug: string, boardSlug: string | undefined, options: Omit<WidgetOptions, 'url'> & {
19
+ theme?: string;
20
+ }): {
21
+ destroy: () => void;
22
+ };
23
+ export declare function createWidget(options: WidgetOptions): {
24
+ destroy: () => void;
25
+ };
26
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRoadmapWidget = createRoadmapWidget;
4
+ exports.createChangelogWidget = createChangelogWidget;
5
+ exports.createFeedbackWidget = createFeedbackWidget;
6
+ exports.createWidget = createWidget;
7
+ // For now, the production one
8
+ const baseUrl = 'https://squelette.app';
9
+ function createRoadmapWidget(workspaceSlug, boardSlug, options) {
10
+ const params = new URLSearchParams({ board: boardSlug });
11
+ if (options.theme)
12
+ params.set('theme', options.theme);
13
+ const url = `${baseUrl}/widget/${workspaceSlug}/roadmap?${params.toString()}`;
14
+ const { theme: _, ...widgetOptions } = options;
15
+ return createWidget({ ...widgetOptions, url });
16
+ }
17
+ function createChangelogWidget(workspaceSlug, options) {
18
+ const params = new URLSearchParams();
19
+ if (options.theme)
20
+ params.set('theme', options.theme);
21
+ const url = `${baseUrl}/widget/${workspaceSlug}/changelog${params.toString() ? `?${params.toString()}` : ''}`;
22
+ const { theme: _, ...widgetOptions } = options;
23
+ return createWidget({ ...widgetOptions, url });
24
+ }
25
+ function createFeedbackWidget(workspaceSlug, boardSlug, options) {
26
+ const params = new URLSearchParams();
27
+ if (boardSlug)
28
+ params.set('board', boardSlug);
29
+ if (options.theme)
30
+ params.set('theme', options.theme);
31
+ const url = `${baseUrl}/widget/${workspaceSlug}/feedback${params.toString() ? `?${params.toString()}` : ''}`;
32
+ const { theme: _, ...widgetOptions } = options;
33
+ return createWidget({ ...widgetOptions, url });
34
+ }
35
+ function createWidget(options) {
36
+ const { url, buttonSelector, position = 'top', onLoad, onOpenChange, } = options;
37
+ // Store initial URL to reset to when closing
38
+ const initialUrl = url;
39
+ // Create iframe element (initially hidden but preloaded)
40
+ const iframe = document.createElement('iframe');
41
+ iframe.src = url;
42
+ iframe.loading = 'eager';
43
+ // Function to update iframe dimensions based on URL
44
+ const updateIframeDimensions = (currentUrl) => {
45
+ const urlPath = new URL(currentUrl).pathname;
46
+ const isFeedback = urlPath.endsWith('/feedback');
47
+ const isChangelog = urlPath.endsWith('/changelog');
48
+ const isRoadmap = urlPath.endsWith('/roadmap');
49
+ const width = '400px';
50
+ let height = '540px';
51
+ switch (true) {
52
+ case isFeedback:
53
+ height = '250px';
54
+ break;
55
+ case isChangelog:
56
+ height = '500px';
57
+ break;
58
+ case isRoadmap:
59
+ height = '400px';
60
+ break;
61
+ default:
62
+ height = '540px';
63
+ break;
64
+ }
65
+ iframe.style.width = width;
66
+ iframe.style.height = height;
67
+ };
68
+ // Initial dimensions
69
+ updateIframeDimensions(url);
70
+ // Get user-provided button element
71
+ const button = document.querySelector(buttonSelector);
72
+ if (!button) {
73
+ console.error(`Button element not found with selector: ${buttonSelector}`);
74
+ return { destroy: () => { } };
75
+ }
76
+ // Position calculation helper function
77
+ const calculatePosition = (buttonRect, iframeWidth, iframeHeight, preferredPosition) => {
78
+ const viewport = {
79
+ width: window.innerWidth,
80
+ height: window.innerHeight,
81
+ };
82
+ const margin = 12; // Gap between button and iframe
83
+ let left;
84
+ let top;
85
+ switch (preferredPosition) {
86
+ case 'right':
87
+ left = buttonRect.right + margin;
88
+ top = buttonRect.top;
89
+ break;
90
+ case 'left':
91
+ left = buttonRect.left - iframeWidth - margin;
92
+ top = buttonRect.top;
93
+ break;
94
+ case 'top':
95
+ left = buttonRect.left - (iframeWidth - buttonRect.width) / 2;
96
+ top = buttonRect.top - iframeHeight - margin;
97
+ break;
98
+ case 'bottom':
99
+ left = buttonRect.left - (iframeWidth - buttonRect.width) / 2;
100
+ top = buttonRect.bottom + margin;
101
+ break;
102
+ default:
103
+ left = buttonRect.left - (iframeWidth - buttonRect.width) / 2;
104
+ top = buttonRect.top - iframeHeight - margin;
105
+ }
106
+ // Ensure iframe stays within viewport bounds
107
+ left = Math.max(10, Math.min(left, viewport.width - iframeWidth - 10));
108
+ top = Math.max(10, Math.min(top, viewport.height - iframeHeight - 10));
109
+ return { left, top };
110
+ };
111
+ // Function to update iframe position based on button position
112
+ const updateIframePosition = () => {
113
+ if (!button)
114
+ return;
115
+ const buttonRect = button.getBoundingClientRect();
116
+ const iframeWidth = Number.parseInt(iframe.style.width || '400px', 10);
117
+ const iframeHeight = Number.parseInt(iframe.style.height || '540px', 10);
118
+ const pos = calculatePosition(buttonRect, iframeWidth, iframeHeight, position);
119
+ iframe.style.left = `${pos.left}px`;
120
+ iframe.style.top = `${pos.top}px`;
121
+ iframe.style.bottom = 'auto';
122
+ iframe.style.right = 'auto';
123
+ };
124
+ iframe.style.cssText = `
125
+ position: fixed;
126
+ width: ${iframe.style.width || '400px'};
127
+ height: ${iframe.style.height || '540px'};
128
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
129
+ border-radius: 16px;
130
+ z-index: 9999;
131
+ background: transparent;
132
+ opacity: 0;
133
+ transform: translateY(20px);
134
+ transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
135
+ pointer-events: none;
136
+ border: none;
137
+ box-sizing: border-box;
138
+ `;
139
+ // Update position on scroll
140
+ window.addEventListener('scroll', updateIframePosition);
141
+ window.addEventListener('resize', updateIframePosition);
142
+ // Initial position update
143
+ updateIframePosition();
144
+ // Listen for navigation changes and close requests inside iframe
145
+ window.addEventListener('message', (event) => {
146
+ if (event.source === iframe.contentWindow) {
147
+ if (event.data?.type === 'navigation') {
148
+ updateIframeDimensions(event.data.url);
149
+ updateIframePosition(); // Update position when dimensions change
150
+ }
151
+ else if (event.data?.type === 'close-iframe' && isIframeVisible) {
152
+ // Close the iframe when requested
153
+ // Reset iframe URL to initial URL before closing
154
+ iframe.src = initialUrl;
155
+ toggleIframe();
156
+ }
157
+ }
158
+ });
159
+ // Track iframe visibility state
160
+ let isIframeVisible = false;
161
+ // Toggle iframe visibility
162
+ const toggleIframe = () => {
163
+ isIframeVisible = !isIframeVisible;
164
+ if (isIframeVisible) {
165
+ iframe.style.pointerEvents = 'auto';
166
+ iframe.style.opacity = '1';
167
+ iframe.style.transform = 'translateY(0)';
168
+ }
169
+ else {
170
+ iframe.style.pointerEvents = 'none';
171
+ iframe.style.opacity = '0';
172
+ iframe.style.transform = 'translateY(20px)';
173
+ // Reset iframe URL to initial URL when closing
174
+ iframe.src = initialUrl;
175
+ }
176
+ if (onOpenChange) {
177
+ onOpenChange(isIframeVisible);
178
+ }
179
+ };
180
+ // Set up button click handler
181
+ button.addEventListener('click', toggleIframe);
182
+ // Close iframe on click outside
183
+ const handleClickOutside = (event) => {
184
+ const target = event.target;
185
+ if (isIframeVisible &&
186
+ !iframe.contains(target) &&
187
+ !button.contains(target)) {
188
+ toggleIframe();
189
+ }
190
+ };
191
+ document.addEventListener('click', handleClickOutside);
192
+ // Call onLoad callback when iframe is loaded
193
+ iframe.addEventListener('load', () => {
194
+ if (onLoad) {
195
+ onLoad();
196
+ }
197
+ });
198
+ // Check if iframe with same button already exists and remove it
199
+ const existingIframe = document.querySelector(`iframe[data-widget-button="${buttonSelector}"]`);
200
+ if (existingIframe) {
201
+ existingIframe.remove();
202
+ }
203
+ // Mark iframe with button selector for cleanup
204
+ iframe.setAttribute('data-widget-button', buttonSelector);
205
+ // Append iframe to body
206
+ document.body.appendChild(iframe);
207
+ // Return cleanup function
208
+ return {
209
+ destroy: () => {
210
+ // Send onOpenChange(false) if widget is currently open
211
+ if (isIframeVisible && onOpenChange) {
212
+ onOpenChange(false);
213
+ }
214
+ // Remove event listeners
215
+ window.removeEventListener('scroll', updateIframePosition);
216
+ window.removeEventListener('resize', updateIframePosition);
217
+ button.removeEventListener('click', toggleIframe);
218
+ document.removeEventListener('click', handleClickOutside);
219
+ iframe.removeEventListener('load', () => {
220
+ if (onLoad) {
221
+ onLoad();
222
+ }
223
+ });
224
+ // Remove iframe from DOM
225
+ if (iframe.parentNode) {
226
+ iframe.parentNode.removeChild(iframe);
227
+ }
228
+ },
229
+ };
230
+ }
@@ -0,0 +1,567 @@
1
+ *, ::before, ::after {
2
+ --tw-border-spacing-x: 0;
3
+ --tw-border-spacing-y: 0;
4
+ --tw-translate-x: 0;
5
+ --tw-translate-y: 0;
6
+ --tw-rotate: 0;
7
+ --tw-skew-x: 0;
8
+ --tw-skew-y: 0;
9
+ --tw-scale-x: 1;
10
+ --tw-scale-y: 1;
11
+ --tw-pan-x: ;
12
+ --tw-pan-y: ;
13
+ --tw-pinch-zoom: ;
14
+ --tw-scroll-snap-strictness: proximity;
15
+ --tw-gradient-from-position: ;
16
+ --tw-gradient-via-position: ;
17
+ --tw-gradient-to-position: ;
18
+ --tw-ordinal: ;
19
+ --tw-slashed-zero: ;
20
+ --tw-numeric-figure: ;
21
+ --tw-numeric-spacing: ;
22
+ --tw-numeric-fraction: ;
23
+ --tw-ring-inset: ;
24
+ --tw-ring-offset-width: 0px;
25
+ --tw-ring-offset-color: #fff;
26
+ --tw-ring-color: rgb(59 130 246 / 0.5);
27
+ --tw-ring-offset-shadow: 0 0 #0000;
28
+ --tw-ring-shadow: 0 0 #0000;
29
+ --tw-shadow: 0 0 #0000;
30
+ --tw-shadow-colored: 0 0 #0000;
31
+ --tw-blur: ;
32
+ --tw-brightness: ;
33
+ --tw-contrast: ;
34
+ --tw-grayscale: ;
35
+ --tw-hue-rotate: ;
36
+ --tw-invert: ;
37
+ --tw-saturate: ;
38
+ --tw-sepia: ;
39
+ --tw-drop-shadow: ;
40
+ --tw-backdrop-blur: ;
41
+ --tw-backdrop-brightness: ;
42
+ --tw-backdrop-contrast: ;
43
+ --tw-backdrop-grayscale: ;
44
+ --tw-backdrop-hue-rotate: ;
45
+ --tw-backdrop-invert: ;
46
+ --tw-backdrop-opacity: ;
47
+ --tw-backdrop-saturate: ;
48
+ --tw-backdrop-sepia: ;
49
+ --tw-contain-size: ;
50
+ --tw-contain-layout: ;
51
+ --tw-contain-paint: ;
52
+ --tw-contain-style: ;
53
+ }
54
+
55
+ ::backdrop {
56
+ --tw-border-spacing-x: 0;
57
+ --tw-border-spacing-y: 0;
58
+ --tw-translate-x: 0;
59
+ --tw-translate-y: 0;
60
+ --tw-rotate: 0;
61
+ --tw-skew-x: 0;
62
+ --tw-skew-y: 0;
63
+ --tw-scale-x: 1;
64
+ --tw-scale-y: 1;
65
+ --tw-pan-x: ;
66
+ --tw-pan-y: ;
67
+ --tw-pinch-zoom: ;
68
+ --tw-scroll-snap-strictness: proximity;
69
+ --tw-gradient-from-position: ;
70
+ --tw-gradient-via-position: ;
71
+ --tw-gradient-to-position: ;
72
+ --tw-ordinal: ;
73
+ --tw-slashed-zero: ;
74
+ --tw-numeric-figure: ;
75
+ --tw-numeric-spacing: ;
76
+ --tw-numeric-fraction: ;
77
+ --tw-ring-inset: ;
78
+ --tw-ring-offset-width: 0px;
79
+ --tw-ring-offset-color: #fff;
80
+ --tw-ring-color: rgb(59 130 246 / 0.5);
81
+ --tw-ring-offset-shadow: 0 0 #0000;
82
+ --tw-ring-shadow: 0 0 #0000;
83
+ --tw-shadow: 0 0 #0000;
84
+ --tw-shadow-colored: 0 0 #0000;
85
+ --tw-blur: ;
86
+ --tw-brightness: ;
87
+ --tw-contrast: ;
88
+ --tw-grayscale: ;
89
+ --tw-hue-rotate: ;
90
+ --tw-invert: ;
91
+ --tw-saturate: ;
92
+ --tw-sepia: ;
93
+ --tw-drop-shadow: ;
94
+ --tw-backdrop-blur: ;
95
+ --tw-backdrop-brightness: ;
96
+ --tw-backdrop-contrast: ;
97
+ --tw-backdrop-grayscale: ;
98
+ --tw-backdrop-hue-rotate: ;
99
+ --tw-backdrop-invert: ;
100
+ --tw-backdrop-opacity: ;
101
+ --tw-backdrop-saturate: ;
102
+ --tw-backdrop-sepia: ;
103
+ --tw-contain-size: ;
104
+ --tw-contain-layout: ;
105
+ --tw-contain-paint: ;
106
+ --tw-contain-style: ;
107
+ }/*
108
+ ! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com
109
+ *//*
110
+ 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
111
+ 2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
112
+ */
113
+
114
+ *,
115
+ ::before,
116
+ ::after {
117
+ box-sizing: border-box; /* 1 */
118
+ border-width: 0; /* 2 */
119
+ border-style: solid; /* 2 */
120
+ border-color: #e5e7eb; /* 2 */
121
+ }
122
+
123
+ ::before,
124
+ ::after {
125
+ --tw-content: '';
126
+ }
127
+
128
+ /*
129
+ 1. Use a consistent sensible line-height in all browsers.
130
+ 2. Prevent adjustments of font size after orientation changes in iOS.
131
+ 3. Use a more readable tab size.
132
+ 4. Use the user's configured `sans` font-family by default.
133
+ 5. Use the user's configured `sans` font-feature-settings by default.
134
+ 6. Use the user's configured `sans` font-variation-settings by default.
135
+ 7. Disable tap highlights on iOS
136
+ */
137
+
138
+ html,
139
+ :host {
140
+ line-height: 1.5; /* 1 */
141
+ -webkit-text-size-adjust: 100%; /* 2 */
142
+ -moz-tab-size: 4; /* 3 */
143
+ -o-tab-size: 4;
144
+ tab-size: 4; /* 3 */
145
+ font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 4 */
146
+ font-feature-settings: normal; /* 5 */
147
+ font-variation-settings: normal; /* 6 */
148
+ -webkit-tap-highlight-color: transparent; /* 7 */
149
+ }
150
+
151
+ /*
152
+ 1. Remove the margin in all browsers.
153
+ 2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
154
+ */
155
+
156
+ body {
157
+ margin: 0; /* 1 */
158
+ line-height: inherit; /* 2 */
159
+ }
160
+
161
+ /*
162
+ 1. Add the correct height in Firefox.
163
+ 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
164
+ 3. Ensure horizontal rules are visible by default.
165
+ */
166
+
167
+ hr {
168
+ height: 0; /* 1 */
169
+ color: inherit; /* 2 */
170
+ border-top-width: 1px; /* 3 */
171
+ }
172
+
173
+ /*
174
+ Add the correct text decoration in Chrome, Edge, and Safari.
175
+ */
176
+
177
+ abbr:where([title]) {
178
+ -webkit-text-decoration: underline dotted;
179
+ text-decoration: underline dotted;
180
+ }
181
+
182
+ /*
183
+ Remove the default font size and weight for headings.
184
+ */
185
+
186
+ h1,
187
+ h2,
188
+ h3,
189
+ h4,
190
+ h5,
191
+ h6 {
192
+ font-size: inherit;
193
+ font-weight: inherit;
194
+ }
195
+
196
+ /*
197
+ Reset links to optimize for opt-in styling instead of opt-out.
198
+ */
199
+
200
+ a {
201
+ color: inherit;
202
+ text-decoration: inherit;
203
+ }
204
+
205
+ /*
206
+ Add the correct font weight in Edge and Safari.
207
+ */
208
+
209
+ b,
210
+ strong {
211
+ font-weight: bolder;
212
+ }
213
+
214
+ /*
215
+ 1. Use the user's configured `mono` font-family by default.
216
+ 2. Use the user's configured `mono` font-feature-settings by default.
217
+ 3. Use the user's configured `mono` font-variation-settings by default.
218
+ 4. Correct the odd `em` font sizing in all browsers.
219
+ */
220
+
221
+ code,
222
+ kbd,
223
+ samp,
224
+ pre {
225
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */
226
+ font-feature-settings: normal; /* 2 */
227
+ font-variation-settings: normal; /* 3 */
228
+ font-size: 1em; /* 4 */
229
+ }
230
+
231
+ /*
232
+ Add the correct font size in all browsers.
233
+ */
234
+
235
+ small {
236
+ font-size: 80%;
237
+ }
238
+
239
+ /*
240
+ Prevent `sub` and `sup` elements from affecting the line height in all browsers.
241
+ */
242
+
243
+ sub,
244
+ sup {
245
+ font-size: 75%;
246
+ line-height: 0;
247
+ position: relative;
248
+ vertical-align: baseline;
249
+ }
250
+
251
+ sub {
252
+ bottom: -0.25em;
253
+ }
254
+
255
+ sup {
256
+ top: -0.5em;
257
+ }
258
+
259
+ /*
260
+ 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
261
+ 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
262
+ 3. Remove gaps between table borders by default.
263
+ */
264
+
265
+ table {
266
+ text-indent: 0; /* 1 */
267
+ border-color: inherit; /* 2 */
268
+ border-collapse: collapse; /* 3 */
269
+ }
270
+
271
+ /*
272
+ 1. Change the font styles in all browsers.
273
+ 2. Remove the margin in Firefox and Safari.
274
+ 3. Remove default padding in all browsers.
275
+ */
276
+
277
+ button,
278
+ input,
279
+ optgroup,
280
+ select,
281
+ textarea {
282
+ font-family: inherit; /* 1 */
283
+ font-feature-settings: inherit; /* 1 */
284
+ font-variation-settings: inherit; /* 1 */
285
+ font-size: 100%; /* 1 */
286
+ font-weight: inherit; /* 1 */
287
+ line-height: inherit; /* 1 */
288
+ letter-spacing: inherit; /* 1 */
289
+ color: inherit; /* 1 */
290
+ margin: 0; /* 2 */
291
+ padding: 0; /* 3 */
292
+ }
293
+
294
+ /*
295
+ Remove the inheritance of text transform in Edge and Firefox.
296
+ */
297
+
298
+ button,
299
+ select {
300
+ text-transform: none;
301
+ }
302
+
303
+ /*
304
+ 1. Correct the inability to style clickable types in iOS and Safari.
305
+ 2. Remove default button styles.
306
+ */
307
+
308
+ button,
309
+ input:where([type='button']),
310
+ input:where([type='reset']),
311
+ input:where([type='submit']) {
312
+ -webkit-appearance: button; /* 1 */
313
+ background-color: transparent; /* 2 */
314
+ background-image: none; /* 2 */
315
+ }
316
+
317
+ /*
318
+ Use the modern Firefox focus style for all focusable elements.
319
+ */
320
+
321
+ :-moz-focusring {
322
+ outline: auto;
323
+ }
324
+
325
+ /*
326
+ Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
327
+ */
328
+
329
+ :-moz-ui-invalid {
330
+ box-shadow: none;
331
+ }
332
+
333
+ /*
334
+ Add the correct vertical alignment in Chrome and Firefox.
335
+ */
336
+
337
+ progress {
338
+ vertical-align: baseline;
339
+ }
340
+
341
+ /*
342
+ Correct the cursor style of increment and decrement buttons in Safari.
343
+ */
344
+
345
+ ::-webkit-inner-spin-button,
346
+ ::-webkit-outer-spin-button {
347
+ height: auto;
348
+ }
349
+
350
+ /*
351
+ 1. Correct the odd appearance in Chrome and Safari.
352
+ 2. Correct the outline style in Safari.
353
+ */
354
+
355
+ [type='search'] {
356
+ -webkit-appearance: textfield; /* 1 */
357
+ outline-offset: -2px; /* 2 */
358
+ }
359
+
360
+ /*
361
+ Remove the inner padding in Chrome and Safari on macOS.
362
+ */
363
+
364
+ ::-webkit-search-decoration {
365
+ -webkit-appearance: none;
366
+ }
367
+
368
+ /*
369
+ 1. Correct the inability to style clickable types in iOS and Safari.
370
+ 2. Change font properties to `inherit` in Safari.
371
+ */
372
+
373
+ ::-webkit-file-upload-button {
374
+ -webkit-appearance: button; /* 1 */
375
+ font: inherit; /* 2 */
376
+ }
377
+
378
+ /*
379
+ Add the correct display in Chrome and Safari.
380
+ */
381
+
382
+ summary {
383
+ display: list-item;
384
+ }
385
+
386
+ /*
387
+ Removes the default spacing and border for appropriate elements.
388
+ */
389
+
390
+ blockquote,
391
+ dl,
392
+ dd,
393
+ h1,
394
+ h2,
395
+ h3,
396
+ h4,
397
+ h5,
398
+ h6,
399
+ hr,
400
+ figure,
401
+ p,
402
+ pre {
403
+ margin: 0;
404
+ }
405
+
406
+ fieldset {
407
+ margin: 0;
408
+ padding: 0;
409
+ }
410
+
411
+ legend {
412
+ padding: 0;
413
+ }
414
+
415
+ ol,
416
+ ul,
417
+ menu {
418
+ list-style: none;
419
+ margin: 0;
420
+ padding: 0;
421
+ }
422
+
423
+ /*
424
+ Reset default styling for dialogs.
425
+ */
426
+ dialog {
427
+ padding: 0;
428
+ }
429
+
430
+ /*
431
+ Prevent resizing textareas horizontally by default.
432
+ */
433
+
434
+ textarea {
435
+ resize: vertical;
436
+ }
437
+
438
+ /*
439
+ 1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
440
+ 2. Set the default placeholder color to the user's configured gray 400 color.
441
+ */
442
+
443
+ input::-moz-placeholder, textarea::-moz-placeholder {
444
+ opacity: 1; /* 1 */
445
+ color: #9ca3af; /* 2 */
446
+ }
447
+
448
+ input::placeholder,
449
+ textarea::placeholder {
450
+ opacity: 1; /* 1 */
451
+ color: #9ca3af; /* 2 */
452
+ }
453
+
454
+ /*
455
+ Set the default cursor for buttons.
456
+ */
457
+
458
+ button,
459
+ [role="button"] {
460
+ cursor: pointer;
461
+ }
462
+
463
+ /*
464
+ Make sure disabled buttons don't get the pointer cursor.
465
+ */
466
+ :disabled {
467
+ cursor: default;
468
+ }
469
+
470
+ /*
471
+ 1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
472
+ 2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
473
+ This can trigger a poorly considered lint error in some tools but is included by design.
474
+ */
475
+
476
+ img,
477
+ svg,
478
+ video,
479
+ canvas,
480
+ audio,
481
+ iframe,
482
+ embed,
483
+ object {
484
+ display: block; /* 1 */
485
+ vertical-align: middle; /* 2 */
486
+ }
487
+
488
+ /*
489
+ Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
490
+ */
491
+
492
+ img,
493
+ video {
494
+ max-width: 100%;
495
+ height: auto;
496
+ }
497
+
498
+ /* Make elements with the HTML hidden attribute stay hidden by default */
499
+ [hidden]:where(:not([hidden="until-found"])) {
500
+ display: none;
501
+ }
502
+ .fixed {
503
+ position: fixed;
504
+ }
505
+ .hidden {
506
+ display: none;
507
+ }
508
+ .transform {
509
+ transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
510
+ }
511
+ .resize {
512
+ resize: both;
513
+ }
514
+ .transition {
515
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
516
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
517
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;
518
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
519
+ transition-duration: 150ms;
520
+ }
521
+
522
+ .widget-button {
523
+ position: fixed;
524
+ bottom: 1.25rem;
525
+ right: 1.25rem;
526
+ display: flex;
527
+ height: 2.25rem;
528
+ cursor: pointer;
529
+ align-items: center;
530
+ justify-content: center;
531
+ gap: 0px;
532
+ border-radius: 9999px;
533
+ border-width: 1px;
534
+ --tw-border-opacity: 1;
535
+ border-color: rgb(229 231 235 / var(--tw-border-opacity, 1));
536
+ --tw-bg-opacity: 1;
537
+ background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1));
538
+ padding-left: 0.75rem;
539
+ padding-right: 0.75rem;
540
+ font-size: 0.875rem;
541
+ line-height: 1.25rem;
542
+ font-weight: 500;
543
+ --tw-text-opacity: 1;
544
+ color: rgb(255 255 255 / var(--tw-text-opacity, 1));
545
+ --tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
546
+ --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);
547
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
548
+ transition-property: all;
549
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
550
+ transition-duration: 150ms;
551
+ z-index: 9998;
552
+ }
553
+
554
+ .widget-button:hover {
555
+ --tw-bg-opacity: 1;
556
+ background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1));
557
+ }
558
+
559
+ .widget-button-text {
560
+ display: inline-block;
561
+ max-width: 18rem;
562
+ overflow: hidden;
563
+ white-space: nowrap;
564
+ transition-property: all;
565
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
566
+ transition-duration: 150ms;
567
+ }
@@ -0,0 +1,42 @@
1
+ interface SqueletteWidgetOptions {
2
+ buttonSelector: string;
3
+ position?: 'top' | 'bottom' | 'left' | 'right';
4
+ onLoad?: () => void;
5
+ onOpenChange?: (isOpen: boolean) => void;
6
+ theme?: string;
7
+ }
8
+
9
+ interface SqueletteWidgetInstance {
10
+ destroy: () => void;
11
+ }
12
+
13
+ declare global {
14
+ const SqueletteWidget: {
15
+ createFeedbackWidget(
16
+ workspaceSlug: string,
17
+ boardSlug: string | undefined,
18
+ options: SqueletteWidgetOptions
19
+ ): SqueletteWidgetInstance;
20
+
21
+ createRoadmapWidget(
22
+ workspaceSlug: string,
23
+ boardSlug: string,
24
+ options: SqueletteWidgetOptions
25
+ ): SqueletteWidgetInstance;
26
+
27
+ createChangelogWidget(
28
+ workspaceSlug: string,
29
+ options: SqueletteWidgetOptions
30
+ ): SqueletteWidgetInstance;
31
+
32
+ createWidget(options: {
33
+ url: string;
34
+ buttonSelector: string;
35
+ position?: 'top' | 'bottom' | 'left' | 'right';
36
+ onLoad?: () => void;
37
+ onOpenChange?: (isOpen: boolean) => void;
38
+ }): SqueletteWidgetInstance;
39
+ };
40
+ }
41
+
42
+ export {};
package/dist/widget.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";var SqueletteWidget=(()=>{var v=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var I=(r,n)=>{for(var i in n)v(r,i,{get:n[i],enumerable:!0})},M=(r,n,i,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of W(n))!C.call(r,o)&&o!==i&&v(r,o,{get:()=>n[o],enumerable:!(s=S(n,o))||s.enumerable});return r};var P=r=>M(v({},"__esModule",{value:!0}),r);var T={};I(T,{createChangelogWidget:()=>z,createFeedbackWidget:()=>N,createRoadmapWidget:()=>U,createWidget:()=>x});var L="https://squelette.app";function U(r,n,i){let s=new URLSearchParams({board:n});i.theme&&s.set("theme",i.theme);let o=`${L}/widget/${r}/roadmap?${s.toString()}`,{theme:c,...h}=i;return x({...h,url:o})}function z(r,n){let i=new URLSearchParams;n.theme&&i.set("theme",n.theme);let s=`${L}/widget/${r}/changelog${i.toString()?`?${i.toString()}`:""}`,{theme:o,...c}=n;return x({...c,url:s})}function N(r,n,i){let s=new URLSearchParams;n&&s.set("board",n),i.theme&&s.set("theme",i.theme);let o=`${L}/widget/${r}/feedback${s.toString()?`?${s.toString()}`:""}`,{theme:c,...h}=i;return x({...h,url:o})}function x(r){let{url:n,buttonSelector:i,position:s="top",onLoad:o,onOpenChange:c}=r,h=n,e=document.createElement("iframe");e.src=n,e.loading="eager";let k=t=>{let a=new URL(t).pathname,g=a.endsWith("/feedback"),w=a.endsWith("/changelog"),y=a.endsWith("/roadmap"),p="400px",d="540px";switch(!0){case g:d="250px";break;case w:d="500px";break;case y:d="400px";break;default:d="540px";break}e.style.width=p,e.style.height=d};k(n);let f=document.querySelector(i);if(!f)return console.error(`Button element not found with selector: ${i}`),{destroy:()=>{}};let O=(t,a,g,w)=>{let y={width:window.innerWidth,height:window.innerHeight},p=12,d,l;switch(w){case"right":d=t.right+p,l=t.top;break;case"left":d=t.left-a-p,l=t.top;break;case"top":d=t.left-(a-t.width)/2,l=t.top-g-p;break;case"bottom":d=t.left-(a-t.width)/2,l=t.bottom+p;break;default:d=t.left-(a-t.width)/2,l=t.top-g-p}return d=Math.max(10,Math.min(d,y.width-a-10)),l=Math.max(10,Math.min(l,y.height-g-10)),{left:d,top:l}},u=()=>{if(!f)return;let t=f.getBoundingClientRect(),a=Number.parseInt(e.style.width||"400px",10),g=Number.parseInt(e.style.height||"540px",10),w=O(t,a,g,s);e.style.left=`${w.left}px`,e.style.top=`${w.top}px`,e.style.bottom="auto",e.style.right="auto"};e.style.cssText=`
2
+ position: fixed;
3
+ width: ${e.style.width||"400px"};
4
+ height: ${e.style.height||"540px"};
5
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
6
+ border-radius: 16px;
7
+ z-index: 9999;
8
+ background: transparent;
9
+ opacity: 0;
10
+ transform: translateY(20px);
11
+ transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
12
+ pointer-events: none;
13
+ border: none;
14
+ box-sizing: border-box;
15
+ `,window.addEventListener("scroll",u),window.addEventListener("resize",u),u(),window.addEventListener("message",t=>{t.source===e.contentWindow&&(t.data?.type==="navigation"?(k(t.data.url),u()):t.data?.type==="close-iframe"&&m&&(e.src=h,b()))});let m=!1,b=()=>{m=!m,m?(e.style.pointerEvents="auto",e.style.opacity="1",e.style.transform="translateY(0)"):(e.style.pointerEvents="none",e.style.opacity="0",e.style.transform="translateY(20px)",e.src=h),c&&c(m)};f.addEventListener("click",b);let E=t=>{let a=t.target;m&&!e.contains(a)&&!f.contains(a)&&b()};document.addEventListener("click",E),e.addEventListener("load",()=>{o&&o()});let $=document.querySelector(`iframe[data-widget-button="${i}"]`);return $&&$.remove(),e.setAttribute("data-widget-button",i),document.body.appendChild(e),{destroy:()=>{m&&c&&c(!1),window.removeEventListener("scroll",u),window.removeEventListener("resize",u),f.removeEventListener("click",b),document.removeEventListener("click",E),e.removeEventListener("load",()=>{o&&o()}),e.parentNode&&e.parentNode.removeChild(e)}}}return P(T);})();
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@squeletteapp/widget",
3
+ "version": "0.1.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc && npm run build:browser",
17
+ "build:browser": "esbuild src/index.ts --bundle --format=iife --global-name=SqueletteWidget --outfile=dist/widget.js --minify --define:process.env.NEXT_PUBLIC_DASHBOARD_URL='\"https://squelette.app\"'",
18
+ "dev": "tsc --watch",
19
+ "prepublishOnly": "npm run build",
20
+ "publish:widget": "npm publish --access public"
21
+ },
22
+ "keywords": [
23
+ "widget",
24
+ "feedback",
25
+ "squelette",
26
+ "iframe"
27
+ ],
28
+ "author": "Squelette",
29
+ "license": "MIT",
30
+ "description": "Vanilla JavaScript widget for Squelette feedback collection",
31
+ "devDependencies": {
32
+ "autoprefixer": "^10.4.16",
33
+ "esbuild": "^0.21.5",
34
+ "postcss": "^8.4.35",
35
+ "postcss-cli": "^11.0.0",
36
+ "tailwindcss": "^3.4.0",
37
+ "typescript": "^5.8.3"
38
+ }
39
+ }