Skip to content

Commit

Permalink
Added support for @script annotation tag (#15)
Browse files Browse the repository at this point in the history
* Added support for @script annotation tag

* Support for external script files. Fixed tests on Atoms not completing succesfully
  • Loading branch information
jcfariadias authored and michaelseibt committed Jan 24, 2017
1 parent c9a4fe3 commit 01b56a9
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $('[data-d-code-preview-toggle]').each(function (i, element ) {
$(element).on('click', function () {
$(element)
.closest('.SG-component')
.find('.SG-component__markup')
.find('.SG-component__markup, .SG-code__title')
.stop()
.clearQueue()
.slideToggle(250);
Expand Down
5 changes: 4 additions & 1 deletion assets/styles/atoms/code.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
}
}

.SG-code__title{
display: none;
}

/**
* Alternative code block with monospaced font, maily used for code examples
* and command instructions on the documentation pages.
Expand Down Expand Up @@ -77,4 +81,3 @@
}
}
}

4 changes: 4 additions & 0 deletions assets/styles/structures/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
* @{include:.SG-nav-icons}
* @{include:.SG-nav}
* </div>
* @script
* $('body').on('click','button',function(){
* $(this).doSomething();
* });
*/

.SG-header {
Expand Down
13 changes: 13 additions & 0 deletions assets/views/common/components.pug
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ include ../entities/colors.pug
include ../entities/icons.pug
include ../entities/mixins.pug



mixin components(components)

-var lastEntity = null
each component in components

Expand Down Expand Up @@ -98,8 +101,18 @@ mixin component(component)
div.SG-table__cell= val.description || ''

-if (component.markup)

div.SG-row
div.SG-gr-12.SG-nogutter
div.SG-code.SG-code--hidden.SG-component__markup.language-html(data-d-code-preview)
code
| #{component.markup}

-if (component.script)
div.SG-row
div.SG-gr-12.SG-nogutter
h3.SG-code__title.
Script
div.SG-code.SG-code--hidden.SG-component__markup.language-javascript(data-d-code-preview)
code
| #{component.script}
4 changes: 4 additions & 0 deletions assets/views/common/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
include ./toc.pug


doctype html
html(lang="en")
head
Expand Down Expand Up @@ -38,3 +39,6 @@ html(lang="en")
block content

script(src="scripts/app.js")
-if(meta.scripts)
each script in meta.scripts
script(src=script)
5 changes: 3 additions & 2 deletions config.nucleus.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"docs/src/styles/**/*.scss"
],
"css": "../docs/build/styles/app.css",
"target" : "styleguide",
"namespace": null
"target" : "./styleguide",
"namespace": null,
"scripts" : ["./scripts/ui-kit.js","./assets/scripts/ui-kit2.js"]
}
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ for(var t in templateFiles) {
title: config.title,
namespace: config.namespace,
counterCSS: config.counterCSS,
scripts: config.scripts,
demo: !!config.demo
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/entities/Atom.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var Atom = function (raw) {

// Set atom-specific entity properties
this.type = "Atom";
this.fillable = ['atom', 'section', 'description', 'modifiers', 'markup', 'deprecated'];
this.fillable = ['atom', 'section', 'description', 'modifiers' , 'markup', 'deprecated', 'script'];

// Validate the raw input data for common mistakes
if (!this.validate()) return {};
Expand All @@ -32,6 +32,7 @@ var Atom = function (raw) {
description: raw.annotations.description,
modifiers: this.getModifiers(),
markup: raw.annotations.markup,
script: raw.annotations.script || false,
deprecated: raw.annotations.deprecated,
location: 'atoms.html',
hash: this.hash()
Expand Down
4 changes: 2 additions & 2 deletions src/entities/Molecule.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/

'use strict';

var Entity = require('./Entity');
Expand All @@ -19,7 +18,7 @@ var Molecule = function(raw) {

// Set molecule-specific entity properties
this.type = "Molecule";
this.fillable = ['molecule', 'section', 'description', 'modifiers', 'markup', 'deprecated'];
this.fillable = ['molecule', 'section', 'description', 'modifiers', 'markup', 'deprecated','script'];

// Validate the raw input data for common mistakes
if (!this.validate()) return {};
Expand All @@ -32,6 +31,7 @@ var Molecule = function(raw) {
description: raw.annotations.description,
modifiers: this.getModifiers(),
markup: raw.annotations.markup,
script: raw.annotations.script || false,
deprecated: raw.annotations.deprecated,
hash: this.hash(),
location: 'molecules.html'
Expand Down
4 changes: 2 additions & 2 deletions src/entities/Structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Copyright (C) 2016 Michael Seibt
*
* With contributions from: -
* - Ryan Potter (www.ryanpotter.co.nz)
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
Expand All @@ -19,7 +18,7 @@ var Structure = function(raw) {

// Set structure-specific entity properties
this.type = "Structure";
this.fillable = ['structure', 'section', 'description', 'modifiers', 'markup', 'flag', 'deprecated'];
this.fillable = ['structure', 'section', 'description', 'modifiers', 'markup', 'flag', 'deprecated','script'];

// Validate the raw input data for common mistakes
if (!this.validate()) return {};
Expand All @@ -32,6 +31,7 @@ var Structure = function(raw) {
description: raw.annotations.description,
modifiers: this.getModifiers(),
markup: raw.annotations.markup,
script: raw.annotations.script || false,
deprecated: raw.annotations.deprecated,
flags: this.getFlags(),
location: 'structures.html',
Expand Down
10 changes: 7 additions & 3 deletions test/Atom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@ describe('Atom', function() {
annotations: {
description: 'A test description',
atom: 'Test-Component',
markup: '...'
markup: '...',
script: '....'
}
});

assert.deepEqual(a, {
name: 'Test-Component',
type: 'atom',
hash: '7cf4b2beae2f0536b3ebb3030ccef2ed3d89c0fe',
hash: '47edcec9fa48df43335b12fc0e3e1cc9a4709bf1',
descriptor: '.test',
location: 'atoms.html',
section: 'Atoms > Other',
description: 'A test description',
modifiers: null,
markup: '...',
script: '....',
deprecated: false
});
});
Expand All @@ -58,20 +60,22 @@ describe('Atom', function() {
description: 'A test description',
atom: 'Test-Component',
markup: '...',
script: '...',
deprecated: true
}
});

assert.deepEqual(a, {
name: 'Test-Component',
type: 'atom',
hash: 'f7f408f0cf9b50d98473832406bb5ea2b750db2a',
hash: '1af43675b26c728f36bb88af3dcabdc7c0dc9a35',
descriptor: '.test',
location: 'atoms.html',
section: 'Atoms > Other',
description: 'A test description',
modifiers: null,
markup: '...',
script: '...',
deprecated: true
});
});
Expand Down

0 comments on commit 01b56a9

Please sign in to comment.