// ============= // EDGE CODE // ============= // Based on Prism.js - Coy Theme // @origin Tim Shedor // https://github.com/tshedor/workshop-wp-theme $code-font-family : "Consolas", Courier, "monospace" !default; $code-theme : light !default; // dark or light $code-margin-bottom : 1.5em !default; @if $include-typography { $code-margin-bottom : $p-margin-bottom; } $code-markup-color : $blue-color; $code-js-color : #ff8f00; // orange $code-css-color : $green-color; $code-ruby-color : $red-color; $code-php-color : #626293; // purple $code-sass-color : #c6538c; // pink $code-python-color : #376a94; // dark-blue // Add decoration to the code-block @mixin code-decor($color) { &:after { background: $color; } code { @include background-image(linear-gradient(transparent 50%, rgba($color, .03) 50% ) ); } .line-highlight:before, .line-highlight[data-end]:after { background: $color; } } // Add styling to code-block @mixin code-block($theme: $code-theme) { @if $code-theme == light { @include contrasted(#fff); } @else if $code-theme == dark { @include contrasted(#252525); } } @if $include-code and not $external-call { /* ---------------------- EDGE CODE Highlighter ---------------------- */ // Reset code, kbd, samp { display: inline-block; &, pre { font-size: 1em; font-family: $code-font-family; } } pre, code { @include code-block(); white-space: pre; word-spacing: normal; @include css3(tab-size, 2, $webkit:false, $moz:true, $ms:false, $o:true); @include css3(hyphens, none, $webkit:true, $moz:true, $ms:true, $o:false); } pre { position: relative; overflow: auto; padding: 0; margin-bottom: $code-margin-bottom; max-height: 30em; @include code-decor($passive-color); @include box-shadow(-1px 0px 0px 0px #ddd, 0px 0px 0px 1px #ddd); @include below(small) { &:hover { &:after { opacity: 0; } } } &:after { content: ""; position: absolute; top: .5em; right: .5em; width: 1em; height: 1em; background: $passive-color; @if $code-theme == dark { opacity: .5; } @else { opacity: .2; } padding: em(5px 10px); font-family: $code-font-family; color: white; text-transform: uppercase; @include transition($g-transition); } &[data-lang="markup"] { @include code-decor($code-markup-color); } &[data-lang="css"] { @include code-decor($code-css-color); } &[data-lang="javascript"] { @include code-decor($code-js-color); } &[data-lang="ruby"] { @include code-decor($code-ruby-color); } &[data-lang="python"] { @include code-decor($code-python-color); } > code { display: block; overflow: auto; background-size: 3em 3em; background-origin: content-box; padding-left: 0.5em; } } :not(pre) { > code { @include code-block(); } } /* Inline code */ :not(pre) > code[class*="language-"] { display: inline-block; overflow: hidden; position:relative; padding: 0; color: #c92c2c; vertical-align: bottom; } @if $code-theme == light { .token { &.comment, &.block-comment, &.prolog, &.doctype, &.cdata { color: #7D8B99; } &.punctuation { color: #5F6364; } &.property, &.tag, &.boolean, &.number, &.function-name, &.constant, &.symbol { color: #c92c2c; } &.selector, &.attr-name, &.string, &.function, &.builtin { color: #2f9c0a; } &.operator, &.entity, &.url, &.variable { color: #a67f59; background: rgba(255, 255, 255, 0.5); } &.atrule, &.attr-value, &.keyword, &.class-name { color: #1990b8; } &.regex, &.important { color: #e90; } } [data-lang="css"] .token.string, .style .token.string { color: #a67f59; background: rgba(255, 255, 255, 0.5); } } @else if $code-theme == dark { .token { &.property, &.tag, &.constant, &.symbol { color: #f92672; } &.boolean, &.number{ color: #ae81ff; } &.selector, &.attr-name, &.string, &.builtin { color: #a6e22e; } &.atrule, &.attr-value { color: #e6db74; } &.keyword{ color: #66d9ef; } &.regex, &.important { color: #fd971f; } &.operator, &.entity, &.url, &.variable { color: #f8f8f2; } } [data-lang="css"] .token.string, .style .token.string { color: #f8f8f2; } } .token { &.important { font-weight: normal; } &.entity { cursor: help; } &.tab:not(:empty):before, &.cr:before, &.lf:before { color: #e0d7d1; } } pre { .namespace { opacity: .7; } // LINE HIGHLIGHTER .line-highlight { position: absolute; right: 0; left: 0; pointer-events: none; line-height: inherit; white-space: pre; @if $code-theme == dark { @include background-image(linear-gradient(left, rgba(#e2e2e2, .1) 70%, rgba(#e2e2e2, 0) ) ); } @else { @include background-image(linear-gradient(left, rgba(#8c8c8c, .1) 70%, rgba(#8c8c8c, 0) ) ); } &:before, &[data-end]:after { content: attr(data-start); position: absolute; z-index: 2; top: 0; left: 0; padding: 0 .5em; opacity: .5; color: #f5f2f0; font-weight: 700; font-size: 1em; text-align: center; } &[data-end]:after { content: attr(data-end); top: auto; bottom: 0; } } // LINE NUMBERS &.line-numbers { position: relative; counter-reset: linenumber; > code { position: relative; padding-left: 2.5em; } } .line-numbers-rows { position: absolute; pointer-events: none; top: 0; font-size: 100%; left: .5em; letter-spacing: -1px; @include user-select(none); > span { pointer-events: none; display: block; counter-increment: linenumber; &:before { content: counter(linenumber); color: #ddd; display: block; padding-right: 0.8em; text-align: right; } } } } } // $include-code