Set illust badge's background color to red if the illust is AI-generated
This commit is contained in:
		
							parent
							
								
									2a6130b16c
								
							
						
					
					
						commit
						727f5dd32b
					
				| 
						 | 
				
			
			@ -9,6 +9,7 @@ void css_route(const httplib::Request& req, httplib::Response& res) {
 | 
			
		|||
        --text-color: white;
 | 
			
		||||
 | 
			
		||||
        --illust-badge-background-color: rgba(0, 0, 0, .5);
 | 
			
		||||
        --illust-badge-ai-background-color: rgba(255, 0, 0, .5);
 | 
			
		||||
 | 
			
		||||
        --error-background-color: rgb(100, 0, 0);
 | 
			
		||||
        --error-border-color: red;
 | 
			
		||||
| 
						 | 
				
			
			@ -93,6 +94,9 @@ void css_route(const httplib::Request& req, httplib::Response& res) {
 | 
			
		|||
        background-color: var(--illust-badge-background-color);
 | 
			
		||||
        text-decoration: none !important;
 | 
			
		||||
    }
 | 
			
		||||
    .illustbadge.ai {
 | 
			
		||||
        background-color: var(--illust-badge-ai-background-color);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* ILLUSTRATIONS PAGE */
 | 
			
		||||
    .illusttags {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -156,7 +156,7 @@ static inline Element generate_illusts_grid_item(const httplib::Request& req, co
 | 
			
		|||
        })
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    if (illust.page_count > 1) {
 | 
			
		||||
    if (illust.page_count > 1 || illust.ai_generated) {
 | 
			
		||||
        div.nodes.push_back(generate_illust_badge(illust, std::move(illust_url)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -164,10 +164,15 @@ static inline Element generate_illusts_grid_item(const httplib::Request& req, co
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static inline Element generate_illust_badge(const Illust& illust, const std::string& illust_url) {
 | 
			
		||||
    std::string text = std::to_string(illust.page_count) + " pages";
 | 
			
		||||
    std::string illust_preview_url = illust_url + "?preview=1";
 | 
			
		||||
    const char* css_class = !illust.ai_generated ? "illustbadge" : "illustbadge ai";
 | 
			
		||||
 | 
			
		||||
    return Element("a", {{"class", "illustbadge"}, {"href", std::move(illust_preview_url)}}, {
 | 
			
		||||
        std::move(text)
 | 
			
		||||
    });
 | 
			
		||||
    if (illust.page_count > 1) {
 | 
			
		||||
        return Element("a", {{"class", css_class}, {"href", illust_url + "?preview=1"}}, {
 | 
			
		||||
            std::to_string(illust.page_count), " pages"
 | 
			
		||||
        });
 | 
			
		||||
    } else {
 | 
			
		||||
        return Element("span", {{"class", css_class}}, {
 | 
			
		||||
            "AI"
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue