Skip to content

Instantly share code, notes, and snippets.

@Naedri
Last active November 24, 2023 08:21
Show Gist options
  • Save Naedri/ba53cb0b372d01e4e615ababbacddba8 to your computer and use it in GitHub Desktop.
Save Naedri/ba53cb0b372d01e4e615ababbacddba8 to your computer and use it in GitHub Desktop.
Checklist to know if a SCSS style file can be simplified into CSS.
// 1. File Extension
// - Example: The file is named styles.scss
// 2. SCSS Syntax Features
// - Example: Use of variables, nesting, mixins, and extends in this file.
$base-font-size: 16px;
body {
font-size: $base-font-size;
color: #333;
}
.container {
width: 100%;
max-width: 1200px;
margin: 0 auto;
// 3. Mixins and Functions
// - Example: Custom mixin for box-shadow.
@mixin box-shadow($x, $y, $blur, $color) {
box-shadow: $x $y $blur $color;
}
.box {
@include box-shadow(2px, 2px, 5px, #888);
}
}
// 4. Nested Selectors
// - Example: Nested selector for the hover state of anchor tags.
a {
color: blue;
&:hover {
color: darkblue;
}
}
// 5. Variables
// - Example: Use of variables.
$primary-color: #3498db;
.button {
background-color: $primary-color;
color: white;
}
// 6. Functions
// - Example: Use of SCSS functions.
$base-color: #333;
.link {
color: lighten($base-color, 20%);
}
// 7. Mixins
// - Example: Custom mixin for transitions.
@mixin transition($property, $duration) {
transition: $property $duration ease-in-out;
}
.element {
@include transition(all, 0.3s);
}
// 8. Extends
// - Example: Using @extend to share styles between selectors.
%text-style {
font-weight: bold;
font-style: italic;
}
.title {
@extend %text-style;
font-size: 24px;
}
// 9. Check Imports
// - Example: Importing another SCSS file with specific features.
@import 'reset';
// 10. File Size
// - Example: Medium-sized file with various features.
// 11. Dependency Analysis
// - Example: The file imports 'reset', which may use SCSS features.
// 12. Compile and Test
// - Example: Compile the SCSS file to ensure it works as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment