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

feat: implement redesign of the home page #3600

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions components/CodeAnimation/AsyncAPIcontent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @description Renders the content related to AsyncAPI in a styled div container.
* This is used as the default content for the "AsyncAPI Document" tab in the DemoAnimation component.
*/
export default function renderAsyncAPIContent() {
return <div className='font-mono text-sm leading-relaxed text-[#98c379]'>content here</div>;
}
11 changes: 11 additions & 0 deletions components/CodeAnimation/CodeGeneration.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @description Renders the content related to code generation in a styled div container.
* This is used as the content for the "Code Generation" tab in the DemoAnimation component.
*/
export default function renderCodeGeneration() {
return (
<div className='font-mono text-sm leading-relaxed'>
<h1 className='text-[#98c379]'>content here</h1>
</div>
);
}
70 changes: 70 additions & 0 deletions components/CodeAnimation/DemoAnimation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React, { useState } from 'react';

import Container from '../layout/Container';
import renderAsyncAPIContent from './AsyncAPIcontent';
import renderCodeGeneration from './CodeGeneration';
import renderDocumentation from './Documentation';

/**
* @description A React component that displays a demo animation interface with three tabs:
* "AsyncAPI Document," "Code Generation," and "Documentation." The content of each tab
* dynamically updates based on the active tab selected by the user.
*
*/
export default function DemoAnimation() {
const [activeTab, setActiveTab] = useState('AsyncAPI Document');
const tabs = ['AsyncAPI Document', 'Code Generation', 'Documentation'];

/**
* @description Determines and renders the content for the currently active tab.
*/
const renderContent = () => {
switch (activeTab) {
case 'Code Generation':
return renderCodeGeneration() || <p>No content available</p>;
case 'Documentation':
return renderDocumentation() || <p>No content available</p>;
default:
return renderAsyncAPIContent() || <p>No content available</p>;
}
};
Comment on lines +21 to +30
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error boundaries for render functions.

The render functions should be wrapped in error boundaries to gracefully handle rendering failures.

   const renderContent = () => {
+    try {
       switch (activeTab) {
         case 'Code Generation':
           return renderCodeGeneration() || <p>No content available</p>;
         case 'Documentation':
           return renderDocumentation() || <p>No content available</p>;
         default:
           return renderAsyncAPIContent() || <p>No content available</p>;
       }
+    } catch (error) {
+      console.error('Failed to render tab content:', error);
+      return <p>Failed to load content</p>;
+    }
   };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const renderContent = () => {
switch (activeTab) {
case 'Code Generation':
return renderCodeGeneration() || <p>No content available</p>;
case 'Documentation':
return renderDocumentation() || <p>No content available</p>;
default:
return renderAsyncAPIContent() || <p>No content available</p>;
}
};
const renderContent = () => {
try {
switch (activeTab) {
case 'Code Generation':
return renderCodeGeneration() || <p>No content available</p>;
case 'Documentation':
return renderDocumentation() || <p>No content available</p>;
default:
return renderAsyncAPIContent() || <p>No content available</p>;
}
} catch (error) {
console.error('Failed to render tab content:', error);
return <p>Failed to load content</p>;
}
};


return (
<div className='relative inset-x-1/2 mx-[-50vw] w-screen bg-blue-100 p-6 font-sans'>
<Container>
<h1 className='mb-2 text-center text-2xl font-medium'>Sneak Peek Into The Real Process</h1>
<p className='mb-6 text-center text-sm text-gray-600'>
One of our main goals is to improve the current state of Event
<br />
Driven Architecture (EDA!)
</p>

<div className='mb-4 flex flex-wrap overflow-hidden rounded-lg bg-black'>
{tabs.map((tab) => (
<button
key={tab}
className={`m-2 flex-1 rounded px-4 py-2 text-center text-sm transition-colors duration-200 ${
activeTab === tab ? 'bg-white text-black' : 'bg-gray-700 text-gray-300 hover:bg-gray-800'
}`}
onClick={() => setActiveTab(tab)}
aria-selected={activeTab === tab}
role='tab'
>
{tab}
</button>
))}
</div>

<div
className='min-h-[400px] rounded-lg bg-[#1a1b26] p-6 transition-all duration-200'
role='tabpanel'
aria-labelledby={`tab-${activeTab}`}
>
<div className='max-w-full overflow-auto'>
<div className='overflow-x-auto whitespace-pre-wrap'>{renderContent()}</div>
</div>
</div>
</Container>
</div>
);
}
11 changes: 11 additions & 0 deletions components/CodeAnimation/Documentation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @description Renders the documentation content in a styled container.
* This is used as the content for the "Documentation" tab in the DemoAnimation component.
*/
export default function renderDocumentation() {
return (
<div className='font-sans text-white'>
<h1 className='mb-4 text-xl font-semibold'>Documentation</h1>
</div>
);
}
Loading
Loading