Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-style section headings #270

Merged
merged 1 commit into from
Nov 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions lib/app/js/controllers/sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,10 @@ angular.module('sgApp')
}
}

// Check section level (main/sub/sub-sub/sub-sub-sub)
$scope.getLevel = function(section) {
if (/([0-9]\.)/.test(section.reference)) {
return section.reference.split('.').map(function(i) {
return 'sub'
}).join('-').substring(4);
}
return 'main';
}

$scope.getActive = function(section) {
return section.reference == $rootScope.currentReference.section.reference ? 'active' : '';
}

$scope.getClass = function(section) {
return this.getLevel(section) + ' ' + this.getActive(section);
}

$scope.filterSection = function(section) {
if ($scope.currentSection === 'all') return true;
var re = new RegExp('(^' + $scope.currentSection + '$)|(^' +
Expand Down
128 changes: 65 additions & 63 deletions lib/app/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,7 @@ $mobile: new-breakpoint(max-width 480px);
@include span-columns(12);
}

// Remove top margin from first header in markdown and in every section
// Make sure that style does not leak to previews
.sg.section:first-child > header {
h1, h2, h3, h4 {
margin-top: 0;
padding-top: 0;
}
}
// Remove top margin from first header in markdown
.sg.heading:nth-of-type(1) {
margin-top: 0;
padding-top: 0;
Expand Down Expand Up @@ -353,7 +346,6 @@ $mobile: new-breakpoint(max-width 480px);
// <header class="sg header {$modifiers}">
// <div class="inner">
// <div class="title">
// <img class="logo" src="assets/img/sc5logo.svg" alt="SC5 logo">
// <h1>Title</h1>
// </div>
// </div>
Expand Down Expand Up @@ -670,20 +662,67 @@ $mobile: new-breakpoint(max-width 480px);
}
}

// Sections header
//
// Sections can be used to structure content. Sections are generated from
// KSS reference numbers.
//
// Markup:
// <header class="sg section-header">
// <h1 class="sg"><span class="reference-number">1.0</span> Section title </h1>
// </header>
//
// Styleguide 3.4.

.sg.section-header {
@include default-font;
background-color: $primary-color;
border-top-left-radius: 5px;
border-top-right-radius: 5px;

h1 {
padding: 13px;
margin: 0;
font-size: 1.777em;
color: $secondary-color;

.reference-number {
color: white;
}
}

i.fa {
padding: 0.4em 0.7em;
float: right;
color: rgba($secondary-color, .6);

@include transition(all .4s ease-out);

&:hover {
color: rgba($secondary-color, 1);
&:after {
opacity: 1;
}
}
}
}


// Sections
// Sections blocks
//
// Sections can be used to structure content. Sections are generated from
// KSS reference numbers.
//
// Markup:
// <secion class="sg section">
// <ul class="sg modifier-list">
// <li class="item"><strong>.modifier1</strong> - <span>Modifier1 description</span></li>
// <li class="item"><strong>.modifier2</strong> - <span>Modifier2 description</span></li>
// <li class="item"><strong>.modifier3</strong> - <span>Modifier3 description</span></li>
// </ul>
// <div class="sg section-partial">
// <p class="sg">Section description</p>
// <ul class="sg modifier-list">
// <li class="item"><strong>.modifier1</strong> - <span>Modifier1 description</span></li>
// <li class="item"><strong>.modifier2</strong> - <span>Modifier2 description</span></li>
// <li class="item"><strong>.modifier3</strong> - <span>Modifier3 description</span></li>
// </ul>
// </div>
// <div class="sg modifier">
// <div class="sg section-partial">
// <div class="sg label">
Expand Down Expand Up @@ -732,9 +771,11 @@ $mobile: new-breakpoint(max-width 480px);
// </div>
// </div>
//
// Styleguide 3.4.
// Styleguide 3.5.

