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 Modular CSS with Sass Sass and BEM Styling Form Elements

Bruno Dias
Bruno Dias
10,554 Points

Classes for btn

Where did you define the classes for btn--default, btn--success, btn--error, btn--warning and btn--info?

Sorry lost you on this part. We may have done this on previous lessons but I can't find it.

2 Answers

Hi Bruno,

btn-- styles are defined in _main.scss and _extends.scss. Colors are defined in _config.scss

/* _main.scss */
.btn {
    @include bg-colors($ui-colors);
}

[class^="btn--"] {
  @extend %btn;
  margin-bottom: em(20px, 14px); 
  width: auto;
  display: inline-block;
  margin-right: em(15px, 14px);
} 
/* _extends.scss */

%btn {
  padding: 15px 30px;
  border: 0;
  border-radius : $br--default;
  color: $white;
  text-transform: uppercase;
  font-size : em(14px);
  font-weight: $font-weight--medium;
  transition: opacity $trns-duration;
  display: block;
  &:hover {
    opacity: .75;
  }
  &:active {
    opacity: initial;
  }
}
/* _config.scss */

$fountain-blue  : #52bab3;
$emerald        : #5ece7f;
$sunglo         : #e67478;
$coral          : #ff784f;
$purple-majesty : #9279c3;
$scooter        : #39add1;

// UI Colors
$ui-colors: (
    default : $fountain-blue,
    success : $emerald,
    error   : $sunglo,
    warning : $coral,
    info    : $purple-majesty
);

Think thats all of them.

Hope this helps :)

EDIT:

Also see _utilities.scss for the bg-colors mixin

// Mixins

@mixin bg-colors($map) {
    @each $theme, $color in $map {
        &--#{$theme} {
            background-color: $color;    
        }
    }
}