Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object - without content / free space #313

Closed
dos1973 opened this issue Jan 29, 2024 · 3 comments
Closed

Object - without content / free space #313

dos1973 opened this issue Jan 29, 2024 · 3 comments

Comments

@dos1973
Copy link

dos1973 commented Jan 29, 2024

Hi,
can you make an object without content?

i know section is possible without Naming, but Object without content would allow more flexibility.
i would like to have the option to add some free space, between the buttons.

Bildschirmfoto 2024-01-29 um 01 11 32
@meanaverage
Copy link

meanaverage commented Jan 29, 2024

I like this idea. Currently this is kind of possible using the custom_javascript.js, but only if the tile you want to hide is on the first page that Fusion loads (unless you setup the equivalent function as a document observer that kicks off when DOM changes).

If you add the following code to custom_javascript.js, any tile you've given the friendly name of Blank Tile will be hidden as long as it's on the first page loaded.

const levelsUp = 2;
function hideParentOfDivWithText(className, textContent, levels) {
    const elements = document.querySelectorAll(`.${className}`);

    elements.forEach(element => {
        if (element.textContent.trim() === textContent) {
            let parentElement = element;
            // Go up 'levels' levels in the DOM tree
            for (let i = 0; i < levels; i++) {
                if (parentElement.parentNode) {
                    parentElement = parentElement.parentNode;
                } else {
                    break; // Stop if there are no more parent nodes
                }
            }
            // Hide the Blank Tile's proper parent DIV and disable pointer events so it's no longer interactable
            parentElement.style.opacity = '0';
            parentElement.style.pointerEvents = 'none';
        }
    });
}
hideParentOfDivWithText('name', 'Blank Tile', levelsUp);
image

@meanaverage
Copy link

meanaverage commented Jan 30, 2024

Fixed so it works on all pages without the need for an observer. Binds the function dynamically to clicks of any links existing in the top navigation bar and sidebar.

// Function to hide the parent div of elements with a specific class and text content
function hideParentOfDivWithText(className, textContent, levels) {
    const elements = document.querySelectorAll(`.${className}`);

    elements.forEach(element => {
        if (element.textContent.trim() === textContent) {
            let parentElement = element;
            // Go up 'levels' levels in the DOM tree
            for (let i = 0; i < levels; i++) {
                if (parentElement.parentNode) {
                    parentElement = parentElement.parentNode;
                } else {
                    break; // Stop if there are no more parent nodes
                }
            }
            // Apply the style to hide the element
            parentElement.style.opacity = '0';
            parentElement.style.pointerEvents = 'none';
        }
    });
}

// Function to attach event listeners to link elements in a given container
function attachEventListenersToLinks(containerSelector, linkSelector) {
    const container = document.querySelector(containerSelector);
    if (container) {
        const linkElements = container.querySelectorAll(linkSelector);

        linkElements.forEach(linkElement => {
            const linkName = linkElement.textContent.trim();
            linkElement.addEventListener('click', () => {
                console.log(linkName + ' link clicked');
                hideParentOfDivWithText('name', 'Blank Tile', 2);
            });
        });
    } else {
        console.warn('Container not found:', containerSelector);
    }
}

// Attaching listeners to links in the top navigation bar
attachEventListenersToLinks('.top-bar.svelte-1k4q95j #navigation', '.nav-button.svelte-1k4q95j');

// Attaching listeners to links in the sidebar
attachEventListenersToLinks('.svelte-10lgb5p', 'button.svelte-10q7c4z');

// Run once on page load
hideParentOfDivWithText('name', 'Blank Tile', 2);

@xrolfex
Copy link
Contributor

xrolfex commented Jan 30, 2024

I took a stab at adding a support object type for placeholder take a look at PR #316

@matt8707 matt8707 closed this as completed Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants