You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Contributions are always welcome! Before contributing, please read the [code of conduct](https://github.com/WebComponentsGuide/webcomponents.guide/blob/main/CODE_OF_CONDUCT.md).
3
+
Contributions are always welcome! Before contributing, please read the
4
+
[code of conduct](https://github.com/WebComponentsGuide/webcomponents.guide/blob/main/CODE_OF_CONDUCT.md).
4
5
5
6
## Where to start
6
7
7
8
- If you've found typos or mistakes in the documentation, please go right ahead and raise a PR!.
8
-
- If you're looking for issues to resolve, a good place to start is the [help wanted label](https://github.com/WebComponentsGuide/webcomponents.guide/labels/help%20wanted) and/or [good first issue label](https://github.com/WebComponentsGuide/webcomponents.guide/labels/good%20first%20issue).
9
-
- If you have to contribute to bigger pieces, like an idea or new section, tutorial, or blog post, then please raise an issue first! This way we can discuss an action plan and figure out a high level overview of what should be written.
9
+
- If you're looking for issues to resolve, a good place to start is the
[good first issue label](https://github.com/WebComponentsGuide/webcomponents.guide/labels/good%20first%20issue).
12
+
- If you have to contribute to bigger pieces, like an idea or new section, tutorial, or blog post, then please raise an
13
+
issue first! This way we can discuss an action plan and figure out a high level overview of what should be written.
10
14
11
15
### Setup
12
16
@@ -19,8 +23,10 @@ $ npm install
19
23
$ npm start
20
24
```
21
25
22
-
Once this is done you can visit http://localhost:8080/ to see the local copy of the website. As you edit files the website will automatically rebuild, and you can see the changes reflected in your browser.
26
+
Once this is done you can visit http://localhost:8080/ to see the local copy of the website. As you edit files the
27
+
website will automatically rebuild, and you can see the changes reflected in your browser.
23
28
24
29
### Running checks/tests
25
30
26
-
When making contributions, please make sure to run `npm run check`, to ensure your contributions are correctly formatted and spelled. You can also run `npm run format` to automatically format all files.
31
+
When making contributions, please make sure to run `npm run check`, to ensure your contributions are correctly formatted
32
+
and spelled. You can also run `npm run format` to automatically format all files.
Copy file name to clipboardExpand all lines: learn/components/naming-your-components.md
+17-14Lines changed: 17 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,8 @@ Try typing a tag name below to see if it's a valid custom element tag:
39
39
40
40
### Reserved tag names
41
41
42
-
Some names are **disallowed** because they have existed in the _HTML spec_ before _custom elements_ were added. These are:
42
+
Some names are **disallowed** because they have existed in the _HTML spec_ before _custom elements_ were added. These
43
+
are:
43
44
44
45
-`annotation-xml`
45
46
-`color-profile`
@@ -58,19 +59,20 @@ DOMException: CustomElementRegistry.define: 'annotation-xml' is not a valid cust
58
59
59
60
## Tips on naming element
60
61
61
-
While none of the following is prescriptive, here are some tips and tricks on how to pick a good name for your _custom elements_:
62
+
While none of the following is prescriptive, here are some tips and tricks on how to pick a good name for your _custom
63
+
elements_:
62
64
63
65
### Avoid splitting compound words
64
66
65
-
It can be tricky to think of two words for every element, so it might be tempting to add a dash inside a compound word.
67
+
It can be tricky to think of two words for every element, so it might be tempting to add a dash inside a compound word.
66
68
For example splitting "tooltip" into `tool-tip` or "overlay" into `over-lay`. Adding dashes to compound words like this
67
-
can look a little confusing so it might be beneficial to spend the effort and think of another word to add to these,
68
-
for example `tooltip-popover` or `overlay-dialog`.
69
+
can look a little confusing so it might be beneficial to spend the effort and think of another word to add to these, for
70
+
example `tooltip-popover` or `overlay-dialog`.
69
71
70
72
### Using names from existing elements
71
73
72
74
If your _Autonomous Custom Element_ borrows concepts from other _built-ins_ then you could make up a similar name. For
73
-
example `fancy-button` for an element like `<button>`, `color-input` for an element like `<input>`, or `radial-meter`
75
+
example `fancy-button` for an element like `<button>`, `color-input` for an element like `<input>`, or `radial-meter`
74
76
for an element like `<meter>`. You might want to avoid doing this for all except _Customised Built-ins_. If your element
75
77
doesn't share anything in common with an existing _built-in_, then it's best to avoid having a similar name, as it might
76
78
cause confusion.
@@ -83,22 +85,23 @@ unclear what they do until you familiarise yourself with them. Good components h
83
85
clear!
84
86
85
87
Conversely using difficult to spell words can cause errors and typos more often. It's best to avoid difficult to spell
86
-
element names like `<abbreviated-text>` or `<widget-accessory>`. Words longer than 10 characters tend to be difficult
87
-
to spell, so try to avoid those. Words with double letters (abbreviated, occasion, accommodate) can be tricky too. Words
88
+
element names like `<abbreviated-text>` or `<widget-accessory>`. Words longer than 10 characters tend to be difficult to
89
+
spell, so try to avoid those. Words with double letters (abbreviated, occasion, accommodate) can be tricky too. Words
88
90
using different letters with the same sound (necessary, accessory) often get misspelled. Words with "silent" consanants
89
-
(knack, assign, doubt) are difficult, especially people whom English is not their first language. In these cases it might
90
-
be better to replace a hard to spell word with a simpler word, e.g. `<abbreviated-text>` could be come `<short-text>`, `<approximate-date>` could be `<rounded-date>`. Alternatively you could replace one hard to spell word with two easier to
91
-
spell words that mean the same thing, for example `<establish-account>` could be `<set-up-account>`.
91
+
(knack, assign, doubt) are difficult, especially people whom English is not their first language. In these cases it
92
+
might be better to replace a hard to spell word with a simpler word, e.g. `<abbreviated-text>` could be come
93
+
`<short-text>`, `<approximate-date>` could be `<rounded-date>`. Alternatively you could replace one hard to spell word
94
+
with two easier to spell words that mean the same thing, for example `<establish-account>` could be `<set-up-account>`.
92
95
93
96
Tag names don't have to use a single dash! Names like `<auto-complete-input>` or `<ajax-form-provider>` are valid, and
94
97
can sometimes be clearer! However just like long methods or class names they can be overly verbose which makes them
95
98
tiresome to read and type. It's good to avoid generic "filler" words that don't add to the meaning, like `wrapper`,
96
99
`provider`, `effect`, or `element`.
97
100
98
101
Some design systems will prefix their _Web Components_ with a branding. For example all of [Adobe Spectrum's][spectrum]
99
-
_Web Components_ are prefixed `<sp-`, [Shoelace Components][shoelace] are prefixed `<sl-`. This can be useful, as you can
100
-
easily tell apart a component from a design system to a generic off-the-shelf component. On the other hand, this makes
101
-
every component name longer.
102
+
_Web Components_ are prefixed `<sp-`, [Shoelace Components][shoelace] are prefixed `<sl-`. This can be useful, as you
103
+
can easily tell apart a component from a design system to a generic off-the-shelf component. On the other hand, this
0 commit comments