Skip to content

Commit 6ea01dd

Browse files
Update index.js
1 parent a36023a commit 6ea01dd

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

js/index.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ function loadWidgets() {
763763
renderWidgets();
764764
}
765765

766-
function addWidget(widgetData) {
766+
function addWidget(widgetData, isTransparent = false) {
767767
const baseUnit = 200; // The size of a 1x1 widget block
768768
const gridW = widgetData.defaultSize ? widgetData.defaultSize[0] : 1;
769769
const gridH = widgetData.defaultSize ? widgetData.defaultSize[1] : 1;
@@ -776,9 +776,9 @@ function addWidget(widgetData) {
776776
appName: widgetData.appName,
777777
w: defaultWidth,
778778
h: defaultHeight,
779-
// Place new widgets in the top-left, avoiding the clock area
780779
x: 10,
781-
y: 80,
780+
y: 80,
781+
transparent: isTransparent // Save transparency state
782782
});
783783
renderWidgets();
784784
saveWidgets();
@@ -814,13 +814,26 @@ function renderWidgets() {
814814
instance.style.left = `${widget.x}px`;
815815
instance.style.top = `${widget.y}px`;
816816

817+
// Apply transparency styles if flag is set
818+
if (widget.transparent) {
819+
instance.style.background = 'transparent';
820+
instance.style.border = 'none';
821+
instance.style.backdropFilter = 'none';
822+
instance.style.boxShadow = 'none';
823+
}
824+
817825
embedContainer = document.createElement('div');
818826
const iframe = document.createElement('iframe');
819827
iframe.src = widgetDef.url;
820828
iframe.setAttribute('data-gurasuraisu-iframe', 'true');
821829
const overlay = document.createElement('div');
822830
overlay.className = 'widget-instance-overlay';
823831

832+
// Remove overlay shadow if transparent
833+
if (widget.transparent) {
834+
overlay.style.boxShadow = 'none';
835+
}
836+
824837
// --- Create the invisible resize handle ---
825838
const resizeHandle = document.createElement('div');
826839
resizeHandle.className = 'widget-resize-handle';
@@ -1139,6 +1152,10 @@ function openWidgetPicker() {
11391152
content.scrollTop = 0; // Scroll to top
11401153
grid.innerHTML = ''; // Clear old items
11411154

1155+
// Reset transparency toggle
1156+
const transparentSwitch = document.getElementById('widget-transparent-switch');
1157+
if (transparentSwitch) transparentSwitch.checked = false;
1158+
11421159
// Check if there are any available widgets
11431160
if (Object.keys(availableWidgets).length === 0) {
11441161
grid.innerHTML = `<p style="text-align: center; opacity: 0.7;">No widgets available. Install apps that provide widgets.</p>`;
@@ -1182,7 +1199,8 @@ function openWidgetPicker() {
11821199
item.appendChild(title);
11831200

11841201
item.addEventListener('click', () => {
1185-
addWidget(widgetData);
1202+
const isTransparent = document.getElementById('widget-transparent-switch')?.checked || false;
1203+
addWidget(widgetData, isTransparent);
11861204
closeWidgetPicker();
11871205
});
11881206
grid.appendChild(item);

0 commit comments

Comments
 (0)