.sg.section {
margin-bottom: 20px;

.sg.section-partial {
position: relative;
position: relative;
Expand All @@ -748,10 +789,12 @@ $mobile: new-breakpoint(max-width 480px);
background: rgba(#fff, 1);
}

.sg.section-partial:last-child {
border-bottom: 1px solid $secondary-color;
}

.sg.code-listing {
padding: 0;

border-bottom: 1px solid $secondary-color;
background-color: #f8f8f8;

pre {
Expand All @@ -772,48 +815,6 @@ $mobile: new-breakpoint(max-width 480px);
cursor: pointer;
}
}

> header {
display: inline-block;

padding: 0 1em .5em 0;
h1,
h2,
h3,
h4 {
display: inline-block;
}

i.fa {
margin-left: .5em;

color: rgba($primary-color, .2);

@include transition(all .4s ease-out);

&:after {
margin-left: .5em;

opacity: 0;
color: rgba($primary-color, .4);

@include transition(all .4s ease-out);
}

&:hover {
color: rgba($primary-color, .7);
&:after {
opacity: 1;
}
}
}
i.fa-link {
&:after {
content: 'Link to this section';
}
}
}

.sg.modifier-list {
@include default-font;
list-style: none;
Expand All @@ -827,11 +828,12 @@ $mobile: new-breakpoint(max-width 480px);
}
}

.desigerToolVisible .sg.section {
.sg.desigerToolVisible .sg.section {
padding-right: $min-content-margin;
border-right: transparent 2px solid;
}

.desigerToolVisible .sg.section.active {
.sg.desigerToolVisible .sg.section.active {
border-right: $default-action-color 2px solid;
}

Expand Down Expand Up @@ -915,7 +917,7 @@ $mobile: new-breakpoint(max-width 480px);
// <span class="sg current-variable">variable name</span>
// </h2>
//
// Styleguide 3.5.
// Styleguide 3.6.

.sg.heading .current-variable {
display: inline;
Expand Down
99 changes: 46 additions & 53 deletions lib/app/views/partials/section.html
Original file line number Diff line number Diff line change
@@ -1,71 +1,64 @@
<section class="sg section"
ng-class="getClass(section)">
<header class="header">
<h1 ng-show="getLevel(section) === 'main'" class="sg section-header" ng-bind-template="{{ section.reference }} {{ section.header }}"></h1>
<h2 ng-show="getLevel(section) === 'sub'" class="sg section-header" ng-bind-template="{{ section.reference }} {{ section.header }}"></h2>
<h3 ng-show="getLevel(section) === 'sub-sub'" ng-show="" class="sg section-header" ng-bind-template="{{ section.reference }} {{ section.header }}" ></h3>
<h4 ng-show="getLevel(section) === 'sub-sub-sub'" ng-show="" class="sg section-header" ng-bind-template="{{ section.reference }} {{ section.header }}"></h4>
ng-class="getActive(section)">
<header class="sg section-header">
<a ng-href="{{section.reference}}"><i class="fa fa-link"></i></a>
<h1 class="sg"><span class="reference-number">{{ section.reference }}</span> {{ section.header }}</h1>
</header>
<div class="body">
<div class="sg section-partial" ng-if="section.modifiers.length || section.description">
<p class="sg section-description" ng-bind-html="section.description | unsafe"></p>

<ul ng-if="section.modifiers.length" class="sg modifier-list">
<li class="item" ng-repeat="mod in section.modifiers">
<strong ng-bind-html="mod.name | unsafe"></strong> - <span ng-bind-html="mod.description | unsafe"></span>
</li>
</ul>

<div ng-if="section.modifiers.length"
class="sg modifier"
ng-repeat="mod in section.modifiers">
<div class="sg section-partial">
<div class="sg label">
<a ng-href="{{section.reference}}-{{mod.id}}/fullscreen" target="_blank">
<span class="sg name" ng-bind-html="mod.name | unsafe"></span><i class="fa fa-arrows-alt"></i>
</a>
</div>
<div
ng-bind-html="mod.wrappedMarkup | setModifierClass: mod.className | setVariables: variables | unsafe ">
</div>
</div>
</div>
<div ng-repeat-start="mod in section.modifiers"></div>
<div class="sg section-partial">
<div class="sg label">
<a ng-href="{{section.reference}}-{{mod.id}}/fullscreen" target="_blank">
<span class="sg name" ng-bind-html="mod.name | unsafe"></span><i class="fa fa-arrows-alt"></i>
</a>
</div>
<div
class="sg section-partial"
ng-class="getCommonClass()"
ng-if="!section.modifiers.length && section.markup">
<div class="sg label">
<a ng-href="{{section.reference}}/fullscreen" target="_blank">
<i class="fa fa-arrows-alt"></i>
</a>
</div>
<div
ng-bind-html="section.wrappedMarkup | setVariables: variables | unsafe" dynamic-compile>
</div>
ng-bind-html="mod.wrappedMarkup | setModifierClass: mod.className | setVariables: variables | unsafe ">
</div>
</div>
<div ng-repeat-end></div>
<div
class="sg section-partial"
ng-class="getCommonClass()"
ng-if="!section.modifiers.length && section.markup">
<div class="sg label">
<a ng-href="{{section.reference}}/fullscreen" target="_blank">
<i class="fa fa-arrows-alt"></i>
</a>
</div>
<div
ng-bind-html="section.wrappedMarkup | setVariables: variables | unsafe" dynamic-compile>
</div>
</div>

<div class="sg section-partial code-listing" ng-if="section.css">
<div ng-if="section.showCSS" class="sg label">
<a ng-click="section.showCSS = false" target="_blank">
<i class="fa fa-close"></i>
</a>
</div>
<pre class="sg" ng-if="section.showCSS"><!--
--><code hljs source="section.css" class="html"></code><!--
--></pre>
<a class="sg show-section" ng-hide="section.showCSS" ng-click="section.showCSS = true">Show CSS</a>
<div class="sg section-partial code-listing" ng-if="section.css">
<div ng-if="section.showCSS" class="sg label">
<a ng-click="section.showCSS = false" target="_blank">
<i class="fa fa-close"></i>
</a>
</div>
<pre class="sg" ng-if="section.showCSS"><!--
--><code hljs source="section.css" class="html"></code><!--
--></pre>
<a class="sg show-section" ng-hide="section.showCSS" ng-click="section.showCSS = true">Show CSS</a>
</div>

<div class="sg section-partial code-listing" ng-if="section.markup">
<div ng-if="section.showMarkup" class="sg label">
<a ng-click="section.showMarkup = false" target="_blank">
<i class="fa fa-close"></i>
</a>
</div>
<pre class="sg" ng-if="section.showMarkup"><!--
--><code hljs source="section.markup" class="css"></code><!--
--></pre>
<a class="sg show-section" ng-hide="section.showMarkup" ng-click="section.showMarkup = true">Show markup</a>
<div class="sg section-partial code-listing" ng-if="section.markup">
<div ng-if="section.showMarkup" class="sg label">
<a ng-click="section.showMarkup = false" target="_blank">
<i class="fa fa-close"></i>
</a>
</div>
<pre class="sg" ng-if="section.showMarkup"><!--
--><code hljs source="section.markup" class="css"></code><!--
--></pre>
<a class="sg show-section" ng-hide="section.showMarkup" ng-click="section.showMarkup = true">Show markup</a>
</div>
</section>