svg_sprite 0.2.2 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/.github/CODEOWNERS +4 -0
  3. data/.github/FUNDING.yml +4 -0
  4. data/.github/ISSUE_TEMPLATE/bug_report.md +41 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
  6. data/.github/PULL_REQUEST_TEMPLATE.md +38 -0
  7. data/.github/dependabot.yml +15 -0
  8. data/.github/workflows/ruby-tests.yml +54 -0
  9. data/.gitignore +1 -0
  10. data/.rubocop.yml +10 -0
  11. data/CHANGELOG.md +24 -0
  12. data/CODE_OF_CONDUCT.md +55 -30
  13. data/CONTRIBUTING.md +79 -0
  14. data/Gemfile +3 -1
  15. data/{LICENSE.txt → LICENSE.md} +0 -0
  16. data/README.md +131 -83
  17. data/Rakefile +6 -1
  18. data/bin/console +1 -0
  19. data/examples/images/doc-fill.svg +3 -0
  20. data/examples/images/doc.svg +3 -0
  21. data/examples/images/trash-fill.svg +3 -0
  22. data/examples/images/trash.svg +3 -0
  23. data/examples/index.html +94 -15
  24. data/examples/sprite/current-color.css +26 -0
  25. data/examples/sprite/current-color.svg +16 -0
  26. data/examples/sprite/original.css +26 -0
  27. data/examples/sprite/original.svg +16 -0
  28. data/examples/sprite/remove.css +26 -0
  29. data/examples/sprite/remove.svg +16 -0
  30. data/exe/svg_sprite +2 -0
  31. data/lib/svg_sprite/cli.rb +44 -27
  32. data/lib/svg_sprite/svg.rb +45 -46
  33. data/lib/svg_sprite/version.rb +4 -2
  34. data/lib/svg_sprite.rb +138 -25
  35. data/svg_sprite.gemspec +15 -6
  36. metadata +89 -41
  37. data/.travis.yml +0 -4
  38. data/examples/README.md +0 -19
  39. data/examples/source/a/blue-square.svg +0 -10
  40. data/examples/source/a/orange-square.svg +0 -10
  41. data/examples/source/b/green-square.svg +0 -10
  42. data/examples/source/b/yellow-square.svg +0 -10
  43. data/examples/source/scss.scss +0 -13
  44. data/lib/svg_sprite/source.rb +0 -17
  45. data/lib/svg_sprite/sprite.rb +0 -13
  46. data/lib/svg_sprite/template/css.erb +0 -12
  47. data/lib/svg_sprite/template/css.rb +0 -13
  48. data/lib/svg_sprite/template/scss.erb +0 -33
  49. data/lib/svg_sprite/template/scss.rb +0 -19
  50. data/lib/svg_sprite/template.rb +0 -6
