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

Website/refactor #267

Merged
merged 15 commits into from
Aug 5, 2024
Merged

Website/refactor #267

merged 15 commits into from
Aug 5, 2024

Conversation

tulsiojha
Copy link
Contributor

@tulsiojha tulsiojha commented Aug 5, 2024

Summary by Sourcery

Refactor the design system and contact form, enhance the footer layout, add a new FAQ section, and introduce a theme switcher component. Update dependencies and add sitemap configuration.

Enhancements:

  • Add new CSS utility classes for various styles including positioning, margin, padding, display, height, width, and animations.
  • Refactor the contact form to include country selection with country codes and improve form submission handling.
  • Update the footer component to include section titles and improve layout for different screen sizes.
  • Introduce a new FAQ section with collapsible items and dynamic content loading based on selected categories.
  • Add a theme switcher component for toggling between light, dark, and system themes.

Documentation:

  • Add detailed FAQ content for various categories including general questions, setup and configuration, feature capabilities, plans and pricing, AI & ML workflows, and troubleshooting and support.

Chores:

  • Update dependencies in pnpm-lock.yaml to the latest versions.
  • Remove unused logger import and related code from the production package setup script.
  • Add a sitemap configuration file for generating sitemaps and robots.txt.

Copy link

sourcery-ai bot commented Aug 5, 2024

Reviewer's Guide by Sourcery

This pull request refactors and enhances various components and utilities across the project. Key changes include the addition of new CSS classes, enhanced Select and Input components, a new FAQ section, country selection in the contact form, and a theme switcher. Additionally, new constants and utility functions were introduced to support these features.

File-Level Changes

Files Changes
src/apps/devdoc/app/components/page/contact-us.tsx
src/apps/devdoc/app/components/website/home/faq.tsx
src/apps/devdoc/app/components/footer.tsx
src/apps/devdoc/app/components/theme-switcher.tsx
Refactored and enhanced components to include new features such as country selection, FAQ section, and theme switching.
src/design-system/components/css/index.scss
src/design-system/components/atoms/select.tsx
src/design-system/components/atoms/input.tsx
src/design-system/index.css
Updated design system components and styles to include new CSS classes, enhanced Select and Input components, and imported new styles.
src/apps/devdoc/app/utils/const.tsx
src/apps/devdoc/app/utils/commons.tsx
src/apps/devdoc/app/utils/config.tsx
Added new constants, utility functions, and updated configuration to support new features and components.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @tulsiojha - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider splitting this large PR into smaller, more focused ones to improve reviewability and reduce the risk of introducing bugs.
  • Remove commented-out code, such as the logger import in prod-package.js, or reinstate it if it's still needed.
Here's what I looked at during the review
  • 🟡 General issues: 5 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟡 Documentation: 2 issues found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -412,6 +412,649 @@
border-style: none;
}

.zener-select,.zener-select *{
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Consider optimizing the large CSS addition

The addition of numerous CSS classes for the zener-select component could potentially lead to CSS bloat. Consider using CSS optimization techniques or exploring CSS-in-JS solutions for better tree-shaking of unused styles.

Suggested change
.zener-select,.zener-select *{
.zener-select {
&, & * {
scroll-behavior: unset !important;
}
}

</Block>
);
};

const ContactRoot = () => {
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider breaking down the ContactRoot component

The ContactRoot component has grown quite complex with the addition of country selection, phone code handling, and the FAQ section. Consider breaking it down into smaller, more focused components for better maintainability and potential reusability.

const ContactForm = () => {
  // ... form-related logic and JSX
};

const FAQSection = () => {
  // ... FAQ-related logic and JSX
};

const ContactRoot = () => {
  return (
    <>
      <ContactForm />
      <FAQSection />
    </>
  );
};


const items = Object.entries(consts.helpandsupport.kloudliteOverviewFaqs);

useEffect(() => {
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Optimize useEffect for auto-sizing

The use of useEffect for auto-sizing could potentially lead to unnecessary re-renders. Consider implementing debouncing or memoization techniques to optimize this operation and improve performance.

import { useCallback, useEffect } from 'react';
import debounce from 'lodash/debounce';

// ... other imports and code

const debouncedAutoSize = useCallback(
  debounce(() => {
    // Auto-sizing logic here
  }, 250),
  []
);

useEffect(() => {
  debouncedAutoSize();
  window.addEventListener('resize', debouncedAutoSize);
  return () => window.removeEventListener('resize', debouncedAutoSize);
}, [debouncedAutoSize]);

import OptionList from 'kl-design-system/atoms/option-list';
import { GraphExtended, GraphItem } from '../graph';
import * as Accordion from '@radix-ui/react-accordion';
import consts from '~/app/utils/const';
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Consider dynamic loading for FAQ data

If the FAQ data in the constants file is expected to grow significantly, consider implementing dynamic loading of this data to improve initial load times and overall application performance.

import { lazy } from 'react';

const consts = lazy(() => import('~/app/utils/const'));

@@ -0,0 +1,1930 @@
[
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Consider optimizing the file size and structure for better performance

The file size is quite large, which could impact load times and performance. Consider splitting the data into smaller files, implementing lazy loading, or removing redundant information that can be generated programmatically (e.g., 'image' and possibly 'unicode' fields).

import { lazy } from 'react';

const CountryData = lazy(() => import('./CountryData'));

export const getCountries = () => {
  return <CountryData />;
};

@@ -589,6 +597,107 @@ const consts = {
},
],
},
helpandsupport: {
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider refactoring to a more modular approach to reduce complexity and improve maintainability.

The new code is more complex due to the increased number of imports, deeply nested structure, and redundancy. This makes it harder to read, navigate, and maintain. Consider refactoring to a more modular approach to reduce complexity and improve maintainability. For example:

  1. Define teamMembers and faqSections arrays separately.
  2. Use faqSections to dynamically build the helpandsupport object.

This will make the code more readable and easier to manage. Here's a simplified version:

const teamMembers = [
  {
    name: 'Harsh Malviya',
    role: 'Jr product designer',
    image: profileHarsh.src,
    imageClassName: '!wb-object-contain',
    linkedin: 'harsh-malviya-a232011a0',
    x: 'lucnerf_harsh',
    github: 'malviyaharsh',
  },
];

const faqSections = [
  {
    key: 'general',
    label: 'General Questions',
    icon: Question,
    items: [
      {
        title: 'What is Kloudlite?',
        desc: 'Kloudlite is a platform that provides seamless and secure development environments for building distributed applications. It connects developer’s workspaces(local/remote) with remote Kubernetes environments using WireGuard, ensuring full development and production parity.',
      },
      {
        title: 'How does Kloudlite help developers?',
        desc: 'Kloudlite enhances productivity by enabling developers to work in environments that mirror production settings. It provides unified network interface eliminating the need for local setups. It supports collaborative coding and service interception for testing and debugging.',
      },
      {
        title: 'Who can benefit from using Kloudlite?',
        desc: 'Kloudlite is ideal for developers building distributed applications, teams needing consistent development environments, and organizations looking to streamline their development workflows and improve productivity.',
      },
    ],
  },
  {
    key: 'setupConfiguration',
    label: 'Setup & Configuration',
    icon: Config,
    items: [
      {
        title: 'How do I setup Kloudlite?',
        desc: 'Setting up Kloudlite involves creating a cluster reference on the Kloudlite dashboard, attaching your cluster, and configuring local development containers to connect to the environment. you can follow these instructions https://kloudlite.io/docs/getting-started.',
      },
      {
        title: 'What are the requirements for using Kloudlite?',
        desc: 'You need a Kubernetes cluster to run environments and local container runtime to run your workspace. Detailed setup instructions are provided in our documentation (https://kloudlite.io/docs/getting-started).',
      },
      {
        title: 'Does Kloudlite provide us compute?',
        desc: "No, Kloudlite doesn't yet provide compute.",
      },
      {
        title: 'Does Kloudlite manage Kubernetes clusters?',
        desc: 'No, Kloudlite does not manage Kubernetes clusters. It runs environments within the clusters connected through WireGuard.',
      },
    ],
  },
  // Add other sections similarly...
];

const consts = {
  team: {
    members: teamMembers,
  },
  helpandsupport: faqSections.reduce((acc, section) => {
    acc[section.key] = section;
    return acc;
  }, {}),
};

export default consts;

This approach reduces redundancy and makes the code easier to maintain.

Comment on lines +158 to +159
if (ref.current?.parentElement)
autoSize(ref.current?.parentElement, 'animationend');
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (ref.current?.parentElement)
autoSize(ref.current?.parentElement, 'animationend');
if (ref.current?.parentElement) {
autoSize(ref.current?.parentElement, 'animationend');
}


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

Comment on lines +18 to +19
if (ref.current?.parentElement)
autoSize(ref.current?.parentElement, 'animationend');
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (ref.current?.parentElement)
autoSize(ref.current?.parentElement, 'animationend');
if (ref.current?.parentElement) {
autoSize(ref.current?.parentElement, 'animationend');
}


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).


export const autoSize = (element: HTMLElement, event: string) => {
const action = () => {
if (!element) return;
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (!element) return;
if (!element) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

(element?.getBoundingClientRect().height || 0) -
parseInt(element?.style.paddingBottom || '0px', 10);
const padding = 32 - (parentHeight % 32);
if (padding !== 32) element.style.paddingBottom = `${padding}px`;
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (padding !== 32) element.style.paddingBottom = `${padding}px`;
if (padding !== 32) {


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

@tulsiojha tulsiojha merged commit ae36aa8 into release-v1.0.5 Aug 5, 2024
5 checks passed
@tulsiojha tulsiojha deleted the website/refactor branch August 5, 2024 05:36
abdheshnayak pushed a commit that referenced this pull request Oct 28, 2024
tulsiojha added a commit that referenced this pull request Nov 1, 2024
abdheshnayak pushed a commit that referenced this pull request Nov 5, 2024
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.

1 participant