From a styling point of view I can achieve what I need but it feels like I am duplicating a lot of code.
I've created a very small example of what I am trying to achieve on a much bigger scale. Each difficulty level as a colour associated with it and is used for different things like font colour, border colour, background colour etc.
<div class="lesson easy">
<h2>Easy Lesson</h2>
<p>Description</p>
<button>More Info</button>
</div>
<div class="lesson medium">
<h2>Medium Lesson</h2>
<p>Description</p>
<button>More Info</button>
</div>
<div class="lesson hard">
<h2>Hard Lesson</h2>
<p>Description</p>
<button>More Info</button>
</div>
//variables that relate to a specific difficulty
$easy: green;
$medium: orange;
$hard: red;
//base styles
.lesson {
border: 2px solid black;
width: 200px;
float: left;
margin-right: 10px;
padding: 0px 20px 20px 20px;
}
button {
border: 0;
padding: 10px;
}
//specific styles, is there an easier, cleaner way to write this using a mixin that will allow me to use it on a much larger scale with even more nested HTML elements?
.lesson {
&.easy {
border-color: $easy;
button {
background: $easy;
}
p {
color: $easy;
}
}
&.medium {
border-color: $medium;
button {
background: $medium;
}
p {
color: $medium;
}
}
&.hard {
border-color: $hard;
button {
background: $hard;
}
p {
color: $hard;
}
}
}