From cc1bb924e71a0938988984740ee5c0a00b4b5c50 Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Sun, 1 Dec 2019 17:50:10 +0200 Subject: [PATCH] [HTML] Adjust embed color to theme --- DiscordChatExporter.Core.Models/Embed.cs | 5 +- .../Resources/HtmlDark.css | 4 + .../Resources/HtmlLight.css | 4 + .../Resources/HtmlShared.html | 196 +++++++++--------- .../DataService.Parsers.cs | 2 +- 5 files changed, 111 insertions(+), 100 deletions(-) diff --git a/DiscordChatExporter.Core.Models/Embed.cs b/DiscordChatExporter.Core.Models/Embed.cs index 8cf4434..dc84d7f 100644 --- a/DiscordChatExporter.Core.Models/Embed.cs +++ b/DiscordChatExporter.Core.Models/Embed.cs @@ -14,8 +14,7 @@ namespace DiscordChatExporter.Core.Models public DateTimeOffset? Timestamp { get; } - // TODO: this should be nullable and default color should be set in CSS - public Color Color { get; } + public Color? Color { get; } public EmbedAuthor? Author { get; } @@ -29,7 +28,7 @@ namespace DiscordChatExporter.Core.Models public EmbedFooter? Footer { get; } - public Embed(string? title, string? url, DateTimeOffset? timestamp, Color color, EmbedAuthor? author, string? description, + public Embed(string? title, string? url, DateTimeOffset? timestamp, Color? color, EmbedAuthor? author, string? description, IReadOnlyList fields, EmbedImage? thumbnail, EmbedImage? image, EmbedFooter? footer) { Title = title; diff --git a/DiscordChatExporter.Core.Rendering/Resources/HtmlDark.css b/DiscordChatExporter.Core.Rendering/Resources/HtmlDark.css index 6233721..b133b99 100644 --- a/DiscordChatExporter.Core.Rendering/Resources/HtmlDark.css +++ b/DiscordChatExporter.Core.Rendering/Resources/HtmlDark.css @@ -70,6 +70,10 @@ a { color: rgba(255, 255, 255, 0.2); } +.chatlog__embed-color-pill--default { + background-color: rgba(79, 84, 92, 1); +} + .chatlog__embed-content-container { background-color: rgba(46, 48, 54, 0.3); border-color: rgba(46, 48, 54, 0.6); diff --git a/DiscordChatExporter.Core.Rendering/Resources/HtmlLight.css b/DiscordChatExporter.Core.Rendering/Resources/HtmlLight.css index 65f0f62..872352c 100644 --- a/DiscordChatExporter.Core.Rendering/Resources/HtmlLight.css +++ b/DiscordChatExporter.Core.Rendering/Resources/HtmlLight.css @@ -73,6 +73,10 @@ a { color: #747f8d; } +.chatlog__embed-color-pill--default { + background-color: rgba(227, 229, 232, 1); +} + .chatlog__embed-content-container { background-color: rgba(249, 249, 249, 0.3); border-color: rgba(204, 204, 204, 0.3); diff --git a/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.html b/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.html index dc0cce9..9fc036a 100644 --- a/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.html +++ b/DiscordChatExporter.Core.Rendering/Resources/HtmlShared.html @@ -15,12 +15,23 @@ {{ ThemeStyleSheet }} + {{~ # Syntax highlighting ~}} + + + + {{~ # Local scripts ~}} - - {{~ # Syntax highlighting ~}} - - - @@ -130,107 +130,111 @@ {{~ # Embeds ~}} {{~ for embed in message.Embeds ~}} -
-
-
-
-
- {{~ # Author ~}} - {{~ if embed.Author ~}} -
- {{~ if embed.Author.IconUrl ~}} - - {{~ end ~}} - - {{~ if embed.Author.Name ~}} - - {{~ if embed.Author.Url ~}} - {{ embed.Author.Name | html.escape }} - {{~ else ~}} - {{ embed.Author.Name | html.escape }} - {{~ end ~}} - - {{~ end ~}} -
- {{~ end ~}} - - {{~ # Title ~}} - {{~ if embed.Title ~}} -
- {{~ if embed.Url ~}} - {{ embed.Title | FormatMarkdown }} - {{~ else ~}} - {{ embed.Title | FormatMarkdown }} - {{~ end ~}} -
+
+ {{~ if embed.Color ~}} +
+ {{~ else ~}} +
+ {{~ end ~}} +
+
+
+ {{~ # Author ~}} + {{~ if embed.Author ~}} +
+ {{~ if embed.Author.IconUrl ~}} + {{~ end ~}} - {{~ # Description ~}} - {{~ if embed.Description ~}} -
{{ embed.Description | FormatMarkdown }}
+ {{~ if embed.Author.Name ~}} + + {{~ if embed.Author.Url ~}} + {{ embed.Author.Name | html.escape }} + {{~ else ~}} + {{ embed.Author.Name | html.escape }} + {{~ end ~}} + {{~ end ~}} +
+ {{~ end ~}} - {{~ # Fields ~}} - {{~ if embed.Fields | array.size > 0 ~}} -
- {{~ for field in embed.Fields ~}} -
- {{~ if field.Name ~}} -
{{ field.Name | FormatMarkdown }}
- {{~ end ~}} - {{~ if field.Value ~}} -
{{ field.Value | FormatMarkdown }}
- {{~ end ~}} -
- {{~ end ~}} -
+ {{~ # Title ~}} + {{~ if embed.Title ~}} +
+ {{~ if embed.Url ~}} + {{ embed.Title | FormatMarkdown }} + {{~ else ~}} + {{ embed.Title | FormatMarkdown }} {{~ end ~}}
+ {{~ end ~}} + + {{~ # Description ~}} + {{~ if embed.Description ~}} +
{{ embed.Description | FormatMarkdown }}
+ {{~ end ~}} - {{~ # Thumbnail ~}} - {{~ if embed.Thumbnail ~}} -
- - - + {{~ # Fields ~}} + {{~ if embed.Fields | array.size > 0 ~}} +
+ {{~ for field in embed.Fields ~}} +
+ {{~ if field.Name ~}} +
{{ field.Name | FormatMarkdown }}
+ {{~ end ~}} + {{~ if field.Value ~}} +
{{ field.Value | FormatMarkdown }}
+ {{~ end ~}}
+ {{~ end ~}} +
{{~ end ~}}
- {{~ # Image ~}} - {{~ if embed.Image ~}} -
- - - -
+ {{~ # Thumbnail ~}} + {{~ if embed.Thumbnail ~}} +
+ + + +
{{~ end ~}} +
- {{~ # Footer ~}} - {{~ if embed.Footer || embed.Timestamp ~}} - + {{~ # Footer ~}} + {{~ if embed.Footer || embed.Timestamp ~}} + + {{~ end ~}}
+
{{~ end ~}} {{~ # Reactions ~}} diff --git a/DiscordChatExporter.Core.Services/DataService.Parsers.cs b/DiscordChatExporter.Core.Services/DataService.Parsers.cs index c4ed7ef..3d301ed 100644 --- a/DiscordChatExporter.Core.Services/DataService.Parsers.cs +++ b/DiscordChatExporter.Core.Services/DataService.Parsers.cs @@ -123,7 +123,7 @@ namespace DiscordChatExporter.Core.Services // Get color var color = json["color"] != null ? Color.FromArgb(json["color"]!.Value()).ResetAlpha() - : Color.FromArgb(79, 84, 92); // default color + : default(Color?); // Get author var author = json["author"] != null ? ParseEmbedAuthor(json["author"]!) : null;