-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move fixed elements functions into alchemy_admin package
Move createTab and removeTab functions into alchemy_admin - package. These two functions are still available in the Alchemy.FixedElements - namespace until we move all calls out of these js.erb - files. The functions are also migrated to vanilla Javascript.
- Loading branch information
1 parent
840d7ff
commit 1e59d50
Showing
5 changed files
with
28 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Creates a fixed element tab. | ||
export function createTab(element_id, label) { | ||
const fixed_elements = document.getElementById("fixed-elements") | ||
const panel_name = `fixed-element-${element_id}` | ||
|
||
const tab = `<sl-tab slot="nav" panel="${panel_name}">${label}</sl-tab>` | ||
const panel = `<sl-tab-panel name="${panel_name}" style="--padding: 0" />` | ||
|
||
fixed_elements.innerHTML += tab + panel | ||
|
||
window.requestAnimationFrame(function () { | ||
fixed_elements.show(panel_name) | ||
}) | ||
} | ||
|
||
export function removeTab(element_id) { | ||
const fixed_elements = document.getElementById("fixed-elements") | ||
const panel_name = `fixed-element-${element_id}` | ||
|
||
fixed_elements.querySelector(`sl-tab[panel="${panel_name}"]`).remove() | ||
fixed_elements.querySelector(`sl-tab-panel[name="${panel_name}"]`).remove() | ||
|
||
fixed_elements.show("main-content-elements") | ||
} |