Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fomantic-dropdown webcomponent #33723

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/repo/issue/view_content/context_menu.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="item action ui dropdown jump pointing top right context-dropdown">
<fomantic-dropdown class="item action ui dropdown jump pointing top right context-dropdown">
<a class="context-menu muted">
{{svg "octicon-kebab-horizontal"}}
</a>
Expand Down Expand Up @@ -41,4 +41,4 @@
{{end}}
{{end}}
</div>
</div>
</fomantic-dropdown>
20 changes: 20 additions & 0 deletions web_src/js/webcomponents/fomantic-dropdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Dropdown web component.
*
* This component wraps a Fomantic UI dropdown, allowing you to apply the same
* classes and attributes as you would with a standard Fomantic dropdown.
*
* It ensures automatic initialization when connected to the DOM, which is useful
* for dynamically added elements, eliminating the need for manual initialization.
*/
class FomanticDropdown extends HTMLElement {
connectedCallback() {
if (window.jQuery) {
window.$(this).dropdown();
}
// note: if jquery is not defined then this component was part of the initial page load and
// will be initialized by the fomantic-ui js
}
}

customElements.define('fomantic-dropdown', FomanticDropdown);
1 change: 1 addition & 0 deletions web_src/js/webcomponents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ import '@github/relative-time-element';
import './origin-url.ts';
import './overflow-menu.ts';
import './absolute-date.ts';
import './fomantic-dropdown.ts';
Loading