better examples and some comments.

This commit is contained in:
Chris Eppstein 2010-02-16 22:13:07 -08:00
parent aef52bd57e
commit cee0eef688
5 changed files with 43 additions and 16 deletions

View File

@ -30,21 +30,37 @@
%h2 Gradients %h2 Gradients
%pre.horizontal %pre.horizontal
%code<> %code<>
+h-gradient(#d92626, #2626d9) :preserve
+linear-gradient(
color_stops(#d92626, #2626d9),
"left")
%pre.vertical %pre.vertical
%code<> %code<>
+v-gradient(#d92626, #2626d9) :preserve
+linear-gradient(
color_stops(#d92626, #2626d9))
%pre.diagonal %pre.diagonal
%code< %code<
+linear-gradient("left top", :preserve
"right bottom",
\#d92626, #2626d9)
+linear-gradient(
color_stops(#d92626, #2626d9),
"top left")
%pre.radial %pre.radial
%code<> %code<>
+radial-gradient(<br /> "center center, 10, center center, 100",<br /> #d92626, #2626d9) +radial-gradient(<br /> "center center, 10, center center, 100",<br /> #d92626, #2626d9)
.examples .examples
#border-radius.example #border-radius.example
%h2 Border Radius %h2 Border Radius
%p This box has rounded corners
.gutter .gutter
#box-shadow.example #box-shadow.example
%h2 Box Shadow %h2 Box Shadow

View File

@ -1,6 +1,6 @@
@import compass/css3.sass @import compass/css3.sass
+font-face("Angelina", font-files("angelina.ttf", 'truetype')) +font-face("Angelina", font_files("angelina.ttf", "truetype"))
h1 h1
font-family: "Angelina" font-family: "Angelina"
font-size: 5em font-size: 5em

View File

@ -5,6 +5,6 @@
height: 100px height: 100px
border: 1px solid #777 border: 1px solid #777
.linear .linear
+v-gradient(#fff, #aaa, color_stop(50%, #ccc, 50%, #bbb)) +linear-gradient(color_stops(#fff, #f00 50%, #ff0 75%, #0f0))
.radial .radial
+radial-gradient("45 45, 10, 52 50, 30", "Cyan", "DodgerBlue") +radial-gradient("45 45, 10, 52 50, 30", "Cyan", "DodgerBlue")

View File

@ -39,7 +39,7 @@ h1
content: " " content: " "
.example .example
+v-gradient(#fff, #ccc) +linear-gradient(color_stops(#fff, #ccc))
pre pre
padding: 1em padding: 1em
margin: 1em margin: 1em
@ -48,8 +48,8 @@ h1
font-weight: bold font-weight: bold
#background-clip #background-clip
pre pre
background: transparent #{image-url("fresh-peas.jpg")} no-repeat background: transparent #{image_url("fresh-peas.jpg")} no-repeat
border: 1em solid #{transparentize(red, .75)} border: 1em solid rgba(255,0,0,.25)
.padding-box .padding-box
+background-clip("padding-box") +background-clip("padding-box")
+background-origin("padding-box") +background-origin("padding-box")
@ -59,8 +59,9 @@ h1
#background-size #background-size
pre pre
background: transparent #{image-url("fresh-peas.jpg")} no-repeat background: transparent #{image_url("fresh-peas.jpg")} no-repeat
border: 1em solid #{transparentize(red, .75)} border: 1em solid #{mix(red, white, .5)}
border: 1em solid rgba(255,0,0,.25)
.top-left .top-left
+background-size(50% 50%) +background-size(50% 50%)
.centered .centered
@ -69,12 +70,13 @@ h1
#gradients #gradients
.horizontal .horizontal
+h-gradient(#d92626, #2626d9) +linear-gradient(color_stops(#d92626, #2626d9), "left")
.vertical .vertical
+v-gradient(#d92626, #2626d9) +linear-gradient(color_stops(#d92626, #2626d9))
.diagonal .diagonal
+linear-gradient("left top", "right bottom", #d92626, #2626d9) +linear-gradient(color_stops(#d92626, #2626d9), "right top")
.radial .radial
+radial-gradient("center center, 10, center center, 100", #d92626, #2626d9) +radial-gradient("center center, 10, center center, 100", #d92626, #2626d9)
background-image: -moz-radial-gradient(20px center, circle, 40px center #d92626 10px, #2626d9 100px)
background-color: #2626d9 background-color: #2626d9

View File

@ -33,6 +33,7 @@ module Compass::SassExtensions::Functions::GradientSupport
end end
module Functions module Functions
# returns the opposite position of a side or corner.
def grad_opposite_position(position) def grad_opposite_position(position)
opposite = position.value.split(/ +/).map do |pos| opposite = position.value.split(/ +/).map do |pos|
case pos case pos
@ -46,6 +47,8 @@ module Compass::SassExtensions::Functions::GradientSupport
end end
Sass::Script::String.new(opposite.join(" ")) Sass::Script::String.new(opposite.join(" "))
end end
# returns color-stop() calls for use in webkit.
def grad_color_stops(color_list) def grad_color_stops(color_list)
positions = color_list.values.map{|c| [c.stop && c.stop.value, c.color]} positions = color_list.values.map{|c| [c.stop && c.stop.value, c.color]}
# fill in the blank positions # fill in the blank positions
@ -74,12 +77,18 @@ module Compass::SassExtensions::Functions::GradientSupport
Sass::Script::String.new(color_stops.join(", ")) Sass::Script::String.new(color_stops.join(", "))
end end
end end
# the first color from a list of color stops
def grad_start_color(color_list) def grad_start_color(color_list)
color_list.values.first.color color_list.values.first.color
end end
# the last color from a list of color stops
def grad_end_color(color_list) def grad_end_color(color_list)
color_list.values.last.color color_list.values.last.color
end end
# the given a position, return a point in percents
def grad_point(position) def grad_point(position)
position = position.value position = position.value
position = if position[" "] position = if position[" "]