Show notification icons

FossilOrigin-Name: 2b77af10823e2c9a0c7181102992cb421538f041745290603f24a5f78a5d5b48
This commit is contained in:
me@ow.nekobit.net 2022-03-30 19:42:44 +00:00
parent aef9560da0
commit eaa850da87
10 changed files with 46 additions and 2 deletions

View file

@ -68,6 +68,11 @@ $(PAGES_DIR)/navigation.chtml: $(PAGES_DIR)/navigation.html
./filec $< data_navigation_html > $@
$(PAGES_DIR)/config_sidebar.chtml: $(PAGES_DIR)/config_sidebar.html
./filec $< data_config_sidebar_html > $@
$(PAGES_DIR)/like_svg.chtml: $(PAGES_DIR)/like_svg.html
./filec $< data_like_svg_html > $@
$(PAGES_DIR)/repeat_svg.chtml: $(PAGES_DIR)/repeat_svg.html
./filec $< data_repeat_svg_html > $@
$(MASTODONT_DIR):
git clone $(MASTODONT_URL) || true

12
dist/treebird20.css vendored
View file

@ -308,6 +308,18 @@ ul li:first-child a.sidebarbtn
font-weight: bold;
}
.notification-info svg
{
width: 16px;
height: 16px;
stroke: #aa0000;
}
.notification-info svg.like
{
fill: #aa0000;
}
.notification-compact .notification-content
{
color: #808080;

View file

@ -29,6 +29,8 @@
#include "../static/notifications.chtml"
#include "../static/notification.chtml"
#include "../static/notification_compact.chtml"
#include "../static/like_svg.chtml"
#include "../static/repeat_svg.chtml"
char* construct_notification(struct mstdnt_notification* notif, int* size)
{
@ -55,6 +57,7 @@ char* construct_notification_compact(struct mstdnt_notification* notif, int* siz
char* notif_stats = NULL;
const char* type_str = notification_type_str(notif->type);
const char* type_svg = notification_type_svg(notif->type);
if (notif->status)
easprintf(&notif_stats, "%d - %d - %d",
@ -67,6 +70,7 @@ char* construct_notification_compact(struct mstdnt_notification* notif, int* siz
notif->account->avatar,
notif->account->display_name,
type_str,
type_svg,
/* Might show follower address */
notif->type == MSTDNT_NOTIFICATION_FOLLOW ?
notif->account->acct :

View file

@ -106,6 +106,7 @@ char* construct_status(struct mstdnt_status* status,
uint8_t flags)
{
char* stat_html;
const char* type_svg = notification_type_svg(notif->type);
// Counts
char* reply_count = NULL;
@ -128,7 +129,8 @@ char* construct_status(struct mstdnt_status* status,
easprintf(&notif_info, data_notification_html,
notif->account->avatar,
notif->account->display_name,
notification_type_str(notif->type));
notification_type_str(notif->type),
type_svg);
size_t s = easprintf(&stat_html, data_status_html,

View file

@ -17,6 +17,8 @@
*/
#include "type_string.h"
#include "../static/like_svg.chtml"
#include "../static/repeat_svg.chtml"
const char* notification_type_str(mstdnt_notification_t type)
{
@ -31,3 +33,18 @@ const char* notification_type_str(mstdnt_notification_t type)
default: return "";
}
}
const char* notification_type_svg(mstdnt_notification_t type)
{
switch (type)
{
case MSTDNT_NOTIFICATION_FOLLOW: return "";
case MSTDNT_NOTIFICATION_FOLLOW_REQUEST: return "";
case MSTDNT_NOTIFICATION_REBLOG: return data_repeat_svg_html;
case MSTDNT_NOTIFICATION_FAVOURITE: return data_like_svg_html;
case MSTDNT_NOTIFICATION_POLL: return "";
case MSTDNT_NOTIFICATION_EMOJI_REACT: return "";
default: return "";
}
}

View file

@ -21,6 +21,7 @@
#include <mastodont.h>
#include "l10n.h"
const char* notification_type_svg(mstdnt_notification_t type);
const char* notification_type_str(mstdnt_notification_t type);
#endif // TYPE_STRING_H

1
static/like_svg.html Normal file
View file

@ -0,0 +1 @@
<svg class="like" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>

After

Width:  |  Height:  |  Size: 319 B

View file

@ -3,5 +3,6 @@
<div class="notification-user">
<span class="username">%s</span>
<span class="action">%s</span>
%s
</div>
</div>

View file

@ -5,7 +5,7 @@
</td>
<td>
<div class="notification-info">
<span class="username">%s</span> <span class="action">%s</span>
<span class="username">%s</span> <span class="action">%s</span> %s
</div>
<div class="notification-content">%s</div>
<div class="notification-stats">%s</div>

1
static/repeat_svg.html Normal file
View file

@ -0,0 +1 @@
<svg class="repeat" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 2.1l4 4-4 4"/><path d="M3 12.2v-2a4 4 0 0 1 4-4h12.8M7 21.9l-4-4 4-4"/><path d="M21 11.8v2a4 4 0 0 1-4 4H4.2"/></svg>

After

Width:  |  Height:  |  Size: 322 B