diff options
author | wxiaoguang | 2023-03-05 22:23:42 +0800 |
---|---|---|
committer | GitHub | 2023-03-05 22:23:42 +0800 |
commit | 21a1d7691124dc5c1fca0ecab3de852a8671f4b8 (patch) | |
tree | 996d0e10347d06591b711e8ee896628028d0e7be /web_src | |
parent | e8935606f5f1fff3c59222ebca6d4615ab06fb0b (diff) |
Improve the frontend guideline (#23298)
### The CustomEvent prefix
There was already `ce-quick-submit`, the `ce-` prefix seems better than
`us-`. Rename the only `us-` prefixed `us-load-context-popup` to `ce-`
prefixed.
### Styles and Attributes in Go HTML Template
https://github.com/go-gitea/gitea/pull/21855#issuecomment-1429643073
Suggest to stick to `class="c1 {{if $var}}c2{{end}}"`
The readability and maintainability should be applied to the code which
is read by developers, but not for the generated outputs.
The template code is the code for developers, while the generated HTML
are only for browsers.
The `class="c1 {{if $var}}c2{{end}}"` style is clearer for developers
and more intuitive, and the generated HTML also makes browsers happy (a
few spaces do not affect anything)
Think about a more complex case:
* `class="{{if $active}}active{{end}} menu item {{if $show}}show{{end}}
{{if $warn}}warn{{end}}"`
* --vs--
* `class="{{if $active}}active {{end}}menu item{{if $show}}
show{{end}}{{if $warn}} warn{{end}}"`
The first style make it clearer to see each CSS class name with its
`{{if}}` block.
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'web_src')
-rw-r--r-- | web_src/js/components/ContextPopup.vue | 2 | ||||
-rw-r--r-- | web_src/js/features/contextpopup.js | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/web_src/js/components/ContextPopup.vue b/web_src/js/components/ContextPopup.vue index 324403478..ad305b23a 100644 --- a/web_src/js/components/ContextPopup.vue +++ b/web_src/js/components/ContextPopup.vue @@ -87,7 +87,7 @@ export default { } }, mounted() { - this.$refs.root.addEventListener('us-load-context-popup', (e) => { + this.$refs.root.addEventListener('ce-load-context-popup', (e) => { const data = e.detail; if (!this.loading && this.issue === null) { this.load(data); diff --git a/web_src/js/features/contextpopup.js b/web_src/js/features/contextpopup.js index 61f712090..21e6bec31 100644 --- a/web_src/js/features/contextpopup.js +++ b/web_src/js/features/contextpopup.js @@ -32,7 +32,7 @@ export function initContextPopups() { content: el, interactive: true, onShow: () => { - el.firstChild.dispatchEvent(new CustomEvent('us-load-context-popup', {detail: {owner, repo, index}})); + el.firstChild.dispatchEvent(new CustomEvent('ce-load-context-popup', {detail: {owner, repo, index}})); } }); }); |