In this blog post, I discuss how I was introduced to the magical world of SVG's and why I will definitely be using them in the future!
I recently had the pleasure of building TEDx Folkestone, designed by Flourish Studios. I really loved the design - it’s modern and I love the big fonts and quirky graphics that give the whole website some personality. Being such a fan of the design I really wanted to do it justice when I was building the site, especially with the translucent graphics that show throughout.
I had to create this graphic, half of a red translucent X, that would be positioned to the right of the page.
I didn’t want it to be a JPEG/PNG, as it had to be scalable and I didn’t want the image to lose any sort of resolution on smaller screens. My solution to this was to use CSS to create the shape. I had made shapes in CSS before, I didn’t think this would be too different! I could set the transparency, have control over how it resizes on small screens with media queries (what was I thinking) and I would feel really clever for doing all of this in code.
Me @ past me for considering media queries and css as a solution
Of course, doing this in CSS was not the most efficient way. It involved a lot of pseudo elements, a lot of negative positioning, empty divs on the page. It was frustrating and I was wondering why I was putting myself through this. I asked for some help and Luke said “Why don’t you use SVG’s? It'll scale nicer and also have really good browser support”.
The reason, is simply I just hadn’t considered it before! I had never really worked with them before and my only exposure was following Sara Soueidan, one of the most influential SVG writers, on Twitter. I knew that they were a way of creating images and animations but I wasn’t sure why/when I would use them over my usual image formats. Until now! I saw this as a great opportunity to learn something new and anything that scales nicely and has good browser support is definitely worth picking up!
A solution that offers scalable, customisable and small sized images? Mind blown
I was able to create the SVG xml files using the Sketch App free trial. In Sketch, you can create an image/symbol and then convert that symbol into an SVG. If I didn’t have Sketch, I would use an online conversion tool, that would cleverly pick out all of the lines/co-ordinates of an image and give you them in XML. A great example is Vector Magic. SVG conversions work better on 2 dimensional images that are quite flat in design, like illustrations and symbols. For images that have a lot of complexity, and are colour heavy like a photograph it is better to stick with PNG/JPEG type images.
After a lot of help from my team I had a set of graphics, that looked great and true to the design!
Here are my reasons why for future projects, I will be thinking SVG first!
To learn more, have a look at this SVG course from CSS Tricks: https://css-tricks.com/lodge/svg/ I still have a lot to learn and I look forward to blogging about SVG’s in the future!