承接 scan/kss-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

scan/kss-bundle

最新稳定版本:v0.6.1

Composer 安装命令:

composer require scan/kss-bundle

包简介

A Symfony2 implementation of KSS: a methodology for documenting CSS and generating styleguides

README 文档

README

This bundle provides a simple integration of the kss-php library into Symfony2. KSS is a methodology for documenting CSS and generating styleguides. You can find more information about KSS here at http://warpspire.com/kss/.

Installation

The easiest way to install this bundle is through composer. In your Symfony2 project folder, type the following command:

$ composer require scan/kss-bundle

This will install the bundle and all dependencies needed for the bundle to work.

Next, you will need to enable the bundle by adding it to your Kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...

        new Scan\Bundle\KssBundle\ScanKssBundle(),
    );
}

Finally, if you'd like try out the example provided in the bundle, you'll need to add the following to your symfony2 routes.

# app/config/routing_dev.yml
scan_kss:
    resource: @ScanKssBundle/Controller/
    type:     annotation
    prefix:   /_kssExample

Basic Usage

To output the dynamically generated styleguides, you'll need to create a \Scan\Kss\Parser in your controller and pass it the directory containing your stylesheets.

<?php

namespace Scan\Bundle\KssBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Scan\Kss\Parser;

class ExampleController extends Controller
{
    /**
     * @Route("/styleguide")
     * @Template
     */
    public function styleguideAction()
    {
        $kss = new Parser($this->getRequest()->server->get('DOCUMENT_ROOT') . '/bundles/scankss/css');
        return array(
            'kss' => $kss,
        );
    }
}

Then in your views, when you want to output a styleguide section, use the following twig include:

{% include 'ScanKssBundle:Blocks:block.html.twig' with
    {
        'section' : kss.getSection('Buttons - Stars')
    }
%}

Finally, you'll need to include a small JavaScript file to help rendering of pseudo-classes such as :hover, :disabled, etc. in the styleguide. This can be done with the following lines somewhere in your layout or view:

{% javascripts '@ScanKssBundle/Resources/public/js/*' %}
    <script src="{{ asset_url }}"></script>
{% endjavascripts %}

If you would like, you can either create your own styles for the block or use the styles included. To use the styles included, add the following to your layout or view:

{% stylesheets 'bundles/scankss/css/*' %}
    <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

For a complete example, take a look at the included example controllers, views, and stylesheets.

统计信息

  • 总下载量: 4.16k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 4
  • Forks: 1
  • 开发语言: CSS

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-01-29