livingstyleguide 2.0.0.pre.2 → 2.0.0.pre.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 449f49344b6ba3da4f7f40904374e6e1475c1ab8
4
- data.tar.gz: 2fe7b4c46f9051d9843bc6a9c50736739cf0ac57
3
+ metadata.gz: a121cfdb20c0610f7812247a4566ae7143f97ca4
4
+ data.tar.gz: 83af58f208d28380bfb9e38546c6c1612313e407
5
5
  SHA512:
6
- metadata.gz: 14246bdf8204e3cb21e7fce5365812db0a67f8526e30664c9f7a3cba422bde47087b243495a62ee257b1c36c90bdd65f117d399f63a0fb2f9e90f5d556056927
7
- data.tar.gz: 8dd2a4c1892812ab483c0dade82fa4d2e921a837cab489bf8742d7d32f99d822fd25389c887e5289dead692028d81298bb10e1c63179783b99f55366de3b4ad9
6
+ metadata.gz: c41a5dd16192b78f8c42e2ceb2753d8e83ef9e32e767495bd68fa0f22ce0a6674f4eb82d8aa63a0dd2f208a75e03265cb175b8152d2b55f986c7b53ce1e467cb
7
+ data.tar.gz: 399f81fd8d0a3e4d358d65294790e8cf21ed8713c8d3bc721d2fc671d8609ef149f355b75f363933cb983a27fb31477ed31937ecc35d4961db93f955e5887c32
@@ -1,28 +1,34 @@
1
+ require "digest/sha1"
2
+
1
3
  LivingStyleGuide.command :colors do |arguments, options, content|
2
- colors = content.split(/\n+/).map{ |l| l.strip.split(/\s+/) }
4
+ colors = content.split(/\n+/).map{ |l| l.strip.split(/(?<![,\(])\s+(?!\))/) }
3
5
  columns = colors.map{ |l| l.size }.max
4
6
  colors = colors.flatten
5
7
 
8
+ def color_class(color)
9
+ "lsg--color-" + Digest::SHA1.hexdigest(color)[0..7]
10
+ end
11
+
6
12
  document.scss << <<-SCSS
