Skip to content

Commit 7cc9f4d

Browse files
committed
doc & rename
1 parent 188c8c1 commit 7cc9f4d

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

docs/content/doc/developers/guidelines-frontend.en-us.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/h
4747
7. Clarify variable types, prefer `elem.disabled = true` instead of `elem.setAttribute('disabled', 'anything')`, prefer `$el.prop('checked', var === 'yes')` instead of `$el.prop('checked', var)`.
4848
8. Use semantic elements, prefer `<button class="ui button">` instead of `<div class="ui button">`.
4949
9. Avoid unnecessary `!important` in CSS, add comments to explain why it's necessary if it can't be avoided.
50+
10. Avoid mixing different events in one event listener, prefer to use individual event listeners for every event.
51+
11. Custom event names are recommended to use `ce-` prefix.
5052

5153
### Accessibility / ARIA
5254

@@ -109,6 +111,22 @@ However, there are still some special cases, so the current guideline is:
109111
* Vue components are recommended to use `v-if` and `v-show` to show/hide elements.
110112
* Go template code should use Gitea's `.gt-hidden` and `showElem()/hideElem()/toggleElem()`, see more details in `.gt-hidden`'s comment.
111113

114+
### Styles and Attributes in Go HTML Template
115+
116+
It's recommended to use:
117+
118+
```html
119+
<div class="gt-name1 gt-name2 {{if .IsFoo}}gt-foo{{end}}" {{if .IsFoo}}data-foo{{end}}></div>
120+
```
121+
122+
instead of:
123+
124+
```html
125+
<div class="gt-name1 gt-name2{{if .IsFoo}} gt-foo{{end}}"{{if .IsFoo}} data-foo{{end}}></div>
126+
```
127+
128+
to make the code more readable.
129+
112130
### Legacy Code
113131

114132
A lot of legacy code already existed before this document's written. It's recommended to refactor legacy code to follow the guidelines.

web_src/js/components/ContextPopup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default {
8787
}
8888
},
8989
mounted() {
90-
this.$refs.root.addEventListener('us-load-context-popup', (e) => {
90+
this.$refs.root.addEventListener('ce-load-context-popup', (e) => {
9191
const data = e.detail;
9292
if (!this.loading && this.issue === null) {
9393
this.load(data);

web_src/js/features/contextpopup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function initContextPopups() {
3232
content: el,
3333
interactive: true,
3434
onShow: () => {
35-
el.firstChild.dispatchEvent(new CustomEvent('us-load-context-popup', {detail: {owner, repo, index}}));
35+
el.firstChild.dispatchEvent(new CustomEvent('ce-load-context-popup', {detail: {owner, repo, index}}));
3636
}
3737
});
3838
});

0 commit comments

Comments
 (0)