bemify 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.md +215 -0
- data/lib/bemify.rb +17 -0
- data/sass/_bemify.scss +104 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NGI1MmI0OWNjMDMxNTFmMDNhOGE1ZTZjYjViZTEyZWU5MjBjOGQ5OA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OWI3ODlmMTJiNzA3NDU3YTIwY2JlNWQzN2QzMDQxMWViMjY4YTg2Ng==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmRmNDZlMDg4MmM2YjdmYTgzYWUxZGFiOTJkOTZmYWNjMWQ5NDg0MThiMTBm
|
10
|
+
OGIyNjc1NzA5NzczMmE5ODA2NzhlZGUwY2VkMjQ3YTk4NTFlZmQ5NWJlYjYw
|
11
|
+
ZjE2NGIzYzJkNTc4ZTQ1ZTUxZWMyYjY2ODVlYzgwYTg2NWVkMTM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjgyZTMxNTBiYjUxNjJhNDVlNjFiN2NiYmY1MmEzNDE4YTViN2MyOWUwYjk1
|
14
|
+
NDE1ZDhhZjA0ZDk2MTMzZGUzMWE3YzAzZWUxOGM3NjUyNjdlYjQwY2RhZTBi
|
15
|
+
ODJkMTczMzBmYTFiYzk2NjIxZjI3NjI5MWZkZThjZDgxMWEwMDI=
|
data/README.md
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
# bemify
|
2
|
+
|
3
|
+
[![Bower Version](https://img.shields.io/bower/v/bemify.svg)](https://img.shields.io/bower/v/bemify.svg)
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/bemify.svg)](https://img.shields.io/gem/v/bemify.svg)
|
5
|
+
|
6
|
+
Bemify is a set of mixins to help you write well-structured, readable, maintainable, component-based modular SCSS source using a BEM-style syntax.
|
7
|
+
|
8
|
+
|
9
|
+
## Install
|
10
|
+
|
11
|
+
Bemify can be installed as a Ruby Gem, via [Bower](http://bower.io), or manually.
|
12
|
+
|
13
|
+
### Bower
|
14
|
+
To install via bower run:
|
15
|
+
|
16
|
+
$ bower install --save-dev bemify
|
17
|
+
|
18
|
+
### Ruby Gem
|
19
|
+
When installed as a Ruby Gem, Bemify will be installed as a Compass extension if Compass is installed on your system.
|
20
|
+
|
21
|
+
$ gem install bemify
|
22
|
+
|
23
|
+
### Manual Install
|
24
|
+
Include `sass/_bemify.scss`in the appropriate location in your project.
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
First, import bemify:
|
30
|
+
|
31
|
+
@import 'bemify';
|
32
|
+
|
33
|
+
|
34
|
+
Once imported, the bemify mixins can now be used to write BEM-style SCSS, making your source cleaner and easier to read and change.
|
35
|
+
|
36
|
+
@include block('my-element') {
|
37
|
+
…
|
38
|
+
|
39
|
+
@include element('child') {
|
40
|
+
…
|
41
|
+
}
|
42
|
+
|
43
|
+
@include modifier('small') {
|
44
|
+
…
|
45
|
+
}
|
46
|
+
|
47
|
+
@include modifier('large') {
|
48
|
+
…
|
49
|
+
}
|
50
|
+
|
51
|
+
@include state('active') {
|
52
|
+
…
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
The output will be full, non-nested BEM-style class selectors:
|
58
|
+
|
59
|
+
|
60
|
+
.my-element {
|
61
|
+
…
|
62
|
+
}
|
63
|
+
|
64
|
+
.my-element__child {
|
65
|
+
…
|
66
|
+
}
|
67
|
+
|
68
|
+
.my-element--large {
|
69
|
+
…
|
70
|
+
}
|
71
|
+
|
72
|
+
.my-element.is-active {
|
73
|
+
…
|
74
|
+
}
|
75
|
+
|
76
|
+
By default, bemify will output combined `.block.state` / `.block__element.state` selectors.
|
77
|
+
Bemify can also be configured to output full `.block--state` / `.block__element--state` selectors.
|
78
|
+
For details, see Configuration below.
|
79
|
+
|
80
|
+
|
81
|
+
The mixins can be nested to create modifiers for subcomponents:
|
82
|
+
|
83
|
+
@include block('my-element') {
|
84
|
+
|
85
|
+
@include element('child') {
|
86
|
+
@include modifier('bad') {
|
87
|
+
@include state('happy') {
|
88
|
+
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
@include modifier('large') {
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
@include state('active') {
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
This will result in:
|
104
|
+
|
105
|
+
.my-element {
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
.my-element__child {
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
.my-element__child--bad {
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
.my-element__child--bad.is-happy {
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
.my-element--large {
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
.my-element.is-active {
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
### Scoping
|
130
|
+
|
131
|
+
Bemify can can of course also be used inside any scope:
|
132
|
+
|
133
|
+
.scope {
|
134
|
+
|
135
|
+
@include block('nav') {
|
136
|
+
|
137
|
+
// etc.
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
### Configuration Options
|
145
|
+
|
146
|
+
bemify uses a configuration file where you can adjust the block-element and the state separator, as well as the state prefix.
|
147
|
+
To overwrite bemify's config with your own configuration file, import your configuration AFTER importing bemify, BUT BEFORE calling the mixins.
|
148
|
+
|
149
|
+
@import "bemify";
|
150
|
+
@import "my_config";
|
151
|
+
|
152
|
+
@include block('my-block') {
|
153
|
+
//…
|
154
|
+
}
|
155
|
+
|
156
|
+
Configurable options and their defaults are:
|
157
|
+
|
158
|
+
* `$combined-state-selectors`: `true`
|
159
|
+
|
160
|
+
Will output selectors like: .element.is-active, set to false to write .element--is-active
|
161
|
+
|
162
|
+
* `$element-separator`: `__`
|
163
|
+
|
164
|
+
* `$modifier-separator`: `--`
|
165
|
+
|
166
|
+
* `$state-prefix`: `is`
|
167
|
+
|
168
|
+
Note that `$state-prefix` can be overridden with each call to the `state` mixin, so you can use both `--is-active` and `--has-error` using the same configuration:
|
169
|
+
|
170
|
+
@include state('error', 'has') {}
|
171
|
+
|
172
|
+
|
173
|
+
## Aliases
|
174
|
+
Not everyone thinks in the categories of 'block, element, modifier', but many of us still want to write modularized, components-based CSS. There are a couple of aliases included for those who think in terms of components, parent-child / -subcomponents included:
|
175
|
+
|
176
|
+
@include block('name') {}
|
177
|
+
== @include component('name') {}
|
178
|
+
|
179
|
+
@include element('name') {}
|
180
|
+
== @include child('name') {}
|
181
|
+
== @include subcomponent('name') {}
|
182
|
+
== @include sub('name') {}
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
## Resources
|
189
|
+
|
190
|
+
* [Harry Roberts: MindBEMding – getting your head ’round BEM syntax](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/)
|
191
|
+
* [Nicolas Gallagher: About HTML semantics and front-end architecture](http://nicolasgallagher.com/about-html-semantics-front-end-architecture/)
|
192
|
+
|
193
|
+
|
194
|
+
---
|
195
|
+
The MIT License (MIT)
|
196
|
+
|
197
|
+
Copyright (c) 2015 Franz Heidl
|
198
|
+
|
199
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
200
|
+
of this software and associated documentation files (the "Software"), to deal
|
201
|
+
in the Software without restriction, including without limitation the rights
|
202
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
203
|
+
copies of the Software, and to permit persons to whom the Software is
|
204
|
+
furnished to do so, subject to the following conditions:
|
205
|
+
|
206
|
+
The above copyright notice and this permission notice shall be included in all
|
207
|
+
copies or substantial portions of the Software.
|
208
|
+
|
209
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
210
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
211
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
212
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
213
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
214
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
215
|
+
SOFTWARE.
|
data/lib/bemify.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
2
|
+
stylesheets_path = File.join(extension_path, 'sass')
|
3
|
+
|
4
|
+
if (defined? Compass)
|
5
|
+
Compass::Frameworks.register('bemify', :path => extension_path, :stylesheets_directory => stylesheets_path)
|
6
|
+
else
|
7
|
+
if ENV.has_key?("SASS_PATH")
|
8
|
+
ENV["SASS_PATH"] = ENV["SASS_PATH"] + File::PATH_SEPARATOR + stylesheets_path
|
9
|
+
else
|
10
|
+
ENV["SASS_PATH"] = stylesheets_path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Bemify
|
15
|
+
VERSION = "0.0.1"
|
16
|
+
DATE = "2015-04-17"
|
17
|
+
end
|
data/sass/_bemify.scss
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
// bemify
|
2
|
+
// https://gtihub.com/franzheidl/bemify
|
3
|
+
// Franz Heidl 2015
|
4
|
+
// MIT License
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
// CONFIG
|
9
|
+
// ======
|
10
|
+
|
11
|
+
// You can change the configuration here. To use your own config/variables file, import your config after importing bemify and before calling bemify's mixins.
|
12
|
+
|
13
|
+
// Output combined state selectors like:
|
14
|
+
// .block__element.is-active {}
|
15
|
+
// Set to false to output single, non-combined state modifiers:
|
16
|
+
// .block__element--is-active {}
|
17
|
+
$combined-state-selectors: true;
|
18
|
+
|
19
|
+
// .block[separator]element:
|
20
|
+
$element-separator: "__";
|
21
|
+
|
22
|
+
// .block[separator]modifier:
|
23
|
+
$modifier-separator: "--";
|
24
|
+
|
25
|
+
// The default prefix for state modifier selectors, will be combined with $modifier-separator:
|
26
|
+
$state-prefix: "is";
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
// MIXINS
|
32
|
+
// ======
|
33
|
+
|
34
|
+
@mixin block($name) {
|
35
|
+
.#{$name} {
|
36
|
+
@content;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
|
41
|
+
@mixin element($name) {
|
42
|
+
@at-root {
|
43
|
+
&#{$element-separator}#{$name} {
|
44
|
+
@content;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
@mixin modifier($name) {
|
51
|
+
@at-root {
|
52
|
+
&#{$modifier-separator}#{$name} {
|
53
|
+
@content;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
|
59
|
+
@mixin state($state, $prefix: $state-prefix) {
|
60
|
+
@if $combined-state-selectors == true {
|
61
|
+
@at-root {
|
62
|
+
&.#{$prefix}-#{$state} {
|
63
|
+
@content;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
@else {
|
68
|
+
@at-root {
|
69
|
+
&#{$modifier-separator}#{$prefix}-#{$state} {
|
70
|
+
@content;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
// ALIASES
|
80
|
+
// =======
|
81
|
+
|
82
|
+
@mixin component($name) {
|
83
|
+
@include block($name) {
|
84
|
+
@content;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
@mixin child($name) {
|
89
|
+
@include element($name) {
|
90
|
+
@content;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
@mixin subcomponent($name) {
|
95
|
+
@include element($name) {
|
96
|
+
@content;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
@mixin sub($name) {
|
101
|
+
@include element($name) {
|
102
|
+
@content;
|
103
|
+
}
|
104
|
+
}
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bemify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Franz Heidl
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sass
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.3'
|
27
|
+
description: Bemify is a set of mixins to help you write well-structured, component-based
|
28
|
+
modular SCSS source using a BEM-style syntax.
|
29
|
+
email:
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- README.md
|
35
|
+
- lib/bemify.rb
|
36
|
+
- sass/_bemify.scss
|
37
|
+
homepage: https://github.com/franzheidl/bemify
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.6
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.0.0.rc.2
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Sass Mixins to write BEM-style SCSS source
|
61
|
+
test_files: []
|