Skip to content

Commit f9a3453

Browse files
committed
Tweak annotations styles and pattern description
1 parent cebf672 commit f9a3453

File tree

6 files changed

+123
-110
lines changed

6 files changed

+123
-110
lines changed

dist/styleguide/css/styleguide.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,9 @@
11501150
* Pattern Description inside modal
11511151
*/
11521152
/**
1153+
* Pattern Annotations inside modal
1154+
*/
1155+
/**
11531156
* Pattern tab panel inside modal
11541157
*/
11551158
}
@@ -1188,6 +1191,9 @@
11881191
.sg-modal .sg-pattern-desc {
11891192
border-bottom-color: #808080;
11901193
}
1194+
.sg-modal .sg-annotations {
1195+
border-top-color: #808080;
1196+
}
11911197
.sg-modal .sg-tabs-content {
11921198
border: 0;
11931199
}
@@ -1307,7 +1313,7 @@
13071313
}
13081314

13091315
.sg-annotations-title {
1310-
font-size: 1.2rem !important;
1316+
font-size: 1rem !important;
13111317
margin: 0 0 0.5rem;
13121318
}
13131319

dist/styleguide/css/styleguide.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/styleguide/js/patternlab-viewer.js

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -858,59 +858,59 @@ Dispatcher.trigger('setupPanels');
858858
*/
859859

