Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Modern tools for Magento development Part 2

Erfan
August 26, 2014

Modern tools for Magento development Part 2

In the web industry there are a lot of tools available to make a developers life easier. Because this ecosystem moves so fast - and it's hard to keep track of everything - I thought it would be a good idea to do a roundup of tools I personally use for Magento development. These slides cover Sass, Compass, Bundler and a method to compartmentalise styling for large websites.

Erfan

August 26, 2014
Tweet

More Decks by Erfan

Other Decks in Programming

Transcript

  1. Sass • CSS pre-processor • Compiles to CSS “Sass is

    an extension of CSS3 which adds nested rules, variables, mixins, selector inheritance, and more. Sass generates well formatted CSS and makes your stylesheets easier to organize and maintain.” - compass-style.org
  2. Compass • Framework for Sass • Allows you to manage

    settings for a project (config.rb) • Library of handy mixins
  3. Config.rb • Cache busting • Control CSS output style •

    Paths and URL’s • Include functionality from Ruby Gems
  4. Bundler • Dependency manager for Ruby Gems ◦ Gemfile ◦

    Gemfile.lock ◦ .bundle/config ▪ bundle install --path vendor
  5. Integration with Magento • config.rb goes somewhere in theme’s skin

    folder ◦ skin/frontend/rwd/default/. . . • You tell config.rb where to put generated CSS
  6. Folder structure - skin/frontend/{package}/default/ - img/ - js/ - scss/

    - _catalog.scss - _grid.scss - styles.scss - css/ - styles.css - config.rb
  7. What if you need “homepage.css” ? - skin/frontend/{package}/default/ - scss/

    - _catalog.scss - _grid.scss - homepage.scss - styles.scss - css/ - homepage.css - styles.css - config.rb
  8. We can do better • Why? ◦ Importing partials -

    which produce output - might cause certain CSS rules to be included twice on the page ◦ This can become difficult to scale for large projects ▪ The more pages, the longer compilation time ▪ Difficult to manage partials
  9. Multiple themes • Overwrite templates • Overwrite any asset in

    skin folder Using themes keeps the default theme relevant and clean in terms of CSS/JS and template files
  10. Compass and multiple themes • We want to have access

    to our main theme’s Sass so we can use its variables and mixins
  11. Compass and multiple themes • We want to have access

    to our main theme’s Sass so we can use its variables and mixins • add_import_path ◦ add_import_path "../default/scss"
  12. - default/ - img/ - scss/ - components/ - styles.scss

    - landingpage/ - scss/ - _landingpage.scss - styles.scss
  13. - default/ - img/ - scss/ - components/ - styles.scss

    - landingpage/ - scss/ - _landingpage.scss - styles.scss @include “styles”; @include “landingpage”;
  14. - default/ - img/ - scss/ - components/ - styles.scss

    - landingpage/ - scss/ - _landingpage.scss - styles.scss @include “styles”; @include “landingpage”; @import loop!
  15. - default/ - img/ - scss/ - components/ - _styles.default.scss

    - styles.scss - @include “styles.default”; - landingpage/ - scss/ - _landingpage.scss - styles.scss @include “styles.default”; @include “landingpage”;