Skip to content

Commit 0ff68f1

Browse files
authored
Merge pull request #111 from github/docs-dry-up-callout-markup
2 parents 0b88731 + a731049 commit 0ff68f1

6 files changed

Lines changed: 28 additions & 84 deletions

File tree

docs/_guide/actions.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,9 @@ subtitle: Binding Events
55

66
Catalyst Components automatically bind actions upon instantiation. Automatically as part of the `connectedCallback`, a component will search for any children with the `data-action` attribute, and bind events based on the value of this attribute. Any _public method_ on a Controller can be bound to via `data-action`.
77

8-
<div class="d-flex border rounded-1 my-3 box-shadow-medium">
9-
<span class="d-flex flex-items-center bg-blue text-white rounded-left-1 p-3">
10-
<svg width="24" height="24" viewBox="0 0 14 16" class="octicon octicon-info" aria-hidden="true">
11-
<path
12-
fill-rule="evenodd"
13-
d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"
14-
/>
15-
</svg>
16-
</span>
17-
<div class="p-3">
18-
8+
{% capture callout %}
199
Remember! Actions are _automatically_ bound using the `@controller` decorator. There's no extra JavaScript code needed.
20-
21-
</div>
22-
</div>
10+
{% endcapture %}{% include callout.md %}
2311

2412
### Example
2513

docs/_guide/attrs.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,9 @@ When an element gets connected to the DOM, the attr is initialized. During this
133133
- When connected, if the element _does not_ have a matching attribute, the default _is_ applied.
134134
- When connected, if the element _does_ have a matching attribute, the default _is not_ applied, the property will be assigned to the value of the attribute instead.
135135

136-
<div class="d-flex border rounded-1 my-3 box-shadow-medium">
137-
<span class="d-flex flex-items-center bg-blue text-white rounded-left-1 p-3">
138-
<svg width="24" height="24" viewBox="0 0 14 16" class="octicon octicon-info" aria-hidden="true">
139-
<path
140-
fill-rule="evenodd"
141-
d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"
142-
/>
143-
</svg>
144-
</span>
145-
<div class="p-3">
146-
136+
{% capture callout %}
147137
Remember! The values defined in the class field are the _default_. They won't be set if the element is created and its attribute set to a custom value!
148-
149-
</div>
150-
</div>
138+
{% endcapture %}{% include callout.md %}
151139

152140
The following example illustrates this behavior:
153141

docs/_guide/rendering.md

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,9 @@ subtitle: Rendering HTML subtrees
55

66
Sometimes it's necessary to render an HTML subtree as part of a component. This can be especially useful if a component is driving complex UI that is only interactive with JS.
77

