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

start of a new icon picker. #1794

Merged
merged 3 commits into from
Feb 1, 2022
Merged
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,869 changes: 0 additions & 4,869 deletions apps/dashboard/app/assets/javascripts/fontawesome-iconpicker.js

This file was deleted.

4,997 changes: 0 additions & 4,997 deletions apps/dashboard/app/javascript/packs/fa/faIconInfo.js

This file was deleted.

41 changes: 0 additions & 41 deletions apps/dashboard/app/javascript/packs/fa/faIconPicker.js

This file was deleted.

48 changes: 48 additions & 0 deletions apps/dashboard/app/javascript/packs/icon_picker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';

import ALL_ICONS from 'icons';

const ICON_SHOW_ID = "product_icon"
const ICON_SELECT_ID = "product_icon_select"

function listItem(name) {
return `<li
id="${iconId(name)}"
class="btn btn-outline-dark"
role='button'>
<i class="fas fa-${name} fa-fw"></i>
</li>`;
}

function iconId(name) {
return `icon_${name.replaceAll('-', '_')}`;
}

function iconFromId(id) {
const m = id.match(/^icon_([\w+_]+)/);
if(m && m[1]) { return m[1].replaceAll('_','-') };
}

function picked(event) {
const icon = iconFromId(event.currentTarget.id);
$(`#${ICON_SHOW_ID}`).attr("class", `fas fa-${icon} fa-fw app-icon`);
$(`#${ICON_SELECT_ID}`).val(`fas://${icon}`)
}

function populateList() {
const list = $("#icon_picker_list");
if(list.length == 0 || ALL_ICONS.length == 0) { return; }

const listContent = ALL_ICONS.map(name => {
return listItem(name);
}).join('');
list.html(listContent);

ALL_ICONS.forEach(name => {
$(`#${iconId(name)}`).on('click', (event) => { picked(event)});
});
};

jQuery(() => {
populateList();
})
Loading