summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerman M. Bravo <german.mb@deipi.com>2013-08-13 17:10:09 -0500
committerGerman M. Bravo <german.mb@deipi.com>2013-08-13 17:10:09 -0500
commit534bcaf7191c8455d391c3e628f42a944ef72761 (patch)
tree663599753ee6efde2a410870852470f6d2b9842a
parent81556aab7ee4897f465907453cd197b82f2a8db1 (diff)
downloadpyscss-534bcaf7191c8455d391c3e628f42a944ef72761.tar.gz
Gradients _position() optimizations and default positions
-rw-r--r--scss/functions/compass/gradients.py4
-rw-r--r--scss/functions/compass/helpers.py28
2 files changed, 17 insertions, 15 deletions
diff --git a/scss/functions/compass/gradients.py b/scss/functions/compass/gradients.py
index 5119b39..20646f1 100644
--- a/scss/functions/compass/gradients.py
+++ b/scss/functions/compass/gradients.py
@@ -314,8 +314,8 @@ def linear_gradient(*args):
def to__owg():
args = [
'linear',
- position(position_and_angle or ['center', 'top']),
- opposite_position(position_and_angle or ['center', 'top']),
+ position(position_and_angle or None),
+ opposite_position(position_and_angle or None),
]
args.extend('color-stop(%s, %s)' % (to_str(s), c) for s, c in color_stops)
ret = '-webkit-gradient(' + ', '.join(to_str(a) for a in args or [] if a is not None) + ')'
diff --git a/scss/functions/compass/helpers.py b/scss/functions/compass/helpers.py
index bde12ef..3300df9 100644
--- a/scss/functions/compass/helpers.py
+++ b/scss/functions/compass/helpers.py
@@ -364,29 +364,31 @@ def range_(frm, through=None):
# ------------------------------------------------------------------------------
# Working with CSS constants
-OPPOSITE_POSITIONS = dict(
- top='bottom',
- bottom='top',
- left='right',
- right='left',
- center='center',
-)
+OPPOSITE_POSITIONS = {
+ 'top': StringValue('bottom', quotes=None),
+ 'bottom': StringValue('top', quotes=None),
+ 'left': StringValue('right', quotes=None),
+ 'right': StringValue('left', quotes=None),
+ 'center': StringValue('center', quotes=None),
+}
+DEFAULT_POSITION = [StringValue('center', quotes=None), StringValue('top', quotes=None)]
def _position(opposite, positions):
- positions = List.from_maybe(positions)
+ if positions is None:
+ positions = DEFAULT_POSITION
+ else:
+ positions = List.from_maybe(positions)
ret = []
for pos in positions:
if isinstance(pos, (StringValue, six.string_types)):
- _pos = getattr(pos, 'value', pos)
- if _pos in OPPOSITE_POSITIONS:
+ pos_value = getattr(pos, 'value', pos)
+ if pos_value in OPPOSITE_POSITIONS:
if opposite:
- opp = OPPOSITE_POSITIONS[pos]
- ret.append(StringValue(opp, quotes=None))
+ ret.append(OPPOSITE_POSITIONS[pos_value])
else:
ret.append(pos)
-
continue
elif isinstance(pos, NumberValue):