anything-scripts

Disposable scripts to fix day to day problems.
git clone git://soucy.cc/anything-scripts.git
Log | Files | Refs

get-svg-sizes-to-css-class (675B)


      1 #!/bin/bash
      2 
      3 pth=$1
      4 
      5 get_svg_sizes_to_css_class () {
      6     svg_location="$pth"
      7     css_file="$(basename $svg_location).css"
      8 
      9     touch "/tmp/$css_file"
     10 
     11     for svg in $(find "$svg_location" -type f \( -name "*.svg" \)); do
     12         svg_width=$(cat "$svg" | ~/go/bin/pup "svg attr{width}")
     13         svg_height=$(cat "$svg" | ~/go/bin/pup "svg attr{height}")
     14         svg_name=$(basename "$svg")
     15         svg_classname="${svg_name%.*}"
     16 
     17         echo ".$svg_classname {"
     18         echo "  height: calc-em($svg_height," '$base-size);'
     19         echo "  width: calc-em($svg_width," '$base-size);'
     20         echo "}"
     21         echo ""
     22 
     23     done > "/tmp/$css_file"
     24 }
     25 
     26 get_svg_sizes_to_css_class