timhovius/bootstrap-material-design 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

timhovius/bootstrap-material-design

Composer 安装命令:

composer require timhovius/bootstrap-material-design

包简介

Bootstrap material theme for Symfony2

README 文档

README

build status

banner

This Bootstrap theme is an easy way to use the new Material Design guidelines by Google in your Symfony2 application.

NOTE: This theme is still in development, it could be used on production websites but I can't guarantee compatibility with previous versions.

Check out the demo at this link.

How to install

Add the folowing line to your composer.json file: "timhovius/bootstrap-material-design": "dev-master"
Run php composer.phar install and the bundle can be used now.

###Bonus If you want to use this bundle with the BraincraftedBootstrapBundle, you have to add the following lines to your config.yml:

# Assetic Confguration
...
assets:
    bootstrap_css:
        inputs:
            - %kernel.root_dir%/../vendor/twbs/bootstrap/less/bootstrap.less
            - %kernel.root_dir%/../vendor/timhovius/bootstrap-material-design/less/ripples.less
            - %kernel.root_dir%/../vendor/timhovius/bootstrap-material-design/less/material.less
            - %kernel.root_dir%/../vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Resources/less/form.less
        filters:
            - less
            - cssrewrite
        output: css/material.css
    bootstrap_js:
        inputs:
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/transition.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/alert.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/button.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/carousel.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/collapse.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/dropdown.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/modal.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/tooltip.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/popover.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/scrollspy.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/tab.js
            - %kernel.root_dir%/../vendor/twbs/bootstrap/js/affix.js
            - %kernel.root_dir%/../vendor/timhovius/bootstrap-material-design/scripts/ripples.js
            - %kernel.root_dir%/../vendor/timhovius/bootstrap-material-design/scripts/material.js
            - %kernel.root_dir%/../vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Resources/js/bc-bootstrap-collection.js
        output: js/material.js

And in the braincrafted_bootstrap section you have to set assetic to false and set the assets_dir to the bootstrap-material-design folder.

braincrafted_bootstrap:
    ...
    assets_dir: %kernel.root_dir%/../vendor/timhovius/bootstrap-material-design
    ...
    auto_configure:
        assetic: false
        ...

You can use the basic template from the BraincraftedBootstrapBundle to include the CSS and JavaScript files:

<!DOCTYPE html>
<html>
<head>

    <title>Bootstrap 101 Template</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="{{ asset('css/material.css') }}" rel="stylesheet" media="screen">

    <!-- HTML5 Shim and Respond.js add IE8 support of HTML5 elements and media queries -->
    {% include 'BraincraftedBootstrapBundle::ie8-support.html.twig' %}

</head>

<body>
    <h1>Hello, world!</h1>

    <!-- jQuery (necessary for Bootstraps JavaScript plugins) -->
    <script src="{{ asset('js/jquery.js') }}"></script>
    <!-- Include all JavaScripts, compiled by Assetic -->
    <script src="{{ asset('js/material.js') }}"></script>
    <!-- Enable Android effects -->
    <script>
        $(function() {
            $.material.init();
        });
    </script>
</body>
</html>

material-wfont.less or material.less?

The only difference is that material-wfont.less has the Google web fonts included.

Documentation

Material Design for Bootstrap provides some additional stuff to get the best from Material Design.

Variations

There are 17 additional color variations (in addition to the classic 4 variations) for buttons, inputs, checkboxes, radios, alerts, navbars, tabs, labels, paginations, progress bars and more. They can be used by adding the class suffix -material-color to the desired element and replacing color with the desired one.

Example:

<button class="btn btn-material-deep-purple">Deep purple button</button>

These colors are taken from the Material Design color palette and are reported below:

palette

Buttons

Add .btn-flat to a button to make it flat, without shadows. Add .btn-raised to a button to add a permanent shadow to it.

Inputs

Add .floating-label to an input field with a placeholder to transform the placeholder in a floating label.

