Created
August 2, 2014 03:51
-
-
Save MichaelArestad/7715b71971433fa5aff0 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.4.0.rc.3) | |
// Compass (v1.0.0.rc.0) | |
// ---- | |
// Sets initial toc value | |
$toc-value: 0; | |
@mixin toc($content, $sub: false) { | |
// Creates map for toc mixin to use | |
@if variable-exists(toc){} @else { | |
$toc:() !global; | |
} | |
// Sets index numbering | |
@if $sub == false { // increments by 1 (rounding down) | |
$toc-value: floor($toc-value) + 1 !global; | |
} @else { // increments by .1 | |
$toc-value: $toc-value + .1 !global; | |
} | |
// adds key (toc number) and value (string) to $toc map | |
$toc: map-merge($toc, ($toc-value: $content)) !global; | |
/*-------------------------------------------------------------- | |
#{$toc-value} - #{$content} | |
--------------------------------------------------------------*/ | |
} | |
// Outputs TOC - only works at the end of the file :( | |
@mixin toc-list($map) { | |
$toc-list:(); | |
@each $number, $item in $map { | |
$spacing: ' '; | |
@for $i from 1 to (6 - str-length('#{$number}')) { | |
$spacing: $spacing + ' '; | |
} | |
/* #{$number}#{$spacing}- #{$item} */ | |
} | |
} | |
@include toc("Hello friend!"); | |
.hello { | |
color: hello; | |
} | |
@include toc("Let's tak about indices.", true); | |
.index { | |
background: awesome; | |
} | |
@include toc("Who doesn't love a good table of contents?"); | |
// @import 'some/file'; | |
.code { | |
font-size: bazillions; | |
} | |
@include toc("I do.", true); | |
@include toc("I especially love generated ToCs."); | |
@include toc("That's why I made this mixin.", true); | |
@include toc("Now, reararranging partials with a ToC isn't a nightmare."); | |
@include toc("You're welcome.", true); | |
/* | |
I would love the list below to be at the top of the compiled CSS. | |
Any ideas? | |
*/ | |
@include toc-list($toc); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*-------------------------------------------------------------- | |
1 - Hello friend! | |
--------------------------------------------------------------*/ | |
.hello { | |
color: hello; | |
} | |
/*-------------------------------------------------------------- | |
1.1 - Let's tak about indices. | |
--------------------------------------------------------------*/ | |
.index { | |
background: awesome; | |
} | |
/*-------------------------------------------------------------- | |
2 - Who doesn't love a good table of contents? | |
--------------------------------------------------------------*/ | |
.code { | |
font-size: bazillions; | |
} | |
/*-------------------------------------------------------------- | |
2.1 - I do. | |
--------------------------------------------------------------*/ | |
/*-------------------------------------------------------------- | |
3 - I especially love generated ToCs. | |
--------------------------------------------------------------*/ | |
/*-------------------------------------------------------------- | |
3.1 - That's why I made this mixin. | |
--------------------------------------------------------------*/ | |
/*-------------------------------------------------------------- | |
4 - Now, reararranging partials with a ToC isn't a nightmare. | |
--------------------------------------------------------------*/ | |
/*-------------------------------------------------------------- | |
4.1 - You're welcome. | |
--------------------------------------------------------------*/ | |
/* | |
I would love the list below to be at the top of the compiled CSS. | |
Any ideas? | |
*/ | |
/* 1 - Hello friend! */ | |
/* 1.1 - Let's tak about indices. */ | |
/* 2 - Who doesn't love a good table of contents? */ | |
/* 2.1 - I do. */ | |
/* 3 - I especially love generated ToCs. */ | |
/* 3.1 - That's why I made this mixin. */ | |
/* 4 - Now, reararranging partials with a ToC isn't a nightmare. */ | |
/* 4.1 - You're welcome. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment