Skip to content

Commit a2dd18a

Browse files
authored
Merge pull request #276 from rackerlabs/feat-add-declarative-methods
Add declarative functionality
2 parents 7c4568a + 7a8c318 commit a2dd18a

File tree

21 files changed

+474
-232
lines changed

21 files changed

+474
-232
lines changed

docs/components/search/test.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Testing - Search
3+
---
4+
{% extends 'test.njk' %}
5+
{% block content %}
6+
<section>
7+
<h2>Declarative APIs</h2>
8+
<div class="hxRow">
9+
<div class="hxCol hxSpan-4">
10+
<p>
11+
<hx-search id="testSearch"></hx-search>
12+
</p>
13+
<p>
14+
<button class="hxBtn" type="button" id="btnFocus">focus()</button>
15+
<button class="hxBtn" type="button" id="btnClear">clear()</button>
16+
<button class="hxBtn" type="button" id="btnFocusThenBlur">focus() (blur() after 2s)</button>
17+
</p>
18+
</div>
19+
</div>
20+
</section>
21+
22+
<script>
23+
(function () {
24+
let elSearch = document.getElementById('testSearch');
25+
26+
document.getElementById('btnFocus').addEventListener('click', function () {
27+
elSearch.focus();
28+
});
29+
30+
document.getElementById('btnClear').addEventListener('click', function () {
31+
elSearch.clear();
32+
});
33+
34+
document.getElementById('btnFocusThenBlur').addEventListener('click', function () {
35+
elSearch.focus();
36+
37+
setTimeout(function () {
38+
elSearch.blur();
39+
}, 2000);
40+
});
41+
})();
42+
</script>
43+
{% endblock %}

docs/elements/hx-accordion/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ <h2 id="modes">Modes</h2>
5151
<section>
5252
<h2 id="methods">Methods</h2>
5353
<dl>
54-
<dt>nextPanel()</dt>
54+
<dt>selectNext()</dt>
5555
<dd>
5656
Opens the next sibling panel.
5757
<br />
5858
<hx-icon type="exclamation-triangle"></hx-icon>
5959
Requires the <code>current-panel</code> attribute to be present.
6060
</dd>
6161

62-
<dt>previousPanel()</dt>
62+
<dt>selectPrevious()</dt>
6363
<dd>
6464
Opens the previous sibling panel.
6565
<br />

docs/elements/hx-alert/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
<h2 id="methods">Methods</h2>
4141
<dl>
4242
<dt>dismiss()</dt>
43-
<dd>Dismisses the alert.</dd>
43+
<dd>Dismiss the alert (removes element from the DOM).</dd>
44+
</dl>
45+
<dl>
46+
<dt>submit()</dt>
47+
<dd>Simulates a mouse click on the CTA.</dd>
4448
</dl>
4549
</section>
4650
{% endblock %}

docs/elements/hx-checkbox/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
</hx-def>
2828
</hx-dl>
2929
</section>
30+
31+
<section>
32+
<h2 id="methods">Methods</h2>
33+
<dl>
34+
<dt>click()</dt>
35+
<dd>Simulates a mouse click on the element</dd>
36+
</dl>
37+
</section>
3038
{% endblock %}
3139

3240
{% block attributes %}

docs/elements/hx-disclosure/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ <h2 id="target-element">Target Element</h2>
4141
</li>
4242
</ol>
4343
</section>
44+
45+
<section>
46+
<h2 id="methods">Methods</h2>
47+
<dl>
48+
<dt>click()</dt>
49+
<dd>Simulates a mouse click on the element</dd>
50+
</dl>
51+
</section>
4452
{% endblock %}
4553

4654
{% block attributes %}

docs/elements/hx-file-tile/index.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<section>
1111
<p>
12-
The custom <code>{{page.title}}</code> element describes the states of
12+
The custom <code>{{page.title}}</code> element describes the states of
1313
a downloadable asset.
1414
</p>
1515

@@ -38,6 +38,14 @@
3838
</hx-def>
3939
</hx-dl>
4040
</section>
41+
42+
<section>
43+
<h2 id="methods">Methods</h2>
44+
<dl>
45+
<dt>dismiss()</dt>
46+
<dd>Simulates a mouse click on the dismiss button (i.e., clicking the "X")</dd>
47+
</dl>
48+
</section>
4149
{% endblock %}
4250

4351
{% block attributes %}

docs/elements/hx-pill/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<h2 id="methods">Methods</h2>
4040
<dl>
4141
<dt>dismiss()</dt>
42-
<dd>Dismisses the pill.</dd>
42+
<dd>Dismiss the pill (removes element from the DOM).</dd>
4343
</dl>
4444
</section>
4545
{% endblock %}

docs/elements/hx-search/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@
3535
</hx-def>
3636
</hx-dl>
3737
</section>
38+
39+
<section>
40+
<h2 id="methods">Methods</h2>
41+
<dl>
42+
<dt>focus()</dt>
43+
<dd>Overrides default HTMLElement behavior to focus the input in the Shadow DOM.</dd>
44+
45+
<dt>clear()</dt>
46+
<dd>Simulates pressing "x" to clear the value of the input.</dd>
47+
</dl>
48+
</section>
3849
{% endblock %}
3950

4051
{% block attributes %}

docs/elements/hx-tabset/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@
4242
</hx-def>
4343
</hx-dl>
4444
</section>
45+
46+
<section>
47+
<h2 id="methods">Methods</h2>
48+
<dl>
49+
<dt>selectNext()</dt>
50+
<dd>
51+
Selects the next tab in the tabset. If the last tab is currently active,
52+
selects the first tab.
53+
</dd>
54+
</dl>
55+
<dl>
56+
<dt>selectPrevious()</dt>
57+
<dd>
58+
Selects the previous tab in the tabset. If the first tab is currently
59+
active, selects the last tab.
60+
</dd>
61+
</dl>
62+
</section>
4563
{% endblock %}
4664

4765
{% block attributes %}

docs/elements/hx-toast/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@
4141
<h2 id="methods">Methods</h2>
4242
<dl>
4343
<dt>dismiss()</dt>
44-
<dd>Dismisses the toast.</dd>
44+
<dd>Dismiss the toast (removes element from the DOM).</dd>
45+
</dl>
46+
<dl>
47+
<dt>submit()</dt>
48+
<dd>Simulate a mouse click on the CTA button.</dd>
4549
</dl>
4650
</section>
4751
{% endblock %}

0 commit comments

Comments
 (0)