Created
November 11, 2015 18:59
-
-
Save csswizardry/fc0d393c38455cb80bdb 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
| <p class="u-text--large">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
| <article class="c-widget"> | |
| <h1 class="c-widget__title">Widget Title</h1> | |
| <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
| </article> | |
| <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
| <h1 class="c-widget__title">Widget Title</h1> |
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.14) | |
| // Compass (v1.0.3) | |
| // ---- | |
| ///*----------------------------------*\ | |
| // #CONFIG | |
| //\*----------------------------------*/ | |
| // Config-level settings (environment switches, debugging modes, etc.). | |
| $config: ( | |
| env: dev, | |
| debug: true, | |
| ); | |
| @function config($key) { | |
| @return map-get($config, $key); | |
| } | |
| ///*----------------------------------*\ | |
| // #MIXINS | |
| //\*----------------------------------*/ | |
| // DEBUGGING | |
| // This is the general style of a warning that’s passed out to the UI. Wrap it | |
| // up in a mixin so that we can use it for different types of warning. | |
| @mixin ui-warn() { | |
| position: relative; | |
| outline: 1px solid red; | |
| &:after { | |
| position: absolute; | |
| bottom: 100%; | |
| left: 0; | |
| font: normal 12px/1 monospace; | |
| white-space: nowrap; | |
| background-color: white; | |
| color: red; | |
| } | |
| } | |
| // Mixin that gives visual feedback in the DOM if a selector is used outside of | |
| // a given context. Useful for detecting misused Elements in BEM. | |
| // | |
| // .simple { | |
| // font-weight: bold; | |
| // } | |
| // | |
| // .simple__usage { | |
| // color: red; | |
| // @include nest-check(".simple"); | |
| // } | |
| // | |
| @mixin nest-check($element) { | |
| @if (config(debug) == true) { | |
| /** | |
| * Immediately apply error states to all instances of the element… | |
| */ | |
| @include ui-warn(); | |
| &:after { | |
| content: "Error: Element `." attr(class) "` should only appear within `#{$element}`."; | |
| } | |
| /** | |
| * …but remove the errors if things are nested correctly. | |
| */ | |
| #{$element} & { | |
| outline: none; | |
| &:after { | |
| content: normal; | |
| } | |
| } | |
| } | |
| } | |
| /*----------------------------------*\ | |
| #WIDGET | |
| \*----------------------------------*/ | |
| .c-widget { | |
| display: block; | |
| padding: 18px; | |
| background-color: rgba(0, 0, 0, 0.05); | |
| margin-bottom: 18px; | |
| > :last-child { | |
| margin-bottom: 0; | |
| } | |
| } | |
| .c-widget__title { | |
| @include nest-check('.c-widget'); | |
| font-size: 100%; | |
| margin: 0; | |
| } | |
| /*------------------------------------*\ | |
| #DEBUG | |
| \*------------------------------------*/ | |
| @if (config(debug) == true) { | |
| /** | |
| * If an element has a class attribute containing two hyphens but no space | |
| * (i.e. only one class is being used, and it’s a Modifier), provide visual | |
| * feedback in the DOM. | |
| * | |
| * N.B. This isn’t bulletproof: `class="foo--bar baz"` would pass, as would | |
| * `class=" foo--bar"`. Use with a pinch of salt. | |
| */ | |
| [class*="--"]:not([class*=" "]) { | |
| @include ui-warn(); | |
| &:after { | |
| content: "Error: Cannot have a Modifier (i.e. `." attr(class) "`) without a Block."; | |
| } | |
| } | |
| } |
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
| @charset "UTF-8"; | |
| /*----------------------------------*\ | |
| #WIDGET | |
| \*----------------------------------*/ | |
| .c-widget { | |
| display: block; | |
| padding: 18px; | |
| background-color: rgba(0, 0, 0, 0.05); | |
| margin-bottom: 18px; | |
| } | |
| .c-widget > :last-child { | |
| margin-bottom: 0; | |
| } | |
| .c-widget__title { | |
| /** | |
| * Immediately apply error states to all instances of the element… | |
| */ | |
| position: relative; | |
| outline: 1px solid red; | |
| /** | |
| * …but remove the errors if things are nested correctly. | |
| */ | |
| font-size: 100%; | |
| margin: 0; | |
| } | |
| .c-widget__title:after { | |
| position: absolute; | |
| bottom: 100%; | |
| left: 0; | |
| font: normal 12px/1 monospace; | |
| white-space: nowrap; | |
| background-color: white; | |
| color: red; | |
| } | |
| .c-widget__title:after { | |
| content: "Error: Element `." attr(class) "` should only appear within `.c-widget`."; | |
| } | |
| .c-widget .c-widget__title { | |
| outline: none; | |
| } | |
| .c-widget .c-widget__title:after { | |
| content: normal; | |
| } | |
| /*------------------------------------*\ | |
| #DEBUG | |
| \*------------------------------------*/ | |
| /** | |
| * If an element has a class attribute containing two hyphens but no space | |
| * (i.e. only one class is being used, and it’s a Modifier), provide visual | |
| * feedback in the DOM. | |
| * | |
| * N.B. This isn’t bulletproof: `class="foo--bar baz"` would pass, as would | |
| * `class=" foo--bar"`. Use with a pinch of salt. | |
| */ | |
| [class*="--"]:not([class*=" "]) { | |
| position: relative; | |
| outline: 1px solid red; | |
| } | |
| [class*="--"]:not([class*=" "]):after { | |
| position: absolute; | |
| bottom: 100%; | |
| left: 0; | |
| font: normal 12px/1 monospace; | |
| white-space: nowrap; | |
| background-color: white; | |
| color: red; | |
| } | |
| [class*="--"]:not([class*=" "]):after { | |
| content: "Error: Cannot have a Modifier (i.e. `." attr(class) "`) without a Block."; | |
| } |
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
| <p class="u-text--large">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
| <article class="c-widget"> | |
| <h1 class="c-widget__title">Widget Title</h1> | |
| <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
| </article> | |
| <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
| <h1 class="c-widget__title">Widget Title</h1> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment