Skip to content

Commit

Permalink
feat(tags): Add properties to tags so it can render in tables
Browse files Browse the repository at this point in the history
  • Loading branch information
tcomboeanu committed Nov 5, 2021
1 parent 36be8dd commit 2669d79
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
68 changes: 68 additions & 0 deletions docs/src/xhtml/components/table/extras.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
src: src
};
}
function gettag(data, type) {
return {
item: 'Tag',
data,
type
};
}
</script>
</head>
<body class="nosticky">
Expand All @@ -63,6 +70,7 @@
<li><a href="#image">Image</a></li>
<li><a href="#switch">Switch</a></li>
<li><a href="#userimage">UserImage</a></li>
<li><a href="#tag">Tag</a></li>
</ul>
</section>

Expand Down Expand Up @@ -479,6 +487,66 @@
</script>
</div>
</section>

<section id="tag">
<h3>Tag</h3>
<p>
This function returns the JSON to generate a Tag
</p>
<figure data-ts="DoxScript">
<script type="text/plain">
function getTag(data, type) {
return {
item: 'Tag',
data,
type
};
}
</script>
</figure>
<ul class="splitscreen">
<li>
<figure data-ts="DoxScript">
<script type="runnable">
ts.ui.get('#table6', table => {
table.cols(['One', 'Two']);
table.rows([
['A', gettag('Active', 'ts-success')]
]);
});
</script>
</figure>
</li>
<li>
<div data-ts="Table" id="table6"></div>
</li>
</ul>
<p>Here are the properties of the Tag.</p>
<div data-ts="DoxApi">
<script type="application/json">
{
"name": "ts.ui.TagModel",
"properties": [
{
"name": "id",
"type": "string",
"desc": "Id"
},
{
"name": "data",
"type": "string",
"desc": "Value of the tag"
},
{
"name": "type",
"type": "string",
"desc": "The CSS classname."
}
]
}
</script>
</div>
</section>
</article>
</body>
</html>
7 changes: 4 additions & 3 deletions src/runtime/edbml/functions/ts.ui.tag.edbml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE edbml>
<script>
<?param name="tag" type="ts.ui.TagModel"?>
@id = 'tag' + tag.$instanceid;

<figure data-ts="Tag" @id></figure>
@id = tag.id || 'tag' + tag.$instanceid;
$att['data-ts.type'] = tag.type || null;
$att['data-ts.data'] = tag.data || null;
<figure data-ts="Tag" @data-ts.type @data-ts.data @id></figure>
</script>

0 comments on commit 2669d79

Please sign in to comment.