diff --git a/dist/treebird20.css b/dist/treebird20.css index 168d845..71a94e5 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -1371,9 +1371,15 @@ p} background-color: #fff; background: linear-gradient(#fff, #f3f3f3); border-radius: 8px; + z-index: 5; box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.2); } +.emoji-picker .tabs .btn +{ + display: inline-block; +} + .emoji-picker .navigation { border-top: 1px solid #cacaca; @@ -1385,6 +1391,7 @@ p} text-align: center; vertical-align: center; padding: 8px 0; + max-width: 28px; } .emoji-picker .emoji:hover @@ -1398,6 +1405,19 @@ p} transform: scale(1.0); } +.emoji-picker-emojos-wrapper +{ + overflow-y: auto; + overflow-x: hidden; + height: 180px; + max-height: 180px; +} + +input[type=radio].hidden:not(:checked) + .emoji-picker-emojos +{ + display: none; +} + .emoji-picker-emojos { display: grid; @@ -1597,7 +1617,7 @@ ul.large-list li .edit-list-btn border-bottom: 1px solid #dadada; } -.list-radio-show:not(:checked) + .list-edit-content +.input[type=checkbox].hidden:not(:checked) + .list-edit-content { display: none; } @@ -1657,7 +1677,8 @@ ul.large-list li .edit-list-btn text-shadow: unset; } -.tabs .tab-btn.active +.tabs .tab-btn.active, +.tabs .tab-btn:checked { background: linear-gradient(#fff, #f7f7f7); box-shadow: inset 0px 2px 4px rgba(0, 0, 0, 0.15); diff --git a/src/base_page.c b/src/base_page.c index 733c53f..e237e9f 100644 --- a/src/base_page.c +++ b/src/base_page.c @@ -19,6 +19,7 @@ #include #include #include +#include "helpers.h" #include "base_page.h" #include "easprintf.h" #include "cookie.h" diff --git a/src/emoji.c b/src/emoji.c index e60f922..92d5b5e 100644 --- a/src/emoji.c +++ b/src/emoji.c @@ -27,6 +27,19 @@ #include "../static/emoji.ctmpl" #include "../static/emoji_picker.ctmpl" +enum emoji_categories +{ + EMO_CAT_SMILEYS, + EMO_CAT_ANIMALS, + EMO_CAT_FOOD, + EMO_CAT_TRAVEL, + EMO_CAT_ACTIVITIES, + EMO_CAT_OBJECTS, + EMO_CAT_SYMBOLS, + EMO_CAT_FLAGS, + EMO_CAT_LEN +}; + char* emojify(char* content, struct mstdnt_emoji* emos, size_t emos_len) { if (!content) return NULL; @@ -81,46 +94,52 @@ static char* construct_emoji_voidwrap(void* passed, size_t index, size_t* res) { struct construct_emoji_picker_args* args = passed; size_t calc_index = index + args->index; - return calc_index < 0 || calc_index >= emojos_size ? NULL : - construct_emoji(emojos + calc_index, args->status_id, res); + return construct_emoji(emojos + calc_index, args->status_id, res); } -char* construct_emoji_picker(char* status_id, unsigned index, size_t* size) -{ - struct construct_emoji_picker_args args = { - .status_id = status_id, - .index = index - }; - char* emoji_picker_html; - char* emojis; +#define EMOJI_PICKER_ARGS(this_index) { .status_id = status_id, .index = this_index } - emojis = construct_func_strings(construct_emoji_voidwrap, &args, EMOJI_FACTOR_NUM, NULL); +char* construct_emoji_picker(char* status_id, size_t* size) +{ + + char* emoji_picker_html; + + struct construct_emoji_picker_args args[EMO_CAT_LEN] = { + EMOJI_PICKER_ARGS(EMOJO_CAT_SMILEY), + EMOJI_PICKER_ARGS(EMOJO_CAT_ANIMALS), + EMOJI_PICKER_ARGS(EMOJO_CAT_FOOD), + EMOJI_PICKER_ARGS(EMOJO_CAT_TRAVEL), + EMOJI_PICKER_ARGS(EMOJO_CAT_ACTIVITIES), + EMOJI_PICKER_ARGS(EMOJO_CAT_OBJECTS), + EMOJI_PICKER_ARGS(EMOJO_CAT_SYMBOLS), + EMOJI_PICKER_ARGS(EMOJO_CAT_FLAGS), + }; + + char* emojis[EMO_CAT_LEN]; + + // TODO refactor to use #define lol + emojis[EMO_CAT_SMILEYS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_SMILEYS, EMOJO_CAT_ANIMALS - EMOJO_CAT_SMILEY, NULL); + emojis[EMO_CAT_ANIMALS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_ANIMALS, EMOJO_CAT_FOOD - EMOJO_CAT_ANIMALS, NULL); + emojis[EMO_CAT_FOOD] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_FOOD, EMOJO_CAT_TRAVEL - EMOJO_CAT_FOOD, NULL); + emojis[EMO_CAT_TRAVEL] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_TRAVEL, EMOJO_CAT_ACTIVITIES - EMOJO_CAT_TRAVEL, NULL); + emojis[EMO_CAT_ACTIVITIES] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_ACTIVITIES, EMOJO_CAT_OBJECTS - EMOJO_CAT_ACTIVITIES, NULL); + emojis[EMO_CAT_OBJECTS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_OBJECTS, EMOJO_CAT_SYMBOLS - EMOJO_CAT_OBJECTS, NULL); + emojis[EMO_CAT_SYMBOLS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_SYMBOLS, EMOJO_CAT_FLAGS - EMOJO_CAT_SYMBOLS, NULL); + emojis[EMO_CAT_FLAGS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_FLAGS, 30 /* TODO there are not 100 flags */, NULL); struct emoji_picker_template data = { - .cat_smileys = ACTIVE_CONDITION(index >= 0 && index < EMOJO_CAT_ANIMALS), - .animals = EMOJO_CAT_ANIMALS, - .cat_animals = ACTIVE_CONDITION(index >= EMOJO_CAT_ANIMALS && index < EMOJO_CAT_FOOD), - .food = EMOJO_CAT_FOOD, - .cat_food = ACTIVE_CONDITION(index >= EMOJO_CAT_FOOD && index < EMOJO_CAT_TRAVEL), - .travel = EMOJO_CAT_TRAVEL, - .cat_travel = ACTIVE_CONDITION(index >= EMOJO_CAT_TRAVEL && index < EMOJO_CAT_ACTIVITIES), - .activities = EMOJO_CAT_ACTIVITIES, - .cat_activities = ACTIVE_CONDITION(index >= EMOJO_CAT_ACTIVITIES && index < EMOJO_CAT_OBJECTS), - .objects = EMOJO_CAT_OBJECTS, - .cat_objects = ACTIVE_CONDITION(index >= EMOJO_CAT_OBJECTS && index < EMOJO_CAT_SYMBOLS), - .symbols = EMOJO_CAT_SYMBOLS, - .cat_symbols = ACTIVE_CONDITION(index >= EMOJO_CAT_SYMBOLS && index < EMOJO_CAT_FLAGS), - .flags = EMOJO_CAT_FLAGS, - .cat_flags = ACTIVE_CONDITION(index >= EMOJO_CAT_FLAGS && index < emojos_size), - .emojis = emojis, - // Index movements - .status_id = status_id, - .index_previous = index > 0 ? index - EMOJI_FACTOR_NUM : 0, - .previous_enabled = 0 > index - EMOJI_FACTOR_NUM ? "disabled" : "", - .index_next = index + EMOJI_FACTOR_NUM + .emojis_smileys = emojis[EMO_CAT_SMILEYS], + .emojis_animals = emojis[EMO_CAT_ANIMALS], + .emojis_food = emojis[EMO_CAT_FOOD], + .emojis_travel = emojis[EMO_CAT_TRAVEL], + .emojis_activities = emojis[EMO_CAT_ACTIVITIES], + .emojis_objects = emojis[EMO_CAT_OBJECTS], + .emojis_symbols = emojis[EMO_CAT_SYMBOLS], + .emojis_flags = emojis[EMO_CAT_FLAGS], }; emoji_picker_html = tmpl_gen_emoji_picker(&data, size); - free(emojis); + for (size_t i = 0; i < EMO_CAT_LEN; ++i) + free(emojis[i]); return emoji_picker_html; } diff --git a/src/emoji.h b/src/emoji.h index 6130c79..1b5d98c 100644 --- a/src/emoji.h +++ b/src/emoji.h @@ -33,6 +33,6 @@ enum emoji_picker_cat char* emojify(char* content, struct mstdnt_emoji* emos, size_t emos_len); char* construct_emoji(struct emoji_info* emoji, char* status_id, size_t* size); -char* construct_emoji_picker(char* status_id, unsigned index, size_t* size); +char* construct_emoji_picker(char* status_id, size_t* size); #endif // EMOJI_H diff --git a/src/search.c b/src/search.c index 7b8483e..209bc35 100644 --- a/src/search.c +++ b/src/search.c @@ -17,6 +17,7 @@ */ #include +#include "helpers.h" #include "search.h" #include "easprintf.h" #include "../config.h" diff --git a/src/status.c b/src/status.c index efe67b2..f37080c 100644 --- a/src/status.c +++ b/src/status.c @@ -241,7 +241,7 @@ char* construct_interaction_buttons(struct session* ssn, // Emojo picker if ((flags & STATUS_EMOJI_PICKER) == STATUS_EMOJI_PICKER) { - emoji_picker_html = construct_emoji_picker(status->id, keyint(ssn->post.emojoindex), NULL); + emoji_picker_html = construct_emoji_picker(status->id, NULL); } struct reactions_btn_template tdata = { diff --git a/src/timeline.c b/src/timeline.c index b57f7fb..bda7a13 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -18,6 +18,7 @@ #include "timeline.h" #include +#include "helpers.h" #include "base_page.h" #include "../config.h" #include "index.h" diff --git a/static/emoji_picker.tmpl b/static/emoji_picker.tmpl index d5fbaeb..70cd38a 100644 --- a/static/emoji_picker.tmpl +++ b/static/emoji_picker.tmpl @@ -2,81 +2,80 @@
-
- - -
+
-
- - -
+
-
- - -
+
-
- - -
+
-
- - -
+
-
- - -
+
-
- - -
+
-
- - -
+
- -
- {{%s:emojis}} +
+ +
+ {{%s:emojis_smileys}} +
+ +
+ {{%s:emojis_animals}} +
+ +
+ {{%s:emojis_food}} +
+ +
+ {{%s:emojis_travel}} +
+ +
+ {{%s:emojis_activities}} +
+ +
+ {{%s:emojis_objects}} +
+ +
+ {{%s:emojis_symbols}} +
+ +
+ {{%s:emojis_flags}} +
- - - - - - -
diff --git a/static/reactions_btn.tmpl b/static/reactions_btn.tmpl index 28f4b8a..fa6be6b 100644 --- a/static/reactions_btn.tmpl +++ b/static/reactions_btn.tmpl @@ -1,6 +1,6 @@ - {{%s:emoji_picker}} - + + {{%s:emoji_picker}}