Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: heavy iteration on render #40

Merged
merged 2 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Empty file modified .env.production
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions src/components/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Carousel: React.FC<CarouselProps> = (props) => {
for (let i = 0; i < totalItems; i += 1) {
retval.push(
<div
key={i}
className={`w-7 h-full rounded-sm ${
currentIndex === i ? 'bg-white' : 'bg-slate-400'
} opacity-75`}
Expand Down
10 changes: 8 additions & 2 deletions src/layout/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ const BaseLayout: React.FC<BaseProps> = (props) => {
fontSize={{ lg: 'xl', md: 'md' }}
>
{links.map((link) => (
<Navbar key={`navlink${links.indexOf(link)}`} to={link.to}>
<Navbar
key={`navlink${links.indexOf(link)}`}
to={link.to}
>
{link.name}
</Navbar>
))}
Expand All @@ -144,7 +147,10 @@ const BaseLayout: React.FC<BaseProps> = (props) => {
>
<Stack as="nav" spacing={4}>
{links.map((link) => (
<Navbar key={`navlink${links.indexOf(link)}`} to={link.to}>
<Navbar
key={`navlink${links.indexOf(link)}`}
to={link.to}
>
<Flex alignItems="center" gap="2">
{link.icon}
<span>{link.name}</span>
Expand Down
7 changes: 6 additions & 1 deletion src/pages/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ const About: React.FC<{}> = () => {
alt=""
/>
{aboutContents.map((content: string) => (
<p key={`aboutcontent${aboutContents.indexOf(content)}`} className="text-h6 md:text-[40px] lg:text-h3">
<p
key={`aboutcontent${aboutContents.indexOf(
content
)}`}
className="text-h6 md:text-[40px] lg:text-h3"
>
{content}
</p>
))}
Expand Down
10 changes: 7 additions & 3 deletions src/pages/About/AboutDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ const AboutDetail: React.FC<AboutProps> = ({ toggle }) => {
alt=""
/>
{aboutDetailContents.map((content: string) => (
<div key={`aboutdetailcontent${aboutDetailContents.indexOf(content)}`}>
<div
key={`aboutdetailcontent${aboutDetailContents.indexOf(
content
)}`}
>
<p>{content}</p>
<br/>
<br />
</div>
))}
<button
<button
type="button"
onClick={toggle}
className="bg-MediumOrange text-white px-4 py-3 mt-8 rounded-[15px] drop-shadow-lg hover:drop-shadow-xl"
Expand Down
16 changes: 8 additions & 8 deletions src/pages/Detailpage/Render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ const Render = {
),
OL: (id: number, node: NodeExtended) => {
const listItems: JSX.Element[] = [];
for (const innerNode of node.childNodes) {
node.childNodes.forEach((innerNode) => {
listItems.push(<li>{innerNode.text}</li>);
}
});
return (
<div
key={id}
Expand All @@ -79,9 +79,9 @@ const Render = {
},
UL: (id: number, node: NodeExtended) => {
const listItems: JSX.Element[] = [];
for (const innerNode of node.childNodes) {
node.childNodes.forEach((innerNode) => {
listItems.push(<li>{innerNode.text}</li>);
}
});
return (
<div
key={id}
Expand Down Expand Up @@ -262,13 +262,13 @@ const Render = {
}
if (node.attrs.class.includes('kg-gallery-card')) {
const srcItems: string[] = [];
for (const innerNode of node.childNodes[0].childNodes) {
for (const extraInnerNode of innerNode.childNodes) {
node.childNodes[0].childNodes.forEach((innerNode) => {
innerNode.childNodes.forEach((extraInnerNode) => {
srcItems.push(
formatUrl(extraInnerNode.childNodes[0].attrs.src)
);
}
}
});
});
return <Carousel key={id} items={srcItems} />;
}
return null;
Expand Down
14 changes: 12 additions & 2 deletions src/pages/Homepage/Homepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ const Homepage: React.FC<{}> = () => {
</h2>
<div className="grid justify-items-center gap-4 p-2 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{sponsorMD.map((image: imgPartner) => (
<a href={image.link} key={`sponsorimg${sponsorMD.indexOf(image)}`}>
<a
href={image.link}
key={`sponsorimg${sponsorMD.indexOf(
image
)}`}
>
<img
alt={image.title}
src={image.imageUrl}
Expand All @@ -89,7 +94,12 @@ const Homepage: React.FC<{}> = () => {
</h2>
<div className="grid justify-items-center gap-4 p-2 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{listOfMedpar.map((image: imgPartner) => (
<a href={image.link} key={`medparimg${listOfMedpar.indexOf(image)}`}>
<a
href={image.link}
key={`medparimg${listOfMedpar.indexOf(
image
)}`}
>
<img
alt={image.title}
src={image.imageUrl}
Expand Down
14 changes: 12 additions & 2 deletions src/pages/Partnerpage/PartnerPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ const PartnerPage: React.FC<{}> = () => (
<div className="min-h-[200px] py-8 p-4 bg-LightBrown flex justify-center items-center rounded-md ">
<div className="image flex flex-wrap place-content-center gap-3">
{sponsorLG.map((image: imgPartner) => (
<a href={image.link} key={`sponsorimg${sponsorLG.indexOf(image)}`}>
<a
href={image.link}
key={`sponsorimg${sponsorLG.indexOf(
image
)}`}
>
<img
alt={image.title}
src={image.imageUrl}
Expand All @@ -168,7 +173,12 @@ const PartnerPage: React.FC<{}> = () => (
<div className="min-h-[200px] py-8 p-4 bg-LightBrown flex justify-center items-center rounded-md">
<div className="image flex flex-wrap place-content-center gap-3">
{listOfMedpar.map((image: imgPartner) => (
<a href={image.link} key={`medparimg${listOfMedpar.indexOf(image)}`}>
<a
href={image.link}
key={`medparimg${listOfMedpar.indexOf(
image
)}`}
>
<img
alt={image.title}
src={image.imageUrl}
Expand Down