Skip to content

Commit 7cf215a

Browse files
committed
feat: add support for categories in the Dev Center
1 parent 10b2ae6 commit 7cf215a

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

src/dev-center/css/style.css

+25-1
Original file line numberDiff line numberDiff line change
@@ -1169,4 +1169,28 @@ dialog{
11691169
color: #666;
11701170
font-size: 13px;
11711171
margin-top: 5px;
1172-
}
1172+
}
1173+
1174+
.app-categories {
1175+
margin-top: 4px;
1176+
display: flex;
1177+
gap: 8px;
1178+
}
1179+
1180+
.app-category {
1181+
font-size: 12px;
1182+
padding: 2px 8px;
1183+
border-radius: 12px;
1184+
display: inline-block;
1185+
background-color: #e3f2fd;
1186+
color: #1976d2;
1187+
}
1188+
1189+
.category-select {
1190+
width: 300px;
1191+
padding: 8px;
1192+
margin-bottom: 16px;
1193+
border: 1px solid #ddd;
1194+
border-radius: 4px;
1195+
font-size: 14px;
1196+
}

src/dev-center/js/dev-center.js

+38
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ let currently_editing_app;
3030
let dropped_items;
3131
let search_query;
3232

33+
const APP_CATEGORIES = [
34+
{ id: 'games', label: 'Games' },
35+
{ id: 'developer-tools', label: 'Developer Tools' },
36+
{ id: 'photo-video', label: 'Photo & Video' },
37+
{ id: 'productivity', label: 'Productivity' },
38+
{ id: 'utilities', label: 'Utilities' },
39+
{ id: 'education', label: 'Education' },
40+
{ id: 'business', label: 'Business' },
41+
{ id: 'social', label: 'Social' },
42+
{ id: 'graphics-design', label: 'Graphics & Design' },
43+
{ id: 'music-audio', label: 'Music & Audio' },
44+
{ id: 'news', label: 'News' },
45+
{ id: 'entertainment', label: 'Entertainment' },
46+
{ id: 'finance', label: 'Finance' },
47+
{ id: 'health-fitness', label: 'Health & Fitness' },
48+
{ id: 'lifestyle', label: 'Lifestyle' },
49+
];
50+
3351
const deploying_spinner = `<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_P7sC{transform-origin:center;animation:spinner_svv2 .75s infinite linear}@keyframes spinner_svv2{100%{transform:rotate(360deg)}}</style><path d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z" class="spinner_P7sC"/></svg>`;
3452
const loading_spinner = `<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_P7sC{transform-origin:center;animation:spinner_svv2 .75s infinite linear}@keyframes spinner_svv2{100%{transform:rotate(360deg)}}</style><path d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z" class="spinner_P7sC"/></svg>`;
3553
const drop_area_placeholder = `<p>Drop your app folder and files here to deploy.</p><p style="font-size: 16px; margin-top: 0px;">HTML, JS, CSS, ...</p>`;
@@ -526,6 +544,14 @@ function generate_edit_app_section(app) {
526544
<label for="edit-app-description">Description</label>
527545
<textarea id="edit-app-description">${html_encode(app.description)}</textarea>
528546
547+
<label for="edit-app-category">Category</label>
548+
<select id="edit-app-category" class="category-select">
549+
<option value="">Select a category</option>
550+
${APP_CATEGORIES.map(category =>
551+
`<option value="${html_encode(category.id)}" ${app.metadata?.category === category.id ? 'selected' : ''}>${html_encode(category.label)}</option>`
552+
).join('')}
553+
</select>
554+
529555
<label for="edit-app-filetype-associations">File Associations</label>
530556
<p style="margin-top: 10px; font-size:13px;">A comma-separated list of file type specifiers. For example if you include <code>.txt</code>, your apps could be opened when a user clicks on a TXT file.</p>
531557
<textarea id="edit-app-filetype-associations" placeholder=".txt, .jpg, application/json">${app.filetype_associations}</textarea>
@@ -881,6 +907,7 @@ $(document).on('click', '.edit-app-save-btn', async function (e) {
881907
const width = $('#edit-app-window-width').val();
882908
const top = $('#edit-app-window-top').val();
883909
const left = $('#edit-app-window-left').val();
910+
const category = $('#edit-app-category').val();
884911

885912
let filetype_associations = $('#edit-app-filetype-associations').val();
886913

@@ -978,6 +1005,7 @@ $(document).on('click', '.edit-app-save-btn', async function (e) {
9781005
metadata: {
9791006
fullpage_on_landing: $('#edit-app-fullpage-on-landing').is(":checked"),
9801007
social_image: socialImageUrl,
1008+
category: category || null,
9811009
window_size: {
9821010
width: width ?? 800,
9831011
height: height ?? 600,
@@ -1263,6 +1291,16 @@ function generate_app_card(app) {
12631291
h += `<div style="float:left; padding-left: 10px;">`;
12641292
// Title
12651293
h += `<h3 class="got-to-edit-app app-card-title" data-app-name="${html_encode(app.name)}" data-app-title="${html_encode(app.title)}" data-app-uid="${html_encode(app.uid)}">${html_encode(app.title)}${app.metadata?.locked ? '<svg style="width: 20px; height: 20px; margin-bottom: -5px; margin-left: 5px; opacity: 0.5;" width="59px" height="59px" stroke-width="1.9" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="#000000"><path d="M16 12H17.4C17.7314 12 18 12.2686 18 12.6V19.4C18 19.7314 17.7314 20 17.4 20H6.6C6.26863 20 6 19.7314 6 19.4V12.6C6 12.2686 6.26863 12 6.6 12H8M16 12V8C16 6.66667 15.2 4 12 4C8.8 4 8 6.66667 8 8V12M16 12H8" stroke="#000000" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"></path></svg>' : ''}</h3>`;
1294+
// // Category
1295+
// if (app.metadata?.category) {
1296+
// const category = APP_CATEGORIES.find(c => c.id === app.metadata.category);
1297+
// if (category) {
1298+
// h += `<div class="app-categories">`;
1299+
// h += `<span class="app-category">${category.label}</span>`;
1300+
// h += `</div>`;
1301+
// }
1302+
// }
1303+
12661304
// link
12671305
h += `<a class="app-card-link" href="${html_encode(applink(app))}" target="_blank">${html_encode(applink(app))}</a>`;
12681306

0 commit comments

Comments
 (0)