archetype 0.0.1.pre.13 → 1.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (253) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +97 -24
  3. data/README.md +11 -5
  4. data/VERSION +1 -0
  5. data/lib/archetype.rb +30 -18
  6. data/lib/archetype/actions/migrate.rb +152 -0
  7. data/lib/archetype/actions/theme.rb +6 -7
  8. data/lib/archetype/executor.rb +21 -7
  9. data/lib/archetype/extensions.rb +57 -0
  10. data/lib/archetype/functions.rb +2 -3
  11. data/lib/archetype/functions/css.rb +70 -0
  12. data/lib/archetype/functions/css/constants.rb +247 -0
  13. data/lib/archetype/functions/css/helpers.rb +265 -0
  14. data/lib/archetype/functions/css/routers.rb +28 -0
  15. data/lib/archetype/functions/css/routers/animation.rb +55 -0
  16. data/lib/archetype/functions/css/routers/background.rb +38 -0
  17. data/lib/archetype/functions/css/routers/border.rb +151 -0
  18. data/lib/archetype/functions/css/routers/list.rb +63 -0
  19. data/lib/archetype/functions/css/routers/margin_padding.rb +40 -0
  20. data/lib/archetype/functions/css/routers/outline.rb +56 -0
  21. data/lib/archetype/functions/css/routers/overflow.rb +11 -0
  22. data/lib/archetype/functions/css/routers/target.rb +38 -0
  23. data/lib/archetype/functions/css/routers/transition.rb +48 -0
  24. data/lib/archetype/functions/css/shorthands.rb +43 -0
  25. data/lib/archetype/functions/css/shorthands/animation.rb +18 -0
  26. data/lib/archetype/functions/css/shorthands/background.rb +68 -0
  27. data/lib/archetype/functions/css/shorthands/border.rb +102 -0
  28. data/lib/archetype/functions/hash.rb +3 -149
  29. data/lib/archetype/functions/hash/extend.rb +74 -0
  30. data/lib/archetype/functions/hash/shim.rb +48 -0
  31. data/lib/archetype/functions/helpers.rb +231 -22
  32. data/lib/archetype/functions/styleguide_memoizer.rb +18 -1
  33. data/lib/archetype/sass_extensions.rb +1 -3
  34. data/lib/archetype/sass_extensions/functions.rb +15 -1
  35. data/lib/archetype/sass_extensions/functions/environment.rb +152 -1
  36. data/lib/archetype/sass_extensions/functions/lists.rb +95 -45
  37. data/lib/archetype/sass_extensions/functions/locale.rb +107 -28
  38. data/lib/archetype/sass_extensions/functions/numbers.rb +118 -4
  39. data/lib/archetype/sass_extensions/functions/strings.rb +53 -0
  40. data/lib/archetype/sass_extensions/functions/styleguide.rb +43 -375
  41. data/lib/archetype/sass_extensions/functions/styleguide/components.rb +25 -0
  42. data/lib/archetype/sass_extensions/functions/styleguide/constants.rb +27 -0
  43. data/lib/archetype/sass_extensions/functions/styleguide/grammar.rb +80 -0
  44. data/lib/archetype/sass_extensions/functions/styleguide/helpers.rb +36 -0
  45. data/lib/archetype/sass_extensions/functions/styleguide/resolve.rb +159 -0
  46. data/lib/archetype/sass_extensions/functions/styleguide/styles.rb +146 -0
  47. data/lib/archetype/sass_extensions/functions/styleguide/themes.rb +40 -0
  48. data/lib/archetype/sass_extensions/functions/ui.rb +7 -57
  49. data/lib/archetype/sass_extensions/functions/ui/glyphs.rb +118 -0
  50. data/lib/archetype/sass_extensions/functions/ui/scopes.rb +96 -0
  51. data/lib/archetype/sass_extensions/functions/util.rb +14 -0
  52. data/lib/archetype/sass_extensions/functions/util/debug.rb +22 -0
  53. data/lib/archetype/sass_extensions/functions/util/hacks.rb +44 -0
  54. data/lib/archetype/sass_extensions/functions/util/images.rb +132 -0
  55. data/lib/archetype/sass_extensions/functions/util/misc.rb +220 -0
  56. data/lib/archetype/sass_extensions/functions/util/spacing.rb +83 -0
  57. data/lib/archetype/sass_extensions/functions/version.rb +12 -17
  58. data/lib/archetype/version.rb +1 -1
  59. data/stylesheets/archetype/_config.scss +1 -389
  60. data/stylesheets/archetype/_core.scss +15 -0
  61. data/stylesheets/archetype/_hacks.scss +4 -120
  62. data/stylesheets/archetype/_init.scss +4 -22
  63. data/stylesheets/archetype/_required.scss +3 -0
  64. data/stylesheets/archetype/_reset.scss +3 -0
  65. data/stylesheets/archetype/_styleguide.scss +2 -6
  66. data/stylesheets/archetype/_ui.scss +2 -358
  67. data/stylesheets/archetype/_util.scss +3 -10
  68. data/stylesheets/archetype/config/_core.scss +14 -0
  69. data/stylesheets/archetype/config/_environment.scss +19 -0
  70. data/stylesheets/archetype/config/_formatting.scss +63 -0
  71. data/stylesheets/archetype/config/_glyphs.scss +252 -0
  72. data/stylesheets/archetype/config/_resets.scss +7 -0
  73. data/stylesheets/archetype/config/_resolution.scss +3 -0
  74. data/stylesheets/archetype/config/_spacing.scss +5 -0
  75. data/stylesheets/archetype/config/_targeting.scss +18 -0
  76. data/stylesheets/archetype/config/_theme.scss +3 -0
  77. data/stylesheets/archetype/config/_typography.scss +56 -0
  78. data/stylesheets/archetype/config/_units.scss +2 -0
  79. data/stylesheets/archetype/config/_vars.scss +10 -0
  80. data/stylesheets/archetype/hacks/_core.scss +4 -0
  81. data/stylesheets/archetype/hacks/_hacks.scss +160 -0
  82. data/stylesheets/archetype/hacks/_init.scss +2 -0
  83. data/stylesheets/archetype/styleguide/_core.scss +4 -0
  84. data/stylesheets/archetype/styleguide/_init.scss +1 -0
  85. data/stylesheets/archetype/styleguide/_styleguide.scss +41 -18
  86. data/stylesheets/archetype/ui/_accessibility.scss +41 -0
  87. data/stylesheets/archetype/ui/_breakpoints.scss +19 -0
  88. data/stylesheets/archetype/ui/_core.scss +10 -0
  89. data/stylesheets/archetype/ui/_elements.scss +98 -0
  90. data/stylesheets/archetype/ui/_glyphs.scss +244 -0
  91. data/stylesheets/archetype/ui/_init.scss +5 -0
  92. data/stylesheets/archetype/ui/_layout.scss +37 -0
  93. data/stylesheets/archetype/ui/_locale.scss +12 -0
  94. data/stylesheets/archetype/ui/_scopes.scss +42 -0
  95. data/stylesheets/archetype/util/_core.scss +8 -0
  96. data/stylesheets/archetype/util/_debug.scss +9 -21
  97. data/stylesheets/archetype/util/_init.scss +1 -0
  98. data/stylesheets/archetype/util/_misc.scss +21 -86
  99. data/stylesheets/archetype/util/_spacing.scss +9 -40
  100. data/stylesheets/archetype/util/_styles.scss +189 -178
  101. data/stylesheets/archetype/util/_targeting.scss +51 -68
  102. data/templates/example/manifest.rb +2 -2
  103. data/templates/example/screen.scss +0 -1
  104. data/templates/project/manifest.rb +3 -8
  105. metadata +93 -263
  106. data/bin/archetype +0 -3
  107. data/lib/archetype/sass_extensions/monkey_patches.rb +0 -3
  108. data/lib/archetype/sass_extensions/monkey_patches/handle_include_loop.rb +0 -13
  109. data/stylesheets/archetype/_base.scss +0 -54
  110. data/stylesheets/archetype/_grid.scss +0 -3
  111. data/stylesheets/archetype/base/_h5bp.scss +0 -307
  112. data/stylesheets/archetype/base/_hybrid.scss +0 -25
  113. data/stylesheets/archetype/base/_normalize.scss +0 -634
  114. data/stylesheets/archetype/base/_reset.scss +0 -72
  115. data/stylesheets/archetype/grid/_config.scss +0 -14
  116. data/stylesheets/archetype/grid/_grid.scss +0 -391
  117. data/stylesheets/archetype/styleguide/_components.scss +0 -25
  118. data/stylesheets/archetype/styleguide/_helpers.scss +0 -215
  119. data/stylesheets/archetype/styleguide/_primitives.scss +0 -10
  120. data/stylesheets/archetype/styleguide/components/_alerts.scss +0 -59
  121. data/stylesheets/archetype/styleguide/components/_annotations.scss +0 -27
  122. data/stylesheets/archetype/styleguide/components/_bristol.scss +0 -15
  123. data/stylesheets/archetype/styleguide/components/_button_groups.scss +0 -47
  124. data/stylesheets/archetype/styleguide/components/_button_toolbars.scss +0 -17
  125. data/stylesheets/archetype/styleguide/components/_buttons.scss +0 -339
  126. data/stylesheets/archetype/styleguide/components/_canvas.scss +0 -15
  127. data/stylesheets/archetype/styleguide/components/_carets.scss +0 -336
  128. data/stylesheets/archetype/styleguide/components/_closes.scss +0 -63
  129. data/stylesheets/archetype/styleguide/components/_container.scss +0 -27
  130. data/stylesheets/archetype/styleguide/components/_copy.scss +0 -85
  131. data/stylesheets/archetype/styleguide/components/_flyouts.scss +0 -52
  132. data/stylesheets/archetype/styleguide/components/_headings.scss +0 -33
  133. data/stylesheets/archetype/styleguide/components/_headlines.scss +0 -64
  134. data/stylesheets/archetype/styleguide/components/_hovercards.scss +0 -27
  135. data/stylesheets/archetype/styleguide/components/_icons.scss +0 -17
  136. data/stylesheets/archetype/styleguide/components/_identities.scss +0 -34
  137. data/stylesheets/archetype/styleguide/components/_links.scss +0 -68
  138. data/stylesheets/archetype/styleguide/components/_loaders.scss +0 -154
  139. data/stylesheets/archetype/styleguide/components/_menu_items.scss +0 -31
  140. data/stylesheets/archetype/styleguide/components/_module.scss +0 -15
  141. data/stylesheets/archetype/styleguide/components/_pullquotes.scss +0 -29
  142. data/stylesheets/archetype/styleguide/components/_punchcut.scss +0 -18
  143. data/stylesheets/archetype/styleguide/components/_tooltips.scss +0 -28
  144. data/stylesheets/archetype/styleguide/primitives/_animations.scss +0 -17
  145. data/stylesheets/archetype/styleguide/primitives/_dimensions.scss +0 -50
  146. data/stylesheets/archetype/styleguide/primitives/_glyphs.scss +0 -11
  147. data/stylesheets/archetype/styleguide/primitives/_misc.scss +0 -8
  148. data/stylesheets/archetype/styleguide/primitives/_palettes.scss +0 -94
  149. data/stylesheets/archetype/styleguide/primitives/_shadows.scss +0 -23
  150. data/stylesheets/archetype/styleguide/primitives/_sprites.scss +0 -46
  151. data/stylesheets/archetype/styleguide/primitives/_textures.scss +0 -10
  152. data/stylesheets/archetype/styleguide/primitives/_typography.scss +0 -56
  153. data/stylesheets/archetype/util/_lists.scss +0 -57
  154. data/stylesheets/archetype/util/_rtl.scss +0 -279
  155. data/stylesheets/archetype/util/_units.scss +0 -18
  156. data/templates/project/screen.scss +0 -1
  157. data/templates/project/vendor/archetype/animations/loaders/large/large.png +0 -0
  158. data/templates/project/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
  159. data/templates/project/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
  160. data/templates/project/vendor/archetype/animations/loaders/large/large_static.png +0 -0
  161. data/templates/project/vendor/archetype/animations/loaders/medium/medium.png +0 -0
  162. data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
  163. data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
  164. data/templates/project/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
  165. data/templates/project/vendor/archetype/animations/loaders/small/small.png +0 -0
  166. data/templates/project/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
  167. data/templates/project/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
  168. data/templates/project/vendor/archetype/animations/loaders/small/small_static.png +0 -0
  169. data/templates/project/vendor/archetype/fontawesome-webfont.eot +0 -0
  170. data/templates/project/vendor/archetype/fontawesome-webfont.svg +0 -255
  171. data/templates/project/vendor/archetype/fontawesome-webfont.ttf +0 -0
  172. data/templates/project/vendor/archetype/fontawesome-webfont.woff +0 -0
  173. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.eot +0 -0
  174. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.svg +0 -255
  175. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.ttf +0 -0
  176. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.woff +0 -0
  177. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders-s7889ccc8c1.png +0 -0
  178. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large.png +0 -0
  179. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
  180. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
  181. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_static.png +0 -0
  182. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium.png +0 -0
  183. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
  184. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
  185. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
  186. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small.png +0 -0
  187. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
  188. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
  189. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_static.png +0 -0
  190. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/sprites/hovercard_tip.png +0 -0
  191. data/test/fixtures/stylesheets/archetype/config.rb +0 -21
  192. data/test/fixtures/stylesheets/archetype/source/b.scss +0 -9
  193. data/test/fixtures/stylesheets/archetype/source/base.scss +0 -3
  194. data/test/fixtures/stylesheets/archetype/source/hacks/ie_pseudo.scss +0 -13
  195. data/test/fixtures/stylesheets/archetype/source/hacks/transparent_focusable.scss +0 -5
  196. data/test/fixtures/stylesheets/archetype/source/locale.scss +0 -43
  197. data/test/fixtures/stylesheets/archetype/source/styleguide/alerts.scss +0 -21
  198. data/test/fixtures/stylesheets/archetype/source/styleguide/buttons.scss +0 -18
  199. data/test/fixtures/stylesheets/archetype/source/styleguide/drop.scss +0 -101
  200. data/test/fixtures/stylesheets/archetype/source/styleguide/extend.scss +0 -24
  201. data/test/fixtures/stylesheets/archetype/source/styleguide/fallback_styles.scss +0 -23
  202. data/test/fixtures/stylesheets/archetype/source/styleguide/invalid_structures.scss +0 -85
  203. data/test/fixtures/stylesheets/archetype/source/styleguide/multi_value.scss +0 -18
  204. data/test/fixtures/stylesheets/archetype/source/styleguide/nested_styleguides.scss +0 -40
  205. data/test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss +0 -22
  206. data/test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss +0 -35
  207. data/test/fixtures/stylesheets/archetype/source/ui/hide_element.scss +0 -5
  208. data/test/fixtures/stylesheets/archetype/source/ui/stroke.scss +0 -13
  209. data/test/fixtures/stylesheets/archetype/source/ui/triangle.scss +0 -13
  210. data/test/fixtures/stylesheets/archetype/source/utilities/associative.scss +0 -24
  211. data/test/fixtures/stylesheets/archetype/source/utilities/custom_output_styler.scss +0 -22
  212. data/test/fixtures/stylesheets/archetype/source/utilities/if-set.scss +0 -16
  213. data/test/fixtures/stylesheets/archetype/source/utilities/spacing/horizontal-spacing.scss +0 -27
  214. data/test/fixtures/stylesheets/archetype/source/utilities/spacing/vertical-spacing.scss +0 -27
  215. data/test/fixtures/stylesheets/archetype/source/utilities/styles/filter.scss +0 -9
  216. data/test/fixtures/stylesheets/archetype/source/utilities/styles/font-family.scss +0 -9
  217. data/test/fixtures/stylesheets/archetype/source/utilities/styles/z-index.scss +0 -18
  218. data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-browser.scss +0 -77
  219. data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-os.scss +0 -42
  220. data/test/fixtures/stylesheets/archetype/tmp/b.css +0 -14
  221. data/test/fixtures/stylesheets/archetype/tmp/base.css +0 -349
  222. data/test/fixtures/stylesheets/archetype/tmp/hacks/ie_pseudo.css +0 -11
  223. data/test/fixtures/stylesheets/archetype/tmp/hacks/transparent_focusable.css +0 -4
  224. data/test/fixtures/stylesheets/archetype/tmp/locale.css +0 -23
  225. data/test/fixtures/stylesheets/archetype/tmp/styleguide/alerts.css +0 -711
  226. data/test/fixtures/stylesheets/archetype/tmp/styleguide/buttons.css +0 -2119
  227. data/test/fixtures/stylesheets/archetype/tmp/styleguide/drop.css +0 -63
  228. data/test/fixtures/stylesheets/archetype/tmp/styleguide/extend.css +0 -11
  229. data/test/fixtures/stylesheets/archetype/tmp/styleguide/fallback_styles.css +0 -10
  230. data/test/fixtures/stylesheets/archetype/tmp/styleguide/invalid_structures.css +0 -21
  231. data/test/fixtures/stylesheets/archetype/tmp/styleguide/multi_value.css +0 -13
  232. data/test/fixtures/stylesheets/archetype/tmp/styleguide/nested_styleguides.css +0 -28
  233. data/test/fixtures/stylesheets/archetype/tmp/styleguide/selective_state.css +0 -177
  234. data/test/fixtures/stylesheets/archetype/tmp/ui/glyph_icon.css +0 -127
  235. data/test/fixtures/stylesheets/archetype/tmp/ui/hide_element.css +0 -8
  236. data/test/fixtures/stylesheets/archetype/tmp/ui/stroke.css +0 -17
  237. data/test/fixtures/stylesheets/archetype/tmp/ui/triangle.css +0 -35
  238. data/test/fixtures/stylesheets/archetype/tmp/utilities/associative.css +0 -9
  239. data/test/fixtures/stylesheets/archetype/tmp/utilities/custom_output_styler.css +0 -8
  240. data/test/fixtures/stylesheets/archetype/tmp/utilities/if-set.css +0 -9
  241. data/test/fixtures/stylesheets/archetype/tmp/utilities/spacing/horizontal-spacing.css +0 -29
  242. data/test/fixtures/stylesheets/archetype/tmp/utilities/spacing/vertical-spacing.css +0 -29
  243. data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/filter.css +0 -11
  244. data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/font-family.css +0 -16
  245. data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/z-index.css +0 -15
  246. data/test/fixtures/stylesheets/archetype/tmp/utilities/targeting/target-browser.css +0 -105
  247. data/test/fixtures/stylesheets/archetype/tmp/utilities/targeting/target-os.css +0 -55
  248. data/test/helpers/diff.rb +0 -49
  249. data/test/helpers/io.rb +0 -36
  250. data/test/helpers/test_case.rb +0 -62
  251. data/test/integrations/archetype_test.rb +0 -126
  252. data/test/test_helper.rb +0 -26
  253. data/test/units/sass_extensions_test.rb +0 -200
@@ -0,0 +1,63 @@
1
+ module Archetype::Functions::CSS
2
+
3
+ private
4
+
5
+ #
6
+ # router for `list-style` properties
7
+ #
8
+ def self.get_derived_styles_router_for_list(related, property)
9
+ properties = %w(style-type style-position style-image)
10
+ styles, reconstruct = with_each_available_relative_if_root(related, property) do |items, comma_separated|
11
+ styles = ::Archetype::Hash.new
12
+ if helpers.to_str(items) == 'inherit'
13
+ styles[:style_image] = styles[:style_type] = styles[:style_position] = items
14
+ else
15
+ items.reject! do |item|
16
+ case helpers.to_str(item)
17
+ when /^(?:armenian|circle|cjk-ideographic|decimal(?:-leading-zero)?|disc|georgian|hebrew|(?:hiragana|katakana)(?:-iroha)?|(?:lower|upper)-(?:alpha|greek|latin|roman)|square)$/
18
+ styles[:style_type] = item
19
+ when /^(?:inside|outside)$/
20
+ styles[:style_position] = item
21
+ when /^url\(.*\)$/
22
+ styles[:style_image] = item
23
+ else
24
+ next
25
+ end
26
+ true
27
+ end
28
+
29
+ items.each do |item|
30
+ case helpers.to_str(item)
31
+ when 'none'
32
+ if styles[:style_type].nil?
33
+ styles[:style_type] = item
34
+ else
35
+ styles[:style_image] ||= item
36
+ end
37
+ when 'inherit'
38
+ if styles[:style_type].nil?
39
+ styles[:style_type] = item
40
+ elsif styles[:style_type].nil?
41
+ styles[:style_position] = item
42
+ else
43
+ styles[:style_image] ||= item
44
+ end
45
+ end
46
+ end
47
+ end
48
+ styles
49
+ end
50
+
51
+ if reconstruct
52
+ return nil if styles.nil? or styles.empty?
53
+ styles = set_default_styles(styles, 'list', properties)
54
+ value = [styles[:style_type], styles[:style_position], styles[:style_image]]
55
+ # we simplify it if the values are all identical
56
+ return value.first if value.uniq.length == 1
57
+ return Sass::Script::Value::List.new(value, :space)
58
+ end
59
+
60
+ # otherwise just return the value we were asked for
61
+ return styles
62
+ end
63
+ end
@@ -0,0 +1,40 @@
1
+ module Archetype::Functions::CSS
2
+
3
+ private
4
+
5
+ #
6
+ # router for `margin` properties
7
+ #
8
+ def self.get_derived_styles_router_for_margin(related, property)
9
+ return get_derived_styles_router_for_margin_padding(related, property)
10
+ end
11
+
12
+ #
13
+ # router for `padding` properties
14
+ #
15
+ def self.get_derived_styles_router_for_padding(related, property)
16
+ return get_derived_styles_router_for_margin_padding(related, property)
17
+ end
18
+
19
+ #
20
+ # (real) router for both `margin` and `padding` properties
21
+ #
22
+ def self.get_derived_styles_router_for_margin_padding(related, property)
23
+ styles, reconstruct = with_each_available_relative_if_root(related, property) do |items, comma_separated|
24
+ # blow away anything we've already discovered (because it's irrelevant)
25
+ # and extract the top/right/bottom/left values
26
+ # make the styles available to the calling context
27
+ extract_symmetical_values(items)
28
+ end
29
+ # if we're getting the shorthand property, reconstruct the shorthand value
30
+ if reconstruct
31
+ value = extrapolate_shorthand_symmetrical(styles)
32
+ # if the value came back nil, we were missing something, so throw a warning...
33
+ return warn_not_enough_infomation_to_derive(property) if value.nil?
34
+ return value
35
+ end
36
+
37
+ # otherwise just return the value we were asked for
38
+ return styles
39
+ end
40
+ end
@@ -0,0 +1,56 @@
1
+ module Archetype::Functions::CSS
2
+
3
+ private
4
+
5
+ #
6
+ # router for `outline` properties
7
+ #
8
+ def self.get_derived_styles_router_for_outline(related, property)
9
+ properties = %w(color style width)
10
+ styles, reconstruct = with_each_available_relative_if_root(related, property) do |items, comma_separated|
11
+ # blow away anything we've already discovered (because it's irrelevant)
12
+ styles = ::Archetype::Hash.new
13
+ items.reject! do |item|
14
+ if item.is_a?(Sass::Script::Value::Color)
15
+ styles[:color] = item
16
+ elsif item.is_a?(Sass::Script::Value::Number)
17
+ styles[:width] = item
18
+ else
19
+ case helpers.to_str(item)
20
+ when 'invert'
21
+ styles[:color] = item
22
+ when /^(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/
23
+ styles[:style] = item
24
+ when /^(?:thin|medium|thick)$/
25
+ styles[:width] = item
26
+ when 'inherit'
27
+ next
28
+ end
29
+ end
30
+ true
31
+ end
32
+ # at this point, we should only have `inherit` values left
33
+ items.each do |item|
34
+ if styles[:color].nil?
35
+ styles[:color] = item
36
+ elsif styles[:style].nil?
37
+ styles[:style] = item
38
+ else
39
+ styles[:width] ||= item
40
+ end
41
+ end
42
+ styles = set_default_styles(styles, 'outline', properties)
43
+ # make the styles available to the calling context
44
+ styles
45
+ end
46
+
47
+ if reconstruct
48
+ return nil if styles.nil? or styles.empty?
49
+ styles = set_default_styles(styles, 'outline', properties)
50
+ return Sass::Script::Value::List.new([styles[:color], styles[:style], styles[:width]], :space)
51
+ end
52
+
53
+ # otherwise just return the value we were asked for
54
+ return styles
55
+ end
56
+ end
@@ -0,0 +1,11 @@
1
+ module Archetype::Functions::CSS
2
+
3
+ private
4
+
5
+ #
6
+ # router for `overflow` properties
7
+ #
8
+ def self.get_derived_styles_router_for_overflow(related, property)
9
+ return is_root_property?(property) ? nil : filter_available_relatives(related, property).values.last
10
+ end
11
+ end
@@ -0,0 +1,38 @@
1
+ module Archetype::Functions::CSS
2
+
3
+ private
4
+
5
+ #
6
+ # router for `target` properties
7
+ #
8
+ def self.get_derived_styles_router_for_target(related, property)
9
+ properties = %w(name new position)
10
+ styles, reconstruct = with_each_available_relative_if_root(related, property) do |items, comma_separated|
11
+ # blow away anything we've already discovered (because it's irrelevant)
12
+ # target-name target-new target-position
13
+ styles = ::Archetype::Hash.new
14
+ styles[:name] = items.shift
15
+
16
+ items.each do |item|
17
+ case helpers.to_str(item)
18
+ when /^(?:window|tab|none)$/
19
+ styles[:new] = item
20
+ when /^(?:above|behind|front|back)$/
21
+ styles[:position] = item
22
+ end
23
+ end
24
+ # set defaults if we missed anything...
25
+ styles = set_default_styles(styles, 'target', properties)
26
+ # make the styles available to the calling context
27
+ styles
28
+ end
29
+ if reconstruct
30
+ return warn_not_enough_infomation_to_derive(property) if styles.nil? or styles[:name].nil?
31
+ value = extrapolate_shorthand_simple(styles, property, properties)
32
+ return Sass::Script::Value::List.new(value, :space)
33
+ end
34
+
35
+ # otherwise just return the value we were asked for
36
+ return styles
37
+ end
38
+ end
@@ -0,0 +1,48 @@
1
+ module Archetype::Functions::CSS
2
+
3
+ private
4
+
5
+ #
6
+ # router for `transition` properties
7
+ #
8
+ def self.get_derived_styles_router_for_transition(related, property)
9
+ properties = %w(property duration timing-function delay)
10
+ styles, reconstruct = with_each_available_relative_if_root(related, property) do |items, comma_separated|
11
+ # blow away anything we've already discovered (because it's irrelevant)
12
+ timings = get_timing_values(items)
13
+ items = items - timings
14
+ # property duration timing-function delay
15
+ styles = ::Archetype::Hash.new
16
+ styles[:duration] = timings.shift
17
+ styles[:delay] = timings.shift
18
+
19
+ items.reject! do |item|
20
+ case helpers.to_str(item)
21
+ when R_TIMING_FUNCTION
22
+ styles[:timing_function] = item
23
+ else
24
+ next
25
+ end
26
+ true
27
+ end
28
+
29
+ # set defaults if we missed anything...
30
+ styles[:property] = items.shift
31
+ styles = set_default_styles(styles, 'transition', properties)
32
+ # make the styles available to the calling context
33
+ styles
34
+ end
35
+
36
+ if reconstruct
37
+ if styles.nil? or styles[:property].nil?
38
+ return warn_not_enough_infomation_to_derive(property) if not styles.empty?
39
+ return nil
40
+ end
41
+ value = extrapolate_shorthand_simple(styles, property, properties)
42
+ return Sass::Script::Value::List.new(value, :space)
43
+ end
44
+
45
+ # otherwise just return the value we were asked for
46
+ return styles
47
+ end
48
+ end
@@ -0,0 +1,43 @@
1
+ module Archetype::Functions::CSS
2
+
3
+ private
4
+
5
+ #
6
+ # extrapolates shorthand value from a simple list of ordered properties
7
+ #
8
+ def self.extrapolate_shorthand_simple(styles, base, properties)
9
+ styles = set_default_styles(styles, base, properties)
10
+ value = []
11
+ properties.each { |k| value << styles[normalize_property_key(k, base)] }
12
+ return value
13
+ end
14
+
15
+ #
16
+ # extrapolates shorthand value for symmetrical properties
17
+ #
18
+ def self.extrapolate_shorthand_symmetrical(styles)
19
+ # make sure we have enough info to continue
20
+ return nil if styles.nil? or styles.length < 4
21
+ # can we use 3 values?
22
+ if styles[:left] == styles[:right]
23
+ # can we use 2 values?
24
+ if styles[:bottom] == styles[:top]
25
+ # can we use just 1 value?
26
+ if styles[:top] == styles[:right]
27
+ styles = [styles[:top]] # 1 value
28
+ else
29
+ styles = [styles[:top], styles[:right]] # 2 values
30
+ end
31
+ else
32
+ styles = [styles[:top], styles[:right], styles[:bottom]] # 3 values
33
+ end
34
+ else
35
+ styles = [styles[:top], styles[:right], styles[:bottom], styles[:left]] # 4 values
36
+ end
37
+ return Sass::Script::Value::List.new(styles, :space)
38
+ end
39
+ end
40
+
41
+ %w(animation background border).each do |shorthand|
42
+ require "archetype/functions/css/shorthands/#{shorthand}"
43
+ end
@@ -0,0 +1,18 @@
1
+ module Archetype::Functions::CSS
2
+
3
+ private
4
+
5
+ #
6
+ # extrapolates shorthand value for `animation` property
7
+ #
8
+ def self.extrapolate_shorthand_animation(styles)
9
+ # make sure we have enough info to continue
10
+ return nil if styles.nil? or styles[:name].nil?
11
+ shorthand = []
12
+ shorthand << styles[:name]
13
+ %w(duration timing-function delay iteration-count direction fill-mode play-state).each do |k|
14
+ shorthand << (styles[normalize_property_key(k, 'animation')] || default("animation-#{k}")).to_a.first
15
+ end
16
+ return Sass::Script::Value::List.new(shorthand, :space)
17
+ end
18
+ end
@@ -0,0 +1,68 @@
1
+ module Archetype::Functions::CSS
2
+
3
+ private
4
+
5
+ #
6
+ # deconstructs `background` shorthand property into it's longhand values
7
+ #
8
+ def self.deconstruct_shorthand_for_background(items, comma_separated, properties)
9
+ i = 0
10
+ # blow away anything we've already discovered (because it's irrelevant)
11
+ styles = ::Archetype::Hash.new
12
+ properties.each { |k| styles[k.to_sym] = [] }
13
+
14
+ (comma_separated ? items.to_a : [items]).each do |items|
15
+ items = items.to_a.dup if items.respond_to?(:to_a)
16
+ items.reject! do |item|
17
+ if item.is_a?(Sass::Script::Value::Color)
18
+ styles[:color] << item
19
+ else
20
+ case helpers.to_str(item)
21
+ when /^(?:(?:no-)?repeat(?:-[xy])?|inherit)$/
22
+ styles[:repeat] << item
23
+ # origin or clip
24
+ when /^(?:border|padding|content)-box$/
25
+ # if we already have an `origin`, then this is `clip`, otherwise it's `origin`
26
+ styles[styles[:origin][iteration].nil? ? :origin : :clip] << item
27
+ when /^(?:url\(.*\)|none)$/
28
+ # record multiple images if needed
29
+ styles[:image] << item
30
+ when /^(?:scroll|fixed|local)$/
31
+ styles[:attachment] << item
32
+ when /^(?:cover|contain)$/
33
+ styles[:size] << item
34
+ when /^(?:top|right|bottom|left|center)$/
35
+ styles[:position][i] ||= []
36
+ styles[:position][i] << item
37
+ else
38
+ next
39
+ end
40
+ end
41
+ true
42
+ end
43
+
44
+ # deal with the `position` and `size`, as they're order dependent...
45
+ items.each do |item|
46
+ if item.is_a?(Sass::Script::Value::Number) or helpers.to_str(item) == 'auto'
47
+ styles[:position][i] ||= []
48
+ if styles[:position][i].length < 2
49
+ styles[:position][i] << item
50
+ else
51
+ styles[:size][i] ||= []
52
+ styles[:size][i] = styles[:size][i].to_a
53
+ styles[:size][i] << item
54
+ end
55
+ end
56
+ end
57
+
58
+ [:position, :size].each do |k|
59
+ styles[k][i] = Sass::Script::List.new(styles[k][i], :space) if styles[k][i].is_a?(Array)
60
+ end
61
+
62
+ # ...
63
+ properties.each { |k| styles[k.to_sym] << default("background-#{k}") if styles[k.to_sym][i].nil?}
64
+ i += 1
65
+ end
66
+ return styles
67
+ end
68
+ end
@@ -0,0 +1,102 @@
1
+ module Archetype::Functions::CSS
2
+
3
+ private
4
+
5
+ #
6
+ # deconstructs `border` shorthand properties into it's longhand values
7
+ #
8
+ def self.deconstruct_shorthand_for_border(items, types)
9
+ tmp = ::Archetype::Hash.new
10
+ items.reject! do |item|
11
+ if item.is_a?(Sass::Script::Value::Number)
12
+ tmp[:width] = item
13
+ elsif item.is_a?(Sass::Script::Value::Color)
14
+ tmp[:color] = item
15
+ else
16
+ case helpers.to_str(item)
17
+ when /^(?:thin|medium|thick)$/
18
+ tmp[:width] = item
19
+ when /^(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/
20
+ tmp[:style] = item
21
+ else
22
+ next
23
+ end
24
+ end
25
+ true
26
+ end
27
+ items.each do |item|
28
+ if helpers.to_str(item) == 'inherit'
29
+ if tmp[:width].nil?
30
+ tmp[:width] = item
31
+ elsif tmp[:style].nil?
32
+ tmp[:style] = item
33
+ else
34
+ tmp[:color] ||= item
35
+ end
36
+ end
37
+ end
38
+ return set_default_styles(tmp, 'border', types)
39
+ end
40
+
41
+ #
42
+ # deconstructs `border-image` shorthand property into it's longhand values
43
+ #
44
+ def self.deconstruct_shorthand_for_border_image(items, properties)
45
+ contexts = [:image_slice, :image_width, :image_outset]
46
+ context = contexts.shift
47
+ count = 1
48
+ styles = ::Archetype::Hash.new
49
+ items.each do |item|
50
+ # source slice width outset repeat
51
+ # <source> <slice {1,4}> / <width {1,4}> <outset> <repeat{1,2}>
52
+ case helpers.to_str(item)
53
+ when /^(?:url\(.*\)|none)$/
54
+ styles[:image_source] = item
55
+ when /^(?:stretch|repeat|round|space)$/
56
+ styles[:image_repeat] ||= []
57
+ styles[:image_repeat] << item
58
+ when /(.+)\/(.+)/ # delimiter to denote which context (slice, width, outset) we're observing
59
+ [$1, $2].each_with_index do |item, i|
60
+ count -= 1 if item == 'fill' # don't count `fill`
61
+ if count > 4 or i == 1
62
+ context = contexts.shift
63
+ count = 1
64
+ end
65
+ if context
66
+ item = (item =~ /^(\d+(?:\.\d+)?)(.*)/) ? Sass::Script::Value::Number.new($1.to_f, [$2]) : Sass::Script::Value::String.new(item)
67
+ styles[context] ||= []
68
+ styles[context] << item
69
+ count += 1
70
+ end
71
+ end
72
+ when /^\d+/
73
+ # if we've reached out limit for the current context, adjust
74
+ if count > 4
75
+ context = contexts.shift
76
+ count = 1
77
+ end
78
+ # if we have a context, stash the value onto it
79
+ if context
80
+ styles[context] ||= []
81
+ styles[context] << item
82
+ count += 1
83
+ end
84
+ when /^fill$/
85
+ styles[:image_slice] ||= []
86
+ styles[:image_slice] << item
87
+ # don't count `fill`
88
+ when /^auto$/
89
+ styles[:image_width] ||= []
90
+ styles[:image_width] << item
91
+ count += 1
92
+ when '/'
93
+ context = contexts.shift
94
+ count = 1
95
+ else
96
+ next
97
+ end
98
+ true
99
+ end
100
+ styles = set_default_styles(styles, 'border-image', properties)
101
+ end
102
+ end