Add data-hint="some hint" to show an hint under the input when the user focus it.

Remember to use the proper HTML markup to get radio and checkboxes styled correctly (choose between radio or checkbox):

<div class="radio/checkbox radio-primary">
    <label>
        <input type="radio/checkbox" checked>
        Option one is this
    </label>
</div>

Icons

Material Design for Bootstrap includes 490 original Material Design icons! These icons are extracted from the original Google sources and are licensed under the BSD license. They are provided as an iconic and easy to use font.

Variations are available for every icon, including the original Bootstrap icons.

The syntax to add a Material icon is:

 <i class="icon icon-material-favorite"></i>

Material.js

Material.js is a jQuery plugin that adds some magic to your markup and allows Material Design for Bootstrap to style some elements like inputs, checkboxes, radios etc.

Functions

  • $.material.init() - shortcut to run all the following commands:
  • $.material.ripples() will apply ripples.js to the default elements.
  • $.material.input() will enable the MD style to the text inputs, and other kind of inputs (number, email, file etc).
  • $.material.checkbox(): will enable the MD style to the checkboxes (remember to follow the markup guidelines explained in the Inputs section.
  • $.material.radio(): will enable the MD style to the checkboxes (remember to follow the markup guidelines explained in the Inputs section.

Apply Material.js only to specific elements

Every function expects an optional value that will be used as a selector for the function; for example, $.material.ripples("#selector, #foobar") will apply Ripples.js only to #selector and #foobar. The functions that allows an optional selector are $.material.ripples, $.material.input, $.material.checkbox and $.material.radio.

You can even override the default values using the $.material.options function. The default values are:

$.material.options = {
    "withRipples": ".btn:not(.btn-link), .card-image, .navbar a:not(.withoutripple), .nav-tabs a:not(.withoutripple), .withripple",
    "inputElements": "input.form-control, textarea.form-control, select.form-control",
    "checkboxElements": ".checkbox > label > input[type=checkbox]",
    "radioElements": ".radio > label > input[type=radio]"
}

Arrive.js support

If you need to dynamically add elements to your DOM then you may need to include Arrive.js before Material.js. This will automatically apply Material.js to every new element added via JavaScript.

Plugins

Material Design for Bootstrap comes with styling support for various external scripts:

SnackbarJS

Create snackbars and toasts with the SnackbarJS plugin. The default toast style is the squared one (snackbar style). If you like to use the rounded style (toast style), please add the toast class to the style option of SnackbarJS.

RipplesJS

This is part of the Material Design for Bootstrap project and is a plain JavaScript script which creates the ripple effect when clicking on the specified elements. At the moment RipplesJS does not have its own repository but it will probably have one in the future.

You may want to set a custom color to the ripples of a specific element, to do so write:

<button class="btn btn-default" data-ripple-color="#F0F0F0">Custom ripple</button>

noUiSlider

Make cross-browser sliders and get them styled with Material Design thanks to the support provided by this theme. Read more about noUiSlider here.

Dropdown.js

Finally a dropdown plugin that transforms select inputs in nice dropdowns and does not drive you crazy. Read more about Dropdown.js here.

Selectize.js

Transform select and multi-select inputs into advanced text inputs. Material Design for BS provides a full replacement of the plugin's CSS, so don't include it. Read more about selectize.js.

Compatibility

Currently, Material Design for Bootstrap supports Google Chrome (tested v37+), Mozilla Firefox (tested 30+), and Internet Explorer (tested 11+). Mobile browsers are not currently tested but they may work.

timhovius/bootstrap-material-design 适用场景与选型建议

timhovius/bootstrap-material-design 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 1.12k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2015 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「framework」 「symfony」 「Symfony2」 「css」 「JS」 「web」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 timhovius/bootstrap-material-design 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 timhovius/bootstrap-material-design 我们能提供哪些服务?
定制开发 / 二次开发

基于 timhovius/bootstrap-material-design 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 3448
  • 开发语言: CSS

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-08