Skip to content

Conversation

@scopsy
Copy link
Contributor

@scopsy scopsy commented May 12, 2025

What changed? Why was the change needed?

Introduce a new icons key in the appereance prop:

const appereance = {
  icons: {
     cogs: () => '⚙️'
  }
};

Icon keys are discovarable via the 🖼️ emoji on the class.

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

@linear
Copy link

linear bot commented May 12, 2025

@netlify
Copy link

netlify bot commented May 12, 2025

Deploy Preview for dashboard-v2-novu-staging canceled.

Name Link
🔨 Latest commit 924d20f
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/6824aeec236c500008503552

@scopsy scopsy changed the title feat(inbox): override icon set for inbox component feat(js): override icon set for inbox component May 12, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented May 14, 2025

Open in StackBlitz

@novu/js

npm i https://pkg.pr.new/novuhq/novu/@novu/js@8293

@novu/nextjs

npm i https://pkg.pr.new/novuhq/novu/@novu/nextjs@8293

novu

npm i https://pkg.pr.new/novuhq/novu@8293

@novu/react

npm i https://pkg.pr.new/novuhq/novu/@novu/react@8293

@novu/react-native

npm i https://pkg.pr.new/novuhq/novu/@novu/react-native@8293

commit: 924d20f

Comment on lines 6 to 33
type IconRendererWrapperProps = {
iconKey: IconKey;
fallback: JSX.Element;
class?: string;
};

export const IconRendererWrapper = (props: IconRendererWrapperProps) => {
let el: HTMLDivElement | undefined;
let cleanup: (() => void) | undefined;
const appearance = useAppearance();
const customRenderer = () => appearance.icons()?.[props.iconKey];

onMount(() => {
if (el && customRenderer()) {
cleanup = (customRenderer() as IconRenderer)(el, { class: props.class });
}
});

onCleanup(() => {
cleanup?.();
});

return (
<Show when={customRenderer()} fallback={props.fallback}>
{/* Render the placeholder div. The user's renderer will populate it. */}
<span ref={el} />
</Show>
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LetItRock this is the rendering wrapper utility function for icons

Comment on lines +20 to +24
{
iconKey,
}: {
iconKey?: IconKey;
} = {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added options object, with an optional iconKey param

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was duplicated with clock

};
}

export function adaptAppearanceForJs(appearance?: ReactAppearance): JsAppearance | undefined {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function remaps the jsx syntx to novu/js


if (hasAppearanceKey) {
return; // Skip reporting if appearanceKey is present, as it is most likely forwarded.
if (!node.name || node.name.name !== 'class') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed the linter to allow using variables with style

Copy link
Contributor

@LetItRock LetItRock left a comment

Choose a reason for hiding this comment

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

💎

@scopsy scopsy merged commit 7d9c1f9 into next May 14, 2025
28 checks passed
@scopsy scopsy deleted the nv-5822-override-icon-set-for-inbox branch May 14, 2025 15:37
bricehemery pushed a commit to jack-agency/novu that referenced this pull request Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants