question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question]: How to change device from dropdown to icon

See original GitHub issue

I’m trying to replace the dropdown with icon for the devices following the example in the newsletter template yet it doesn’t work.

//custom commands
    // Turn off default devices select and create new one
    let pnm = editor.Panels;
    editor.getConfig().showDevices = false;
    let devicePanel = pnm.addPanel({
        id: 'devices-c'
    });
    let deviceBtns = devicePanel.get('buttons');
    devicePanel.get('buttons').add([{
        id: 'deviceDesktop',
        command: 'set-device-desktop',
        className: 'fa fa-desktop',
        attributes: {title: 'Desktop'},
        active: 1,
    }, {
        id: 'deviceTablet',
        command: 'set-device-tablet',
        className: 'fa fa-tablet',
        attributes: {title:'Tablet'},
    }, {
        id: 'deviceMobile',
        command: 'set-device-mobile',
        className: 'fa fa-mobile',
        attributes: {title: 'Mobile'},
    }])

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
Phil-Bcommented, Nov 3, 2021

The above examples didn’t work for me in version 0.17.28 (I presume the API has changed). This worked:

    editor.getConfig().showDevices = 0;

    editor.Panels.addPanel({
        id: 'devices', buttons: [
            { id: "set-device-desktop", command: function (e) { return e.setDevice("Desktop") }, className: "fa fa-desktop", active: 1 },
            { id: "set-device-tablet", command: function (e) { return e.setDevice("Tablet") }, className: "fa fa-tablet" },
            { id: "set-device-mobile", command: function (e) { return e.setDevice("Mobile portrait") }, className: "fa fa-mobile" }
        ]
    });
1reaction
umerrinayatcommented, Jan 31, 2020

@petervandeput https://github.com/artf/grapesjs/issues/1507#issuecomment-496280105 After grapesjs init.

editor.getConfig().showDevices = 0;
editor.Panels.addPanel({ id: "devices-c" }).get("buttons").add([
{ id: "set-device-desktop", command: function(e) { return e.setDevice("Desktop") }, className: "fa fa-desktop", active: 1},
{ id: "set-device-tablet", command: function(e) { return e.setDevice("Tablet") }, className: "fa fa-tablet" },
{ id: "set-device-mobile", command: function(e) { return e.setDevice("Mobile portrait") }, className: "fa fa-mobile" },
]);

// Panel should re render again otherwise 
// New button will not be shown on device panel
editor.Panels.render();

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change Spinner dropdown icon - android - Stack Overflow
Change Spinner dropdown icon · 1. create a custom drawable · 2. Set the drawable as the spinner background:
Read more >
How to replace dropdown-toggle icon with another default ...
Step 3: After applying the CSS, copy the embed code of the icon that you want to display on the webpage from the...
Read more >
Android : Change Spinner dropdown icon - YouTube
Android : Change Spinner dropdown icon [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] Android : Change Spinner ...
Read more >
Components - Bootstrap
Over a dozen reusable components built to provide iconography, dropdowns, input groups, navigation, alerts, and much more.
Read more >
Create Dashboard Layouts for Different Device Types - Tableau
For Phone layouts, either click the lock icon , or choose Edit Layout from the pop-up menu: Anything you can add to your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found