-
Notifications
You must be signed in to change notification settings - Fork 53
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
PTV-1620/PTV-1845 fix kbaseTabs #3117
Open
eapearson
wants to merge
10
commits into
develop
Choose a base branch
from
PTV-1620-fix-kbase-tabs
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ecd8be4
fix tabs behavior when deleting a dynamic tab; also removed unused co…
eapearson dea1bd4
add a "gallery" to visualize variants of widgets - a poor person's st…
eapearson c7a3770
expand tests for kbaseTabs to cover more use cases [PTV-1620]
eapearson 54c062f
gallery readme style [PTV-1620]
eapearson 9dd7b90
try to make sonarcloud happy [PTV-1620]
eapearson ca9158f
try to make deepscan happy [PTV-1620]
eapearson 7f90629
more silly markdown formatting [PTV-1620]
eapearson 2d6f56a
add release note [PTV-1620]
eapearson c5c6a11
add comments, address tab initialization issue, add additional usage …
eapearson dbce801
tests fixed; should do another pass to cover more use cases, and DRY …
eapearson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Demos | ||
|
||
These demos are static html pages which demonstrate some relatively simple and isolatable aspect of the Narrative. This simple demo system is particularly suitable for ui components. | ||
|
||
Demo pages are available from an index page, e.g. `https://ci.kbase.us/narrative/static/kbase/demo/index.html`. The files are located in `kbase-extension/static/kbase/demo`. | ||
|
||
## Creating a Demo Page | ||
|
||
- Start from an existing demo page, assuming `template.html` | ||
- Edit the head title appropriate, replacing `TEMPLATE` with the name of the component or file being demoed | ||
- edit the `H1` title, similarly | ||
- add a section per demo (see below) | ||
- add matching rendering code in the `script` | ||
- add a link to the demo in the main `index.html` page | ||
|
||
## Demo Page Layout | ||
|
||
- header which includes required components: | ||
- javascript | ||
- `require.js` for AMD | ||
- `common.js` for bootstrap AMD configuration | ||
|
||
- stylesheets | ||
- `style.min.css` for the Jupyter notebook styles (e.g. bootstrap) | ||
- `common.css` for some styles used in demo pages | ||
- `all_concat.css` to include the bulk of the KBase Narrative styles title | ||
- In the title, replace `TEMPLATE` with the class or filename being demoed | ||
|
||
- body | ||
- H1 title describing what is being demoed, replace `TEMPLATE` with the class or filename being demoed | ||
|
||
- A section for each demo | ||
- `H2` title for each demo | ||
- a sentence or short paragraph to describe the demo | ||
- `div` with class `"Example"` to wrap the demo | ||
- within this, a `div` with a unique id (will match code below) in which to render the demo | ||
|
||
- script section to invoke the demo | ||
- code must be wrapped in a `require` of `narrative_paths` | ||
|
||
- code must also be wrapped in a `require` of your component and, optionally, a local data file (or data may be simply included in the script) | ||
|
||
- each demo will render the component into the div already in the page, by id. | ||
- more complex components which require setup will not be as "simple", of course. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.Demo { | ||
padding: 1em; | ||
} | ||
|
||
.Demo .Example { | ||
border: 3px solid rgb(200, 200, 200); | ||
padding: 1em; | ||
border-radius: 1em; | ||
background: repeating-linear-gradient( | ||
45deg, | ||
rgba(200, 200, 200, 0.2), | ||
rgba(200, 200, 200, 0.2) 10px, | ||
rgba(150, 150, 150, 0.2) 10px, | ||
rgba(150, 150, 150, 0.2) 20px | ||
); | ||
} | ||
|
||
.Demo .Example + .Example { | ||
margin-top: 1em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require.config({ | ||
waitSeconds: 60, | ||
|
||
urlArgs: 'v=20220524153658', | ||
|
||
baseUrl: '/narrative/static/', | ||
paths: { | ||
'auth/js/main': 'auth/js/main.min', | ||
custom: '/narrative/static/kbase/custom', | ||
nbextensions: '/narrative/nbextensions', | ||
kernelspecs: '/narrative/kernelspecs', | ||
underscore: 'components/underscore/underscore-min', | ||
backbone: 'components/backbone/backbone-min', | ||
jed: 'components/jed/jed', | ||
jquery: 'components/jquery/jquery.min', | ||
bootstrap: '/narrative/static/ext_components/bootstrap/dist/js/bootstrap.min', | ||
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min', | ||
'jquery-ui': 'components/jquery-ui/jquery-ui.min', | ||
moment: 'components/moment/moment', | ||
codemirror: 'components/codemirror', | ||
termjs: 'components/term.js/src/term', | ||
typeahead: 'components/jquery-typeahead/dist/jquery.typeahead', | ||
}, | ||
map: { | ||
'*': { | ||
jqueryui: 'jquery-ui', | ||
contents: 'services/contents', | ||
}, | ||
}, | ||
shim: { | ||
typeahead: { | ||
deps: ['jquery'], | ||
exports: 'typeahead', | ||
}, | ||
underscore: { | ||
exports: '_', | ||
}, | ||
backbone: { | ||
deps: ['underscore', 'jquery'], | ||
exports: 'Backbone', | ||
}, | ||
bootstrap: { | ||
deps: ['jquery'], | ||
exports: 'bootstrap', | ||
}, | ||
bootstraptour: { | ||
deps: ['bootstrap'], | ||
exports: 'Tour', | ||
}, | ||
'jquery-ui': { | ||
deps: ['jquery'], | ||
exports: '$', | ||
}, | ||
}, | ||
}); | ||
|
||
document.nbjs_translations = { domain: 'nbjs', locale_data: { nbjs: { '': { domain: 'nbjs' } } } }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<link type="text/css" rel="stylesheet" href="/narrative/static/style/style.min.css"> | ||
<link type="text/css" rel="stylesheet" href="/narrative/static/kbase/gallery/common.css"> | ||
<link type="text/css" rel="stylesheet" href="/narrative/static/kbase/css/all_concat.css"> | ||
<meta charset="utf-8"> | ||
<title>KBase Narrative Demos</title> | ||
</head> | ||
<body class="Demo"> | ||
<h1>Demos</h1> | ||
|
||
<p>Demonstrations of Narrative components.</p> | ||
|
||
<ul> | ||
<li> | ||
widgets | ||
<ul> | ||
<li><a href="./widgets/kbaseTabs.html">KBase Tabs</a></li> | ||
<li> | ||
common | ||
<ul> | ||
<li><a href="./widgets/common/AlertMessage.html">Alert Message</a></li> | ||
<li><a href="./widgets/common/ErrorMessage.html">Error Message</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
|
||
</li> | ||
</ul> | ||
|
||
|
||
<p>A <a href="./template.html">TEMPLATE</a> is available to start a new demo page; or simply use one of the existing | ||
pages which is closer to your use case.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<script src="/narrative/static/components/requirejs/require.js"></script> | ||
<script src="/narrative/static/kbase/gallery/common.js"></script> | ||
<link type="text/css" rel="stylesheet" href="/narrative/static/style/style.min.css"> | ||
<link type="text/css" rel="stylesheet" href="/narrative/static/kbase/gallery/common.css"> | ||
<link type="text/css" rel="stylesheet" href="/narrative/static/kbase/css/all_concat.css"> | ||
<meta charset="utf-8"> | ||
<title>KBase Demo - TEMPLATE</title> | ||
</head> | ||
<body class="Demo"> | ||
<h1>TEMPLATE Demo</h1> | ||
|
||
<p><a href="index.html">Index</a></p> | ||
|
||
<!-- Add a section per demo --> | ||
<h2>SOME VIEW</h2> | ||
|
||
<p>Briefly describe the view</p> | ||
|
||
<!-- Wrap in this class to provide a consistent framing for demod components --> | ||
<div class="Example"> | ||
<!-- Note that SOMEID1 matches $("#SOMEID1") below --> | ||
<div id="SOMEID1"></div> | ||
</div> | ||
|
||
<div class="Example"> | ||
<!-- Note that SOMEID2 matches $("#SOMEID2") below --> | ||
<div id="SOMEID2"></div> | ||
</div> | ||
|
||
|
||
<script> | ||
// Wrap in narrative_paths in order to get the AMD configuration used by KBase | ||
require(['narrative_paths'], () => { | ||
// Your demo code will require whatever it needs, as per the usual narrative module patterms | ||
// defined in narrative_paths. | ||
// You may also include local files for additional support, e.g. data to supply to | ||
// your component. | ||
// jquery is required here to be complete. | ||
require(['jquery', 'widgets/common/AlertMessage', 'json!kbase/gallery/template.json'], ($, $AlertMessage, demoData) => { | ||
// This example is quite simply, but most usages should follow this pattern. | ||
$('#SOMEID1').html($AlertMessage("Hello, this is a template for future demos")); | ||
|
||
$('#SOMEID2').html($AlertMessage(demoData.template)); | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"template": "Hi, I'm some data associated with this demo" | ||
} |
73 changes: 73 additions & 0 deletions
73
kbase-extension/static/kbase/gallery/widgets/common/AlertMessage.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<script src="/narrative/static/components/requirejs/require.js"></script> | ||
<script src="/narrative/static/kbase/gallery/common.js"></script> | ||
<link type="text/css" rel="stylesheet" href="/narrative/static/style/style.min.css"> | ||
<link type="text/css" rel="stylesheet" href="/narrative/static/kbase/gallery/common.css"> | ||
<link type="text/css" rel="stylesheet" href="/narrative/static/kbase/css/all_concat.css"> | ||
<meta charset="utf-8"> | ||
<title>KBase Demo - AlertMessage.js</title> | ||
</head> | ||
<body class="Demo"> | ||
<h1>AlertMessage Demo</h1> | ||
|
||
<p><a href="../../index.html">Index</a></p> | ||
|
||
<h2>Default Alert</h2> | ||
|
||
<p>By default, the Alert will use the "info" styling</p> | ||
|
||
<div class="Example"> | ||
<div id="alertmessage1"></div> | ||
</div> | ||
|
||
<h2>Info Alert</h2> | ||
|
||
<p>Here we explicitly use the "info" message styling</p> | ||
|
||
<div class="Example"> | ||
<div id="alertmessage2"></div> | ||
</div> | ||
|
||
<h2>Warning Alert</h2> | ||
|
||
<p>Here we explicitly use the "warning" message styling</p> | ||
|
||
<div class="Example"> | ||
<div id="alertmessage3"></div> | ||
</div> | ||
|
||
<h2>Danger Alert</h2> | ||
|
||
<p>Here we explicitly use the "danger", or error, message styling</p> | ||
|
||
<div class="Example"> | ||
<div id="alertmessage4"></div> | ||
</div> | ||
|
||
<h2>Success Alert</h2> | ||
|
||
<p>Here we explicitly use the "success" message styling</p> | ||
|
||
<div class="Example"> | ||
<div id="alertmessage5"></div> | ||
</div> | ||
|
||
<script> | ||
require(['narrative_paths'], () => { | ||
require(['jquery', 'widgets/common/AlertMessage'], ($, $AlertMessage) => { | ||
$('#alertmessage1').html($AlertMessage("This is a default alert")); | ||
|
||
$('#alertmessage2').html($AlertMessage("This is an info alert", {type: 'info'})); | ||
|
||
$('#alertmessage3').html($AlertMessage("This is a warning alert", {type: 'warning'})); | ||
|
||
$('#alertmessage4').html($AlertMessage("This is a danger alert", {type: 'danger'})); | ||
|
||
$('#alertmessage5').html($AlertMessage("This is a success alert", {type: 'success'})); | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a whole lot like Storybook. So why not just use Storybook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted something simple to be able to preview components w/out having to fire up the narrative and without having to introduce something like storybook to the codebase. I'll just remove this. It is useful for me, and I thought it might be for others as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm definitely not against something like this for the Narrative, this does seem a bit out of scope for this PR, though, and could use some discussion.
Thanks for removing for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. It was the only way I could actually use the tab control with all combinations of options, since they don't actually all exist in the codebase; so it served its purpose for me at least :)