8-
<div class="d-flex border rounded-1 my-3 box-shadow-medium">
9-
<span class="d-flex flex-items-center bg-blue text-white rounded-left-1 p-3">
10-
<svg width="24" height="24" viewBox="0 0 14 16" class="octicon octicon-info" aria-hidden="true">
11-
<path
12-
fill-rule="evenodd"
13-
d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"
14-
/>
15-
</svg>
16-
</span>
17-
<div class="p-3">
18-
8+
{% capture callout %}
199
Remember to _always_ make your JavaScript progressively enhanced, where possible. Using JS to render large portions of the UI, that could be rendered server-side is an anti-pattern; it can be difficult for users to interact with - especially users who disable JS, or when JS fails to load, or those using assistive technologies. Rendering on the client can also impact the [CLS Web Vital](https://web.dev/cls/).
20-
21-
</div>
22-
</div>
10+
{% endcapture %}{% include callout.md %}
2311

2412
By leveraging the native [`ShadowDOM`](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM) feature, Catalyst components can render complex sub-trees, fully encapsulated from the rest of the page.
2513

@@ -55,21 +43,9 @@ class HelloWorldElement extends HTMLElement {
5543

5644
Providing the `<template data-shadowroot>` element as a direct child of the `hello-world` element tells Catalyst to render the templates contents automatically, and so all `HelloWorldElements` with this template will be rendered with the contents.
5745

58-
<div class="d-flex border rounded-1 my-3 box-shadow-medium">
59-
<span class="d-flex flex-items-center bg-blue text-white rounded-left-1 p-3">
60-
<svg width="24" height="24" viewBox="0 0 14 16" class="octicon octicon-info" aria-hidden="true">
61-
<path
62-
fill-rule="evenodd"
63-
d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"
64-
/>
65-
</svg>
66-
</span>
67-
<div class="p-3">
68-
46+
{% capture callout %}
6947
Remember that _all_ instances of your controller _must_ add the `<template data-shadowroot>` HTML. If an instance does not have the `<template data-shadowroot>` as a direct child, then the shadow DOM won't be rendered for it!
70-
71-
</div>
72-
</div>
48+
{% endcapture %}{% include callout.md %}
7349

7450
### Updating a Template element using JS templates
7551

docs/_guide/targets.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,9 @@ The target syntax follows a pattern of `controller.target`.
5050

5151
### Multiple Targets
5252

53-
<div class="d-flex border rounded-1 my-3 box-shadow-medium">
54-
<span class="d-flex flex-items-center bg-blue text-white rounded-left-1 p-3">
55-
<svg width="24" height="24" viewBox="0 0 14 16" class="octicon octicon-info" aria-hidden="true">
56-
<path
57-
fill-rule="evenodd"
58-
d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"
59-
/>
60-
</svg>
61-
</span>
62-
<div class="p-3">
63-
53+
{% capture callout %}
6454
Remember! There are two decorators available, `@target` which fetches only one `data-target` element, and `@targets` which fetches multiple `data-targets` elements!
65-
66-
</div>
67-
</div>
55+
{% endcapture %}{% include callout.md %}
6856

6957
The `@target` decorator will only ever return _one_ element, just like `querySelector`. If you want to get multiple Targets, you need the `@targets` decorator which works almost the same, but returns an Array of elements, and it searches the `data-targets` attribute (not `data-target`).
7058

docs/_guide/your-first-component.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,9 @@ Catalyst will automatically convert the classes name; removing the trailing `Ele
2222

2323
By convention Catalyst controllers end in `Element`; Catalyst will omit this when generating a tag name. The `Element` suffix is _not_ required - just convention. All examples in this guide use `Element` suffixed names.
2424

25-
<div class="d-flex border rounded-1 my-3 box-shadow-medium">
26-
<span class="d-flex flex-items-center bg-blue text-white rounded-left-1 p-3">
27-
<svg width="24" height="24" viewBox="0 0 14 16" class="octicon octicon-info" aria-hidden="true">
28-
<path
29-
fill-rule="evenodd"
30-
d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"
31-
/>
32-
</svg>
33-
</span>
34-
<div class="p-3">
35-
25+
{% capture callout %}
3626
Remember! A class name _must_ include at least two CamelCased words (not including the `Element` suffix). One-word elements will raise exceptions. Example of good names: `UserListElement`, `SubTaskElement`, `PagerContainerElement`
37-
38-
</div>
39-
</div>
27+
{% endcapture %}{% include callout.md %}
4028

4129

4230
### What does `@controller` do?

docs/_includes/callout.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
<div class="d-flex border rounded-1 my-3 box-shadow-medium">
3+
<span class="d-flex flex-items-center bg-blue text-white rounded-left-1 p-3">
4+
<svg width="24" height="24" viewBox="0 0 14 16" class="octicon octicon-info" aria-hidden="true">
5+
<path
6+
fill-rule="evenodd"
7+
d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"
8+
/>
9+
</svg>
10+
</span>
11+
<div class="p-3">
12+
13+
{{ callout }}
14+
15+
</div>
16+
</div>

0 commit comments

Comments
 (0)