Skip to content

Commit

Permalink
document option-passing and css customization
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuhr committed Jul 31, 2022
1 parent e87ee51 commit 168ee3a
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 5 deletions.
96 changes: 91 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,69 @@
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>


Expand Down Expand Up @@ -65,7 +128,7 @@ <h2 class="anchored" data-anchor-id="rcsb-pdb">RCSB PDB</h2>

</div>
<script type="text/javascript">
molstar.Viewer.create('app-7sgl', {"viewportShowAnimation":true,"layoutShowLeftPanel":true,"layoutShowControls":false,"viewportShowExpand":true,"emdbProvider":"rcsb","layoutIsExpanded":false,"layoutShowRemoteState":false,"viewportShowSelectionMode":false,"layoutShowSequence":false,"pdbProvider":"rcsb","layoutShowLog":false}).then(viewer => {
molstar.Viewer.create('app-7sgl', {"pdbProvider":"rcsb","layoutShowControls":false,"viewportShowAnimation":true,"layoutShowLog":false,"viewportShowSelectionMode":false,"emdbProvider":"rcsb","layoutShowSequence":false,"viewportShowExpand":true,"layoutShowLeftPanel":true,"layoutShowRemoteState":false,"layoutIsExpanded":false}).then(viewer => {
viewer.loadPdb('7sgl');
});
</script>
Expand All @@ -79,7 +142,7 @@ <h2 class="anchored" data-anchor-id="local-pdb-file">Local pdb file</h2>

</div>
<script type="text/javascript">
molstar.Viewer.create('app-./www/7sgl.pdb', {"viewportShowAnimation":true,"layoutShowLeftPanel":true,"layoutShowControls":false,"viewportShowExpand":true,"emdbProvider":"rcsb","layoutIsExpanded":false,"layoutShowRemoteState":false,"viewportShowSelectionMode":false,"layoutShowSequence":false,"pdbProvider":"rcsb","layoutShowLog":false}).then(viewer => {
molstar.Viewer.create('app-./www/7sgl.pdb', {"pdbProvider":"rcsb","layoutShowControls":false,"viewportShowAnimation":true,"layoutShowLog":false,"viewportShowSelectionMode":false,"emdbProvider":"rcsb","layoutShowSequence":false,"viewportShowExpand":true,"layoutShowLeftPanel":true,"layoutShowRemoteState":false,"layoutIsExpanded":false}).then(viewer => {
viewer.loadStructureFromUrl('./www/7sgl.pdb', format='pdb');
});
</script>
Expand All @@ -93,7 +156,7 @@ <h2 class="anchored" data-anchor-id="pdb-file-from-url">pdb file from url</h2>

</div>
<script type="text/javascript">
molstar.Viewer.create('app-https://files.rcsb.org/download/7sgl.pdb', {"viewportShowAnimation":true,"layoutShowLeftPanel":true,"layoutShowControls":false,"viewportShowExpand":true,"emdbProvider":"rcsb","layoutIsExpanded":false,"layoutShowRemoteState":false,"viewportShowSelectionMode":false,"layoutShowSequence":false,"pdbProvider":"rcsb","layoutShowLog":false}).then(viewer => {
molstar.Viewer.create('app-https://files.rcsb.org/download/7sgl.pdb', {"pdbProvider":"rcsb","layoutShowControls":false,"viewportShowAnimation":true,"layoutShowLog":false,"viewportShowSelectionMode":false,"emdbProvider":"rcsb","layoutShowSequence":false,"viewportShowExpand":true,"layoutShowLeftPanel":true,"layoutShowRemoteState":false,"layoutIsExpanded":false}).then(viewer => {
viewer.loadStructureFromUrl('https://files.rcsb.org/download/7sgl.pdb', format='pdb');
});
</script>
Expand All @@ -107,7 +170,7 @@ <h2 class="anchored" data-anchor-id="local-xyz-file">local xyz file</h2>

</div>
<script type="text/javascript">
molstar.Viewer.create('app-./www/example.xyz', {"viewportShowAnimation":true,"layoutShowLeftPanel":true,"layoutShowControls":false,"viewportShowExpand":true,"emdbProvider":"rcsb","layoutIsExpanded":false,"layoutShowRemoteState":false,"viewportShowSelectionMode":false,"layoutShowSequence":false,"pdbProvider":"rcsb","layoutShowLog":false}).then(viewer => {
molstar.Viewer.create('app-./www/example.xyz', {"pdbProvider":"rcsb","layoutShowControls":false,"viewportShowAnimation":true,"layoutShowLog":false,"viewportShowSelectionMode":false,"emdbProvider":"rcsb","layoutShowSequence":false,"viewportShowExpand":true,"layoutShowLeftPanel":true,"layoutShowRemoteState":false,"layoutIsExpanded":false}).then(viewer => {
viewer.loadStructureFromUrl('./www/example.xyz', format='xyz');
});
</script>
Expand All @@ -121,7 +184,7 @@ <h2 class="anchored" data-anchor-id="local-pdb-and-trajectory">local pdb and tra

</div>
<script type="text/javascript">
molstar.Viewer.create('app-./www/example.pdb./www/example.xtc', {"viewportShowAnimation":true,"layoutShowLeftPanel":true,"layoutShowControls":false,"viewportShowExpand":true,"emdbProvider":"rcsb","layoutIsExpanded":false,"layoutShowRemoteState":false,"viewportShowSelectionMode":false,"layoutShowSequence":false,"pdbProvider":"rcsb","layoutShowLog":false}).then(viewer => {
molstar.Viewer.create('app-./www/example.pdb./www/example.xtc', {"pdbProvider":"rcsb","layoutShowControls":false,"viewportShowAnimation":true,"layoutShowLog":false,"viewportShowSelectionMode":false,"emdbProvider":"rcsb","layoutShowSequence":false,"viewportShowExpand":true,"layoutShowLeftPanel":true,"layoutShowRemoteState":false,"layoutIsExpanded":false}).then(viewer => {
viewer.loadTrajectory(
{
model: {
Expand All @@ -137,6 +200,29 @@ <h2 class="anchored" data-anchor-id="local-pdb-and-trajectory">local pdb and tra
</script>

</section>
<section id="customization" class="level2">
<h2 class="anchored" data-anchor-id="customization">Customization</h2>
<section id="molstar-options" class="level3">
<h3 class="anchored" data-anchor-id="molstar-options">Molstar options</h3>
<p>The first argument (plus the second for <code>mol-traj</code>) is a positional argument. After this you can pass keyword arguments, which will be merged with defaults and passed on to <code>molstar.Viewer.create</code>. For example, if you don’t have an animation you might want to hide the animation button and open the right options panel on load:</p>
<p><code>{{&lt; mol-rcsb 7sgl viewportShowAnimation=false layoutShowLeftPanel=false layoutShowControls=true &gt;}}</code></p>
<p>There is a list of available options in the molstar source code: <a href="https://github.com/molstar/molstar/blob/33963c085a79e5eec64160b64c5d6ff3782b477b/src/apps/viewer/app.ts#L72-L103">here</a>.</p>
</section>
<section id="css" class="level3">
<h3 class="anchored" data-anchor-id="css">CSS</h3>
<p>Each embedded app is inserted into a div with an ID created from the path of the pdb-file or trajectory (please don’t embed the same thing twice, it will only show up once). So the first app on this page will respond to css for <code>#app-7sgl</code>.</p>
<p>All apps have the class <code>molstar-app</code> and the following css is included by default:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode css code-with-copy"><code class="sourceCode css"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">.molstar-app</span> {</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">position</span>: <span class="dv">relative</span><span class="op">;</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> <span class="kw">padding-bottom</span>: <span class="dv">56.25</span><span class="dt">%</span><span class="op">;</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>For example, I might want to make one app in a presentation a bit shorter because there is text above it:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode css code-with-copy"><code class="sourceCode css"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#app-7sgl</span> {</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">padding-bottom</span>: <span class="dv">40</span><span class="dt">%</span><span class="op">;</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section>
</section>

</main>
<!-- /main column -->
Expand Down
33 changes: 33 additions & 0 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,37 @@ Load a topology and a trajectory with:

{{< mol-traj ./www/example.pdb ./www/example.xtc >}}

## Customization

### Molstar options

The first argument (plus the second for `mol-traj`) is a positional argument.
After this you can pass keyword arguments, which will be merged with defaults and passed on to `molstar.Viewer.create`.
For example, if you don't have an animation you might want to hide the animation button and open the right options panel on load:

`{{{< mol-rcsb 7sgl viewportShowAnimation=false layoutShowLeftPanel=false layoutShowControls=true >}}}`

There is a list of available options in the molstar source code: [here](https://github.com/molstar/molstar/blob/33963c085a79e5eec64160b64c5d6ff3782b477b/src/apps/viewer/app.ts#L72-L103).

### CSS

Each embedded app is inserted into a div with an ID created from the path of the pdb-file or trajectory (please don't embed the same thing twice, it will only show up once). So the first app on this page will respond to css for `#app-7sgl`.

All apps have the class `molstar-app` and the following css is included by default:

```css
.molstar-app {
position: relative;
width: 100%;
padding-bottom: 56.25%;
}
```

For example, I might want to make one app in a presentation a bit shorter because there is text above it:

```css
#app-7sgl {
padding-bottom: 40%;
}
```

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
position: relative;
width: 100%;
padding-bottom: 56.25%;
margin-bottom: 1rem;
}

0 comments on commit 168ee3a

Please sign in to comment.