Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
Created July 1, 2011 20:32
Show Gist options
  • Save chriseppstein/1059334 to your computer and use it in GitHub Desktop.
Save chriseppstein/1059334 to your computer and use it in GitHub Desktop.
require 'sass'
module Sass::Script::Functions
def svg_circle(radius, color, circle_type)
img = if circle_type.value == "disc"
%Q{<circle cx="#{radius.value}" cy="#{radius.value}" r="#{radius.value}"
stroke-width="0" fill="#{color}"/>}
else
%Q{<circle cx="#{radius.value}" cy="#{radius.value}" r="#{radius.value}"
stroke="#{color}" stroke-width="1" fill="white"/>}
end
inline_image_string(svg_circle_envelope(img).gsub(/ +/, ' '), 'image/svg+xml')
end
private
def svg_circle_envelope(content)
%Q{<?xml version="1.0" encoding="utf-8"?> <svg version="1.1" xmlns="http://www.w3.org/2000/svg">#{content}</svg>}
end
end
// Draw a list style image in svg using the radius and color specified.
@mixin colored-bullet($radius, $color, $type: disc) {
list-style-type: $type;
list-style-image: svg-circle($radius, $color, $type);
}
ul {
@include colored-bullet(2px, $green, disc);
ul {
@include colored-bullet(2px, $green, circle);
}
}
@scottdavis
Copy link

thats bas ass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment