archetype 0.0.1.pre.13 → 1.0.0.alpha.1
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 +4 -4
- data/CHANGELOG.md +97 -24
- data/README.md +11 -5
- data/VERSION +1 -0
- data/lib/archetype.rb +30 -18
- data/lib/archetype/actions/migrate.rb +152 -0
- data/lib/archetype/actions/theme.rb +6 -7
- data/lib/archetype/executor.rb +21 -7
- data/lib/archetype/extensions.rb +57 -0
- data/lib/archetype/functions.rb +2 -3
- data/lib/archetype/functions/css.rb +70 -0
- data/lib/archetype/functions/css/constants.rb +247 -0
- data/lib/archetype/functions/css/helpers.rb +265 -0
- data/lib/archetype/functions/css/routers.rb +28 -0
- data/lib/archetype/functions/css/routers/animation.rb +55 -0
- data/lib/archetype/functions/css/routers/background.rb +38 -0
- data/lib/archetype/functions/css/routers/border.rb +151 -0
- data/lib/archetype/functions/css/routers/list.rb +63 -0
- data/lib/archetype/functions/css/routers/margin_padding.rb +40 -0
- data/lib/archetype/functions/css/routers/outline.rb +56 -0
- data/lib/archetype/functions/css/routers/overflow.rb +11 -0
- data/lib/archetype/functions/css/routers/target.rb +38 -0
- data/lib/archetype/functions/css/routers/transition.rb +48 -0
- data/lib/archetype/functions/css/shorthands.rb +43 -0
- data/lib/archetype/functions/css/shorthands/animation.rb +18 -0
- data/lib/archetype/functions/css/shorthands/background.rb +68 -0
- data/lib/archetype/functions/css/shorthands/border.rb +102 -0
- data/lib/archetype/functions/hash.rb +3 -149
- data/lib/archetype/functions/hash/extend.rb +74 -0
- data/lib/archetype/functions/hash/shim.rb +48 -0
- data/lib/archetype/functions/helpers.rb +231 -22
- data/lib/archetype/functions/styleguide_memoizer.rb +18 -1
- data/lib/archetype/sass_extensions.rb +1 -3
- data/lib/archetype/sass_extensions/functions.rb +15 -1
- data/lib/archetype/sass_extensions/functions/environment.rb +152 -1
- data/lib/archetype/sass_extensions/functions/lists.rb +95 -45
- data/lib/archetype/sass_extensions/functions/locale.rb +107 -28
- data/lib/archetype/sass_extensions/functions/numbers.rb +118 -4
- data/lib/archetype/sass_extensions/functions/strings.rb +53 -0
- data/lib/archetype/sass_extensions/functions/styleguide.rb +43 -375
- data/lib/archetype/sass_extensions/functions/styleguide/components.rb +25 -0
- data/lib/archetype/sass_extensions/functions/styleguide/constants.rb +27 -0
- data/lib/archetype/sass_extensions/functions/styleguide/grammar.rb +80 -0
- data/lib/archetype/sass_extensions/functions/styleguide/helpers.rb +36 -0
- data/lib/archetype/sass_extensions/functions/styleguide/resolve.rb +159 -0
- data/lib/archetype/sass_extensions/functions/styleguide/styles.rb +146 -0
- data/lib/archetype/sass_extensions/functions/styleguide/themes.rb +40 -0
- data/lib/archetype/sass_extensions/functions/ui.rb +7 -57
- data/lib/archetype/sass_extensions/functions/ui/glyphs.rb +118 -0
- data/lib/archetype/sass_extensions/functions/ui/scopes.rb +96 -0
- data/lib/archetype/sass_extensions/functions/util.rb +14 -0
- data/lib/archetype/sass_extensions/functions/util/debug.rb +22 -0
- data/lib/archetype/sass_extensions/functions/util/hacks.rb +44 -0
- data/lib/archetype/sass_extensions/functions/util/images.rb +132 -0
- data/lib/archetype/sass_extensions/functions/util/misc.rb +220 -0
- data/lib/archetype/sass_extensions/functions/util/spacing.rb +83 -0
- data/lib/archetype/sass_extensions/functions/version.rb +12 -17
- data/lib/archetype/version.rb +1 -1
- data/stylesheets/archetype/_config.scss +1 -389
- data/stylesheets/archetype/_core.scss +15 -0
- data/stylesheets/archetype/_hacks.scss +4 -120
- data/stylesheets/archetype/_init.scss +4 -22
- data/stylesheets/archetype/_required.scss +3 -0
- data/stylesheets/archetype/_reset.scss +3 -0
- data/stylesheets/archetype/_styleguide.scss +2 -6
- data/stylesheets/archetype/_ui.scss +2 -358
- data/stylesheets/archetype/_util.scss +3 -10
- data/stylesheets/archetype/config/_core.scss +14 -0
- data/stylesheets/archetype/config/_environment.scss +19 -0
- data/stylesheets/archetype/config/_formatting.scss +63 -0
- data/stylesheets/archetype/config/_glyphs.scss +252 -0
- data/stylesheets/archetype/config/_resets.scss +7 -0
- data/stylesheets/archetype/config/_resolution.scss +3 -0
- data/stylesheets/archetype/config/_spacing.scss +5 -0
- data/stylesheets/archetype/config/_targeting.scss +18 -0
- data/stylesheets/archetype/config/_theme.scss +3 -0
- data/stylesheets/archetype/config/_typography.scss +56 -0
- data/stylesheets/archetype/config/_units.scss +2 -0
- data/stylesheets/archetype/config/_vars.scss +10 -0
- data/stylesheets/archetype/hacks/_core.scss +4 -0
- data/stylesheets/archetype/hacks/_hacks.scss +160 -0
- data/stylesheets/archetype/hacks/_init.scss +2 -0
- data/stylesheets/archetype/styleguide/_core.scss +4 -0
- data/stylesheets/archetype/styleguide/_init.scss +1 -0
- data/stylesheets/archetype/styleguide/_styleguide.scss +41 -18
- data/stylesheets/archetype/ui/_accessibility.scss +41 -0
- data/stylesheets/archetype/ui/_breakpoints.scss +19 -0
- data/stylesheets/archetype/ui/_core.scss +10 -0
- data/stylesheets/archetype/ui/_elements.scss +98 -0
- data/stylesheets/archetype/ui/_glyphs.scss +244 -0
- data/stylesheets/archetype/ui/_init.scss +5 -0
- data/stylesheets/archetype/ui/_layout.scss +37 -0
- data/stylesheets/archetype/ui/_locale.scss +12 -0
- data/stylesheets/archetype/ui/_scopes.scss +42 -0
- data/stylesheets/archetype/util/_core.scss +8 -0
- data/stylesheets/archetype/util/_debug.scss +9 -21
- data/stylesheets/archetype/util/_init.scss +1 -0
- data/stylesheets/archetype/util/_misc.scss +21 -86
- data/stylesheets/archetype/util/_spacing.scss +9 -40
- data/stylesheets/archetype/util/_styles.scss +189 -178
- data/stylesheets/archetype/util/_targeting.scss +51 -68
- data/templates/example/manifest.rb +2 -2
- data/templates/example/screen.scss +0 -1
- data/templates/project/manifest.rb +3 -8
- metadata +93 -263
- data/bin/archetype +0 -3
- data/lib/archetype/sass_extensions/monkey_patches.rb +0 -3
- data/lib/archetype/sass_extensions/monkey_patches/handle_include_loop.rb +0 -13
- data/stylesheets/archetype/_base.scss +0 -54
- data/stylesheets/archetype/_grid.scss +0 -3
- data/stylesheets/archetype/base/_h5bp.scss +0 -307
- data/stylesheets/archetype/base/_hybrid.scss +0 -25
- data/stylesheets/archetype/base/_normalize.scss +0 -634
- data/stylesheets/archetype/base/_reset.scss +0 -72
- data/stylesheets/archetype/grid/_config.scss +0 -14
- data/stylesheets/archetype/grid/_grid.scss +0 -391
- data/stylesheets/archetype/styleguide/_components.scss +0 -25
- data/stylesheets/archetype/styleguide/_helpers.scss +0 -215
- data/stylesheets/archetype/styleguide/_primitives.scss +0 -10
- data/stylesheets/archetype/styleguide/components/_alerts.scss +0 -59
- data/stylesheets/archetype/styleguide/components/_annotations.scss +0 -27
- data/stylesheets/archetype/styleguide/components/_bristol.scss +0 -15
- data/stylesheets/archetype/styleguide/components/_button_groups.scss +0 -47
- data/stylesheets/archetype/styleguide/components/_button_toolbars.scss +0 -17
- data/stylesheets/archetype/styleguide/components/_buttons.scss +0 -339
- data/stylesheets/archetype/styleguide/components/_canvas.scss +0 -15
- data/stylesheets/archetype/styleguide/components/_carets.scss +0 -336
- data/stylesheets/archetype/styleguide/components/_closes.scss +0 -63
- data/stylesheets/archetype/styleguide/components/_container.scss +0 -27
- data/stylesheets/archetype/styleguide/components/_copy.scss +0 -85
- data/stylesheets/archetype/styleguide/components/_flyouts.scss +0 -52
- data/stylesheets/archetype/styleguide/components/_headings.scss +0 -33
- data/stylesheets/archetype/styleguide/components/_headlines.scss +0 -64
- data/stylesheets/archetype/styleguide/components/_hovercards.scss +0 -27
- data/stylesheets/archetype/styleguide/components/_icons.scss +0 -17
- data/stylesheets/archetype/styleguide/components/_identities.scss +0 -34
- data/stylesheets/archetype/styleguide/components/_links.scss +0 -68
- data/stylesheets/archetype/styleguide/components/_loaders.scss +0 -154
- data/stylesheets/archetype/styleguide/components/_menu_items.scss +0 -31
- data/stylesheets/archetype/styleguide/components/_module.scss +0 -15
- data/stylesheets/archetype/styleguide/components/_pullquotes.scss +0 -29
- data/stylesheets/archetype/styleguide/components/_punchcut.scss +0 -18
- data/stylesheets/archetype/styleguide/components/_tooltips.scss +0 -28
- data/stylesheets/archetype/styleguide/primitives/_animations.scss +0 -17
- data/stylesheets/archetype/styleguide/primitives/_dimensions.scss +0 -50
- data/stylesheets/archetype/styleguide/primitives/_glyphs.scss +0 -11
- data/stylesheets/archetype/styleguide/primitives/_misc.scss +0 -8
- data/stylesheets/archetype/styleguide/primitives/_palettes.scss +0 -94
- data/stylesheets/archetype/styleguide/primitives/_shadows.scss +0 -23
- data/stylesheets/archetype/styleguide/primitives/_sprites.scss +0 -46
- data/stylesheets/archetype/styleguide/primitives/_textures.scss +0 -10
- data/stylesheets/archetype/styleguide/primitives/_typography.scss +0 -56
- data/stylesheets/archetype/util/_lists.scss +0 -57
- data/stylesheets/archetype/util/_rtl.scss +0 -279
- data/stylesheets/archetype/util/_units.scss +0 -18
- data/templates/project/screen.scss +0 -1
- data/templates/project/vendor/archetype/animations/loaders/large/large.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/large/large_static.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/medium/medium.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/small/small.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
- data/templates/project/vendor/archetype/animations/loaders/small/small_static.png +0 -0
- data/templates/project/vendor/archetype/fontawesome-webfont.eot +0 -0
- data/templates/project/vendor/archetype/fontawesome-webfont.svg +0 -255
- data/templates/project/vendor/archetype/fontawesome-webfont.ttf +0 -0
- data/templates/project/vendor/archetype/fontawesome-webfont.woff +0 -0
- data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.eot +0 -0
- data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.svg +0 -255
- data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.woff +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders-s7889ccc8c1.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_static.png +0 -0
- data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/sprites/hovercard_tip.png +0 -0
- data/test/fixtures/stylesheets/archetype/config.rb +0 -21
- data/test/fixtures/stylesheets/archetype/source/b.scss +0 -9
- data/test/fixtures/stylesheets/archetype/source/base.scss +0 -3
- data/test/fixtures/stylesheets/archetype/source/hacks/ie_pseudo.scss +0 -13
- data/test/fixtures/stylesheets/archetype/source/hacks/transparent_focusable.scss +0 -5
- data/test/fixtures/stylesheets/archetype/source/locale.scss +0 -43
- data/test/fixtures/stylesheets/archetype/source/styleguide/alerts.scss +0 -21
- data/test/fixtures/stylesheets/archetype/source/styleguide/buttons.scss +0 -18
- data/test/fixtures/stylesheets/archetype/source/styleguide/drop.scss +0 -101
- data/test/fixtures/stylesheets/archetype/source/styleguide/extend.scss +0 -24
- data/test/fixtures/stylesheets/archetype/source/styleguide/fallback_styles.scss +0 -23
- data/test/fixtures/stylesheets/archetype/source/styleguide/invalid_structures.scss +0 -85
- data/test/fixtures/stylesheets/archetype/source/styleguide/multi_value.scss +0 -18
- data/test/fixtures/stylesheets/archetype/source/styleguide/nested_styleguides.scss +0 -40
- data/test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss +0 -22
- data/test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss +0 -35
- data/test/fixtures/stylesheets/archetype/source/ui/hide_element.scss +0 -5
- data/test/fixtures/stylesheets/archetype/source/ui/stroke.scss +0 -13
- data/test/fixtures/stylesheets/archetype/source/ui/triangle.scss +0 -13
- data/test/fixtures/stylesheets/archetype/source/utilities/associative.scss +0 -24
- data/test/fixtures/stylesheets/archetype/source/utilities/custom_output_styler.scss +0 -22
- data/test/fixtures/stylesheets/archetype/source/utilities/if-set.scss +0 -16
- data/test/fixtures/stylesheets/archetype/source/utilities/spacing/horizontal-spacing.scss +0 -27
- data/test/fixtures/stylesheets/archetype/source/utilities/spacing/vertical-spacing.scss +0 -27
- data/test/fixtures/stylesheets/archetype/source/utilities/styles/filter.scss +0 -9
- data/test/fixtures/stylesheets/archetype/source/utilities/styles/font-family.scss +0 -9
- data/test/fixtures/stylesheets/archetype/source/utilities/styles/z-index.scss +0 -18
- data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-browser.scss +0 -77
- data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-os.scss +0 -42
- data/test/fixtures/stylesheets/archetype/tmp/b.css +0 -14
- data/test/fixtures/stylesheets/archetype/tmp/base.css +0 -349
- data/test/fixtures/stylesheets/archetype/tmp/hacks/ie_pseudo.css +0 -11
- data/test/fixtures/stylesheets/archetype/tmp/hacks/transparent_focusable.css +0 -4
- data/test/fixtures/stylesheets/archetype/tmp/locale.css +0 -23
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/alerts.css +0 -711
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/buttons.css +0 -2119
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/drop.css +0 -63
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/extend.css +0 -11
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/fallback_styles.css +0 -10
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/invalid_structures.css +0 -21
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/multi_value.css +0 -13
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/nested_styleguides.css +0 -28
- data/test/fixtures/stylesheets/archetype/tmp/styleguide/selective_state.css +0 -177
- data/test/fixtures/stylesheets/archetype/tmp/ui/glyph_icon.css +0 -127
- data/test/fixtures/stylesheets/archetype/tmp/ui/hide_element.css +0 -8
- data/test/fixtures/stylesheets/archetype/tmp/ui/stroke.css +0 -17
- data/test/fixtures/stylesheets/archetype/tmp/ui/triangle.css +0 -35
- data/test/fixtures/stylesheets/archetype/tmp/utilities/associative.css +0 -9
- data/test/fixtures/stylesheets/archetype/tmp/utilities/custom_output_styler.css +0 -8
- data/test/fixtures/stylesheets/archetype/tmp/utilities/if-set.css +0 -9
- data/test/fixtures/stylesheets/archetype/tmp/utilities/spacing/horizontal-spacing.css +0 -29
- data/test/fixtures/stylesheets/archetype/tmp/utilities/spacing/vertical-spacing.css +0 -29
- data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/filter.css +0 -11
- data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/font-family.css +0 -16
- data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/z-index.css +0 -15
- data/test/fixtures/stylesheets/archetype/tmp/utilities/targeting/target-browser.css +0 -105
- data/test/fixtures/stylesheets/archetype/tmp/utilities/targeting/target-os.css +0 -55
- data/test/helpers/diff.rb +0 -49
- data/test/helpers/io.rb +0 -36
- data/test/helpers/test_case.rb +0 -62
- data/test/integrations/archetype_test.rb +0 -126
- data/test/test_helper.rb +0 -26
- data/test/units/sass_extensions_test.rb +0 -200
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
module Archetype::Functions::CSS
|
|
2
|
+
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# output a warning about a disambiguous property found that can't be fully derived
|
|
7
|
+
#
|
|
8
|
+
# *Parameters*:
|
|
9
|
+
# - <tt>property</tt> {String} the property
|
|
10
|
+
# - <tt>info</tt> {String} additional info to display
|
|
11
|
+
#
|
|
12
|
+
def self.warn_cannot_disambiguate_property(property, info = nil)
|
|
13
|
+
info = (info.nil? or info.empty?) ? '' : " (#{info})"
|
|
14
|
+
return warn("[#{Archetype.name}:css:derive] cannot disambiguate the CSS property `#{property}#{info}`")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#
|
|
18
|
+
# output a warning if there isn't enough information to derive the value requested
|
|
19
|
+
#
|
|
20
|
+
# *Parameters*:
|
|
21
|
+
# - <tt>property</tt> {String} the property
|
|
22
|
+
# *Returns*:
|
|
23
|
+
# - {Sass::Null}
|
|
24
|
+
#
|
|
25
|
+
def self.warn_not_enough_infomation_to_derive(property)
|
|
26
|
+
return warn("[#{Archetype.name}:css:derive] there isn't enough information to derive `#{property}`, so returning `null`")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
#
|
|
30
|
+
# checks to see if a property is the root property or a descendent
|
|
31
|
+
#
|
|
32
|
+
# *Returns*:
|
|
33
|
+
# - {Boolean} true if the property is a root property
|
|
34
|
+
# *Returns*:
|
|
35
|
+
# - {Sass::Null}
|
|
36
|
+
#
|
|
37
|
+
def self.is_root_property?(property)
|
|
38
|
+
special_roots = %w(list-style border-image border-radius)
|
|
39
|
+
return special_roots.push(get_property_base(property)).include?(property)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#
|
|
43
|
+
# given a set of related properties, get the set of properties that are currently available
|
|
44
|
+
#
|
|
45
|
+
# *Parameters*:
|
|
46
|
+
# - <tt>related</tt> {Hash} the hash of styles
|
|
47
|
+
# - <tt>property</tt> {String} the property to observe
|
|
48
|
+
# *Returns*:
|
|
49
|
+
# - {Hash} the available related properties and their values
|
|
50
|
+
#
|
|
51
|
+
def self.filter_available_relatives(related, property)
|
|
52
|
+
handler = "filter_available_relatives_for_#{get_property_base(property)}"
|
|
53
|
+
# handle special cases like `border`
|
|
54
|
+
if self.respond_to?(handler)
|
|
55
|
+
set = self.method(handler).call(related, property)
|
|
56
|
+
else
|
|
57
|
+
set = Set.new
|
|
58
|
+
previous = nil
|
|
59
|
+
# find all potential parents (and self)
|
|
60
|
+
property.split('-').each do |value|
|
|
61
|
+
value = previous.nil? ? value : "#{previous}-#{value}"
|
|
62
|
+
set << value
|
|
63
|
+
previous = value
|
|
64
|
+
end
|
|
65
|
+
base = /(?:^|\s)#{Regexp.escape(property)}-[^\s]+(?:$|\s)/
|
|
66
|
+
related.each do |key, value|
|
|
67
|
+
set << key if key =~ base
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
return related.select { |key, value| set.include?(key) }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# filter relatives for `border`
|
|
75
|
+
#
|
|
76
|
+
def self.filter_available_relatives_for_border(related, property)
|
|
77
|
+
set = Set.new
|
|
78
|
+
set << property
|
|
79
|
+
case property
|
|
80
|
+
# border-radius and border-image
|
|
81
|
+
when R_BORDER_IMG_OR_RADIUS
|
|
82
|
+
match = $1
|
|
83
|
+
if property == "border-#{match}" or match == 'radius'
|
|
84
|
+
pattern = /^border-.*#{match}/
|
|
85
|
+
ALL_CSS_PROPERTIES.each { |k,v| set << k if k =~ pattern }
|
|
86
|
+
else
|
|
87
|
+
set << "border-#{match}"
|
|
88
|
+
end
|
|
89
|
+
when R_BORDER_STD
|
|
90
|
+
pattern = R_BORDER_STD
|
|
91
|
+
if property != 'border'
|
|
92
|
+
position, type = $1, $2
|
|
93
|
+
if position
|
|
94
|
+
if type
|
|
95
|
+
# position and type
|
|
96
|
+
# e.g. for border-top-width
|
|
97
|
+
# we'll need: border, border-top, border-top-width, border-width
|
|
98
|
+
pattern = /^(border|border#{position}(#{type})?$|border#{type})$/
|
|
99
|
+
else
|
|
100
|
+
# position only
|
|
101
|
+
# e.g. for border-top
|
|
102
|
+
# we'll need: border, border-top, border-top-{type}, border-{type}
|
|
103
|
+
pattern = /^(border|border#{position}#{RS_BORDER_TYPE}?$|border#{RS_BORDER_TYPE})$/
|
|
104
|
+
end
|
|
105
|
+
else
|
|
106
|
+
# type only
|
|
107
|
+
# e.g. for border-width
|
|
108
|
+
# we'll need: border, border-width, border-{position}-width, border-{position}
|
|
109
|
+
pattern = /^(border|border#{RS_BORDER_POSITION}?#{type}$|border#{RS_BORDER_POSITION})$/
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
ALL_CSS_PROPERTIES.each { |k,v| set << k if k =~ pattern }
|
|
113
|
+
end
|
|
114
|
+
return set
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
#
|
|
118
|
+
# for each item in a given style object, if the value is an array, convert it to a Sass::List
|
|
119
|
+
#
|
|
120
|
+
# *Parameters*:
|
|
121
|
+
# - <tt>styles</tt> {Hash} the styles
|
|
122
|
+
# - <tt>separator</tt> {Symbol} the separator to use on the generated list
|
|
123
|
+
# *Returns*:
|
|
124
|
+
# - {Hash} the styles hash with updated values
|
|
125
|
+
#
|
|
126
|
+
def self.collapse_multi_value_lists(styles, separator = :space)
|
|
127
|
+
styles.each do |key, value|
|
|
128
|
+
if value.is_a?(Array)
|
|
129
|
+
# if all the values are identical, we just need to return one
|
|
130
|
+
styles[key] = value.uniq.length == 1 ? value.first : Sass::Script::Value::List.new(value, separator)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
return styles
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
#
|
|
137
|
+
# normalizes the property into a key for use on a hash
|
|
138
|
+
#
|
|
139
|
+
# *Parameters*:
|
|
140
|
+
# - <tt>property</tt> {String} the property to be used as a key
|
|
141
|
+
# - <tt>base</tt> {String} the base of the property
|
|
142
|
+
# *Returns*:
|
|
143
|
+
# - {Symbol} the property normalized as a symbol
|
|
144
|
+
#
|
|
145
|
+
def self.normalize_property_key(property, base = nil)
|
|
146
|
+
base ||= get_property_base(property)
|
|
147
|
+
return property.gsub(/^#{Regexp.escape(base)}\-/, '').gsub('-', '_').to_sym
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
#
|
|
151
|
+
# gets the base of a property
|
|
152
|
+
#
|
|
153
|
+
# *Parameters*:
|
|
154
|
+
# - <tt>property</tt> {String} the property
|
|
155
|
+
# *Returns*:
|
|
156
|
+
# - {String} the base of the property
|
|
157
|
+
#
|
|
158
|
+
def self.get_property_base(property)
|
|
159
|
+
return (property.match(/^([a-z]+)/) || [])[0]
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
#
|
|
163
|
+
# extracts potential timing values from an array of values
|
|
164
|
+
#
|
|
165
|
+
# *Parameters*:
|
|
166
|
+
# - <tt>value</tt> {Array} an array of Sass values
|
|
167
|
+
# *Returns*:
|
|
168
|
+
# - {Array} the extracted timing values
|
|
169
|
+
#
|
|
170
|
+
def self.get_timing_values(value)
|
|
171
|
+
return value.select do |item|
|
|
172
|
+
if item.is_a?(Sass::Script::Value::Number)
|
|
173
|
+
unit = helpers.to_str(item.unit_str)
|
|
174
|
+
((item.unitless? and item.value == 0) or unit.include?('s'))
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
#
|
|
180
|
+
# helper to iterate over each available relative property
|
|
181
|
+
#
|
|
182
|
+
# *Parameters*:
|
|
183
|
+
# - <tt>related</tt> {Hash} the hash of styles
|
|
184
|
+
# - <tt>property</tt> {String} the property to observe
|
|
185
|
+
#
|
|
186
|
+
def self.with_each_available_relative(related, property)
|
|
187
|
+
filter_available_relatives(related, property).each do |key, value|
|
|
188
|
+
yield(key, value) if block_given?
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
#
|
|
193
|
+
# helper to iterate over each available relative property, and executes a block if the property is a root property
|
|
194
|
+
#
|
|
195
|
+
# *Parameters*:
|
|
196
|
+
# - <tt>related</tt> {Hash} the hash of styles
|
|
197
|
+
# - <tt>property</tt> {String} the property to observe
|
|
198
|
+
# *Returns*:
|
|
199
|
+
# - {Hash} augmented styles hash
|
|
200
|
+
#
|
|
201
|
+
def self.with_each_available_relative_if_root(related, property)
|
|
202
|
+
styles = ::Archetype::Hash.new
|
|
203
|
+
augmented = false
|
|
204
|
+
with_each_available_relative(related, property) do |key, value|
|
|
205
|
+
styles[normalize_property_key(key)] = value
|
|
206
|
+
augmented = !is_root_property?(key)
|
|
207
|
+
# if it's the shorthand property...
|
|
208
|
+
if !augmented
|
|
209
|
+
styles = yield(value.to_a.dup, (value.is_a?(Sass::Script::Value::List) && value.separator == :comma)) if block_given?
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
return styles, (augmented && is_root_property?(property))
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
#
|
|
216
|
+
# given a styles object, sets default values for each property if not already set
|
|
217
|
+
#
|
|
218
|
+
# *Parameters*:
|
|
219
|
+
# - <tt>styles</tt> {Hash} the styles
|
|
220
|
+
# - <tt>base</tt> {String} the base string
|
|
221
|
+
# - <tt>properties</tt> {Array} the properties to default if not set
|
|
222
|
+
# *Returns*:
|
|
223
|
+
# - {Hash} augmented styles hash
|
|
224
|
+
#
|
|
225
|
+
def self.set_default_styles(styles, base, properties)
|
|
226
|
+
properties.each { |k| styles[normalize_property_key(k, base)] ||= default("#{base}-#{k}") }
|
|
227
|
+
return styles
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
#
|
|
231
|
+
# given a list of symmetrical values, extracts the [top right bottom left] key-value pairs
|
|
232
|
+
#
|
|
233
|
+
# *Parameters*:
|
|
234
|
+
# - <tt>items</tt> {Array} the items
|
|
235
|
+
# *Returns*:
|
|
236
|
+
# - {Hash} the hash of [top right bottom left]
|
|
237
|
+
#
|
|
238
|
+
def self.extract_symmetical_values(items)
|
|
239
|
+
return {
|
|
240
|
+
:top => items[0],
|
|
241
|
+
:right => items[1] || items[0],
|
|
242
|
+
:bottom => items[2] || items[0],
|
|
243
|
+
:left => items[3] || items[1] || items[0]
|
|
244
|
+
}
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
#
|
|
248
|
+
# wrapper to display a warning and return Sass::Null
|
|
249
|
+
#
|
|
250
|
+
# *Parameters*:
|
|
251
|
+
# - <tt>msg</tt> {String} the message to display
|
|
252
|
+
# *Returns*:
|
|
253
|
+
# - {Sass::Null}
|
|
254
|
+
#
|
|
255
|
+
def self.warn(msg)
|
|
256
|
+
helpers.warn msg
|
|
257
|
+
return Sass::Script::Value::Null.new
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
# shortcut to Archetype::Functions::Helpers
|
|
261
|
+
def self.helpers
|
|
262
|
+
Archetype::Functions::Helpers
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Archetype::Functions::CSS
|
|
2
|
+
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# given a set of related properties, compute the property value
|
|
7
|
+
#
|
|
8
|
+
# *Parameters*:
|
|
9
|
+
# - <tt>hsh</tt> {Hash} the hash of styles
|
|
10
|
+
# - <tt>property</tt> {String} the original property we're looking for
|
|
11
|
+
# *Returns*:
|
|
12
|
+
# - {Hash} the derived styles
|
|
13
|
+
#
|
|
14
|
+
def self.get_derived_styles_via_router(hsh, property)
|
|
15
|
+
base = get_property_base(property)
|
|
16
|
+
handler = "get_derived_styles_router_for_#{base}"
|
|
17
|
+
# if we don't need any additional processing, stop here
|
|
18
|
+
return nil if not self.respond_to?(handler)
|
|
19
|
+
base = /^#{base}/
|
|
20
|
+
value = self.method(handler).call(hsh.select { |key, value| key =~ base }, property)
|
|
21
|
+
value = value[normalize_property_key(property)] if value.is_a?(Hash)
|
|
22
|
+
return value
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
%w(animation background border list margin_padding outline overflow target transition).each do |router|
|
|
27
|
+
require "archetype/functions/css/routers/#{router}"
|
|
28
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module Archetype::Functions::CSS
|
|
2
|
+
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# router for `animiation` properties
|
|
7
|
+
#
|
|
8
|
+
def self.get_derived_styles_router_for_animation(related, property)
|
|
9
|
+
properties = %w(name duration timing-function delay iteration-count direction play-state)
|
|
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
|
+
# identify the items that are timing units
|
|
13
|
+
timings = get_timing_values(items)
|
|
14
|
+
items = items - timings
|
|
15
|
+
# name duration timing-function delay iteration-count direction
|
|
16
|
+
styles = ::Archetype::Hash.new
|
|
17
|
+
styles[:duration] = timings.shift
|
|
18
|
+
styles[:delay] = timings.shift
|
|
19
|
+
items.reject! do |item|
|
|
20
|
+
case helpers.to_str(item)
|
|
21
|
+
when /^(?:normal|alternate|reverse|alternate-reverse)$/
|
|
22
|
+
styles[:direction] = item
|
|
23
|
+
when /^(?:none|forwards|backwards|both)$/
|
|
24
|
+
styles[:fill_mode] = item
|
|
25
|
+
when /^(?:running|paused)$/
|
|
26
|
+
styles[:play_state] = item
|
|
27
|
+
when /^(?:[\d\.]+|infinite)$/
|
|
28
|
+
styles[:iteration_count] = item
|
|
29
|
+
when R_TIMING_FUNCTION
|
|
30
|
+
styles[:timing_function] = item
|
|
31
|
+
else
|
|
32
|
+
next
|
|
33
|
+
end
|
|
34
|
+
true
|
|
35
|
+
end
|
|
36
|
+
styles[:name] = items.shift
|
|
37
|
+
styles[:timing_function] = items.shift
|
|
38
|
+
# set defaults if we missed anything...
|
|
39
|
+
styles = set_default_styles(styles, 'animation', properties)
|
|
40
|
+
# make the styles available to the calling context
|
|
41
|
+
styles
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
if reconstruct
|
|
45
|
+
value = extrapolate_shorthand_animation(styles)
|
|
46
|
+
# if the value came back nil, we were missing something, so throw a warning...
|
|
47
|
+
return warn_not_enough_infomation_to_derive(property) if value.nil?
|
|
48
|
+
return value
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# otherwise just return the value we were asked for
|
|
52
|
+
return styles
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Archetype::Functions::CSS
|
|
2
|
+
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# router for `background` properties
|
|
7
|
+
#
|
|
8
|
+
def self.get_derived_styles_router_for_background(related, property)
|
|
9
|
+
properties = %w(color position size repeat origin clip attachment image)
|
|
10
|
+
property_order = [:color, :position, :size, :repeat, :origin, :clip, :attachment, :image]
|
|
11
|
+
|
|
12
|
+
styles, reconstruct = with_each_available_relative_if_root(related, property) do |items, comma_separated|
|
|
13
|
+
deconstruct_shorthand_for_background(items, comma_separated, properties)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
if reconstruct
|
|
17
|
+
return warn_not_enough_infomation_to_derive(property) if styles.nil?
|
|
18
|
+
|
|
19
|
+
shorthands = []
|
|
20
|
+
total = 1
|
|
21
|
+
styles.each do |key, value|
|
|
22
|
+
total = value.length if value.is_a?(Array) && value.length > total
|
|
23
|
+
end
|
|
24
|
+
total.times do |i|
|
|
25
|
+
shorthand = []
|
|
26
|
+
properties.each { |k| shorthand << (styles[k.to_sym].is_a?(Array) ? styles[k.to_sym][i] : styles[k.to_sym]) || default("background-#{k}") }
|
|
27
|
+
shorthands << Sass::Script::Value::List.new(shorthand, :space)
|
|
28
|
+
end
|
|
29
|
+
return Sass::Script::Value::List.new(shorthands, :comma)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# collapse any multi-background values we got
|
|
33
|
+
styles = collapse_multi_value_lists(styles, :comma)
|
|
34
|
+
|
|
35
|
+
# otherwise just return the value we were asked for
|
|
36
|
+
return styles
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
module Archetype::Functions::CSS
|
|
2
|
+
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# router for `border` and `border-{position}`
|
|
7
|
+
#
|
|
8
|
+
def self.get_derived_styles_router_for_border_shorthands(property, types, related)
|
|
9
|
+
styles = ::Archetype::Hash.new
|
|
10
|
+
types.each do |type|
|
|
11
|
+
value = get_derived_styles_router_for_border(related, "#{property}-#{type}")
|
|
12
|
+
if value
|
|
13
|
+
styles[type.to_sym] = value
|
|
14
|
+
return warn_cannot_disambiguate_property(property) if value.to_a.to_a.length > 1
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
return nil if styles.empty?
|
|
18
|
+
return Sass::Script::Value::List.new(extrapolate_shorthand_simple(styles, property, types), :space)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
#
|
|
22
|
+
# router for `border` properties
|
|
23
|
+
#
|
|
24
|
+
def self.get_derived_styles_router_for_border(related, property)
|
|
25
|
+
properties = {
|
|
26
|
+
:image => %w(image-source image-slice image-width image-outset image-repeat),
|
|
27
|
+
:radius => %w(top-left-radius top-right-radius bottom-right-radius bottom-left-radius)
|
|
28
|
+
}
|
|
29
|
+
positions = %w(top right bottom left)
|
|
30
|
+
types = %w(width style color)
|
|
31
|
+
|
|
32
|
+
# shorthand for `border` and `border-{position}` will extrapolate from other shorthands
|
|
33
|
+
return get_derived_styles_router_for_border_shorthands(property, types, related) if property =~ R_BORDER_SHORTHANDS
|
|
34
|
+
|
|
35
|
+
case_type = case property
|
|
36
|
+
when R_BORDER_IMG_OR_RADIUS
|
|
37
|
+
$1.to_sym
|
|
38
|
+
when R_BORDER_STD
|
|
39
|
+
:border
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
properties = properties[case_type] || []
|
|
43
|
+
styles = ::Archetype::Hash.new
|
|
44
|
+
augmented = false
|
|
45
|
+
|
|
46
|
+
with_each_available_relative(related, property) do |key, value|
|
|
47
|
+
items = value.to_a.dup
|
|
48
|
+
|
|
49
|
+
case case_type
|
|
50
|
+
when :image
|
|
51
|
+
# border-image
|
|
52
|
+
styles[normalize_property_key(key)] = value
|
|
53
|
+
augmented = !is_root_property?(key)
|
|
54
|
+
if !augmented
|
|
55
|
+
styles = deconstruct_shorthand_for_border_image(items, properties)
|
|
56
|
+
end
|
|
57
|
+
when :radius
|
|
58
|
+
# border-radius
|
|
59
|
+
pieces = key.split('-')
|
|
60
|
+
if pieces.length > 2
|
|
61
|
+
augmented = true
|
|
62
|
+
if pieces.length > 3
|
|
63
|
+
# one of the longhand properties
|
|
64
|
+
# e.g. `border-top-right-radius`
|
|
65
|
+
styles[normalize_property_key(key)] = value
|
|
66
|
+
else
|
|
67
|
+
# one of the not-so-short shorthands
|
|
68
|
+
# e.g. `border-top-radius` (these aren't real properties, but Compass supports these, so why not)
|
|
69
|
+
position = pieces[1]
|
|
70
|
+
positions = [
|
|
71
|
+
['top', 'bottom'],
|
|
72
|
+
['left', 'right']
|
|
73
|
+
]
|
|
74
|
+
vertical = positions[0].include?(position)
|
|
75
|
+
positions[vertical ? 1 : 0].each do |alt_position|
|
|
76
|
+
str = "border-#{vertical ? position : alt_position}-#{vertical ? alt_position : position}-radius"
|
|
77
|
+
styles[normalize_property_key(str)] = value
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
else
|
|
81
|
+
augmented = false
|
|
82
|
+
shorthand = items.to_a
|
|
83
|
+
# TODO - doesn't support vertical radius correctly
|
|
84
|
+
styles = ::Archetype::Hash.new
|
|
85
|
+
styles[:top_left_radius] = shorthand[0],
|
|
86
|
+
styles[:top_right_radius] = shorthand[1] || shorthand[0],
|
|
87
|
+
styles[:bottom_right_radius] = shorthand[2] || shorthand[0],
|
|
88
|
+
styles[:bottom_left_radius] = shorthand[3] || shorthand[1] || shorthand[0]
|
|
89
|
+
end
|
|
90
|
+
when :border
|
|
91
|
+
key =~ R_BORDER_STD
|
|
92
|
+
position, type = $1, $2
|
|
93
|
+
if position or type
|
|
94
|
+
augmented = true
|
|
95
|
+
if position and type
|
|
96
|
+
# one of the longhand properties
|
|
97
|
+
# e.g. `border-top-style`
|
|
98
|
+
styles[normalize_property_key(key)] = value
|
|
99
|
+
else
|
|
100
|
+
# one of the not-so-short shorthands
|
|
101
|
+
# e.g. `border-top` or `border-style`
|
|
102
|
+
if position
|
|
103
|
+
# e.g. `border-top`
|
|
104
|
+
tmp = deconstruct_shorthand_for_border(items, types)
|
|
105
|
+
types.each { |k| styles[normalize_property_key("#{key}-#{k}")] = tmp[k.to_sym] }
|
|
106
|
+
else
|
|
107
|
+
# e.g. `border-style`
|
|
108
|
+
pattern = /^border#{RS_BORDER_POSITION}#{type}$/
|
|
109
|
+
tmp = extract_symmetical_values(items)
|
|
110
|
+
ALL_CSS_PROPERTIES.each { |k, v| styles[normalize_property_key(k)] = tmp[$1.gsub('-', '').to_sym] if k =~ pattern }
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
else
|
|
114
|
+
tmp = deconstruct_shorthand_for_border(items, types)
|
|
115
|
+
positions.each do |pos|
|
|
116
|
+
types.each { |k| styles[normalize_property_key("border-#{pos}-#{k}")] = tmp[k.to_sym] }
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
pattern = /^border#{RS_BORDER_TYPE}$/
|
|
122
|
+
|
|
123
|
+
styles = collapse_multi_value_lists(styles)
|
|
124
|
+
|
|
125
|
+
if (augmented and is_root_property?(property)) or property =~ pattern
|
|
126
|
+
value = nil
|
|
127
|
+
case case_type
|
|
128
|
+
when :image
|
|
129
|
+
slash = Sass::Script::Value::String.new('/')
|
|
130
|
+
styles = set_default_styles(styles, 'border-image', properties)
|
|
131
|
+
value = [styles[:image_source], styles[:image_slice], slash, styles[:image_width], slash, styles[:image_outset], styles[:image_repeat]]
|
|
132
|
+
when :border
|
|
133
|
+
# e.g. border-color
|
|
134
|
+
type = $1
|
|
135
|
+
tmp = ::Archetype::Hash.new
|
|
136
|
+
positions.each do |pos|
|
|
137
|
+
key = "border-#{pos}#{type}"
|
|
138
|
+
tmp[pos.to_sym] = styles[normalize_property_key(key)] || default(key)
|
|
139
|
+
end
|
|
140
|
+
return nil if tmp.empty?
|
|
141
|
+
return extrapolate_shorthand_symmetrical(tmp)
|
|
142
|
+
else
|
|
143
|
+
# radius
|
|
144
|
+
value = extrapolate_shorthand_simple(styles, property, properties)
|
|
145
|
+
end
|
|
146
|
+
return value ? Sass::Script::Value::List.new(value, :space) : nil
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
return styles[normalize_property_key(property)]
|
|
150
|
+
end
|
|
151
|
+
end
|