dashy 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/_dashy.scss +1 -14
- data/app/assets/stylesheets/dashy/_select.scss +3 -121
- data/app/assets/stylesheets/dashy/_set.scss +3 -76
- data/app/assets/stylesheets/dashy/all/_clears.scss +1 -0
- data/app/assets/stylesheets/dashy/all/_corners.scss +1 -0
- data/app/assets/stylesheets/dashy/all/_dimensions.scss +1 -0
- data/app/assets/stylesheets/dashy/all/_directions.scss +1 -0
- data/app/assets/stylesheets/dashy/all/_displays.scss +1 -0
- data/app/assets/stylesheets/dashy/all/_orientations.scss +1 -0
- data/app/assets/stylesheets/dashy/all/_overflows.scss +1 -0
- data/app/assets/stylesheets/dashy/all/_positions.scss +1 -0
- data/app/assets/stylesheets/dashy/all/_sides.scss +2 -0
- data/app/assets/stylesheets/dashy/all/font/_styles.scss +1 -0
- data/app/assets/stylesheets/dashy/all/font/_weights.scss +1 -0
- data/app/assets/stylesheets/dashy/all/horizontal/_dimensions.scss +1 -0
- data/app/assets/stylesheets/dashy/all/horizontal/_directions.scss +1 -0
- data/app/assets/stylesheets/dashy/all/horizontal/_sides.scss +1 -0
- data/app/assets/stylesheets/dashy/all/text/_aligns.scss +1 -0
- data/app/assets/stylesheets/dashy/all/text/_decorations.scss +1 -0
- data/app/assets/stylesheets/dashy/all/text/_inputs.scss +1 -0
- data/app/assets/stylesheets/dashy/all/text/_transforms.scss +1 -0
- data/app/assets/stylesheets/dashy/all/vertical/_aligns.scss +1 -0
- data/app/assets/stylesheets/dashy/all/vertical/_dimensions.scss +1 -0
- data/app/assets/stylesheets/dashy/all/vertical/_directions.scss +1 -0
- data/app/assets/stylesheets/dashy/all/vertical/_sides.scss +1 -0
- data/app/assets/stylesheets/dashy/default/font/_size.scss +1 -0
- data/app/assets/stylesheets/dashy/default/line/_height.scss +1 -0
- data/app/assets/stylesheets/dashy/default/page/_width.scss +1 -0
- data/app/assets/stylesheets/dashy/default/text/_align.scss +1 -0
- data/app/assets/stylesheets/dashy/default/vertical/_align.scss +1 -0
- data/app/assets/stylesheets/dashy/define/_append.scss +53 -0
- data/app/assets/stylesheets/dashy/define/_backspace.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_clear.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_display.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_float.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_gutter.scss +21 -0
- data/app/assets/stylesheets/dashy/define/_height.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_inner.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_opacity.scss +53 -0
- data/app/assets/stylesheets/dashy/define/_outer.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_overflow.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_pad.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_position.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_prepend.scss +53 -0
- data/app/assets/stylesheets/dashy/define/_pull.scss +17 -0
- data/app/assets/stylesheets/dashy/define/_push.scss +22 -0
- data/app/assets/stylesheets/dashy/define/_space.scss +15 -0
- data/app/assets/stylesheets/dashy/define/_width.scss +53 -0
- data/app/assets/stylesheets/dashy/define/column/_count.scss +15 -0
- data/app/assets/stylesheets/dashy/define/column/_fill.scss +15 -0
- data/app/assets/stylesheets/dashy/define/column/_gap.scss +15 -0
- data/app/assets/stylesheets/dashy/define/column/break/_inside.scss +15 -0
- data/app/assets/stylesheets/dashy/define/font/_size.scss +15 -0
- data/app/assets/stylesheets/dashy/define/font/_style.scss +15 -0
- data/app/assets/stylesheets/dashy/define/font/_weight.scss +15 -0
- data/app/assets/stylesheets/dashy/define/line/_height.scss +17 -0
- data/app/assets/stylesheets/dashy/define/max/_height.scss +15 -0
- data/app/assets/stylesheets/dashy/define/max/_width.scss +15 -0
- data/app/assets/stylesheets/dashy/define/min/_height.scss +15 -0
- data/app/assets/stylesheets/dashy/define/min/_width.scss +15 -0
- data/app/assets/stylesheets/dashy/define/text/_align.scss +15 -0
- data/app/assets/stylesheets/dashy/define/text/_color.scss +15 -0
- data/app/assets/stylesheets/dashy/define/text/_decoration.scss +15 -0
- data/app/assets/stylesheets/dashy/define/text/_transform.scss +15 -0
- data/app/assets/stylesheets/dashy/define/vertical/_align.scss +15 -0
- data/app/assets/stylesheets/dashy/get/_direction.scss +6 -0
- data/app/assets/stylesheets/dashy/get/_side.scss +11 -0
- data/app/assets/stylesheets/dashy/get/opposite/_corner.scss +6 -0
- data/app/assets/stylesheets/dashy/get/opposite/_direction.scss +6 -0
- data/app/assets/stylesheets/dashy/get/opposite/_side.scss +6 -0
- data/app/assets/stylesheets/dashy/initialize/_pull.scss +14 -0
- data/app/assets/stylesheets/dashy/initialize/_push.scss +14 -0
- data/app/assets/stylesheets/dashy/is/_blank.scss +5 -0
- data/app/assets/stylesheets/dashy/is/_boolean.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_color.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_em.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_empty.scss +5 -0
- data/app/assets/stylesheets/dashy/is/_ex.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_list.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_nothing.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_null.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_number.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_percentage.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_px.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_rem.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_round.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_something.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_string.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_unit.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_unitful.scss +4 -0
- data/app/assets/stylesheets/dashy/is/_unitless.scss +4 -0
- data/app/assets/stylesheets/dashy/list/_append.scss +4 -0
- data/app/assets/stylesheets/dashy/list/_first.scss +4 -0
- data/app/assets/stylesheets/dashy/list/_last.scss +4 -0
- data/app/assets/stylesheets/dashy/list/_length.scss +4 -0
- data/app/assets/stylesheets/dashy/list/_nth.scss +5 -0
- data/app/assets/stylesheets/dashy/list/_second.scss +4 -0
- data/app/assets/stylesheets/dashy/number/_approximate.scss +14 -0
- data/app/assets/stylesheets/dashy/number/_ceiling.scss +4 -0
- data/app/assets/stylesheets/dashy/number/_decimal.scss +7 -0
- data/app/assets/stylesheets/dashy/number/_floor.scss +4 -0
- data/app/assets/stylesheets/dashy/number/_fractional.scss +4 -0
- data/app/assets/stylesheets/dashy/number/_integral.scss +4 -0
- data/app/assets/stylesheets/dashy/number/_of.scss +4 -0
- data/app/assets/stylesheets/dashy/number/_one.scss +4 -0
- data/app/assets/stylesheets/dashy/number/_round.scss +4 -0
- data/app/assets/stylesheets/dashy/number/_squared.scss +4 -0
- data/app/assets/stylesheets/dashy/number/_unit.scss +4 -0
- data/app/assets/stylesheets/dashy/select/_as.scss +0 -0
- data/app/assets/stylesheets/dashy/select/_attribute.scss +11 -0
- data/app/assets/stylesheets/dashy/select/_buttons.scss +14 -0
- data/app/assets/stylesheets/dashy/select/_children.scss +4 -0
- data/app/assets/stylesheets/dashy/select/_class.scss +9 -0
- data/app/assets/stylesheets/dashy/select/_descendants.scss +4 -0
- data/app/assets/stylesheets/dashy/select/_either.scss +0 -0
- data/app/assets/stylesheets/dashy/select/_following.scss +4 -0
- data/app/assets/stylesheets/dashy/select/_inputs.scss +9 -0
- data/app/assets/stylesheets/dashy/select/_lists.scss +9 -0
- data/app/assets/stylesheets/dashy/select/_next.scss +4 -0
- data/app/assets/stylesheets/dashy/select/_pseudoclass.scss +0 -0
- data/app/assets/stylesheets/dashy/select/_tables.scss +9 -0
- data/app/assets/stylesheets/dashy/select/_tabloids.scss +9 -0
- data/app/assets/stylesheets/dashy/select/as/_children.scss +4 -0
- data/app/assets/stylesheets/dashy/select/as/_descendants.scss +4 -0
- data/app/assets/stylesheets/dashy/select/as/_following.scss +4 -0
- data/app/assets/stylesheets/dashy/select/as/_next.scss +4 -0
- data/app/assets/stylesheets/dashy/select/attribute/_prefix.scss +9 -0
- data/app/assets/stylesheets/dashy/select/attribute/_suffix.scss +9 -0
- data/app/assets/stylesheets/dashy/select/class/_prefix.scss +9 -0
- data/app/assets/stylesheets/dashy/select/class/_suffix.scss +4 -0
- data/app/assets/stylesheets/dashy/select/list/_items.scss +9 -0
- data/app/assets/stylesheets/dashy/select/lists/_items.scss +9 -0
- data/app/assets/stylesheets/dashy/select/table/_cells.scss +9 -0
- data/app/assets/stylesheets/dashy/select/table/_groups.scss +4 -0
- data/app/assets/stylesheets/dashy/select/table/_rows.scss +4 -0
- data/app/assets/stylesheets/dashy/select/table/groups/_rows.scss +4 -0
- data/app/assets/stylesheets/dashy/select/table/groups/rows/_cells.scss +4 -0
- data/app/assets/stylesheets/dashy/select/tabloids/_rows.scss +10 -0
- data/app/assets/stylesheets/dashy/select/tabloids/rows/_cells.scss +9 -0
- data/app/assets/stylesheets/dashy/select/text/_inputs.scss +11 -0
- data/app/assets/stylesheets/dashy/set/_animation.scss +10 -0
- data/app/assets/stylesheets/dashy/set/_append.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_backspace.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_clear.scss +13 -0
- data/app/assets/stylesheets/dashy/set/_display.scss +11 -0
- data/app/assets/stylesheets/dashy/set/_float.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_height.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_inner.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_keyframes.scss +7 -0
- data/app/assets/stylesheets/dashy/set/_margin.scss +5 -0
- data/app/assets/stylesheets/dashy/set/_opacity.scss +9 -0
- data/app/assets/stylesheets/dashy/set/_outer.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_overflow.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_pad.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_padding.scss +5 -0
- data/app/assets/stylesheets/dashy/set/_position.scss +11 -0
- data/app/assets/stylesheets/dashy/set/_prepend.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_pull.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_push.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_rem.scss +5 -0
- data/app/assets/stylesheets/dashy/set/_rgb.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_rgba.scss +8 -0
- data/app/assets/stylesheets/dashy/set/_space.scss +4 -0
- data/app/assets/stylesheets/dashy/set/_transition.scss +7 -0
- data/app/assets/stylesheets/dashy/set/_tweening.scss +5 -0
- data/app/assets/stylesheets/dashy/set/_width.scss +4 -0
- data/app/assets/stylesheets/dashy/set/background/gradient.scss +37 -0
- data/app/assets/stylesheets/dashy/set/border/_radius.scss +6 -0
- data/app/assets/stylesheets/dashy/set/box/_shadow.scss +6 -0
- data/app/assets/stylesheets/dashy/set/box/_sizing.scss +6 -0
- data/app/assets/stylesheets/dashy/set/column/_count.scss +6 -0
- data/app/assets/stylesheets/dashy/set/column/_fill.scss +6 -0
- data/app/assets/stylesheets/dashy/set/column/_gap.scss +6 -0
- data/app/assets/stylesheets/dashy/set/column/break/_inside.scss +6 -0
- data/app/assets/stylesheets/dashy/set/font/_size.scss +4 -0
- data/app/assets/stylesheets/dashy/set/font/_style.scss +4 -0
- data/app/assets/stylesheets/dashy/set/font/_weight.scss +4 -0
- data/app/assets/stylesheets/dashy/set/line/_height.scss +4 -0
- data/app/assets/stylesheets/dashy/set/max/_height.scss +4 -0
- data/app/assets/stylesheets/dashy/set/max/_width.scss +4 -0
- data/app/assets/stylesheets/dashy/set/min/_height.scss +7 -0
- data/app/assets/stylesheets/dashy/set/min/_width.scss +4 -0
- data/app/assets/stylesheets/dashy/set/text/_align.scss +4 -0
- data/app/assets/stylesheets/dashy/set/text/_color.scss +4 -0
- data/app/assets/stylesheets/dashy/set/text/_decoration.scss +4 -0
- data/app/assets/stylesheets/dashy/set/text/_transform.scss +4 -0
- data/app/assets/stylesheets/dashy/set/vertical/_align.scss +4 -0
- data/app/assets/stylesheets/dashy/string/_hyphenate.scss +4 -0
- data/app/assets/stylesheets/dashy/string/_join.scss +0 -0
- data/app/assets/stylesheets/dashy/to/_dimension.scss +11 -0
- data/app/assets/stylesheets/dashy/to/_fraction.scss +12 -0
- data/app/assets/stylesheets/dashy/to/_number.scss +9 -0
- data/app/assets/stylesheets/dashy/to/_orientation.scss +11 -0
- data/app/assets/stylesheets/dashy/to/_percentage.scss +9 -0
- data/app/assets/stylesheets/dashy/to/_px.scss +9 -0
- data/app/assets/stylesheets/dashy/to/_unitless.scss +4 -0
- data/lib/dashy/version.rb +1 -1
- data/lib/dashy.rb +1 -0
- data/lib/sass/script/functions/dashy.rb +80 -271
- data/lib/sass/script/value/string/dashy.rb +25 -0
- metadata +197 -15
- data/app/assets/stylesheets/dashy/_color.scss +0 -5
- data/app/assets/stylesheets/dashy/_corner.scss +0 -15
- data/app/assets/stylesheets/dashy/_default.scss +0 -14
- data/app/assets/stylesheets/dashy/_define.scss +0 -158
- data/app/assets/stylesheets/dashy/_direction.scss +0 -36
- data/app/assets/stylesheets/dashy/_font-family.scss +0 -36
- data/app/assets/stylesheets/dashy/_is.scss +0 -81
- data/app/assets/stylesheets/dashy/_line-height.scss +0 -10
- data/app/assets/stylesheets/dashy/_list.scss +0 -161
- data/app/assets/stylesheets/dashy/_number.scss +0 -79
- data/app/assets/stylesheets/dashy/_opposite.scss +0 -36
- data/app/assets/stylesheets/dashy/_side.scss +0 -23
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$to-dimension-from-orientation: (horizontal width) (vertical height);
|
2
|
+
|
3
|
+
@function to-dimension-from-orientation($orientation)
|
4
|
+
{
|
5
|
+
@return map-get($to-dimension-from-orientation, $orientation);
|
6
|
+
}
|
7
|
+
|
8
|
+
@function to-dimension($arg)
|
9
|
+
{
|
10
|
+
@if is-orientation($arg) { @return to-dimension-from-orientation($arg); }
|
11
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// @function to-fraction-from-number defined in Sass::Script::Functions::Dashy
|
2
|
+
|
3
|
+
@function to-fraction-from-percentage($per)
|
4
|
+
{
|
5
|
+
@return to-fraction-from-number(to-number-from-percentage($per));
|
6
|
+
}
|
7
|
+
|
8
|
+
@function to-fraction($arg)
|
9
|
+
{
|
10
|
+
@if is-number($arg) { @return to-fraction-from-number($arg); }
|
11
|
+
@if is-percentage($arg) { @return to-fraction-from-percentage($arg); }
|
12
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$to-orientation-from-dimension: (width: horizontal, height: vertical);
|
2
|
+
|
3
|
+
@function to-orientation-from-dimension($dimension)
|
4
|
+
{
|
5
|
+
@return map-get($to-orientation-from-dimension, $dimension);
|
6
|
+
}
|
7
|
+
|
8
|
+
@function to-orientation($arg)
|
9
|
+
{
|
10
|
+
@if is-dimension($arg) { @return to-orientation-from-dimension($arg); }
|
11
|
+
}
|
data/lib/dashy/version.rb
CHANGED
data/lib/dashy.rb
CHANGED
@@ -1,287 +1,96 @@
|
|
1
|
-
|
1
|
+
module Sass::Script::Functions
|
2
|
+
module Dashy
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def to_s opt = {}
|
8
|
-
return @value.gsub(/(?<!\\)(?=[\$\%\/\?\!])/, "\\") if :selector == @type
|
9
|
-
return super
|
10
|
-
end
|
11
|
-
|
12
|
-
}
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
module Sass
|
17
|
-
module Script
|
18
|
-
module Functions
|
19
|
-
|
20
|
-
# Defined directly on `Functions` so we can use `declare`.
|
21
|
-
|
22
|
-
def is_wildcard value
|
23
|
-
'*' == value.to_s
|
24
|
-
end
|
25
|
-
|
26
|
-
def select *selectors
|
27
|
-
this = select_identifier ""
|
28
|
-
select_as this, *selectors
|
29
|
-
end
|
30
|
-
declare :select, [], :var_args => true
|
31
|
-
|
32
|
-
def select_as separator, *selectors
|
33
|
-
unquote = method :unquote
|
34
|
-
separator = separator.value
|
35
|
-
selectors = selectors.first if 1 == selectors.length
|
36
|
-
selectors = selectors.to_a.map { |selector| selector.to_a.map &unquote }
|
37
|
-
selectors = selectors.shift.product *selectors
|
38
|
-
Sass::Script::Value::List.new selectors.map! { |selector|
|
39
|
-
# selector = selector.reject &method(:is_wildcard) unless 1 == selector.length && is_wildcard(selector.first)
|
40
|
-
selector = selector.join separator
|
41
|
-
selector.gsub! /(?<=[\w\-\]])\*/, '' # Remove any wildcards after any words or attributes.
|
42
|
-
selector.gsub! /\*(?=[\w\.\#\[])/, '' # Remove any wildcards before any tags, classes, ids or attributes.
|
43
|
-
select_identifier selector
|
44
|
-
}, :comma
|
45
|
-
end
|
46
|
-
declare :select_with, [:string], :var_args => true
|
47
|
-
|
48
|
-
def select_as_descendants *selectors
|
49
|
-
descendants = select_identifier " "
|
50
|
-
select_as descendants, *selectors
|
51
|
-
end
|
52
|
-
declare :select_as_descendants, [], :var_args => true
|
53
|
-
|
54
|
-
def select_as_children *selectors
|
55
|
-
children = select_identifier ">"
|
56
|
-
select_as children, *selectors
|
57
|
-
end
|
58
|
-
declare :select_as_children, [], :var_args => true
|
59
|
-
|
60
|
-
def select_as_adjacent_siblings *selectors
|
61
|
-
adjacent_siblings = select_identifier "+"
|
62
|
-
select_as adjacent_siblings, *selectors
|
63
|
-
end
|
64
|
-
declare :select_as_adjacent_siblings, [], :var_args => true
|
65
|
-
|
66
|
-
def select_as_general_siblings *selectors
|
67
|
-
general_siblings = select_identifier "~"
|
68
|
-
select_as general_siblings, *selectors
|
69
|
-
end
|
70
|
-
declare :select_as_general_siblings, [], :var_args => true
|
71
|
-
|
72
|
-
def select_descendants selector = select_any
|
73
|
-
descendants = select_identifier " "
|
74
|
-
select descendants, selector
|
75
|
-
end
|
76
|
-
declare :select_descendants, [:string], :var_args => true
|
77
|
-
|
78
|
-
def select_children selector = select_any
|
79
|
-
children = select_identifier ">"
|
80
|
-
select children, selector
|
81
|
-
end
|
82
|
-
declare :select_children, [:string], :var_args => true
|
83
|
-
|
84
|
-
def select_adjacent_siblings selector = select_any
|
85
|
-
adjacent_siblings = select_identifier "+"
|
86
|
-
select adjacent_siblings, selector
|
87
|
-
end
|
88
|
-
declare :select_adjacent_siblings, [:string], :var_args => true
|
89
|
-
|
90
|
-
def select_general_siblings selector = select_any
|
91
|
-
general_siblings = select_identifier "~"
|
92
|
-
select general_siblings, selector
|
93
|
-
end
|
94
|
-
declare :select_general_siblings, [:string], :var_args => true
|
95
|
-
|
96
|
-
def select_either *selectors
|
97
|
-
selectors = selectors.first if 1 == selectors.length
|
98
|
-
selectors = selectors.map &:to_a
|
99
|
-
Sass::Script::Value::List.new selectors.flatten, :comma
|
100
|
-
end
|
101
|
-
declare :select_either, [], :var_args => true
|
102
|
-
|
103
|
-
def select_attribute attribute, *selectors
|
104
|
-
selectors = selectors.first if 1 == selectors.length
|
105
|
-
selectors = selectors.to_a.map { |selector| select_string "[#{ attribute }=\'#{ select_escaped! selector }\']" }
|
106
|
-
Sass::Script::Value::List.new selectors, :comma
|
107
|
-
end
|
108
|
-
|
109
|
-
def select_attribute_prefix attribute, *selectors
|
110
|
-
selectors = selectors.first if 1 == selectors.length
|
111
|
-
selectors = selectors.to_a.map { |selector|
|
112
|
-
[
|
113
|
-
(select_string "[#{ attribute }^=\'#{ select_escaped! selector }\']"),
|
114
|
-
(select_string "[#{ attribute }*=\' #{ select_escaped! selector }\']")
|
115
|
-
]
|
116
|
-
}
|
117
|
-
Sass::Script::Value::List.new selectors.flatten, :comma
|
118
|
-
end
|
119
|
-
|
120
|
-
def select_attribute_suffix attribute, *selectors
|
121
|
-
selectors = selectors.first if 1 == selectors.length
|
122
|
-
selectors = selectors.to_a.map { |selector|
|
123
|
-
[
|
124
|
-
(select_string "[#{ attribute }$=\'#{ select_escaped! selector }\']"),
|
125
|
-
(select_string "[#{ attribute }*=\'#{ select_escaped! selector } \']")
|
126
|
-
]
|
127
|
-
}
|
128
|
-
Sass::Script::Value::List.new selectors.flatten, :comma
|
129
|
-
end
|
130
|
-
|
131
|
-
def select_class_prefix *selectors
|
132
|
-
attribute = select_identifier "class"
|
133
|
-
select_attribute_prefix attribute, *selectors
|
134
|
-
end
|
135
|
-
|
136
|
-
def select_class_suffix *selectors
|
137
|
-
attribute = select_identifier "class"
|
138
|
-
select_attribute_suffix attribute, *selectors
|
139
|
-
end
|
140
|
-
|
141
|
-
def select_class selector
|
142
|
-
selectors = selector.to_a.map &:to_a
|
143
|
-
selectors = selectors.shift.product *selectors
|
144
|
-
selectors.map! { |selector| select_identifier "." + select_escaped!(selector.to_a.map { |s| s.to_s(quote: :none).gsub(/(?<!\\)(?=[.\$\%\/\?\!])/, "\\") }.join "-") }
|
145
|
-
Sass::Script::Value::List.new selectors, :comma
|
146
|
-
end
|
147
|
-
|
148
|
-
def select_classes *selectors
|
149
|
-
select_either *(selectors.map! &(method :select_class))
|
150
|
-
end
|
151
|
-
|
152
|
-
def select_pseudoclass selector
|
153
|
-
select_identifier ":" + (selector.to_a.join "-")
|
154
|
-
end
|
155
|
-
|
156
|
-
def select_pseudoclasses *selectors
|
157
|
-
select_either *(selectors.map! &(method :select_pseudoclass))
|
158
|
-
end
|
159
|
-
|
160
|
-
def select_quasiclass selector
|
161
|
-
select_either select_class(selector), select_pseudoclass(selector)
|
162
|
-
end
|
163
|
-
|
164
|
-
def select_quasiclasses *selectors
|
165
|
-
select_either *(selectors.map! &(method :select_quasiclass))
|
166
|
-
end
|
167
|
-
|
168
|
-
def select_adjacent_odd_siblings limit, *selectors
|
169
|
-
selectors.push select_identifier '*' if selectors.empty?
|
170
|
-
selectors = selectors.first if 1 == selectors.length
|
171
|
-
selectors = (0 .. limit.value).select { |i| 1 == i % 2 }.map { |i| select select_identifier(" + * " * i + " + "), *selectors }
|
172
|
-
select_either *selectors
|
173
|
-
end
|
174
|
-
|
175
|
-
def select_odd_siblings limit, *selectors
|
176
|
-
select_either select_first_sibling, select(select_first_sibling, select_adjacent_odd_siblings(limit, *selectors))
|
177
|
-
end
|
178
|
-
|
179
|
-
def select_odd_children limit, *selectors
|
180
|
-
select_children select_odd_siblings(limit, *selectors)
|
181
|
-
end
|
182
|
-
|
183
|
-
def select_adjacent_even_siblings limit, *selectors
|
184
|
-
selectors.push select_identifier '*' if selectors.empty?
|
185
|
-
selectors = selectors.first if 1 == selectors.length
|
186
|
-
selectors = (0 .. limit.value).select { |i| 0 == i % 2 }.map { |i| select select_identifier(" + * " * i + " + "), *selectors }
|
187
|
-
select_either *selectors
|
188
|
-
end
|
189
|
-
|
190
|
-
def select_even_siblings limit, *selectors
|
191
|
-
select select_first_sibling, select_adjacent_even_siblings(limit, *selectors)
|
192
|
-
end
|
193
|
-
|
194
|
-
def select_even_children limit, *selectors
|
195
|
-
select_children select_even_siblings(limit, *selectors)
|
196
|
-
end
|
197
|
-
|
198
|
-
def select_first_child
|
199
|
-
select_children select_first_sibling
|
200
|
-
end
|
201
|
-
|
202
|
-
def select_first_sibling
|
203
|
-
select_identifier ":first_child"
|
204
|
-
end
|
205
|
-
|
206
|
-
def select_any
|
207
|
-
select_identifier "*"
|
208
|
-
end
|
209
|
-
|
210
|
-
def select_string selector
|
211
|
-
Sass::Script::Value::String.new selector.to_s, :string
|
212
|
-
end
|
213
|
-
|
214
|
-
def select_identifier selector
|
215
|
-
Sass::Script::Value::String.new selector.to_s, :selector
|
216
|
-
end
|
217
|
-
|
218
|
-
def select_escaped! thing
|
219
|
-
thing.tap { |t|
|
220
|
-
case thing
|
221
|
-
|
222
|
-
when Sass::Script::Value::String
|
223
|
-
select_escaped! t.value
|
224
|
-
|
225
|
-
when String
|
226
|
-
t.gsub! /(?<!\\)(?=[\=\$\%\/\?\!\.])/, "\\"
|
4
|
+
def select *selectors
|
5
|
+
select_as unquoted_string(""), *selectors
|
6
|
+
end
|
227
7
|
|
228
|
-
|
229
|
-
|
230
|
-
|
8
|
+
def select_new selector
|
9
|
+
string_new selector, :selector
|
10
|
+
end
|
231
11
|
|
232
|
-
|
233
|
-
|
234
|
-
|
12
|
+
private :select_new
|
13
|
+
|
14
|
+
def select_as separator, *selectors
|
15
|
+
unquote = method :unquote
|
16
|
+
separator = separator.value
|
17
|
+
selectors = selectors.first if 1 == selectors.length
|
18
|
+
selectors = selectors.to_a.map { |selector| selector.to_a.map &unquote }
|
19
|
+
|
20
|
+
selectors = selectors.shift.product *selectors
|
21
|
+
selectors.map! do |selector|
|
22
|
+
selector = selector.join separator
|
23
|
+
|
24
|
+
selector.gsub! %r{ [*] (?=[\\\w\-\.\#\[]) }x, '' # Remove any wildcards before any tags, classes, ids or attributes.
|
25
|
+
selector.gsub! %r{ (?<=[\\\w\-\]]) [*] }x, '' # Remove any wildcards after any words or attributes.
|
26
|
+
|
27
|
+
select_new selector
|
28
|
+
end
|
29
|
+
|
30
|
+
list_new selectors
|
31
|
+
end
|
235
32
|
|
236
|
-
|
237
|
-
|
238
|
-
|
33
|
+
def select_either *selectors
|
34
|
+
list_new selectors.map(&:to_a).flatten
|
35
|
+
end
|
239
36
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
select select_identifier('input:checked'), select_attribute('form', namespace),
|
244
|
-
select_attribute('name', name),
|
245
|
-
select_attribute('value', value)
|
246
|
-
}
|
247
|
-
select_as_general_siblings *inputs
|
37
|
+
def string_new string, type = :string
|
38
|
+
Sass::Script::Value::String.new string, type
|
39
|
+
end
|
248
40
|
|
249
|
-
|
41
|
+
private :string_new
|
250
42
|
|
251
|
-
|
252
|
-
|
43
|
+
def string_join strings, separator
|
44
|
+
strings = strings.to_a
|
45
|
+
type = strings.first.type
|
46
|
+
strings = strings.map { |string| string.to_s quote: :none }
|
47
|
+
separator = separator.to_s quote: :none
|
48
|
+
string_new strings.join(separator), type
|
49
|
+
end
|
253
50
|
|
254
|
-
|
255
|
-
|
51
|
+
def number_new number, numerator_units = nil, denominator_units = nil
|
52
|
+
Sass::Script::Value::Number.new number, numerator_units, denominator_units
|
53
|
+
end
|
256
54
|
|
257
|
-
|
258
|
-
select_either select_ordered_lists(*selectors), select_unordered_lists(*selectors)
|
259
|
-
end
|
55
|
+
private :number_new
|
260
56
|
|
261
|
-
|
262
|
-
|
263
|
-
|
57
|
+
def list_new list, separator = :comma
|
58
|
+
Sass::Script::Value::List.new list, :comma
|
59
|
+
end
|
264
60
|
|
265
|
-
|
266
|
-
|
267
|
-
|
61
|
+
private :list_new
|
62
|
+
|
63
|
+
def list_series *lists
|
64
|
+
lists.map! do |list|
|
65
|
+
list = list.to_a
|
66
|
+
sentinel = list.first
|
67
|
+
|
68
|
+
first, second, operator, *rest, last = list.map &:value
|
69
|
+
next list unless Numeric === last &&
|
70
|
+
Numeric === first &&
|
71
|
+
Numeric === second &&
|
72
|
+
/^_+$/ === operator &&
|
73
|
+
rest.all?(&Numeric.method(:===))
|
74
|
+
|
75
|
+
delta = second - first
|
76
|
+
case operator
|
77
|
+
when "_" then (first.. last)
|
78
|
+
when "__" then (first... last)
|
79
|
+
end.step(delta).map do |value|
|
80
|
+
number_new value, sentinel.numerator_units, sentinel.denominator_units
|
81
|
+
end
|
82
|
+
end
|
83
|
+
list_new lists.flatten, :comma
|
84
|
+
end
|
268
85
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
number = list.first
|
273
|
-
first, second, operator, *rest, last = list.map &:value
|
274
|
-
this = first
|
275
|
-
delta = second - first
|
276
|
-
case operator
|
277
|
-
when "_" then [].tap { |list| while this <= last; list << this; this += delta; end }
|
278
|
-
when "__" then [].tap { |list| while this < last; list << this; this += delta; end }
|
279
|
-
else list
|
280
|
-
end.map { |value| Sass::Script::Value::Number.new value, number.numerator_units, number.denominator_units }
|
281
|
-
}.flatten, :comma
|
282
|
-
end
|
283
|
-
declare :list_of, [:list], :var_args => true
|
86
|
+
def to_number_from_fraction str
|
87
|
+
number_new eval "1.0 * #{ str.value }" if %r{ ^ [0-9]+ / [0-9]+ $ }x === str.value
|
88
|
+
end
|
284
89
|
|
90
|
+
def to_fraction_from_number num
|
91
|
+
string_new Rational(num.value).rationalize(0.0001).to_s, :identifier
|
285
92
|
end
|
93
|
+
|
286
94
|
end
|
95
|
+
prepend Dashy
|
287
96
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Sass::Script::Value::String
|
2
|
+
module Dashy
|
3
|
+
|
4
|
+
def to_s *sig
|
5
|
+
return super unless :selector === type
|
6
|
+
selector = self.value.dup
|
7
|
+
|
8
|
+
# Escape...
|
9
|
+
#
|
10
|
+
# ...decimals:
|
11
|
+
#
|
12
|
+
selector.gsub! %r{ (?<=[0-9]) (?=[.][0-9]) }x, '\\' # Escape any unescaped decimal points...
|
13
|
+
selector.gsub! %r{ (?<=[0-9]) ( [\\][.] [0-9]{2} ) [0-9]+ }x, '\1' # Remove extra precision (> 2).
|
14
|
+
selector.gsub! %r{ (?<=[0-9]) ( [\\][.] [0-9]*? ) [0]+ (?=[^0-9]) }x, '\1' # Remove trailing zeroes.
|
15
|
+
selector.gsub! %r{ (?<=[0-9]) ( [\\][.] ) (?=[^0-9]) }x, '' # Remove trailing dot.
|
16
|
+
#
|
17
|
+
# ...punctuation:
|
18
|
+
#
|
19
|
+
selector.gsub! %r{ (?<!\\) (?=[/%$?!]) }x, "\\" # Escape any unescaped punctuation...
|
20
|
+
selector
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
prepend Dashy
|
25
|
+
end
|