/* * QQQ - Low-code Application Framework for Engineers. * Copyright (C) 2021-2025. Kingsrook, LLC * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States * contact@kingsrook.com * https://github.com/Kingsrook/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.kingsrook.qbits.email.render; import com.kingsrook.qbits.email.outbox.EmailCategory; import com.kingsrook.qbits.email.template.EmailTemplateEngine; import com.kingsrook.qbits.email.template.VariableSchema; import com.kingsrook.qqq.backend.core.model.data.QRecord; /******************************************************************************* ** Single-column, 600px email shell with inline fallbacks and dark-mode hooks. *******************************************************************************/ public final class EmailLayout { /******************************************************************************* ** Utility class. *******************************************************************************/ private EmailLayout() { } /******************************************************************************* ** Render both schemes from the same validated brand. *******************************************************************************/ public static String render(String body, String preheader, QRecord brand, EmailCategory category, String unsubscribe) { EmailBrands.validate(brand); String dark = ".email-shell,.email-content{background-color:" + ContrastCheck.color(brand, "darkBackgroundColor") + "!important;color:" + ContrastCheck.color(brand, "darkTextColor") + "!important}.email-button{background-color:" + ContrastCheck.color(brand, "darkPrimaryColor") + "!important}.email-button a{color:" + ContrastCheck.color(brand, "darkButtonTextColor") + "!important}.email-logo-light{display:none!important}.email-logo-dark{display:block!important}"; String outlook = "[data-ogsc] .email-content,[data-ogsc] .email-shell,[data-ogsb] .email-content,[data-ogsb] .email-shell{background-color:" + ContrastCheck.color(brand, "darkBackgroundColor") + "!important;color:" + ContrastCheck.color(brand, "darkTextColor") + "!important}[data-ogsc] .email-button,[data-ogsb] .email-button{background-color:" + ContrastCheck.color(brand, "darkPrimaryColor") + "!important}[data-ogsc] .email-button a,[data-ogsb] .email-button a{color:" + ContrastCheck.color(brand, "darkButtonTextColor") + "!important}[data-ogsc] .email-logo-light,[data-ogsb] .email-logo-light{display:none!important}[data-ogsc] .email-logo-dark,[data-ogsb] .email-logo-dark{display:block!important}"; return ("
" + "" + "" + "" + ""
+ ""
+ "
|
" + EmailTemplateEngine.escape(brand.getValueString("label")) + "
"); } String dark = brand.getValueString("logoDarkUrl"); return (logo(light, brand.getValueString("logoAlt"), dark == null ? "" : "email-logo-light", "block") + (dark == null ? "" : logo(dark, brand.getValueString("logoAlt"), "email-logo-dark", "none"))); } /******************************************************************************* ** Escaped logo element. *******************************************************************************/ private static String logo(String url, String alt, String css, String display) { return ("