Giter Club home page Giter Club logo

actionnav's People

Contributors

adamcooke avatar fwolfst avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fwolfst

actionnav's Issues

Feature: "extra" field for Items to store, e.g. http-method to use, other style info ...

Although I am likely to be against any "dump whatever you need here"-attributes, an Item#extra or Item#meta attribute would be really helpful, to cover e.g. additional style hints (we mix presentation and logic here, but icon does that already) or indication which http method to use on a specific link.

How would you like the API to look like? Want to specify it via some tests/specs in a branch and I give it a go?

Feature/Doc request: How to add items dynamically

As far as I understand, title, url, etc. accept a Proc to be evaluated at runtime. I however miss some information on how to add items themselves to the nav that are unknown prior to runtime and class definition.

Think of navigation entries that are linked to database entries, e.g. I want to define this in my FacilityNavigation (the example is made up):

class FacilityNavigation < ActionNav::Base

  # ...
  item :rooms do
    title "Rooms"
    Room.each do |room|
     item room.name.to_sym do
        title room.name
        url { Rails.application.routes.url_helpers.room_path(room)
      end
    end
  # ...
end

This will only populate with items that were present on the time of the class evaluation (which in my understanding - depending on the underlying server - most likely happened on server start).

I didnt surf the code yet, but probably something along a dynamic_items { ... } could be implemented, where the whole given block is only evaluated at access time.

Or do I just miss something?

Feature request: Items could be `active?` if url matches current PATH

Items could be marked "auto-active" if their url matches the current PATH_INFO (ideally even more clever). This way, if you have simple routes, you dont need to care about setting the current item active.

Quickest hack to achieve that for every item is to overwrite ItemInstance#active?:

def active?
  @base.active_path?(*self.path) || self.url == @base.controller.instance_eval { request.env['PATH_INFO'] } # or Rails `current_url?()`
end

Not a nice solution, but works. I'd be happy to hear your oppinion and to see the API you'd dream to have ( Item#active_if? { current_path.in? [] } ?).

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.