Giter Club home page Giter Club logo

phoenix-active-link's Introduction

phoenix-active-link

Build Status

Elixir/Phoenix helper to create links with "active" state.

Installation

Add phoenix_active_link to your list of dependencies in mix.exs:

def deps do
  [{:phoenix_active_link, "~> 0.2.1"}]
end

Usage

First, add

import PhoenixActiveLink

to the quote of the view function in your web.ex.

You can then use the functions as follow:

<header>
  <ul>
    <%= active_link(@conn, "Dashboard", to: "/", active: [{Dashboard, :index}], wrap_tag: :li) %>
    <%= active_link(@conn, "Users", to: "/users", wrap_tag: :li) %>
    <%= active_link(@conn, to: "/users", wrap_tag: :li) do %>
      <img src="foo.png">
    <% end %>
  </ul>
</header>

If you prefer to write PhoenixActiveLink.active_link explicitly, you can skip the first step.

Example of Active Tags

To specify the active and inactive tags for the wrap tag, use class_active and class_inactive. Example:

<%= active_link(@conn, "Home", to: "/", wrap_tag: :li, class_active: "active nav-item", class_inactive: "nav-item") %>

Defaults can be set in the config.ex as noted in the documentation

Documentation

For more information, take a look at the documentation

Credits

This library is inspired by/ported from active_link_to.

phoenix-active-link's People

Contributors

danhper avatar mdlkxzmcp avatar matsa59 avatar artemgordinskiy avatar lustrousgorilla avatar jsteiner avatar robinvdvleuten avatar cdesch avatar

Stargazers

Roman avatar

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.