7
- $lsg--variables: () !default;
8
- $lsg--variables: join(
9
- $lsg--variables, (#{
10
- colors.reject{ |c| c == '-' }.map do |variable|
11
- %Q("#{variable}": #{variable})
13
+ $lsg--colors: () !default;
14
+ $lsg--colors: join(
15
+ $lsg--colors, (#{
16
+ colors.reject{ |c| c == '-' }.map do |color|
17
+ %Q("#{color_class(color)}": #{color})
12
18
  end.join(', ')
13
19
  })
14
20
  );
15
21
  SCSS
16
22
 
17
- colors_html = colors.map do |variable|
18
- if variable == "-"
23
+ colors_html = colors.map do |color|
24
+ if color == "-"
19
25
  %Q(<li class="lsg--color-swatch -lsg-empty"></li>\n)
20
26
  else
21
- unless variable =~ /^(#[0-9a-f]{3,6}|[a-z]+)$/
22
- source = %Q(<span class="lsg--color-swatch-source">#{variable}</span>)
27
+ unless color =~ /^(#[0-9a-f]{3,6}|[a-z]+)$/
28
+ source = %Q(<span class="lsg--color-swatch-source">#{color}</span>)
23
29
  end
24
- value = %Q(<span class="lsg--color-swatch-value #{variable}"></span>)
25
- %Q(<li class="lsg--color-swatch #{variable}">#{source}#{value}</li>\n)
30
+ value = %Q(<span class="lsg--color-swatch-value #{color_class(color)}"></span>)
31
+ %Q(<li class="lsg--color-swatch #{color_class(color)}">#{source}#{value}</li>\n)
26
32
  end
27
33
  end.join("\n")
28
34
  %(<ul class="lsg--color-swatches -lsg-#{columns}-columns">\n#{colors_html}\n</ul>\n)
@@ -6,6 +6,8 @@ LivingStyleGuide.command :css do |arguments, options, css|
6
6
  end
7
7
  document.depend_on file
8
8
  document.scss << %Q(@import "#{file}";\n)
9
+ elsif options[:scope] == "global"
10
+ document.scss << css
9
11
  else
10
12
  scope = "#" + document.id.gsub(/[\/\.]/, '\\\\\0')
11
13
  scoped_css = css.gsub(/(?<=\}|\A|;)[^@\};]+?(?=\{)/) do |selector|
@@ -8,8 +8,11 @@ LivingStyleGuide.command :scss do |arguments, options, scss|
8
8
  end
9
9
  document.depend_on file
10
10
  document.scss << %Q(@import "#{file}";\n)
11
+ elsif options[:scope] == "global"
12
+ document.scss << scss
11
13
  else
12
- document.scss << "##{document.id.gsub(/[\/\.]/, '\\\\\0')} {\n#{scss}\n}\n"
14
+ id = document.id.gsub(/[\/\.]/, '\\\\\0')
15
+ document.scss << "##{id} {\n#{scss}\n}\n"
13
16
  end
14
17
  nil
15
18
  end
@@ -17,14 +20,10 @@ end
17
20
  LivingStyleGuide.command :sass do |arguments, options, sass|
18
21
  file = arguments.first
19
22
  if file
20
- if document.file
21
- file = File.join(File.dirname(document.file), file)
22
- end
23
- document.depend_on file
24
- document.scss << %Q(@import "#{file}";\n)
23
+ scss(arguments, options, nil)
25
24
  else
26
- scss = Sass::Engine.new(sass).to_tree.to_scss
27
- document.scss << "##{document.id.gsub(/[\/\.]/, '\\\\\0')} {\n#{scss}\n}\n"
25
+ converted = Sass::Engine.new(sass).to_tree.to_scss
26
+ scss(arguments, options, converted)
28
27
  end
29
28
  nil
30
29
  end
@@ -1,3 +1,3 @@
1
1
  module LivingStyleGuide
2
- VERSION = "2.0.0.pre.2"
2
+ VERSION = "2.0.0.pre.3"
3
3
  end
@@ -101,5 +101,4 @@ $lsg--button-width: $lsg--button-height !default;
101
101
  @import "livingstyleguide/color-swatches";
102
102
  @import "livingstyleguide/toggle-code";
103
103
  @import "livingstyleguide/before";
104
- @import "livingstyleguide/variables";
105
104
  @import "livingstyleguide/search-box";
@@ -117,3 +117,39 @@
117
117
  width: $size;
118
118
  }
119
119
  }
120
+
121
+ $lsg--colors: () !default;
122
+
123
+ @each $color-class, $value in $lsg--colors {
124
+ $value: null !default;
125
+
126
+ @if $value != null {
127
+ .#{$color-class} {
128
+ @if (lightness($value) < 50%) {
129
+ @if (lightness($lsg--background-color) > lightness($lsg--color)) {
130
+ color: $lsg--background-color;
131
+ }
132
+ @else {
133
+ color: $lsg--color;
134
+ }
135
+ }
136
+ @else {
137
+ @if (lightness($lsg--background-color) > lightness($lsg--color)) {
138
+ color: $lsg--color;
139
+ }
140
+ @else {
141
+ color: $lsg--background-color;
142
+ }
143
+ }
144
+
145
+ &::before {
146
+ background-color: $value;
147
+ }
148
+
149
+ &::after {
150
+ @extend %lsg--code !optional;
151
+ content: "#{inspect($value)}";
152
+ }
153
+ }
154
+ }
155
+ }
@@ -6,26 +6,3 @@
6
6
  $color-b 0)
7
7
  repeat 0 0/#{$size} #{$size};
8
8
  }
9
-
10
- @function lsg--str-replace($string, $search, $replace: "") {
11
- $index: str-index($string, $search);
12
-
13
- @if $index {
14
- @return str-slice($string, 1, $index - 1) + $replace +
15
- lsg--str-replace(
16
- str-slice($string, $index + str-length($search)),
17
- $search, $replace
18
- );
19
- }
20
-
21
- @return $string;
22
- }
23
-
24
- $lsg--escapes: ("(": "\\(", ")": "\\)", "$": "\\$", "#": "\\#");
25
-
26
- @function lsg--escape-selector($selector) {
27
- @each $before, $after in $lsg--escapes {
28
- $selector: lsg--str-replace($selector, $before, $after);
29
- }
30
- @return $selector;
31
- }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livingstyleguide
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.2
4
+ version: 2.0.0.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Hagenburger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-12 00:00:00.000000000 Z
11
+ date: 2016-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minisyntax
@@ -274,7 +274,6 @@ files:
274
274
  - stylesheets/livingstyleguide/_reset.scss
275
275
  - stylesheets/livingstyleguide/_search-box.scss
276
276
  - stylesheets/livingstyleguide/_toggle-code.scss
277
- - stylesheets/livingstyleguide/_variables.scss
278
277
  homepage: http://livingstyleguide.org
279
278
  licenses: []
280
279
  metadata: {}
@@ -1,39 +0,0 @@
1
- $lsg--variables: () !default;
2
-
3
- @each $variable, $value in $lsg--variables {
4
- $value: null !default;
5
-
6
- @if $value != null {
7
- $selector: lsg--escape-selector($variable);
8
-
9
- .#{$selector} {
10
- @if type-of($value) == color {
11
- @if (lightness($value) < 50%) {
12
- @if (lightness($lsg--background-color) > lightness($lsg--color)) {
13
- color: $lsg--background-color;
14
- }
15
- @else {
16
- color: $lsg--color;
17
- }
18
- }
19
- @else {
20
- @if (lightness($lsg--background-color) > lightness($lsg--color)) {
21
- color: $lsg--color;
22
- }
23
- @else {
24
- color: $lsg--background-color;
25
- }
26
- }
27
-
28
- &::before {
29
- background-color: $value;
30
- }
31
- }
32
-
33
- &::after {
34
- @extend %lsg--code !optional;
35
- content: "#{inspect($value)}";
36
- }
37
- }
38
- }
39
- }