cyclejs-community / cyclic-router

Router Driver built for Cycle.js
MIT License
109 stars 25 forks source link

Question: its possible to make a Link component? #124

Open cloud-walker opened 7 years ago

cloud-walker commented 7 years ago

I'm wondering if with cyclejs is possible to craft a generic Link component that accept the route from the props, and manage the click event handler internally.

I saw the dynamic change route section on the readme, but it seems ugly to me as you need to create a class for each link, and map them all on the router: xs.merge ... thing.

TylorS commented 7 years ago

but it seems ugly to me as you need to create a class

I've never written a class inside of a Cycle.js application, nor have I seen one :) The PascalCase is a conventionin the Cycle.js community to distinguish components from other functions.

I don't see any particular reason why a Link component couldn't be create, it just hasn't been yet.

cloud-walker commented 7 years ago

I mean css class like them: image

I really have to invent a class to bind every anchor of my application? Or I'm missing something? I'm pretty new here as you may have noticed :sweat_smile:

TylorS commented 7 years ago

You could just listen to anchor tags. DOM.select('a').events('click')

jerive commented 7 years ago

To be able to toggle the "active" state of the link, I feel like a feature is missing on RouterSource for this to be possible: the possibility to know whether the current location matches a path (or the current namespace + path part). Or is there something I missed?