diff --git a/README.md b/README.md index f15e437c..4b924d7a 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ using KSS notation. It can be used as a command line utility, gulp task or Grunt + - [Usage](#usage) - [Prerequisites](#prerequisites) - [With gulp](#with-gulp) @@ -29,6 +30,7 @@ using KSS notation. It can be used as a command line utility, gulp task or Grunt - [Providing additional CSS](#providing-additional-css) - [Providing additional JavaScript](#providing-additional-javascript) - [onRendered event](#onrendered-event) + - [Adding new section in between](#adding-new-section-in-between) - [Demo](#demo) @@ -202,6 +204,11 @@ This string is used as a page title and in the page header These HTML elements are injected inside the style guide head-tag. + +**sideNav** (boolean, optional, default: false) + +Enables side navigation. When this option parameter is enabled, style guide will switch to side navbar. + **beforeBody** (array or string, optional) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 392ddb7e..9c258fd1 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -80,6 +80,7 @@ gulp.task('dev:generate', () => { return gulp.src(['lib/app/css/*.css']) .pipe(styleguide.generate({ title: 'SC5 Styleguide', + sideNav: false, server: true, rootPath: outputPath, overviewPath: 'README.md', diff --git a/lib/app/css/styleguide-app.css b/lib/app/css/styleguide-app.css index 7a8810bb..b3a797a2 100644 --- a/lib/app/css/styleguide-app.css +++ b/lib/app/css/styleguide-app.css @@ -23,9 +23,10 @@ html, body.sg { width: 100%; height: 100%; + overflow: auto; } -.sg.sg-view-index { +.sg.view-index { height: 100%; } @@ -344,40 +345,255 @@ markup: Styleguide 3.1.1 */ - +.sg.full-height { + min-height: 100vh; +} .sg.sg-wrapper { position: relative; - padding: var(--wrapper-vertical-padding) var(--content-margin) var(--wrapper-vertical-padding) var(--min-content-margin); + overflow: hidden; + max-width: 68em; + margin: 0 auto; padding: $wrapper-vertical-padding $content-margin $wrapper-vertical-padding $min-content-margin; - max-width: $content-max-width; - margin-left: auto; - margin-right: auto; - + @media (--mobile) { + padding: 0; + } &.designerToolVisible { margin-right: var(--designer-tool-width); margin-right: $designer-tool-width; } -} -.sg.full-height { - min-height: 100vh; -} + .sg.sg-body { + display: inline-block; + width: 70%; + min-height: 680px; + height: 100%; + @media (--mobile) { + padding: 0.25em; + padding-top: 30px; + width: 100%; + } + // Remove top margin from first header in markdown + .sg.sg-heading:nth-of-type(1) { + margin-top: 0; + padding-top: 0; + } + } -.sg.sg-body { - width: 100%; - height: 100%; - @media (--mobile) { - padding: 0.25em; + .sg.full-width { + width: 100%; } - // Remove top margin from first header in markdown - .sg.sg-heading:nth-of-type(1) { - margin-top: 0; - padding-top: 0; + .sg.sg-side-nav { + float: left; + display: inline-block; + width: 30%; + opacity: 1; + @media (--mobile) { + width: 100%; + padding-top: 30px; + z-index: 99999; + background: #8b8b8b; + overflow: scroll; + transition: opacity .4s cubic-bezier(0.000, 0.995, 0.990, 1.000); + } + + .sg.option { + text-align: center; + a { + color: white; + } + } + + li { + list-style: none; + @media (--mobile) { + background: #8b8b8b; + border-bottom: 1px solid #d4d4d4; + } + } + + & .sg-nav-section { + list-style: none; + margin: 2em 0 0 0; + @media (--mobile) { + margin: 0; + } + padding: 0; + background: rgba(#fff, 1); + & .sg-nav-subsection:before { + position: absolute; + top: 0; + left: -1em; + + display: block; + + width: 5px; + height: 100%; + + content: ''; + + background: lighten($primary-color, 75%); + + transition: all .4s ease-out; + } + } + + & .sg-nav-subsection .plus { + &:before { + position: absolute; + margin-top: 0; + margin-left: -1em; + display: block; + + width: 5px; + height: 100%; + + content: '+'; + + background: lighten($primary-color, 75%); + + transition: all .4s ease-out; + } + } + + & .sg-nav-subsection .minus { + &:before { + position: absolute; + margin-top: 0; + margin-left: -1em; + display: block; + + width: 5px; + height: 100%; + + content: '-'; + + background: lighten($primary-color, 75%); + + transition: all .4s ease-out; + } + } + + & .sg-nav-section li { + margin-bottom: .3em; + @media (--mobile) { + margin-bottom: 0; + } + } + + & .sg-nav-section li a { + @media (--mobile) { + color: $header-text-color; + margin-left: 5px; + } + } + + & .sg-nav-section > li > a { + font-family: $secondary-font; + line-height: 2em; + + position: relative; + + display: block; + + padding: .5em; + + &:before { + position: absolute; + top: 0; + left: -1em; + + display: block; + + width: 5px; + height: 100%; + + content: ''; + + background: lighten($primary-color, 75%); + + transition: all .4s ease-out; + } + + &:after { + position: absolute; + bottom: -.25em; + left: 0; + + display: block; + + width: 100%; + height: 1px; + + content: ''; + + background: rgba($secondary-color, 1); + } + + &:hover, + &.active { + &:before { + background: $primary-color; + } + } + } + .sg-nav-subsubsection { + padding-left: 10px; + } + .sg-nav-subsection { + padding-left: 30px; + & li { + border: none; + & a { + line-height: 2em; + position: relative; + display: block; + color: #23485f; + } + } + } } -} + .sg.animate-show { + opacity: 0; + z-index: -1; + width: 0; + } + + .sg.side-nav-toggle { + font-family: var(--secondary-font); + font-style: normal; + position: absolute; + top: 2.0em; + cursor: pointer; + color: rgba(var(--primary-color), .2); + border-radius: 5px; + user-select: none; + transition: color .3s ease-in; + display: block; + @media (--mobile) { + display: none; + } + + &:before { + position: absolute; + top: -1.5em; + width: 10em; + content: 'Toggle navigation'; + opacity: 0; + color: rgba($primary-color, .2); + transition: opacity .3s ease-in; + } + + &:hover { + color: rgba($primary-color, .7); + &:before { + opacity: 1; + } + } + } +} /* Header and footer @@ -408,8 +624,6 @@ Styleguide 3.2.1 .sg.sg-header { - height: var(--header-height); - height: $header-height; width: 100%; padding: 0; color: #fff; @@ -484,19 +698,80 @@ Styleguide 3.2.1 @media (--mobile) { height: auto; } -} -.sg.sg-search-field { - margin-top: var(--header-height)/2 - 18px; - margin-top: $header-height/2 - 18px; - box-sizing : border-box; - float: right; - @media (--mobile) { - margin-left: 0; - margin-right: 0; - float: none; - width: 100%; + .sg.sg-search-container { + + @media (--mobile) { + clear: both; + } + .sg-hamburger { + display: none; + float: left; + cursor: pointer; + position: relative; + + @media (--mobile) { + display: inline-block; + padding-top: 2px; + padding-bottom: 3px; + } + + &-item { + position: relative; + width: 40px; + height: 4px; + background: white; + margin-bottom: 9px; + top: 0; + transition: transform 0.15s ease-in-out, top 0.1s ease-in-out 0.2s, opacity 0.25s ease-in-out 0.1s; + transform-origin: center; + } + + &-active { + .sg-hamburger-item { + transition: transform 0.15s ease-in-out 0.2s, top 0.1s ease-in-out, opacity 0.25s ease-in-out; + } + .top { + top: 13px; + transform: rotate(135deg); + } + .middle { + opacity: 0; + transform: rotate(135deg); + } + .bottom { + top: -13px; + transform: rotate(225deg); + } + } + } + + .sg.sg-search-field { + margin-top: var(--header-height)/2 - 18px; + margin-top: $header-height/2 - 18px; + box-sizing : border-box; + float: right; + @media (--mobile) { + margin-left: 0; + margin-right: 0; + float: none; + width: 100%; + } + } } + .sg.side-nav-search .sg.sg-search-field { + margin-top: var(--header-height)/2 - 18px; + margin-top: $header-height/2 - 18px; + box-sizing : border-box; + float: right; + @media (--mobile) { + margin-left: 24px; + margin-right: 0; + float: left; + width: auto; + } + } + } /* @@ -926,6 +1201,7 @@ Styleguide 3.5 border: 1px solid $secondary-color; border-bottom: none; background: #fff; + width: 100%; } .sg.sg-section-partial:last-child { diff --git a/lib/app/js/controllers/main.js b/lib/app/js/controllers/main.js index 9ade9f8c..54404c28 100644 --- a/lib/app/js/controllers/main.js +++ b/lib/app/js/controllers/main.js @@ -15,6 +15,12 @@ angular.module('sgApp') $scope.config = Styleguide.config; $scope.status = Styleguide.status; $scope.variables = Variables.variables; + $scope.toggleMenu = false; + + $scope.toggleBool = function(toggleMenu) { + $scope.toggleMenu = !toggleMenu; + return $scope.toggleMenu; + }; // Bind variable to scope to wait for data to be resolved $scope.socketService = Socket; @@ -32,6 +38,17 @@ angular.module('sgApp') }; }; + $scope.hasSubsections = function(parentSection) { + var result = false; + angular.forEach($scope.sections.data, function(section) { + if(parentSection.reference === section.parentReference) { + result = true; + return; + } + }); + return result; + }; + // Toggle all markup boxes visible/hidden state $scope.toggleMarkup = function() { $scope.markupSection.isVisible = !$scope.markupSection.isVisible; diff --git a/lib/app/js/controllers/sections.js b/lib/app/js/controllers/sections.js index a9ab1491..b772e780 100644 --- a/lib/app/js/controllers/sections.js +++ b/lib/app/js/controllers/sections.js @@ -53,6 +53,9 @@ angular.module('sgApp') if ($scope.currentSection === 'all') { return true; } + if ($scope.currentSection.indexOf('.') === -1) { + return new RegExp('^' + $scope.currentSection + '(\\{D}|$)').test(section.reference); + } return new RegExp('^' + $scope.currentSection + '(\\D|$)').test(section.reference); }; diff --git a/lib/app/views/main.html b/lib/app/views/main.html index 5cf304ca..02d97c7b 100644 --- a/lib/app/views/main.html +++ b/lib/app/views/main.html @@ -10,17 +10,25 @@

Error: {{status.error.name}}

{{status.error.message}}
- +
+
+
+
+
+
+ +
-