base.sass 0.2.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/data/browsers.json +1 -0
  3. data/lib/base.sass.rb +13 -6
  4. data/lib/base.sass/caniuse.rb +22 -0
  5. data/lib/base.sass/env.rb +27 -0
  6. data/lib/base.sass/parse-json.rb +41 -0
  7. data/lib/base.sass/ruby-to-sass.rb +33 -0
  8. data/lib/base.sass/sass-to-ruby.rb +25 -0
  9. data/lib/base.sass/selector.rb +60 -0
  10. data/lib/base.sass/strftime.rb +21 -0
  11. data/lib/base.sass/support.rb +136 -0
  12. data/lib/base.sass/url.rb +120 -0
  13. data/stylesheets/base.sass/_*.scss +13 -0
  14. data/stylesheets/base.sass/functions/_list.scss +27 -0
  15. data/stylesheets/base.sass/functions/_map.scss +1 -1
  16. data/stylesheets/base.sass/functions/_support.scss +11 -18
  17. data/stylesheets/base.sass/mixins/_clearfix.scss +19 -0
  18. data/stylesheets/base.sass/mixins/_ellipsis-overflow.scss +7 -0
  19. data/stylesheets/base.sass/mixins/_float.scss +8 -0
  20. data/stylesheets/base.sass/mixins/_font-face.scss +20 -0
  21. data/stylesheets/base.sass/mixins/_inline-block.scss +8 -0
  22. data/stylesheets/base.sass/mixins/_placeholder-wrapper.scss +14 -0
  23. metadata +34 -38
  24. data/stylesheets/_base.functions.scss +0 -15
  25. data/stylesheets/_base.resets.scss +0 -4
  26. data/stylesheets/base.sass/_settings.scss +0 -29
  27. data/stylesheets/base.sass/functions/_clearfix.scss +0 -25
  28. data/stylesheets/base.sass/functions/_compass-hacker.scss +0 -18
  29. data/stylesheets/base.sass/functions/_ellipsis-overflow.scss +0 -15
  30. data/stylesheets/base.sass/functions/_fixed-position.scss +0 -31
  31. data/stylesheets/base.sass/functions/_float.scss +0 -7
  32. data/stylesheets/base.sass/functions/_font-face.scss +0 -70
  33. data/stylesheets/base.sass/functions/_img-retina.scss +0 -27
  34. data/stylesheets/base.sass/resets/_basic.scss +0 -67
  35. data/stylesheets/base.sass/resets/_button-and-input.scss +0 -41
  36. data/stylesheets/base.sass/resets/_html5-tag.scss +0 -7
  37. data/stylesheets/base.sass/resets/_small-label.scss +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f88a430a55771dee575d0009152324c8976436f7
4
- data.tar.gz: 25bf4e85ceda97e0037c33abbb9b9fa491b86367
3
+ metadata.gz: f7d0748e57310baaa88bc57919939822bf241fe7
4
+ data.tar.gz: b1d5d29fd722de9bc21568131fc0759dff2c78ac
5
5
  SHA512:
6
- metadata.gz: f26e4e20663de1ae78842dd4ec08ca5115ebffb3548672ff8950caa75d93298e1c3aaaf88009e615d89c1d97e2777280ec021684309fd10714e72527a52ac865
7
- data.tar.gz: f00abdce92c934f82ff745516910281c1be224008c688a6081acd8900722d4d4948cd0e7000e3b3be72ce0aa26eaabd9208c676e26c799df37dc9155824d0c62
6
+ metadata.gz: b9850d92515e0db589d7c639574c55706972d27cfde34c69feeb710dfd8f1c185b043f64f3f7bda1ee24150886236010d527dcc087540041b3e7b048873dce04
7
+ data.tar.gz: 3c80361d85683dbe1f490971b93cf44bdc7a261018b5adddc0a792cd52567a24f149d2396331f8f4cdbde9df553b545f4323535ec075b34cd2940168bb9959bc
@@ -0,0 +1 @@
1
+ {"chrome":{"prefix":"-webkit-","versions":[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"future":[35,36,37]},"safari":{"prefix":"-webkit-","versions":[3.1,3.2,4,5,5.1,6,6.1,7]},"opera":{"prefix":"-webkit-","versions":[9.5,9.6,10,10.1,10.5,10.6,11,11.1,11.5,11.6,12,12.1,15,16,17,18,19,20],"future":[21,22],"presto":12.1},"ios":{"prefix":"-webkit-","versions":[3.2,4,4.1,4.2,4.3,5,5.1,6,6.1,7]},"android":{"prefix":"-webkit-","versions":[2.1,2.2,2.3,3,4,4.1,4.2,4.3,4.4]},"firefox":{"prefix":"-moz-","versions":[2,3,3.5,3.6,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29],"future":[30,31,32]},"ie":{"prefix":"-ms-","versions":[5.5,6,7,8,9,10,11]}}
@@ -1,7 +1,14 @@
1
- path = File.expand_path(File.join(File.dirname(__FILE__), '../stylesheets'))
1
+ load_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'stylesheets'))
2
2
 
