GithubHelp home page GithubHelp logo

Comments (5)

dillingham avatar dillingham commented on August 15, 2024

You can use two buttons and ->visible($this->is_favorited)
You can also store svg icons and render as first param I believe
And maybe ->reload() to show the other button automatically
Or ->successText($icon) to avoid the reload maybe.

Haven't tried this, just speculating. Hope this helps!

$favoriteSvg = view()->make('svg.favorite')->render();
$unfavoriteSvg = view()->make('svg.unfavorite')->render();

Button::make($favoriteSvg, 'favorite_toggle')
    ->visible($this->is_favorited == false)
    ->reload(),

Button::make($unfavoriteSvg, 'favorite_toggle')
    ->visible($this->is_favorited)
    ->reload(),

Then you'd make a event / listener that attaches / detaches favorites

from nova-button.

didix16 avatar didix16 commented on August 15, 2024

Thanks @dillingham. I'll try it πŸ‘

from nova-button.

didix16 avatar didix16 commented on August 15, 2024

Seems like it works but when successText is rendered , the new button has not a registered event, so I can't trigger again the toggle event.

I don't want to use reload because I want to toggle some of them at the same time.

Is there any chance to register again the event when successText is called?

Thanks in advance

from nova-button.

dillingham avatar dillingham commented on August 15, 2024

No not currently. That would require a new feature. Something like a toggle method with two passed events to switch between. I’m open to a PR but don’t have time to do that myself. Your other option is to fork this or use it as inspiration for your own custom field. Good luck!

from nova-button.

didix16 avatar didix16 commented on August 15, 2024

Thanks @dillingham for the info!
I'll see what I'll do.

P.S: Do you know how can I edit a nova Vue component? I'm really newbie in Laravel and of course in Nova and I don't know how can I edit the resource table row for example. I don't know which file I have to look into nor edit, etc.

Thanks in advance

from nova-button.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.