Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
docs(): make view demo only show up if theres a demo
Browse files Browse the repository at this point in the history
Closes #1052.
  • Loading branch information
ajoslin committed Jan 14, 2015
1 parent 520faa7 commit d68c0c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions docs/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ function(COMPONENTS, DEMOS, PAGES, $location, $rootScope) {
}]
}];

var docsByModule = {};
var apiDocs = {};
COMPONENTS.forEach(function(component) {
component.docs.forEach(function(doc) {
if (angular.isDefined(doc.private)) return;
apiDocs[doc.type] = apiDocs[doc.type] || [];
apiDocs[doc.type].push(doc);

docsByModule[doc.module] = docsByModule[doc.module] || [];
docsByModule[doc.module].push(doc);
});
});
var demoDocs = [];
Expand All @@ -121,6 +125,9 @@ function(COMPONENTS, DEMOS, PAGES, $location, $rootScope) {
name: componentDemos.label,
url: componentDemos.url
});
(docsByModule[componentDemos.name] || []).forEach(function(doc) {
doc.hasDemo = true;
});
});

sections.unshift({
Expand Down
3 changes: 2 additions & 1 deletion docs/config/processors/componentsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ function publicDocData(doc, extraData) {
type: doc.docType,
outputPath: doc.outputPath,
url: doc.path,
label: doc.label || doc.name
label: doc.label || doc.name,
module: doc.module,
}, extraData || {});
}

Expand Down
7 changes: 4 additions & 3 deletions docs/config/template/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h1 class="md-toolbar-tools">

<span flex></span> <!-- use up the empty space -->

<div class="md-toolbar-item md-tools">
<div class="md-toolbar-item md-tools" layout="row">
<div ng-repeat="doc in currentComponent.docs">
<md-button ng-href="#{{doc.url}}"
ng-class="{hide: path().indexOf('demo') == -1}"
Expand All @@ -90,7 +90,7 @@ <h1 class="md-toolbar-tools">
</md-button>
</div>

<md-button ng-class="{hide: !currentDoc}"
<md-button ng-class="{hide: !currentDoc || !currentDoc.hasDemo}"
ng-href="#/demo/{{currentComponent.name}}"
style="position: relative; padding-left: 30px; margin-right: 15px;">
<md-icon icon="/img/icons/ic_play_arrow_24px.svg" style="
Expand All @@ -103,13 +103,14 @@ <h1 class="md-toolbar-tools">

<md-button ng-class="{hide: !currentDoc}"
ng-href="{{currentDoc.githubUrl}}"
hide-sm hide-md
style="position: relative; padding-left: 30px; margin-right: 15px;">
<md-icon icon="/img/icons/ic_launch_24px.svg" style="
height: 36px;
position: absolute;
left: 0px;
top: -3px;"></md-icon>
<span hide-sm hide-md>View on Github</span>
<span>View on Github</span>
</md-button>

<md-button ng-class="{hide: !currentDoc}"
Expand Down

0 comments on commit d68c0c0

Please sign in to comment.