Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Martijn Brackman
seal-mask
.a{fill-rule:evenodd;}techdegree
Martijn Brackman
Full Stack JavaScript Techdegree Student 3,721 Points

Best practices for customizing a Foundation 6 website?

I am making a website using Foundation for Sites 6. I completed the courses "Framework Basics" and "Sass Basics". It's going rather well and, so far, I have achieved what I wanted to achieve and I am very happy with the visual result.

But I am not sure that I customized the framework in the best way possible. I want to learn how to do it proper. The courses learned me the workings of the framework but not really how to properly customize it or what the best practices are to customize it.

I noticed for example that I can use the _settings.scss file to change global settings. That works fine and I perfectly understand how it works. I changed some settings and checked the documentation on how to use them.

But, this settings file only gets you this far. If you really want to customize it you quickly run into a couple of problems. For example ... It's very easy to change the primary color. Once you do, you see a lot of colors change in your website. But, that is not always what you want. Sometimes you want to change the color of a certain button and not everything else.

So, what I did is creating a custom.css file in the css-folder to customize everything. It works perfectly. But, since the version of the framework I use, also uses Sass ... I feel like I do not make proper use of the abilities of the framework.

My big question is ... how do I do it properly or is it OK to work the way I work?

1 Answer

Hey Martijn, I am glad to see some treehouse community members using Foundation for sites. I can't say that I am an expert in this, but I have been using foundation since version 4, and I have built three website so far on Foundation for Sites 6 and many others on the older versions. I'll let you in on my workflow.

My approach to frameworks like Foundation is to use as much or as little as I need from it, and Foundation does a great job at that. It's extremely modular where you can select which sass components you would like to include in the app.scss file and then select which javascript modules you need in the gulp file.

The _settings.scss file works like the core theme file for the website, you can set the colors, general typography, spacing and some of the stylistic choices for the site. The first thing I do when building a website is setup the _settings.scss file to my brand style guide for the project. It doesn't give you full control over every style for each component, because some of the decisions are already made in terms on the core build and structure of the components.

The second step is to create you own components folder inside you scss directory. This should include all the custom components you build and the overrides for the components that come with Foundation. Depending on the size of the project I have the structure of my css changes. But the most common approach is to separate the core structure form the theme of each element.

So my _nav-component.scss would include the size properties and position for my nav, when the _nav-theme.scss includes the typography, colors and interaction states like hover and active styles. This might seem a bit tedious at first, but if it's a big project it's much better to separate the two. Depending on how big the project is, you might even want to separate the interaction states to a another file as well. This keeps you components reusable, so you can use them in other projects.

And on a similar note you would build your javascript side.

As far as your example about buttons. Buttons or any other component in Foundation can be used programmatically in you sass with mixins and extends.

.my-button{
    @include button-style($background, $background-hover, $color);
}

or for the orbit component like this

 .my-orbit--wrapper {
    @include orbit-wrapper;
    .my-orbit--container{
        @include orbit-container;
    }
    .my-orbit--slide{
        @include orbit-slide;
    }
    .my-orbit--caption{
        @include orbit-caption;
    }
}

If you look through the documentation you would be able to find mixins to include in you custom css and build whatever you like using all the components in Foundation under the sass reference for each component.

I hope this helps

Martijn Brackman
seal-mask
.a{fill-rule:evenodd;}techdegree
Martijn Brackman
Full Stack JavaScript Techdegree Student 3,721 Points

Thank you very much for taking the time to answer my question. It's very valuable. I will first finish the project the way I started it and then try to remake it the way you suggest.