@@ -1,10 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
3
- <!-- Generator: Sketch 3.4.4 (17248) - http://www.bohemiancoding.com/sketch -->
4
- <title>Rectangle 1</title>
5
- <desc>Created with Sketch.</desc>
6
- <defs></defs>
7
- <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
8
- <rect id="Rectangle-1" fill="#4990E2" sketch:type="MSShapeGroup" x="0" y="0" width="25" height="25"></rect>
9
- </g>
10
- </svg>
@@ -1,10 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
3
- <!-- Generator: Sketch 3.4.4 (17248) - http://www.bohemiancoding.com/sketch -->
4
- <title>Rectangle 1</title>
5
- <desc>Created with Sketch.</desc>
6
- <defs></defs>
7
- <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
8
- <rect id="Rectangle-1" fill="#F6A623" sketch:type="MSShapeGroup" x="0" y="0" width="25" height="25"></rect>
9
- </g>
10
- </svg>
@@ -1,10 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
3
- <!-- Generator: Sketch 3.4.4 (17248) - http://www.bohemiancoding.com/sketch -->
4
- <title>Rectangle 1</title>
5
- <desc>Created with Sketch.</desc>
6
- <defs></defs>
7
- <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
8
- <rect id="Rectangle-1" fill="#7ED321" sketch:type="MSShapeGroup" x="0" y="0" width="25" height="25"></rect>
9
- </g>
10
- </svg>
@@ -1,10 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
3
- <!-- Generator: Sketch 3.4.4 (17248) - http://www.bohemiancoding.com/sketch -->
4
- <title>Rectangle 1</title>
5
- <desc>Created with Sketch.</desc>
6
- <defs></defs>
7
- <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
8
- <rect id="Rectangle-1" fill="#F8E81C" sketch:type="MSShapeGroup" x="0" y="0" width="25" height="25"></rect>
9
- </g>
10
- </svg>
@@ -1,13 +0,0 @@
1
- @import "./icons";
2
-
3
- .sass-after {
4
- @include sprite-after("blue-square");
5
- }
6
-
7
- .sass-before {
8
- @include sprite-before("orange-square");
9
- }
10
-
11
- .sass-inner {
12
- @extend %sprite-green-square;
13
- }
@@ -1,17 +0,0 @@
1
- module SvgSprite
2
- class Source
3
- def initialize(directory)
4
- @directory = directory
5
- end
6
-
7
- def each(&block)
8
- to_a.each(&block)
9
- end
10
-
11
- def to_a
12
- Dir["#{@directory}/**/*.svg"].map do |file|
13
- SVG.new(file)
14
- end
15
- end
16
- end
17
- end
@@ -1,13 +0,0 @@
1
- module SvgSprite
2
- class Sprite
3
- def initialize(source, template, options)
4
- @source = source
5
- @template = template
6
- @options = options
7
- end
8
-
9
- def render
10
- @template.call(@source, @options)
11
- end
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- /* Generated by sprite_svg v<%= SvgSprite::VERSION %> at <%= Time.now %> */
2
- <% for svg in source %>
3
- .<%= options[:name] %>-<%= svg.name %>,
4
- .<%= options[:name] %>-<%= svg.name %>-before:before,
5
- .<%= options[:name] %>-<%= svg.name %>-after:after {
6
- background-image: url(<%= svg.data_uri %>);
7
- <%- if svg.has_dimensions? -%>
8
- width: <%= svg.width %>;
9
- height: <%= svg.height %>;
10
- <%- end -%>
11
- }
12
- <% end %>
@@ -1,13 +0,0 @@
1
- module SvgSprite
2
- module Template
3
- class CSS
4
- def template
5
- @template ||= File.read("#{__dir__}/css.erb")
6
- end
7
-
8
- def call(source, options)
9
- ERB.new(template, nil, "-").result binding
10
- end
11
- end
12
- end
13
- end
@@ -1,33 +0,0 @@
1
- // Generated by sprite_svg v<%= SvgSprite::VERSION %> at <%= Time.now %>
2
- $<%= options[:name] %>-names: (<%= names(source) %>);
3
- $<%= options[:name] %>-urls: (
4
- <%- for svg in source -%>
5
- <%= svg.name %>: "<%= svg.data_uri %>",
6
- <%- end -%>
7
- );
8
-
9
- @function <%= options[:name] %>-url($name) {
10
- @return map-get($<%= options[:name] %>-urls, $name);
11
- }
12
-
13
- @mixin <%= options[:name] %>-before($name) {
14
- &:before {
15
- @extend %<%= options[:name] %>-#{$name};
16
- }
17
- }
18
-
19
- @mixin <%= options[:name] %>-after($name) {
20
- &:after {
21
- @extend %<%= options[:name] %>-#{$name};
22
- }
23
- }
24
-
25
- <% for svg in source %>
26
- %<%= options[:name] %>-<%= svg.name %> {
27
- background-image: url(<%= options[:name] %>-url("<%= svg.name %>"));
28
- <%- if svg.has_dimensions? -%>
29
- width: <%= svg.width %>;
30
- height: <%= svg.height %>;
31
- <%- end -%>
32
- }
33
- <%- end -%>
@@ -1,19 +0,0 @@
1
- module SvgSprite
2
- module Template
3
- class SCSS
4
- def template
5
- @template ||= File.read("#{__dir__}/scss.erb")
6
- end
7
-
8
- def call(source, options)
9
- ERB.new(template, nil, "-").result binding
10
- end
11
-
12
- private
13
-
14
- def names(source)
15
- source.to_a.map(&:name).join(", ")
16
- end
17
- end
18
- end
19
- end
@@ -1,6 +0,0 @@
1
- module SvgSprite
2
- TEMPLATES = {
3
- "scss" => Template::SCSS.new,
4
- "css" => Template::CSS.new
5
- }
6
- end