Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
c4901bc
fix(integrations): support dark mode whiteIcon and standardize compon…
tejaswiverma121-byte Oct 1, 2026
66a1879
fix(integrations): circular icon badges, expand card size, and align …
tejaswiverma121-byte Oct 2, 2026
334737d
fix(integrations): improve icon fallback robustness, initial render, …
tejaswiverma121-byte Oct 2, 2026
f495264
Merge branch 'master' into fix/8146-integration-component-icons-dark-…
tejaswiverma121-byte Oct 2, 2026
9bd650d
fix(integrations): use unique key with index in component grid
tejaswiverma121-byte Oct 2, 2026
bead3ba
fix(integrations): make component icon fallback theme-aware
tejaswiverma121-byte Oct 2, 2026
f7ac96a
fix(integrations): try alternate component icon before integration fa…
tejaswiverma121-byte Oct 2, 2026
c79d1c6
fix(integrations): initialize component grid as empty until icons val…
tejaswiverma121-byte Oct 2, 2026
574af28
Merge branch 'master' into fix/8146-integration-component-icons-dark-…
tejaswiverma121-byte Oct 4, 2026
da49eaf
fix(integrations): prioritize integration fallback icon over alternat…
tejaswiverma121-byte Oct 8, 2026
f959735
Merge branch 'master' of https://github.com/layer5io/layer5 into fix/…
tejaswiverma121-byte Oct 13, 2026
b072c7f
fix(integrations): add onError safety net and use validComponents count
tejaswiverma121-byte Oct 15, 2026
db39b88
Merge branch 'master' into fix/8146-integration-component-icons-dark-…
tejaswiverma121-byte Oct 16, 2026
293fd50
fix(integrations): revert unrelated formatting, drop svg swap, and fi…
tejaswiverma121-byte Oct 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ export const ComponentsWrapper = styled.div`
font-weight: normal;
}
}
.componentimg {
width: 80px;
height: 80px;
}
.componentimg img {
width: 100%;
height: 100%;
object-fit: contain;
}

.componentsSection {
display: grid;
Expand All @@ -37,23 +28,43 @@ export const ComponentsWrapper = styled.div`
}
}

.componentimg {
width: 48px;
height: 48px;
min-width: 48px;
display: grid;
place-items: center;
border-radius: 50%;
background-color: ${(props) => props.theme.blackToWhite};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In dark mode blackToWhite makes the badge pure black, but the fallback chain can still put a colour icon or a light-mode integrationIcon here. A dark logo on a black circle is nearly invisible, which is the contrast problem this PR is trying to fix. Consider a neutral or contrasting badge for non-white icons.

padding: 8px;
}

.componentimg img {
width: 100%;
height: 100%;
object-fit: contain;
display: block;
}

.maincontainer {
display: flex;
align-items: center;
gap: 1rem;
background-color: ${(props) => props.theme.grey212121ToGreyEEEEEE};
padding: 0.5rem 1rem;
padding: 0.85rem 1.25rem;
border-radius: 0.85rem;
width: 100%;
min-height: 72px;
}

.items {
border-radius: 0.625rem;
text-transform: uppercase;
margin: 0;
color: ${(props) => props.theme.text};
font-size: 0.875rem;
transition: all 0.1s ease-in-out;
line-height: 1.1875rem;
line-height: 1.25;
text-transform: uppercase;
word-break: break-word;
width: 100%;
transition: all 0.1s ease-in-out;
}
`;
Original file line number Diff line number Diff line change
@@ -1,56 +1,150 @@
import React, { useEffect, useState } from "react";
import { ComponentsWrapper } from "./Component.style";
import { checkImageUrlValidity } from "../../../../utils/imageValidate";
import { useStyledDarkMode } from "../../../../theme/app/useStyledDarkMode";

const getFallbackIcon = (frontmatter, isDarkActive) => {
if (isDarkActive) {
return (
frontmatter?.darkModeIntegrationIcon?.publicURL ||
frontmatter?.integrationIcon?.publicURL ||
frontmatter?.integrationIcon_svg?.publicURL ||
""
);
}

return (
frontmatter?.integrationIcon?.publicURL ||
frontmatter?.integrationIcon_svg?.publicURL ||
frontmatter?.darkModeIntegrationIcon?.publicURL ||
""
);
};

const getPreferredIcon = (component, isDarkActive, fallbackIcon) => {
const primary = isDarkActive
? component?.whiteIcon?.publicURL
: component?.colorIcon?.publicURL;
const alternate = isDarkActive
? component?.colorIcon?.publicURL
: component?.whiteIcon?.publicURL;

return primary || fallbackIcon || alternate || "";
};

const ComponentsGrid = ({ frontmatter }) => {
const components = frontmatter.components.map((component) => {
const { name, colorIcon } = component; // currently we don't have description for components
return { name, colorIcon };
});
const { isDark } = useStyledDarkMode();
const darkModeActive = Boolean(isDark);
const fallbackIcon = getFallbackIcon(frontmatter, darkModeActive);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

const candidateComponents = (frontmatter?.components || []).map(
(component) => ({
...component,
preferredIcon: getPreferredIcon(component, darkModeActive, fallbackIcon),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferredIcon computed here by getPreferredIcon is never used: the effect recomputes primary/alternate inline and overwrites it. That leaves two copies of the icon priority logic, which can drift apart. Consider keeping a single helper that returns the ordered candidate list.

}),
);

const [validComponents, setValidComponents] = useState([]);

useEffect(() => {
const fetchData = async () => {
const promises = components.map(async (item) => {
const isSvgPathValid = await checkImageUrlValidity(
item.colorIcon.publicURL
);
if (isSvgPathValid) {
return item;
} else {
item.colorIcon.publicURL = frontmatter.integrationIcon.publicURL;
return item; // Return fallback image
let mounted = true;

const loadIcons = async () => {
let isFallbackValid = null;
const checkFallback = async () => {
if (!fallbackIcon) return false;
if (isFallbackValid === null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cache doesn't work under Promise.all: every component checks isFallbackValid === null before the first probe resolves, so each one starts its own request for the same URL. Cache the promise instead, e.g. fallbackPromise ??= checkImageUrlValidity(fallbackIcon).

isFallbackValid = await checkImageUrlValidity(fallbackIcon);
}
});
return isFallbackValid;
};

const validItems = await Promise.all(
candidateComponents.map(async (item) => {
const primaryIcon = darkModeActive
? item.whiteIcon?.publicURL
: item.colorIcon?.publicURL;
const alternateIcon = darkModeActive
? item.colorIcon?.publicURL
: item.whiteIcon?.publicURL;

if (primaryIcon && (await checkImageUrlValidity(primaryIcon))) {
return {
...item,
preferredIcon: primaryIcon,
};
}

const validItems = await Promise.all(promises);
// Filter out null values (items that are not valid)
const filteredValidComponents = validItems.filter(
(item) => item !== null
// 1. Fallback to the theme-aware integration icon
if (
fallbackIcon &&
fallbackIcon !== primaryIcon &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The integration-level icon is tried before the component's own other-theme icon. In dark mode, a component with a colorIcon but no whiteIcon now shows the generic integration logo instead of its own icon, so every card can look identical. Consider trying alternateIcon before fallbackIcon.

(await checkFallback())
) {
return {
...item,
preferredIcon: fallbackIcon,
};
}

// 2. Last resort: opposite-theme component icon
if (
alternateIcon &&
alternateIcon !== primaryIcon &&
alternateIcon !== fallbackIcon &&
(await checkImageUrlValidity(alternateIcon))
) {
return {
...item,
preferredIcon: alternateIcon,
};
}

return null;
}),
);

setValidComponents(filteredValidComponents);
if (mounted) {
setValidComponents(validItems.filter(Boolean));
}
};

loadIcons();
return () => {
mounted = false;
};
}, [frontmatter, darkModeActive, fallbackIcon]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a theme switch, the cards keep showing the previous theme's icons (for example, colour icons on the new black badge) until all new probes resolve. Cards removed by onError also briefly reappear. Consider resetting the state, or deriving the icon synchronously, when darkModeActive changes.


fetchData();
}, []);
const handleImageError = (nameToRemove) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each icon is validated twice: once by the checkImageUrlValidity probe, then again by the <img> and its onError removal path. Nothing renders until the slowest probe finishes. A single onError fallback chain (primary → alternate → integration icon → hide) would render immediately and remove the async effect, the mounted flag and the probe cache.

setValidComponents((prev) =>
prev.filter((item) => item.name !== nameToRemove),
);
};

return (
<ComponentsWrapper>
<section className="heading">
<h1>
{frontmatter.title} Components ({components.length})
{frontmatter?.title} Components ({validComponents.length})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validComponents starts as [] and is filled asynchronously, so the static/SSR HTML (what crawlers and no-JS users see) says Components (0). With JS, the count jumps after validation and drops again whenever an image fails to load. Consider keeping the count based on frontmatter.components.length, as the PR description says.

</h1>
</section>

<section className="componentsSection">
{validComponents.map((item) => (
<div key={item.id} className="maincontainer">
<div key={item.name} className="maincontainer">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using item.name as both the React key and the identifier in handleImageError breaks when names repeat or are missing. You get duplicate-key warnings, and one failing image removes every card with that name. Consider using the index, or a unique id, for both.

<div className="componentimg">
<img src={item.colorIcon.publicURL} alt={item.name} />
{item.preferredIcon && (
<img
src={item.preferredIcon}
alt={item.name || ""}
onError={(e) => {
e.currentTarget.onerror = null;
handleImageError(item.name);
}}
/>
)}
</div>
<p className="items">{item.name.replaceAll("-", " ")}</p>
{/* <div className="textcontent">
</div> */}
<p className="items">{item.name?.replaceAll("-", " ") || ""}</p>
</div>
))}
</section>
Expand Down
6 changes: 3 additions & 3 deletions src/sections/Resources/Resources-error/emptyStateTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const NoResources = ({ errorMessage,errorSubtitle }) => {
<ResourcePageWrapper>
<div className="no-resources-page">
<Container>
<Row className="empty-state-row">
<Col $xs={12} $lg={4}>
<Row>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also reverts the earlier mobile fix: it removes the empty-state-row class and changes $xs={12} to $sm={12}. Below the sm breakpoint, the columns no longer take full width, so the image and the text can squeeze side by side. Unrelated to #8146, so please drop it.

<Col $sm={12} $lg={4}>
<img src={serviceMesh} alt="service meshes" className="mesh" />
</Col>
<Col $xs={12} $lg={8}>
<Col $sm={12} $lg={8}>
<div className="error-text">
<h1 className="errorMessage"> {errorMessage} </h1>
<h3 className="errorSubtitle">{errorSubtitle}</h3>
Expand Down
68 changes: 3 additions & 65 deletions src/sections/Resources/Resources-grid/resourceGrid.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,90 +75,28 @@ export const ResourcePageWrapper = styled.div`
margin: 1rem;

