Skip to content

Commit

Permalink
Fixed color of Logo element
Browse files Browse the repository at this point in the history
  • Loading branch information
jzongker committed Nov 17, 2024
1 parent f3f6b3f commit 999dc0f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import CascadingHoverMenus from "./CascadingMenus/CascadingHoverMenus";
import CascadingListMenu from "./CascadingMenus/CascadingListMenu";
import { GlobalStyleInterface, PersonHelper, SectionInterface } from "@/helpers";
import { redirect } from "next/navigation";
import { StyleHelper } from "@/helpers/StyleHelper";


type Props = {
Expand Down Expand Up @@ -167,6 +168,16 @@ export function Header(props: Props) {
return result;
}

const getLogo = () => {
if (transparent) {
const textColor=StyleHelper.getTextColor(props.sections[0]?.textColor, props.globalStyles, props.churchSettings);
const logo = AppearanceHelper.getLogoByTextColor(props.churchSettings?.logoLight || null, props.churchSettings?.logoDark || null, textColor);
return logo !== "" ? logo : null;
}
else return props.churchSettings?.logoLight || null;
}

/*
const getLogo = () => {
if (transparent) {
let textColor = props.sections[0]?.textColor || "#FFF";
Expand All @@ -181,7 +192,7 @@ export function Header(props: Props) {
} else {
return props.churchSettings?.logoLight || null;
}
};
};*/

// const getLogo = () => {
// if (transparent) {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Element } from "./Element";
import { YoutubeBackground } from "./YoutubeBackground";
import { ApiHelper, ChurchInterface } from "@churchapps/apphelper";
import { DraggableWrapper } from "./admin/DraggableWrapper";
import { StyleHelper } from "@/helpers/StyleHelper";

interface Props {
first?: boolean,
Expand All @@ -25,7 +26,8 @@ export const Section: React.FC<Props> = props => {
const getElements = () => {
const result: JSX.Element[] = []
props.section.elements.forEach(e => {
result.push(<Element key={e.id} element={e} onEdit={props.onEdit} onMove={props.onMove} church={props.church} churchSettings={props.churchSettings} textColor={props.section.textColor} />)
const textColor = StyleHelper.getTextColor(props.section?.textColor, {}, props.churchSettings);
result.push(<Element key={e.id} element={e} onEdit={props.onEdit} onMove={props.onMove} church={props.church} churchSettings={props.churchSettings} textColor={textColor} />)
});
return result;
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/elementTypes/LogoElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import { AppearanceHelper } from "@churchapps/apphelper";
interface Props { element: ElementInterface; churchSettings: any; textColor: string; }

export const LogoElement: React.FC<Props> = (props) => {



let logoUrl = (props.textColor === "light")
? AppearanceHelper.getLogoDark(props.churchSettings.appearance ?? props.churchSettings, "/images/logo.png")
: AppearanceHelper.getLogoLight(props.churchSettings.appearance ?? props.churchSettings, "/images/logo.png");

console.log("Text Color", props.textColor, logoUrl);

const photo = <img src={logoUrl} alt={props.element.answers?.photoAlt || ""} className="img-fluid" id={"el-" + props.element.id} />
const photoContent = (props.element.answers?.url) ? <a href={props.element.answers?.url}>{photo}</a> : photo;

Expand Down
17 changes: 17 additions & 0 deletions src/helpers/StyleHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@

import { ElementInterface, SectionInterface } from "./interfaces";

export class StyleHelper {

static getTextColor = (textColor:string, globalStyles:any, churchSettings:any) => {
if (!textColor) textColor = "#FFF";
if (textColor.indexOf("var(--") > -1) {
if (globalStyles.palette) {
const palette = JSON.parse(globalStyles.palette);
textColor = textColor.replace("var(--", "").replace(")", "");
textColor = palette[textColor];
} else {
textColor="light";
if (textColor.indexOf("dark")>-1 || textColor.indexOf("darkAccent")>-1 || textColor.indexOf("accent")>-1) textColor="dark";
}
if (!textColor) textColor = "#FFF";
}
return textColor;
};

private static getStyle = (id:string, styles:any) => {
let result:string[] = [];
Object.keys(styles).forEach((key:string) => {
Expand Down

0 comments on commit 999dc0f

Please sign in to comment.