3
- if ENV.has_key?('SASS_PATH')
4
- ENV['SASS_PATH'] = ENV['SASS_PATH'] + File::PATH_SEPARATOR + path
5
- else
6
- ENV['SASS_PATH'] = path
7
- end
3
+ ENV['SASS_PATH'] = [ENV['SASS_PATH'], load_path].compact.join(File::PATH_SEPARATOR)
4
+ ENV['SASS_ENV'] ||= 'development'
5
+
6
+ require 'base.sass/caniuse'
7
+ require 'base.sass/ruby-to-sass'
8
+ require 'base.sass/sass-to-ruby'
9
+ require 'base.sass/env'
10
+ require 'base.sass/parse-json'
11
+ require 'base.sass/strftime'
12
+ require 'base.sass/support'
13
+ require 'base.sass/selector'
14
+ require 'base.sass/url'
@@ -0,0 +1,22 @@
1
+ require 'singleton'
2
+
3
+ class CanIUse
4
+ include Singleton
5
+ include Sass::Script::Functions
6
+
7
+ DATA_DIR = File.join(File.dirname(__FILE__), '..', '..', 'data')
8
+
9
+ def initialize
10
+ @caniuse_browsers = load_json(File.join(DATA_DIR, 'browsers.json'))
11
+ # @caniuse_supports = load_json(File.join(DATA_DIR, 'supports.json'))
12
+ end
13
+
14
+ def browsers
15
+ @caniuse_browsers
16
+ end
17
+
18
+ # def supports
19
+ # @caniuse_supports
20
+ # end
21
+
22
+ end
@@ -0,0 +1,27 @@
1
+ module Sass::Script::Functions
2
+
3
+ # Returns the value for environment variable name as a string.
4
+ # Returns null if the named variable does not exist.
5
+ #
6
+ # Examples:
7
+ # env(SASS_ENV) => development
8
+ # env(sass_env) => development
9
+ # env(sass-env) => development
10
+ def env(name)
11
+ assert_type name, :String
12
+ ruby_to_sass(ENV[name.value.gsub('-', '_').upcase])
13
+ end
14
+
15
+ # Get the configurations of current app.
16
+ # Returns null if the named configuration does not exist.
17
+ #
18
+ # Examples:
19
+ # $app-config: (timestamp: '1.0.0');
20
+ # app-config(timestamp) => 1.0.0
21
+ def app_config(name)
22
+ assert_type name, :String
23
+ config = environment.global_env.var('app-config')
24
+ config.is_a?(Sass::Script::Value::Map) && config.value[name] || null
25
+ end
26
+
27
+ end
@@ -0,0 +1,41 @@
1
+ require 'json'
2
+
3
+ module Sass::Script::Functions
4
+
5
+ $cached_files = {}
6
+
7
+ # Parses a local json file, returns a map, and the result will be cached.
8
+ # If the `path` is not a absolute path, relative to current process directory.
9
+ #
10
+ # Examples:
11
+ # parse-json('~/Desktop/example.json')
12
+ # parse-json('package.json')
13
+ def parse_json(path)
14
+ assert_type path, :String
15
+ path = File.expand_path(path.value)
16
+
17
+ if $cached_files.key? path
18
+ Sass.logger.debug "Reading file from cache: #{path}"
19
+ $cached_files[path]
20
+ else
21
+ $cached_files[path] = ruby_to_sass(load_json(path))
22
+ end
23
+ end
24
+
25
+
26
+ protected
27
+
28
+ def load_json(path)
29
+ JSON.load(
30
+ read_file(File.expand_path(path)).to_s.gsub(/(\\r|\\n)/, '')
31
+ )
32
+ end
33
+
34
+ def read_file(path)
35
+ raise Sass::SyntaxError, "File not found or cannot be read: #{path}" unless File.readable? path
36
+
37
+ Sass.logger.debug "Reading file: #{path}"
38
+ File.open(path, 'rb') { |f| f.read }
39
+ end
40
+
41
+ end
@@ -0,0 +1,33 @@
1
+ module Sass::Script::Functions
2
+
3
+ protected
4
+
5
+ def ruby_to_sass(obj)
6
+ return bool(obj) if obj.is_a?(TrueClass) || obj.is_a?(FalseClass)
7
+ return null if obj.nil?
8
+ return number(obj) if obj.is_a? Numeric
9
+ return to_sass_list(obj) if obj.is_a? Array
10
+ return to_sass_map(obj) if obj.is_a? Hash
11
+ identifier(obj.to_s)
12
+ end
13
+
14
+ def to_sass_map(ruby_hash)
15
+ sass_map = map({})
16
+
17
+ ruby_hash.each do |k, v|
18
+ sass_map = map_merge(
19
+ sass_map,
20
+ map(Hash[identifier(k.to_s), ruby_to_sass(v)])
21
+ )
22
+ end
23
+
24
+ sass_map
25
+ end
26
+
27
+ def to_sass_list(ruby_array)
28
+ list(ruby_array.map { |item|
29
+ ruby_to_sass(item)
30
+ }, :comma)
31
+ end
32
+
33
+ end
@@ -0,0 +1,25 @@
1
+ module Sass::Script::Functions
2
+
3
+ protected
4
+
5
+ def sass_to_ruby(obj)
6
+ return to_ruby_hash(obj) if obj.is_a? Sass::Script::Value::Map
7
+ return to_ruby_array(obj) if obj.is_a? Sass::Script::Value::List
8
+ return obj.inspect if obj.is_a? Sass::Script::Value::Color
9
+ obj.value
10
+ end
11
+
12
+ def to_ruby_hash(sass_map)
13
+ sass_map.value.inject({}) do |memo, (k, v)|
14
+ memo[k.to_s] = sass_to_ruby(v)
15
+ memo
16
+ end
17
+ end
18
+
19
+ def to_ruby_array(sass_list)
20
+ sass_list.value.map do |item|
21
+ sass_to_ruby(item)
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,60 @@
1
+ # Thanks for Compass
2
+ # Document reference: http://beta.compass-style.org/reference/compass/helpers/selectors/
3
+ module Sass::Script::Functions
4
+ COMMA_SEPARATOR = /\s*,\s*/
5
+
6
+ def nest(*args)
7
+ nested = args.map { |a| a.value }.inject do |memo, arg|
8
+ ancestors = memo.split(COMMA_SEPARATOR)
9
+ descendants = arg.split(COMMA_SEPARATOR)
10
+
11
+ ancestors.map { |a|
12
+ descendants.map { |d|
13
+ "#{a} #{d}"
14
+ }.join(', ')
15
+ }.join(', ')
16
+ end
17
+
18
+ identifier(nested)
19
+ end
20
+
21
+ def append_selector(selector, to_append)
22
+ ancestors = selector.value.split(COMMA_SEPARATOR)
23
+ descendants = to_append.value.split(COMMA_SEPARATOR)
24
+
25
+ nested = ancestors.map { |a|
26
+ descendants.map { |d|
27
+ "#{a}#{d}"
28
+ }.join(', ')
29
+ }.join(', ')
30
+
31
+ identifier(nested)
32
+ end
33
+
34
+ def enumerate(prefix, from, through, separator = identifier('-'))
35
+ selectors = (from.value..through.value).map { |i|
36
+ "#{prefix.value}#{separator.value}#{i}"
37
+ }.join(', ')
38
+
39
+ identifier(selectors)
40
+ end
41
+
42
+ def headers(from = nil, to = nil)
43
+ if from && !to
44
+ if from.is_a?(Sass::Script::Value::String) && from.value == 'all'
45
+ from = number(1)
46
+ to = number(6)
47
+ else
48
+ to = from
49
+ from = number(1)
50
+ end
51
+ else
52
+ from ||= number(1)
53
+ to ||= number(6)
54
+ end
55
+
56
+ list((from.value..to.value).map { |n| identifier("h#{n}") }, :comma)
57
+ end
58
+ alias headings headers
59
+
60
+ end
@@ -0,0 +1,21 @@
1
+ module Sass::Script::Functions
2
+
3
+ # Formats time according to the directives in the given format string.
4
+ # Read more: http://www.ruby-doc.org/core-2.1.1/Time.html#method-i-strftime
5
+ #
6
+ # Examples:
7
+ # strftime() => 1399392214
8
+ # strftime('%FT%T%:z') => 2014-05-07T00:03:34+08:00
9
+ # strftime('at %I:%M%p') => at 12:03AM
10
+ def strftime(format = nil)
11
+ time = Time.now.localtime
12
+
13
+ if format
14
+ assert_type format, :String
15
+ identifier(time.strftime(format.value))
16
+ else
17
+ identifier(time.to_i.to_s)
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,136 @@
1
+ module Sass::Script::Functions
2
+
3
+ # Which browsers you wanted support?
4
+ #
5
+ # `last 1 version`
6
+ # is last versions for each browser.
7
+ # `last 2 Chrome versions`
8
+ # is last versions of the specified browser.
9
+ # `IE > 8`
10
+ # is IE versions newer than 8.
11
+ # `IE >= 8`
12
+ # is IE version 8 or newer.
13
+ # `iOS 7`
14
+ # to set browser version directly.
15
+ def parse_rules(*rules)
16
+ rules = rules.map { |rule| sass_to_ruby(rule) }.flatten.uniq
17
+
18
+ @browsers ||= CanIUse.instance.browsers
19
+ selected_browsers =
20
+ rules.map { |rule| rules_parser(rule.downcase) }.compact
21
+ .inject { |memo, versions|
22
+ memo.merge(versions) { |k, orig, added| orig + added }
23
+ }
24
+
25
+ ruby_to_sass(selected_browsers.each { |k, v| v.uniq!; v.sort! })
26
+ end
27
+
28
+ # Returns `(android, chrome, firefox, ie, ios, opera, safari)`.
29
+ def browsers
30
+ ruby_to_sass(CanIUse.instance.browsers.keys.sort)
31
+ end
32
+
33
+ # Returns the versions by the given browser.
34
+ def browser_versions(browser, include_future = bool(true))
35
+ assert_type browser, :String
36
+
37
+ @browsers ||= CanIUse.instance.browsers
38
+ browser = browser.value.downcase
39
+ assert_valid_browser(browser)
40
+
41
+ versions = @browsers[browser]['versions']
42
+ versions += @browsers[browser]['future'].to_a if include_future.to_bool
43
+
44
+ ruby_to_sass(versions)
45
+ end
46
+
47
+ # Grep feature names according to caniuse by regex.
48
+ #
49
+ # Examples:
50
+ # grep-features('^css3?') => /^css3?/
51
+ # grep-features('box sizing') => /box|sizing/
52
+ # grep-features('box-sizing') => /box|sizing/
53
+ # def grep_features(regex)
54
+ # assert_type regex, :String
55
+
56
+ # regex = regex.value.strip.sub(/^-+|-+$/, '')
57
+ # regex = regex.gsub(/\s+|-+/, '|') if regex =~ /^[\w\s-]+$/
58
+ # regex = Regexp.new(regex, Regexp::IGNORECASE)
59
+
60
+ # ruby_to_sass(CanIUse.instance.supports.keys.select { |k| k =~ regex }.sort)
61
+ # end
62
+
63
+
64
+ private
65
+
66
+ def assert_valid_browser(browser, version = nil)
67
+ unless @browsers.key? browser
68
+ raise Sass::SyntaxError, "Unknown browser name: #{browser}\nYou can find all valid names according to `browsers()`"
69
+ end
70
+
71
+ unless version.nil? || sass_to_ruby(browser_versions(identifier(browser))).include?(version)
72
+ raise Sass::SyntaxError, "Unknown version for #{browser}: #{version}\nYou can find all valid versions according to `browser-versions(#{browser})`"
73
+ end
74
+ end
75
+
76
+ def rules_parser(rule)
77
+ case rule
78
+
79
+ # match `last 1 version`
80
+ when /^last (\d+) versions?$/
81
+ last_versions_parser($1)
82
+
83
+ # match `last 3 chrome versions`
84
+ when /^last (\d+) (\w+) versions?$/
85
+ last_browser_versions_parser($1, $2)
86
+
87
+ # match `ie > 9`
88
+ when /^(\w+) (>=?) ([\d\.]+)$/
89
+ newer_then_parser($1, $2, $3)
90
+
91
+ # match `ios 7`
92
+ when /^(\w+) ([\d\.]+)$/
93
+ direct_parser($1, $2)
94
+
95
+ else
96
+ raise Sass::SyntaxError, "Unknown rule: `#{rule}`"
97
+ end
98
+ end
99
+
100
+ def last_versions_parser(num)
101
+ @browsers.inject({}) do |memo, (k, v)|
102
+ memo[k] = v['versions'].last(num.to_i)
103
+ memo
104
+ end
105
+ end
106
+
107
+ def last_browser_versions_parser(num, browser)
108
+ assert_valid_browser(browser)
109
+ Hash[browser, @browsers[browser]['versions'].last(num.to_i)]
110
+ end
111
+
112
+ def newer_then_parser(browser, sign, version)
113
+ assert_valid_browser(browser)
114
+
115
+ versions = @browsers[browser]['versions']
116
+ versions = case sign
117
+ when '>='
118
+ versions.select { |n| n >= version.to_f }
119
+ when '>'
120
+ versions.select { |n| n > version.to_f }
121
+ end
122
+
123
+ versions.empty? ? nil : Hash[browser, versions]
124
+ end
125
+
126
+ def direct_parser(browser, version)
127
+ version = to_if(version)
128
+ assert_valid_browser(browser, version)
129
+ Hash[browser, [version]]
130
+ end
131
+
132
+ def to_if(s)
133
+ s.include?('.') ? s.to_f : s.to_i
134
+ end
135
+
136
+ end
@@ -0,0 +1,120 @@
1
+ module Sass::Script::Functions
2
+
3
+ FONT_TYPES = {
4
+ eot: 'embedded-opentype',
5
+ woff: 'woff',
6
+ ttf: 'truetype',
7
+ svg: 'svg'
8
+ }
9
+
10
+ MIME_TYPES = {
11
+ png: 'image/png',
12
+ jpg: 'image/jpeg',
13
+ jpeg: 'image/jpeg',
14
+ gif: 'image/gif',
15
+ eot: 'application/vnd.ms-fontobject',
16
+ woff: 'application/font-woff',
17
+ ttf: 'font/truetype',
18
+ svg: 'image/svg+xml'
19
+ }
20
+
21
+ PATH_REGEX = /^(.*)(\.\w+)(\??[^#]*)(#?.*)$/
22
+
23
+ # Reinforce the official `url()` in CSS to support multi url and data url.
24
+ # Activates only when all paths are wrapped with quotes.
25
+ #
26
+ # Examples:
27
+ # url(http://a.com/b.png) => url(http://a.com/b.png) # Did nothing
28
+ # url('http://a.com/b.png') => url(http://a.com/b.png?1399394203)
29
+ # url('a.png', 'b.png') => url(a.png?1399394203), url(b.png?1399394203)
30
+ # url('a.eot#iefix', 'b.woff') => url(a.eot?1399394203#iefix) format('embedded-opentype'), url(b.woff?1399394203) format('woff')
31
+ #
32
+ # url('a.png', $timestamp: false) => url(a.png)
33
+ # url('a.png', $timestamp: '1.0.0') => url(a.png?1.0.0)
34
+ #
35
+ # $app-config: (timestamp: '1.0.0');
36
+ # url('a.png') => url(a.png?1.0.0)
37
+ #
38
+ # $app-config: (timestamp: 'p1');
39
+ # url('a.png', $timestamp: 'p0') => url(a.png?p0)
40
+ #
41
+ # url('a.png', $base64: true) => url(data:image/png;base64,iVBORw...)
42
+ def url(*paths)
43
+ kwargs = paths.last.is_a?(Hash) ? paths.pop : {}
44
+ raise Sass::SyntaxError, 'url() needs one path at least' if paths.empty?
45
+
46
+ encode = kwargs['base64'] == bool(true)
47
+ ts = timestamp(kwargs['timestamp'])
48
+
49
+ paths = paths.map { |path| sass_to_ruby(path) }.flatten
50
+ .map { |path| to_url(path, encode, ts) }
51
+
52
+ list(paths, :comma)
53
+ end
54
+ declare :url, [], var_args: true, var_kwargs: true
55
+
56
+
57
+ private
58
+
59
+ def timestamp(ts)
60
+ # no kwargs
61
+ if ts.nil?
62
+ cfg = app_config(identifier('timestamp'))
63
+ ts = cfg == null ? bool(true) : cfg
64
+ end
65
+
66
+ return nil unless ts.to_bool
67
+ return strftime.value if ts.is_a? Sass::Script::Value::Bool
68
+ ts.value.to_s
69
+ end
70
+
71
+ def sign(query)
72
+ case query.size
73
+ when 0
74
+ '?'
75
+ when 1
76
+ ''
77
+ else
78
+ '&'
79
+ end
80
+ end
81
+
82
+ def to_url(path, encode, ts)
83
+ output = "url(#{path})"
84
+
85
+ if path.is_a?(String) && path =~ PATH_REGEX
86
+
87
+ path, ext, query, anchor = $1 + $2, $2[1..-1].downcase.to_sym, $3, $4
88
+
89
+ if MIME_TYPES.key? ext
90
+ output = if encode
91
+ output_data(path, ext)
92
+ else
93
+ output_path(path, ext, query, anchor, ts)
94
+ end
95
+ end
96
+
97
+ end
98
+
99
+ if output.is_a? Array
100
+ list(output, :space)
101
+ else
102
+ identifier(output)
103
+ end
104
+ end
105
+
106
+ def output_data(path, ext)
107
+ data = [read_file(File.expand_path(path))].pack('m').gsub(/\s/, '')
108
+ "url(data:#{MIME_TYPES[ext]};base64,#{data})"
109
+ end
110
+
111
+ def output_path(path, ext, query, anchor, ts)
112
+ query += sign(query) + ts unless ts.nil?
113
+
114
+ output = "url(#{path}#{query}#{anchor})"
115
+ return output unless FONT_TYPES.key? ext
116
+
117
+ [identifier(output), identifier("format('#{FONT_TYPES[ext]}')")]
118
+ end
119
+
120
+ end
@@ -0,0 +1,13 @@
1
+ $app-config: () !default;
2
+ $browser-supports: parse-rules('last 1 version') !default;
3
+
4
+ @import 'mixins/clearfix';
5
+ @import 'mixins/ellipsis-overflow';
6
+ @import 'mixins/float';
7
+ @import 'mixins/font-face';
8
+ @import 'mixins/inline-block';
9
+ @import 'mixins/placeholder-wrapper';
10
+
11
+ @import 'functions/list';
12
+ @import 'functions/map';
13
+ @import 'functions/support';
@@ -0,0 +1,27 @@
1
+ @function comma-list($list: ()) {
2
+ @return join((), $list, comma);
3
+ }
4
+
5
+
6
+ @function slice($list, $min: 1, $max: length($list)) {
7
+ $output: comma-list();
8
+ $length: length($list);
9
+
10
+ @if $max < 0 {
11
+ $max: $length + $max + 1;
12
+ }
13
+
14
+ @if $max > $length {
15
+ $max: $length;
16
+ }
17
+
18
+ @if $min >= 1 and $min <= $length and
19
+ $max >= 1 and $max <= $length and
20
+ $min <= $max {
21
+ @for $i from $min through $max {
22
+ $output: append($output, nth($list, $i));
23
+ }
24
+ }
25
+
26
+ @return $output;
27
+ }
@@ -7,7 +7,7 @@
7
7
  // => ( a: (x: 'x', y: 'y') )
8
8
  @function map-deep-merge($map, $sub-map) {
9
9
  @if type-of($map) != map or type-of($sub-map) != map {
10
- @warn 'Params for `map-deep-merge` require map data.';
10
+ @warn 'Params for `map-deep-merge` require map data';
11
11
  @return null;
12
12
  }
13
13
 
@@ -1,21 +1,14 @@
1
- // Check whether the $prefix is supported according to the supported browsers.
2
- @function support-prefix($prefix) {
3
- $index: index(browser-prefixes($supported-browsers), $prefix);
4
- @return $index != null and $index != false;
5
- }
6
-
7
- // Check whether the $browser is supported according to the supported browsers,
8
- // only declared minimum support (overwrite Compass).
9
- @function support-legacy-browser($browser, $min-version, $max-version: null, $threshold: null) {
10
- @if not index($supported-browsers, $browser) {
11
- @return false;
1
+ // Examples:
2
+ // support-browser(ios)
3
+ // support-browser(ie 8)
4
+ @function support-browser($args) {
5
+ @if length($args) == 1 {
6
+ @return map-has-key($browser-supports, to-lower-case($args));
12
7
  }
13
-
14
- $min-required-version: map-get($browser-minimum-versions, $browser);
15
-
16
- @if not $min-required-version {
17
- @return true;
8
+ @else {
9
+ @return not not index(
10
+ map-get($browser-supports, to-lower-case(nth($args, 1))),
11
+ nth($args, 2)
12
+ );
18
13
  }
19
-
20
- @return compare-browser-versions($browser, '#{$max-version or $min-version}', $min-required-version) >= 0;
21
14
  }
@@ -0,0 +1,19 @@
1
+ @mixin clearfix {
2
+ $colon: unquote(if(support-browser(ie 8), ':', '::')) !global;
3
+
4
+ @include placeholder-wrapper('clearfix') {
5
+ &#{$colon}before,
6
+ &#{$colon}after {
7
+ content: '\20';
8
+ display: table;
9
+ }
10
+
11
+ &#{$colon}after {
12
+ clear: both;
13
+ }
14
+
15
+ @if support-browser(ie 7) {
16
+ *zoom: 1;
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,7 @@
1
+ @mixin ellipsis-overflow {
2
+ @include placeholder-wrapper('ellipsis-overflow') {
3
+ overflow: hidden;
4
+ text-overflow: ellipsis;
5
+ white-space: nowrap;
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ @mixin float($side, $important: false) {
2
+ $flag: if($important, ' !important', '');
3
+
4
+ float: unquote($side) + $flag;
5
+ @if support-browser(ie 6) {
6
+ _display: inline + $flag;
7
+ }
8
+ }
@@ -0,0 +1,20 @@
1
+ @mixin font-face($font-family, $paths...) {
2
+ $ie9-url: null;
3
+
4
+ @if support-browser(ie 9) {
5
+ @each $path in $paths {
6
+ @if str-index($path, '.eot') {
7
+ $i: str-index($path, '#');
8
+ $end: if($i, $i - 1, str-length($path));
9
+ $ie9-url: nth(nth(url(str-slice($path, 1, $end)), 1), 1);
10
+ }
11
+ }
12
+ }
13
+
14
+ @font-face {
15
+ font-family: $font-family;
16
+ @content;
17
+ src: $ie9-url;
18
+ src: url($paths);
19
+ }
20
+ }
@@ -0,0 +1,8 @@
1
+ @mixin inline-block {
2
+ display: inline-block;
3
+
4
+ @if support-browser(ie 7) {
5
+ *display: inline;
6
+ *zoom: 1;
7
+ }
8
+ }
@@ -0,0 +1,14 @@
1
+ $-registered-placeholders: ();
2
+
3
+ @mixin placeholder-wrapper($name) {
4
+ $times: map-get($-registered-placeholders, $name) or 0;
5
+
6
+ @if $times == 0 {
7
+ @at-root %-#{$name} {
8
+ @content;
9
+ }
10
+ }
11
+
12
+ @extend %-#{$name};
13
+ $-registered-placeholders: map-merge($-registered-placeholders, ($name: $times + 1)) !global;
14
+ }
metadata CHANGED
@@ -1,66 +1,62 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base.sass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
- - junjun.zhang <http://MrZhang.me>
7
+ - junjun.zhang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-20 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.3.5
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.5
27
- - !ruby/object:Gem::Dependency
28
- name: compass
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
19
+ version: '3.3'
20
+ - - "<"
32
21
  - !ruby/object:Gem::Version
33
- version: 1.0.0.alpha
22
+ version: '3.5'
34
23
  type: :runtime
35
24
  prerelease: false
36
25
  version_requirements: !ruby/object:Gem::Requirement
37
26
  requirements:
38
- - - "~>"
27
+ - - ">="
39
28
  - !ruby/object:Gem::Version
40
- version: 1.0.0.alpha
41
- description:
42
- email:
29
+ version: '3.3'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.5'
33
+ description: A lot of powerful Sass functions.
34
+ email: i@mrzhang.me
43
35
  executables: []
44
36
  extensions: []
45
37
  extra_rdoc_files: []
46
38
  files:
39
+ - data/browsers.json
47
40
  - lib/base.sass.rb
48
- - stylesheets/_base.functions.scss
49
- - stylesheets/_base.resets.scss
50
- - stylesheets/base.sass/_settings.scss
51
- - stylesheets/base.sass/functions/_clearfix.scss
52
- - stylesheets/base.sass/functions/_compass-hacker.scss
53
- - stylesheets/base.sass/functions/_ellipsis-overflow.scss
54
- - stylesheets/base.sass/functions/_fixed-position.scss
55
- - stylesheets/base.sass/functions/_float.scss
56
- - stylesheets/base.sass/functions/_font-face.scss
57
- - stylesheets/base.sass/functions/_img-retina.scss
41
+ - lib/base.sass/caniuse.rb
42
+ - lib/base.sass/env.rb
43
+ - lib/base.sass/parse-json.rb
44
+ - lib/base.sass/ruby-to-sass.rb
45
+ - lib/base.sass/sass-to-ruby.rb
46
+ - lib/base.sass/selector.rb
47
+ - lib/base.sass/strftime.rb
48
+ - lib/base.sass/support.rb
49
+ - lib/base.sass/url.rb
50
+ - stylesheets/base.sass/_*.scss
51
+ - stylesheets/base.sass/functions/_list.scss
58
52
  - stylesheets/base.sass/functions/_map.scss
59
53
  - stylesheets/base.sass/functions/_support.scss
60
- - stylesheets/base.sass/resets/_basic.scss
61
- - stylesheets/base.sass/resets/_button-and-input.scss
62
- - stylesheets/base.sass/resets/_html5-tag.scss
63
- - stylesheets/base.sass/resets/_small-label.scss
54
+ - stylesheets/base.sass/mixins/_clearfix.scss
55
+ - stylesheets/base.sass/mixins/_ellipsis-overflow.scss
56
+ - stylesheets/base.sass/mixins/_float.scss
57
+ - stylesheets/base.sass/mixins/_font-face.scss
58
+ - stylesheets/base.sass/mixins/_inline-block.scss
59
+ - stylesheets/base.sass/mixins/_placeholder-wrapper.scss
64
60
  homepage: https://github.com/jsw0528/base.sass
65
61
  licenses:
66
62
  - MIT
@@ -73,7 +69,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
69
  requirements:
74
70
  - - ">="
75
71
  - !ruby/object:Gem::Version
76
- version: '0'
72
+ version: '1.9'
77
73
  required_rubygems_version: !ruby/object:Gem::Requirement
78
74
  requirements:
79
75
  - - ">="
@@ -84,5 +80,5 @@ rubyforge_project:
84
80
  rubygems_version: 2.2.0
85
81
  signing_key:
86
82
  specification_version: 4
87
- summary: The beginning of your stylesheets
83
+ summary: The beginning of your stylesheets.
88
84
  test_files: []
@@ -1,15 +0,0 @@
1
- @import 'base.sass/settings';
2
-
3
- @import 'compass/css3';
4
- @import 'compass/css3/selection';
5
- @import 'compass/reset/utilities'; // Only use reset-font, reset-list-style, reset-table and reset-html5
6
- @import 'base.sass/functions/compass-hacker';
7
-
8
- @import 'base.sass/functions/clearfix';
9
- @import 'base.sass/functions/ellipsis-overflow';
10
- @import 'base.sass/functions/fixed-position';
11
- @import 'base.sass/functions/float';
12
- @import 'base.sass/functions/font-face';
13
- @import 'base.sass/functions/img-retina';
14
- @import 'base.sass/functions/map';
15
- @import 'base.sass/functions/support';
@@ -1,4 +0,0 @@
1
- @import 'base.sass/resets/basic';
2
- @import 'base.sass/resets/button-and-input';
3
- @import 'base.sass/resets/html5-tag';
4
- @import 'base.sass/resets/small-label';
@@ -1,29 +0,0 @@
1
- $font-family-base: Helvetica Neue, Helvetica, STHeiTi, sans-serif !default;
2
-
3
- $font-size-base: 14px !default;
4
-
5
- $line-height-base: 1.5 !default;
6
-
7
- $text-color: #333 !default;
8
-
9
- $body-bg-color: null !default;
10
-
11
- $input-placeholder-color: #999 !default;
12
-
13
- $selection-colors: (
14
- // text: defaults to contrast-color(background),
15
- background: null
16
- ) !default;
17
-
18
- $link-status: (
19
- link: (
20
- color: #428bca,
21
- line: none
22
- ),
23
- hover: (
24
- // color: defaults to darken(link.color, 15%),
25
- line: underline
26
- )
27
- ) !default;
28
-
29
- $pseudo-element-colon: unquote(if(support-legacy-browser(ie, 8), ':', '::'));
@@ -1,25 +0,0 @@
1
- @mixin clearfix {
2
- // Only register once
3
- @if not global-variable-exists(-clearfix-exists) {
4
- @at-root %clearfix {
5
- &#{$pseudo-element-colon}before,
6
- &#{$pseudo-element-colon}after {
7
- content: '\20';
8
- display: table;
9
- }
10
-
11
- &#{$pseudo-element-colon}after {
12
- clear: both;
13
- }
14
-
15
- @if support-legacy-browser(ie, 7) {
16
- *zoom: 1;
17
- }
18
- }
19
-
20
- // Mark
21
- $-clearfix-exists: true !global;
22
- }
23
-
24
- @extend %clearfix;
25
- }
@@ -1,18 +0,0 @@
1
- // Override `compass/css3/appearance`
2
- @mixin appearance($appearance) {
3
- @each $prefix in -webkit, -moz {
4
- @if support-prefix($prefix) {
5
- @include prefix-prop(appearance, $appearance, $prefix);
6
- }
7
- }
8
- }
9
-
10
- // Override `compass/css3/inline-block`
11
- @mixin inline-block {
12
- display: inline-block;
13
-
14
- @if support-legacy-browser(ie, 7) {
15
- *display: inline;
16
- *zoom: 1;
17
- }
18
- }
@@ -1,15 +0,0 @@
1
- @mixin ellipsis-overflow {
2
- // Only register once
3
- @if not global-variable-exists(-ellipsis-overflow-exists) {
4
- @at-root %ellipsis-overflow {
5
- overflow: hidden;
6
- text-overflow: ellipsis;
7
- white-space: nowrap;
8
- }
9
-
10
- // Mark
11
- $-ellipsis-overflow-exists: true !global;
12
- }
13
-
14
- @extend %ellipsis-overflow;
15
- }
@@ -1,31 +0,0 @@
1
- @mixin fixed-position($x: center, $y: center) {
2
- $map: (
3
- x: (
4
- left: 0,
5
- right: 0,
6
- center: 50%
7
- ),
8
- y: (
9
- top: 0,
10
- bottom: 0,
11
- center: 50%
12
- )
13
- );
14
-
15
- position: fixed;
16
-
17
- #{if($x == right, right, left)}: map-find($map, 'x.#{$x}') or $x;
18
- #{if($y == bottom, bottom, top)}: map-find($map, 'y.#{$y}') or $y;
19
-
20
- @if $x == center or $y == center {
21
- @include translate(-to-number($x), -to-number($y));
22
- }
23
-
24
- @content;
25
- }
26
-
27
-
28
- // === Pivate (start with hyphen) ===
29
- @function -to-number($s) {
30
- @return if($s == center, -50%, 0);
31
- }
@@ -1,7 +0,0 @@
1
- @mixin float($side, $important: false) {
2
- float: unquote($side + if($important, ' !important', ''));
3
-
4
- @if support-legacy-browser(ie, 6) {
5
- _display: inline;
6
- }
7
- }
@@ -1,70 +0,0 @@
1
- // Override `compass/css3/font-face`
2
- // Browsers support data: http://caniuse.com/fontface
3
- @mixin font-face($filename, $font-family: $filename, $path: null) {
4
- @if not at-stylesheet-root() {
5
- @warn 'include font-face mixin from the root level of your stylesheet.';
6
- }
7
-
8
- $prefix: '#{$filename}';
9
- $ts: if(is-absolute($path), '?' + timestamp(), '');
10
-
11
- @if type-of($path) == string {
12
- @if str-slice($path, str-length($path)) != '/' {
13
- $path: $path + '/';
14
- }
15
-
16
- $prefix: $path + $prefix;
17
- }
18
-
19
- @font-face {
20
- font-family: '#{$font-family}';
21
-
22
- // IE9 compat mode
23
- @if support-legacy-browser(ie, 9) {
24
- src: font-url($prefix + '.eot' + $ts);
25
- }
26
- src: -combo-font-urls($prefix, $ts);
27
-
28
- @content;
29
- }
30
- }
31
-
32
- // Check whether the $path is start with either `/` or `http`.
33
- @function is-absolute($path) {
34
- $path: '#{$path}';
35
- @return str-slice($path, 0, 1) == '/' or str-slice($path, 0, 4) == 'http';
36
- }
37
-
38
- @function timestamp() {
39
- @return current-time('%Y%m%d%H%M%S');
40
- }
41
-
42
-
43
- // === Pivate (start with hyphen) ===
44
- @function -combo-font-urls($prefix, $timestamp) {
45
- $src: comma-list();
46
-
47
- @if support-legacy-browser(ie, 8) {
48
- $src: append($src, font-files($prefix + '.eot' + $timestamp + '#iefix'));
49
- }
50
-
51
- // Modern browsers
52
- $src: append($src, font-files($prefix + '.woff' + $timestamp));
53
-
54
- @if support-legacy-browser(ios-safari, '4.2-4.3') or
55
- support-legacy-browser(android, '4.2-4.3') or
56
- support-legacy-browser(safari, 5) or
57
- support-legacy-browser(opera, 11)
58
- {
59
- $src: append($src, font-files($prefix + '.ttf' + $timestamp));
60
- }
61
-
62
- @if support-legacy-browser(ios-safari, '4.0-4.1') or
63
- support-legacy-browser(android, 2.3) or
64
- index($supported-browsers, opera-mini)
65
- {
66
- $src: append($src, font-files($prefix + '.svg' + $timestamp + '#legacy'));
67
- }
68
-
69
- @return $src;
70
- }
@@ -1,27 +0,0 @@
1
- // Short retina mixin for setting `background-image` and `background-size`.
2
- @mixin img-retina($img-1x, $img-2x, $bg-size: $default-background-size) {
3
- background-image: image-url($img-1x);
4
-
5
- $vendor: comma-list();
6
- @include with-each-prefix(background-img-opts, $background-size-threshold) {
7
- @if $current-prefix == -webkit { $vendor: append($vendor, -vendor(-webkit-min, '2')); }
8
- @if $current-prefix == -moz { $vendor: append($vendor, -vendor(min--moz, '2')); }
9
- @if $current-prefix == -o { $vendor: append($vendor, -vendor(-o-min, '2/1')); }
10
- @if $current-prefix == null { $vendor: append($vendor, -vendor(min, '2')); }
11
- }
12
-
13
- @media #{$vendor},
14
- only screen and (min-resolution: 192dpi),
15
- only screen and (min-resolution: 2dppx) {
16
- background: {
17
- image: image-url($img-2x);
18
- size: unquote($bg-size);
19
- }
20
- }
21
- }
22
-
23
-
24
- // === Pivate (start with hyphen) ===
25
- @function -vendor($prefix, $ratio) {
26
- @return unquote('only screen and (#{$prefix}-device-pixel-ratio: #{$ratio})');
27
- }
@@ -1,67 +0,0 @@
1
- * {
2
- margin: 0;
3
- padding: 0;
4
-
5
- @if support-prefix(-webkit) {
6
- -webkit-tap-highlight-color: rgba(#fff, 0);
7
- }
8
-
9
- $selection-text-color: map-get($selection-colors, text);
10
- $selection-bg-color: map-get($selection-colors, background);
11
-
12
- @if $selection-text-color != null {
13
- @include selection($selection-bg-color, $selection-text-color) {
14
- text-shadow: none;
15
- }
16
- }
17
- @else if $selection-bg-color != null {
18
- @include selection($selection-bg-color) {
19
- text-shadow: none;
20
- }
21
- }
22
- }
23
-
24
- html {
25
- @if support-prefix(-webkit) {
26
- -webkit-overflow-scrolling: touch;
27
- -webkit-text-size-adjust: 100%;
28
- }
29
-
30
- @if index($supported-browsers, ie-mobile) {
31
- -ms-text-size-adjust: 100%;
32
- }
33
- }
34
-
35
- body {
36
- background-color: $body-bg-color;
37
- color: $text-color;
38
- font: unquote($font-size-base + '/' + $line-height-base) $font-family-base;
39
- }
40
-
41
- a {
42
- color: map-find($link-status, 'link.color');
43
- text-decoration: map-find($link-status, 'link.line');
44
-
45
- &:hover {
46
- color: map-find($link-status, 'hover.color')
47
- or
48
- darken(map-find($link-status, 'link.color'), 15%);
49
- text-decoration: map-find($link-status, 'hover.line');
50
- }
51
- }
52
-
53
- em {
54
- font-style: normal;
55
- }
56
-
57
- img {
58
- border: 0;
59
- }
60
-
61
- ol, ul {
62
- @include reset-list-style;
63
- }
64
-
65
- table {
66
- @include reset-table;
67
- }
@@ -1,41 +0,0 @@
1
- button, input, textarea, select {
2
- @include reset-font;
3
- }
4
-
5
- button, input {
6
- @if support-prefix(-moz) {
7
- &::-moz-focus-inner {
8
- padding: 0;
9
- border: 0;
10
- }
11
- }
12
- }
13
-
14
- button, html input[type='button'], input[type='reset'], input[type='submit'] {
15
- cursor: pointer;
16
-
17
- @if index($supported-browsers, ios-safari) {
18
- -webkit-appearance: button;
19
- }
20
-
21
- @if support-legacy-browser(ie, 7) {
22
- *overflow: visible;
23
- }
24
- }
25
-
26
- input[type='search'] {
27
- @include appearance(textfield);
28
- @include box-sizing(content-box);
29
-
30
- @if support-prefix(-webkit) {
31
- &::-webkit-search-decoration {
32
- -webkit-appearance: none;
33
- }
34
- }
35
- }
36
-
37
- #{elements-of-type(text-input)} {
38
- @include input-placeholder {
39
- color: $input-placeholder-color;
40
- }
41
- }
@@ -1,7 +0,0 @@
1
- audio, video, canvas {
2
- @include inline-block;
3
- }
4
-
5
- @if support-legacy-browser(ie, 6, 8) {
6
- @include reset-html5;
7
- }
@@ -1,16 +0,0 @@
1
- sub, sup {
2
- position: relative;
3
- font-size: 75%;
4
- line-height: 0;
5
- vertical-align: baseline;
6
- }
7
- sub {
8
- bottom: -0.25em;
9
- }
10
- sup {
11
- top: -0.5em;
12
- }
13
-
14
- small {
15
- font-size: 80%;
16
- }