Skip to content

Commit

Permalink
Update review
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Jul 31, 2024
1 parent 7cef1cc commit 814637a
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 13 deletions.
18 changes: 11 additions & 7 deletions apps/pesayetu/src/components/HURUmap/Chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,17 @@ function Chart({
);
setCSpec(spec);
if (chartRef?.current) {
const newView = await embed(chartRef.current, spec, {
renderer: "canvas",
actions: false,
tooltip: handler,
});

setView(newView.view);
try {
const newView = await embed(chartRef.current, spec, {
renderer: "canvas",
actions: false,
tooltip: handler,
});

setView(newView.view);
} catch (error) {
console.error(error);
}
}
}
renderChart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ function Download({
const [layout, setLayout] = useState(0);

useEffect(() => {
const viewProp = new vega.View(vega.parse(spec), { renderer: "none" });
setView(viewProp);
try {
const viewProp = new vega.View(vega.parse(spec), { renderer: "none" });
setView(viewProp);
} catch (error) {
console.error("Error creating view", error);
}
}, [spec]);

const setImageLayout = async (e, type) => {
Expand Down
34 changes: 34 additions & 0 deletions packages/hurumap-core/src/Action/Action.snap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Action renders unchanged 1`] = `
<div>
<div
class="MuiBox-root css-0"
>
<button
aria-label="Action"
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeLarge css-16rd89w-MuiButtonBase-root-MuiIconButton-root"
data-mui-internal-clone-element="true"
tabindex="0"
type="button"
>
<svg
height="100"
width="100"
>
<circle
cx="50"
cy="50"
fill="red"
r="40"
stroke="black"
stroke-width="3"
/>
</svg>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
`;
30 changes: 30 additions & 0 deletions packages/hurumap-core/src/Action/Action.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { render } from "@commons-ui/testing-library";
import React from "react";

import Action from "./Action";

const defaultProps = {
id: "1",
title: "Action",
icon: (
<svg width="100" height="100">
<circle
cx="50"
cy="50"
r="40"
stroke="black"
strokeWidth="3"
fill="red"
/>
</svg>
),
header: "Header",
children: <div>Children</div>,
};

describe("Action", () => {
it("renders unchanged", () => {
const { container } = render(<Action {...defaultProps} />);
expect(container).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion packages/hurumap-core/src/Share/Share.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const Share = React.forwardRef(function Share(

return (
<Grid container {...props} ref={ref}>
{shareData.map((social) => (
{shareData?.map((social) => (
<Grid item xs={4} key={social.name}>
<ShareButton
name={social.name}
Expand Down
10 changes: 7 additions & 3 deletions packages/hurumap-core/src/ShareButton/ShareButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ const componentMap = {
};

const ShareButton = React.forwardRef(function ShareButton(
{ ButtonProps, IconProps, icon, name, url, onCopy, ...props },
{ ButtonProps, IconProps, component, icon, name, url, onCopy, ...props },
ref,
) {
const SocialButtonComponent = componentMap[name];
let SocialButtonComponent = component;

if (!SocialButtonComponent && name !== "CopyUrl") {
if (name && name !== "CopyUrl") {
SocialButtonComponent = componentMap[name];
}

if (!SocialButtonComponent) {
return null;
}

Expand Down

0 comments on commit 814637a

Please sign in to comment.