860860
var panelsViewer = {
861-
861+
862862
// set up some defaults
863863
targetOrigin: (window.location.protocol === 'file:') ? '*' : window.location.protocol+'//'+window.location.host,
864864
initCopy: false,
865865
initMoveTo: 0,
866-
866+
867867
/**
868868
* Check to see if all of the panels have been collected before rendering
869869
* @param {String} the collected panels
870870
* @param {String} the data from the pattern
871871
* @param {Boolean} if this is going to be passed back to the styleguide
872872
*/
873873
checkPanels: function(panels, patternData, iframePassback, switchText) {
874-
874+
875875
// count how many panels have rendered content
876876
var panelContentCount = 0;
877877
for (var i = 0; i < panels.length; ++i) {
878878
if (panels[i].content !== undefined) {
879879
panelContentCount++;
880880
}
881881
}
882-
882+
883883
// see if the count of panels with content matches number of panels
884884
if (panelContentCount === Panels.count()) {
885885
panelsViewer.renderPanels(panels, patternData, iframePassback, switchText);
886886
}
887-
887+
888888
},
889-
889+
890890
/**
891891
* Gather the panels related to the modal
892892
* @param {String} the data from the pattern
893893
* @param {Boolean} if this is going to be passed back to the styleguide
894894
*/
895895
gatherPanels: function(patternData, iframePassback, switchText) {
896-
896+
897897
Dispatcher.addListener('checkPanels', panelsViewer.checkPanels);
898-
898+
899899
// set-up defaults
900900
var template, templateCompiled, templateRendered, panel;
901-
901+
902902
// get the base panels
903903
var panels = Panels.get();
904-
904+
905905
// evaluate panels array and create content
906906
for (var i = 0; i < panels.length; ++i) {
907-
907+
908908
panel = panels[i];
909-
909+
910910
if ((panel.templateID !== undefined) && (panel.templateID)) {
911-
911+
912912
if ((panel.httpRequest !== undefined) && (panel.httpRequest)) {
913-
913+
914914
// need a file and then render
915915
var fileName = urlHandler.getFileName(patternData.patternPartial);
916916
var e = new XMLHttpRequest();
@@ -926,73 +926,73 @@ var panelsViewer = {
926926
})(i, panels, patternData, iframePassback);
927927
e.open('GET', fileName.replace(/\.html/,panel.httpRequestReplace)+'?'+(new Date()).getTime(), true);
928928
e.send();
929-
929+
930930
} else {
931-
931+
932932
// vanilla render of pattern data
933933
template = document.getElementById(panel.templateID);
934934
templateCompiled = Hogan.compile(template.innerHTML);
935935
templateRendered = templateCompiled.render(patternData);
936936
panels[i].content = templateRendered;
937937
Dispatcher.trigger('checkPanels', [panels, patternData, iframePassback, switchText]);
938-
938+
939939
}
940-
940+
941941
}
942-
942+
943943
}
944-
944+
945945
},
946-
946+
947947
/**
948948
* Render the panels that have been collected
949949
* @param {String} the collected panels
950950
* @param {String} the data from the pattern
951951
* @param {Boolean} if this is going to be passed back to the styleguide
952952
*/
953953
renderPanels: function(panels, patternData, iframePassback, switchText) {
954-
954+
955955
// set-up defaults
956956
var template, templateCompiled, templateRendered;
957957
var annotation, comment, count, div, els, item, markup, i;
958958
var patternPartial = patternData.patternPartial;
959959
patternData.panels = panels;
960-
960+
961961
// set a default pattern description for modal pop-up
962962
if (!iframePassback && (patternData.patternDesc.length === 0)) {
963-
patternData.patternDesc = "There is no description for this pattern.";
963+
patternData.patternDesc = "";
964964
}
965-
965+
966966
// capitilize the pattern name
967967
patternData.patternNameCaps = patternData.patternName.toUpperCase();
968-
968+
969969
// check for annotations in the given mark-up
970970
markup = document.createElement('div');
971971
markup.innerHTML = patternData.patternMarkup;
972-
972+
973973
count = 1;
974974
patternData.annotations = [];
975975
delete patternData['patternMarkup'];
976-
976+
977977
for (i = 0; i < comments.comments.length; ++i) {
978-
978+
979979
item = comments.comments[i];
980980
els = markup.querySelectorAll(item.el);
981-
981+
982982
if (els.length > 0) {
983983
annotation = { 'displayNumber': count, 'el': item.el, 'title': item.title, 'comment': item.comment };
984984
patternData.annotations.push(annotation);
985985
count++;
986986
}
987-
987+
988988
}
989-
989+
990990
// alert the pattern that annotations should be highlighted
991991
if (patternData.annotations.length > 0) {
992992
var obj = JSON.stringify({ 'event': 'patternLab.annotationsHighlightShow', 'annotations': patternData.annotations });
993993
document.getElementById('sg-viewport').contentWindow.postMessage(obj, panelsViewer.targetOrigin);
994994
}
995-
995+
996996
// add hasComma property to lineage
997997
if (patternData.lineage.length > 0) {
998998
for (i = 0; i < patternData.lineage.length; ++i) {
@@ -1001,7 +1001,7 @@ var panelsViewer = {
10011001
}
10021002
}
10031003
}
1004-
1004+
10051005
// add hasComma property to lineageR
10061006
if (patternData.lineageR.length > 0) {
10071007
for (i = 0; i < patternData.lineageR.length; ++i) {
@@ -1010,72 +1010,72 @@ var panelsViewer = {
10101010
}
10111011
}
10121012
}
1013-
1013+
10141014
// add *Exists attributes for Hogan templates
10151015
// figure out if the description exists
10161016
patternData.patternDescExists = ((patternData.patternDesc.length > 0) || ((patternData.patternDescAdditions !== undefined) && (patternData.patternDescAdditions.length > 0)));
1017-
1017+
10181018
// figure out if lineage should be drawn
10191019
patternData.lineageExists = (patternData.lineage.length !== 0);
1020-
1020+
10211021
// figure out if reverse lineage should be drawn
10221022
patternData.lineageRExists = (patternData.lineageR.length !== 0);
1023-
1023+
10241024
// figure out if pattern state should be drawn
10251025
patternData.patternStateExists = (patternData.patternState.length > 0);
1026-
1026+
10271027
// figure if the entire desc block should be drawn
10281028
patternData.descBlockExists = (patternData.patternDescExists || patternData.lineageExists || patternData.lineageRExists || patternData.patternStateExists);
1029-
1029+
10301030
// figure if annotations should be drawn
10311031
patternData.annotationExists = (patternData.annotations.length > 0);
1032-
1032+
10331033
// set isPatternView based on if we have to pass it back to the styleguide level
10341034
patternData.isPatternView = (iframePassback === false);
1035-
1035+
10361036
// render all of the panels in the base panel template
10371037
template = document.getElementById('pl-panel-template-base');
10381038
templateCompiled = Hogan.compile(template.innerHTML);
10391039
templateRendered = templateCompiled.render(patternData);
1040-
1040+
10411041
// make sure templateRendered is modified to be an HTML element
10421042
div = document.createElement('div');
10431043
div.className = 'sg-modal-content-inner';
10441044
div.innerHTML = templateRendered;
10451045
templateRendered = div;
1046-
1046+
10471047
// add click events
10481048
templateRendered = panelsUtil.addClickEvents(templateRendered, patternPartial);
1049-
1049+
10501050
// add onclick events to the tabs in the rendered content
10511051
for (i = 0; i < panels.length; ++i) {
1052-
1052+
10531053
panel = panels[i];
1054-
1054+
10551055
// default IDs
10561056
panelTab = '#sg-'+patternPartial+'-'+panel.id+'-tab';
10571057
panelBlock = '#sg-'+patternPartial+'-'+panel.id+'-panel';
1058-
1058+
10591059
// show default options
10601060
if ((templateRendered.querySelector(panelTab) !== null) && (panel.default)) {
10611061
templateRendered.querySelector(panelTab).classList.add('sg-tab-title-active');
10621062
templateRendered.querySelector(panelBlock).style.display = 'block';
10631063
}
1064-
1064+
10651065
}
1066-
1066+
10671067
// find lineage links in the rendered content and add postmessage handlers in case it's in the modal
10681068
$('#sg-code-lineage-fill a, #sg-code-lineager-fill a', templateRendered).on('click', function(e){
10691069
e.preventDefault();
10701070
var obj = JSON.stringify({ 'event': 'patternLab.updatePath', 'path': urlHandler.getFileName($(this).attr('data-patternpartial')) });
10711071
document.getElementById('sg-viewport').contentWindow.postMessage(obj, panelsViewer.targetOrigin);
10721072
});
1073-
1073+
10741074
// gather panels from plugins
10751075
Dispatcher.trigger('insertPanels', [templateRendered, patternPartial, iframePassback, switchText]);
1076-
1076+
10771077
}
1078-
1078+
10791079
};
10801080

10811081
/*!

dist/styleguide/js/patternlab-viewer.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)