2017 © Pedro Peláez
 

library css-class-names

An API to support CSS class names.

image

brickrouge/css-class-names

An API to support CSS class names.

  • Sunday, August 16, 2015
  • by olvlvl
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,121 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

CSSClassNames Build Status

An API to support CSS class names., (*1)

Helper

<?php

namespace Brickrouge;

$class_names = [

    'node-id' => 'node-id-13',
    'node-slug' => 'node-slug-example',
    'is-active' => true,
    'is-disabled' => false

];

render_css_class($class_names)
// "node-id-13 node-slug-example is-active"
render_css_class($class_names, [ 'node-id', 'is-active', 'is-disabled' ]);
// "node-id-13 is-active"
render_css_class($class_names, 'node-id is-active is-disabled');
// "node-id-13 is-active"
render_css_class($class_names, [ '-node-id', '-node-slug' ]);
// "is-active"
render_css_class($class_names, '-node-id -node-slug');
// "is-active"

CSSClassNames and CSSClassNamesProperty

Classes that implements the CSSClassNames interface might want to use the CSSClassNamesProperty trait that provides support for the css_class and css_class_names magic properties., (*2)

<?php

namespace Icybee\Modules\Nodes;

use Brickrouge\CSSClassNames;
use Brickrouge\CSSClassNamesProperty;

// …

class Node extends ActiveRecord implements CSSClassNames
{
    use CSSClassNamesProperty;

    // …

    /**
     * Returns the CSS class names of the node.
     *
     * @return array[string]mixed
     */
    protected function get_css_class_names()
    {
        $nid = $this->nid;
        $slug = $this->slug;

        return [

            'type' => 'node',
            'id' => $nid ? "node-{$nid}" : null,
            'slug' => $slug ? "node-slug-{$slug}" : null,
            'constructor' => 'constructor-' . \ICanBoogie\normalize($this->constructor)

        ];
    }
}

An instance of such a Node class could be used as follows:, (*3)

<?php

// …

$node->css_class;
// node node-123 node-slug-example constructor-nodes
$node->css_class_names;
// [ 'type' => node, 'id' => 'node-123', 'slug' => 'node-slug-example', 'constructor' => 'constructor-nodes' ]
$node->css_class('-slug -constructor');
// node node-123
$node->css_class('id slug');
// node-123 node-slug-example

Requirement

The package requires PHP 5.4 or later., (*4)

Installation

The recommended way to install this package is through Composer. Create a composer.json file and run php composer.phar install command to install it:, (*5)

{
    "minimum-stability": "dev",
    "require":
    {
        "brickrouge/css-class-names": "*"
    }
}

Cloning the repository

The package is available on GitHub, its repository can be cloned with the following command line:, (*6)

$ git clone git://github.com/Brickrouge/CSSClassNames.git

Documentation

The documentation for the package and its dependencies can be generated with the make doc command. The documentation is generated in the docs directory using ApiGen. The package directory can later by cleaned with the make clean command., (*7)

Testing

The test suite is ran with the make test command. Composer is automatically installed as well as all the dependencies required to run the suite. The package directory can later be cleaned with the make clean command., (*8)

The package is continuously tested by Travis CI., (*9)

Build Status, (*10)

License

Brickrouge/CSSClassNames is licensed under the New BSD License - See the LICENSE file for details., (*11)

The Versions

16/08 2015

2.0.x-dev

2.0.9999999.9999999-dev http://icanboogie.org/

An API to support CSS class names.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

css class names

24/06 2014

dev-master

9999999-dev http://icanboogie.org/

An API to support CSS class names.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

css class names

26/01 2014

v2.0

2.0.0.0 http://icanboogie.org/

An API to support CSS class names.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

css class names

10/04 2013

1.0.x-dev

1.0.9999999.9999999-dev http://icanboogie.org/

An API to support CSS class names.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

css class names

10/04 2013

v1.0

1.0.0.0 http://icanboogie.org/

An API to support CSS class names.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

css class names