-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Make icon div creation a common function
- Loading branch information
1 parent
8d400b3
commit 305f333
Showing
5 changed files
with
57 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
////////////////////////////////////////////////////////////////////////////////////////// | ||
// _ _ ____ _ _ ___ ____ // | ||
// |_/ |__| |\ | | \ | | This file belongs to Kando, the cross-platform // | ||
// | \_ | | | \| |__/ |__| pie menu. Read more on github.com/menu/kando // | ||
// // | ||
////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de> | ||
// SPDX-License-Identifier: MIT | ||
|
||
/** | ||
* This method creates a div which contains an icon. The icon is created using the | ||
* 'material-symbols-rounded' or 'simple-icons' font. | ||
* | ||
* @param icon The name of the icon to create. | ||
* @param theme The name of the icon theme to use. | ||
* @returns A HTML element which contains the icon. | ||
*/ | ||
export function createDiv(icon: string, theme: string) { | ||
const containerDiv = document.createElement('div'); | ||
containerDiv.classList.add('icon-container'); | ||
|
||
const iconDiv = document.createElement('i'); | ||
containerDiv.appendChild(iconDiv); | ||
|
||
if (theme === 'material-symbols-rounded') { | ||
iconDiv.classList.add(theme); | ||
iconDiv.innerHTML = icon; | ||
} else if (theme === 'simple-icons') { | ||
iconDiv.classList.add('si'); | ||
iconDiv.classList.add('si-' + icon); | ||
} | ||
|
||
return containerDiv; | ||
} |
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
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