Giter Site home page Giter Site logo

Comments (6)

efstajas avatar efstajas commented on September 28, 2024 1

As-is, generally yeah, because the way the step controller functions is by dispatching events, which get consumed by the stepper. So the events need to originate from step components which are nested below the stepper.

However, there's probably a way to work around this. Without having thought about this a lot, I would try something like catching the step controller's events (you can find them here), and exporting a function from your step components that just re-emits any event you pass it, and then using this function to re-emit events within the scope of the stepper.

Another approach could be to use a svelte portal to "portal" the next / previous buttons from within the step components to elsewhere into the DOM.

from svelte-stepper.

efstajas avatar efstajas commented on September 28, 2024

Closing for now, lmk if you run into any trouble with the suggestions 👍

from svelte-stepper.

lucabrini avatar lucabrini commented on September 28, 2024

I think this could be a pretty nice feature

from svelte-stepper.

lucabrini avatar lucabrini commented on September 28, 2024

However, there's probably a way to work around this. Without having thought about this a lot, I would try something like catching the step controller's events (you can find them here), and exporting a function from your step components that just re-emits any event you pass it, and then using this function to re-emit events within the scope of the stepper.

Can you please provide me an example? I'm kinda new to Svelte

from svelte-stepper.

efstajas avatar efstajas commented on September 28, 2024

Re-opening this since I'm thinking exporting a stepController-like object from the Stepper, which could be used in addition or instead of the event-based API, would probably be relatively trivial and solve this need.

@lucabrini I think the easiest approach for now would be to use a "portal", like this one: https://github.com/romkor/svelte-portal

The steps would simply be:

  1. Create an empty div with an explicit ID like #nav-buttons somewhere on your page
  2. Within your step components, put the navigation buttons within a Portal component that points to the div ID from step 1

Disclaimer: I haven't tried it yet, but I can't see why it wouldn't work.

from svelte-stepper.

lucabrini avatar lucabrini commented on September 28, 2024

Re-opening this since I'm thinking exporting a stepController-like object from the Stepper, which could be used in addition or instead of the event-based API, would probably be relatively trivial and solve this need.

Cool!

@lucabrini I think the easiest approach for now would be to use a "portal", like this one: https://github.com/romkor/svelte-portal

Thank you so much, didn't know about portals :)

from svelte-stepper.

Related Issues (8)

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.