box-shadow: 0px 3px 10px 1px rgba(0, 179, 159, 0.5);

.empty-state-row {
flex-wrap: wrap;
}

.errorMessage {
font-size: 2rem;
line-height: 2rem;
overflow-wrap: break-word;
word-break: break-word;
}
.error-text{
margin-top: 5rem;
overflow-wrap: break-word;
word-break: break-word;
}
.errorSubtitle {
font-weight: 400;
font-size: 1.5rem;
color: gray;
font-style: italic;
margin-top: 2.5rem;
overflow-wrap: break-word;
word-break: break-word;
}
img{
display: block;
margin:auto;
margin-top: 3.125rem;
width: 14rem;
max-width: 100%;
height: auto;
object-fit: contain;
}

@media only screen and (max-width: 992px) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR deletes the responsive empty-state styles (the max-width: 992px / 575px media queries, word-break/overflow-wrap, and the max-width: 100% img sizing). They're unrelated to integration icons and look like a revert carried in from a stale branch. Without them, the "no results" page loses its centered layout on tablets and phones, and long error messages overflow horizontally. Please restore them.

padding: 2rem 1.5rem 3rem;
text-align: center;

.empty-state-row {
justify-content: center;
}

img {
margin: 1rem auto 0;
width: 12rem;
max-width: 100%;
height: auto;
}

.error-text {
margin-top: 1.5rem;
text-align: center;
}

.errorMessage {
font-size: 1.5rem;
line-height: 1.3;
}

.errorSubtitle {
font-size: 1.15rem;
line-height: 1.4;
margin-top: 1rem;
}
}

@media only screen and (max-width: 575px) {
padding: 1.5rem 1rem 2.5rem;
margin: 0.5rem;

img {
width: 9rem;
max-width: 100%;
}

.errorMessage {
font-size: 1.25rem;
}

.errorSubtitle {
font-size: 1rem;
margin-top: 0.75rem;
@media only screen and (max-width:700px){
max-width: 100%;
}
}
}
}
`;
4 changes: 4 additions & 0 deletions src/templates/integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export const query = graphql`
extension
publicURL
}
darkModeIntegrationIcon {
extension
publicURL
}
docURL
category
components {
Expand Down
Loading