npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ui-stater

v1.0.0

Published

ui-router helper directive to generate class, attribute or id field based on state name a ui-view directive posseses...

Downloads

7

Readme

ui-stater

ui-router helper directive to generate class, attribute or id field based on state name a ui-view directive posseses...

In a nutshell

ui-stater helps you add class or attribute or id field on ui-view directive, based on name of the state that element represents.

Just add ui-stater attribute on ui-view directive element.

For example, if below element is a template for ui-router state 'photos'

<ui-view ui-stater class="myclass"></ui-view> 

then, above element will mutate (because it has ui-stater attribute) into...

<ui-view ui-stater stater="photo" class="myclass stater-photo" id="stater-photo"></ui-view>

This is incredibly helpful for dom manipulation and css styling.


Install

→ Bower

bower install --save ui-stater

→ Manual

Download angularJS, ui-router and ui-stater and include angular.js, angular-ui-router.js and ui-stater.js files in your application.


Setup application

Include dependencies

var myApp = angular.module('myApp', ['ui.router', 'thatisuday.ui-stater']);

Set options

You can configure options of ui-stater using uiStaterOpsProvider to produce only few or all fields to provide ease.

var myApp.config(['uiStaterOpsProvider', function(uiStaterOpsProvider){
	uiStaterOpsProvider.setOptions({
		class : true,
		attr : true, 
		id : true,
		classPrepend : 'custom-stater-',
		attrName : 'custom-stater',
		idPrepend : 'custom-stater-',
		replaceDot : true
	});
}]);

These options will help you set custom value of class, attribute or id field (almost).

All options are mentioned below

| option | values | default | role | | ------ | ------ | ------- | ---- | | class | true/false | true | Adds a class on directive. | | attr | true/false | false | Adds attribute on directive. | | id | true/false | false | Adds id attribute on directive. | | classPrepend | String | 'stater-' | Name of the class to start with. class name will be classPrepend + state name. e.g. 'stater-photos-cats' for photos.cats state name. | | attrName | String | 'stater' | Name of the attribute. attribute's value will be state name. e.g. stater='photos-cats' for photos.cats state name. | | idPrepend | String | 'stater-' | Value of the id attribute to start with. id's value will be idPrepend + state name. e.g. id='starter-photos-cats' for photos.cats state name. | | replaceDot | true/false | true | Replaces dot(.) with hyphen (-) in output value class, attribute or id |

Note that if the state name have dot (.) in it, then output will replace all (.) with hyphen (-). This is needed to be done so that output value will be a css selector. To turn this off, set replaceDot option to false.


Examples

So far, we have set our application, installed all dependencies and configured ui-stater.

| state-name | output | | ---------- | ------ | | dashboard | <ui-view ui-stater class="custom-stater-dashboard" custom-stater="dashboard" id="custom-stater-dashboard" | | dashboard.photos | <ui-view ui-stater class="custom-stater-dashboard" custom-stater="dashboard-photos" id="custom-stater-dashboard-photos" | | dashboard.photos.cat | <ui-view ui-stater class="custom-stater-dashboard-cats" custom-stater="dashboard-photos-cats" id="custom-stater-dashboard-photos-cats" |


Now I think, you probably got the hang of it.