Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Support preact (#74)
Browse files Browse the repository at this point in the history
* when 'render' is called manually, Preact expects that it always has props. We need to supply an empty argument for compatibility.

* Preact can't use plain objects as components, so we need to use the output of forwardRef and set the 87204iris property on it manually

* ensure children ref exists for accessing properties on it
  • Loading branch information
jdreetz authored Jan 25, 2022
1 parent 4b028a3 commit 4bb4fcd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/components/buttons/Social/SocialButton.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const brandThemes = {
google: {
...themes.light,
name: 'Google',
icon: (GoogleGColor as any).render(),
icon: (GoogleGColor as any).render({}),
formats: {
...themes.light.formats,
primary: '#4285f4',
Expand All @@ -38,7 +38,7 @@ export const brandThemes = {
facebook: {
...themes.light,
name: 'Facebook',
icon: (Facebook as any).render(),
icon: (Facebook as any).render({}),
formats: {
...themes.light.formats,
primary: '#4267b2',
Expand All @@ -58,7 +58,7 @@ export const brandThemes = {
light: {
...themes.dark,
name: 'Apple',
icon: (Apple as any).render(),
icon: (Apple as any).render({}),
formats: {
...themes.dark.formats,
primary: '#000',
Expand All @@ -68,7 +68,7 @@ export const brandThemes = {
dark: {
...themes.light,
name: 'Apple',
icon: (Apple as any).render(),
icon: (Apple as any).render({}),
formats: {
...themes.dark.formats,
primary: '#FFF',
Expand Down
13 changes: 7 additions & 6 deletions src/utils/HOCs/withIris.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ export function withIris<
const component = name?.replace('Component', '');
const dev = { path, debug };

const RefComponentWithIris = {
$$iris: { version, component, dev },
...forwardRef<DOMElement, Props>((props: any, ref) => {
const RefComponentWithIris = forwardRef<DOMElement, Props>(
(props: any, ref) => {
useEffect(() => {
if (debug || (props && props.debug)) {
if (ref) console.log({ Component, ref });
Expand All @@ -86,8 +85,10 @@ export function withIris<
forwardRef: ref,
...props,
});
}),
};
}
);

RefComponentWithIris['$$iris'] = { version, component, dev };

return RefComponentWithIris as unknown as IrisComponent<
DOMElement,
Expand All @@ -111,7 +112,7 @@ const soPretty = `
padding: 0.25rem 1.25rem 0.3rem 0.5rem;
color: white;
text-shadow:
-1px -1px 0 rgba(0,0,0,0.334),
-1px -1px 0 rgba(0,0,0,0.334),
1px -1px 0 rgba(0,0,0,0.334),
-1px 2px 5px rgba(0,0,0,0.334),
1px 2px 5px rgba(0,0,0,0.334);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/hooks/usePortal_DEPRECATED/Anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function Anchor({
}

function useChildZIndex(children) {
if (children.ref.current) {
if (children?.ref?.current) {
const style = getComputedStyle(children.ref.current);
const zIndex = parseInt(style.zIndex);

Expand Down

0 comments on commit 4bb4fcd

Please sign in to comment.