Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
#64 Adding code previews
Browse files Browse the repository at this point in the history
  • Loading branch information
daveredfern committed Nov 3, 2016
1 parent eccab85 commit 58bf1ff
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 29 deletions.
10 changes: 7 additions & 3 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,12 @@ public function printTitle() {
$title .= '</h2>';
$title .= '</div>
<div class="cc-title__actions">
<ul>
<li><a href="'.$this->getUrl(true).'" class="micro">Preview</a></li>
<ul>';

if($this->shouldPrintCode()) {
$title .= '<li><a href="#" data-cc-action="toggle" data-cc-target="cc-code-' . str_replace(' ', '-', strtolower($this->Title)) . '" class="micro">Code</a></li>';
}
$title .= '<li><a href="'.$this->getUrl(true).'" class="micro">Preview</a></li>
</ul>
</div></hgroup>';
}
Expand Down Expand Up @@ -359,7 +363,7 @@ protected function getContents($paths, $options) {
}

if($printCode) {
echo '<div class="u-toggle"><pre class="cc-code"><code class="language-html">';
echo '<div class="u-toggle" id="cc-code-' . str_replace(' ', '-', strtolower($_t->Title)) . '"><pre class="cc-code"><code class="language-html">';
$html = file_get_contents($path);
echo htmlentities(trim(preg_replace('/<\\?.*(\\?>|$)/Us', '', $html)));
echo '</code></pre></div>';
Expand Down
2 changes: 1 addition & 1 deletion pattern/base/blockquote.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php /*
Title: Blockquote
Class: &lt;blockquote&gt;
Code: false
Container: true
*/ ?>

<blockquote>
Expand Down
4 changes: 1 addition & 3 deletions pattern/base/button/2-disabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
Class: &lt;button disabled&gt;
*/ ?>

<p>
<button type="button" disabled>Disabled Button</button>
</p>
<button type="button" disabled>Disabled Button</button>
6 changes: 2 additions & 4 deletions pattern/component/button/1-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
Class: .btn
*/ ?>

<p>
<a href="#" class="btn">Button</a>
<button type="button" class="btn">Button</button>
</p>
<a href="#" class="btn">Button</a>
<button type="button" class="btn">Button</button>
6 changes: 2 additions & 4 deletions pattern/component/button/2-disabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
Class: .btn.btn--disabled
*/ ?>

<p>
<a href="#" class="btn btn--disabled">Disabled Button</a>
<button type="button" class="btn btn--disabled" disabled>Disabled Button</button>
</p>
<a href="#" class="btn btn--disabled">Disabled Button</a>
<button type="button" class="btn btn--disabled" disabled>Disabled Button</button>
6 changes: 2 additions & 4 deletions pattern/component/button/3-text.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
Class: .btn.btn--text
*/ ?>

<p>
<a href="#" class="btn btn--text">Text Button</a>
<button type="button" class="btn btn--text">Text Button</button>
</p>
<a href="#" class="btn btn--text">Text Button</a>
<button type="button" class="btn btn--text">Text Button</button>
6 changes: 2 additions & 4 deletions pattern/component/button/4-small.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
Class: .btn.btn--sm
*/ ?>

<p>
<a href="#" class="btn btn--sm">Button sm</a>
<button type="button" class="btn btn--sm">Button sm</button>
</p>
<a href="#" class="btn btn--sm">Button sm</a>
<button type="button" class="btn btn--sm">Button sm</button>
6 changes: 2 additions & 4 deletions pattern/component/button/5-large.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
Class: .btn.btn--lg
*/ ?>

<p>
<a href="#" class="btn btn--lg">Button lg</a>
<button type="button" class="btn btn--lg">Button lg</button>
</p>
<a href="#" class="btn btn--lg">Button lg</a>
<button type="button" class="btn btn--lg">Button lg</button>
4 changes: 2 additions & 2 deletions pattern/component/button/6-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Class: .btn.btn--block
*/ ?>

<p><a href="#" class="btn btn--block">Button Block</a></p>
<p><button type="button" class="btn btn--block">Button Block</button></p>
<a href="#" class="btn btn--block">Button Block</a>
<button type="button" class="btn btn--block">Button Block</button>
139 changes: 139 additions & 0 deletions src/vendor/prismjs/prism.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript */
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/

code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;

-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;

-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}

pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}

pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}

@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}

/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}

:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}

.token.punctuation {
color: #999;
}

.namespace {
opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #a67f59;
background: hsla(0, 0%, 100%, .5);
}

.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}

.token.function {
color: #DD4A68;
}

.token.regex,
.token.important,
.token.variable {
color: #e90;
}

.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}

.token.entity {
cursor: help;
}

6 changes: 6 additions & 0 deletions src/vendor/prismjs/prism.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 58bf1ff

Please sign in to comment.