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 #222

Merged
merged 52 commits into from
Jun 12, 2024
Merged

Website/refactor #222

merged 52 commits into from
Jun 12, 2024

Conversation

tulsiojha
Copy link
Contributor

@tulsiojha tulsiojha commented Jun 12, 2024

Design system and Website related change

Summary by Sourcery

This pull request refactors the design system and website by introducing a comprehensive set of CSS variables for color theming, adding new stylesheets, and updating the layout and styles of various components. It also includes new documentation sections and a new page for 'Local Development Environments'.

  • New Features:
    • Introduced a comprehensive set of CSS variables for color theming, including support for dark mode.
    • Added new CSS classes for various UI elements and states, such as buttons, text, and borders.
    • Integrated new stylesheets into the devdoc application, including primitives, default, and dark themes.
    • Added a new documentation page for 'Local Development Environments'.
  • Enhancements:
    • Refactored existing CSS to use the new CSS variables for consistent theming.
    • Updated the layout and styles of various components in the devdoc application for better visual consistency.
    • Improved the sidebar transition effect for better user experience on smaller screens.
  • Documentation:
    • Updated the documentation metadata to include new sections like 'Introduction', 'Features', and 'Engage'.
  • Chores:
    • Added a new port configuration for the 'community' service in the Taskfile.yaml.

Copy link

sourcery-ai bot commented Jun 12, 2024

Reviewer's Guide by Sourcery

This pull request refactors the design system and website-related styles. The changes primarily involve the introduction of a new color system using CSS variables, updates to various CSS classes, and the addition of new styles for dark mode. Additionally, there are updates to the documentation structure and some JavaScript code changes.

File-Level Changes

Files Changes
src/design-system/components/css/index.scss
src/apps/devdoc/style.css
Refactored and updated styles to use new CSS variables and added dark mode support.
src/apps/devdoc/pages/docs/_meta.json
src/apps/devdoc/pages/docs/local-devices.mdx
Updated documentation structure and added new content.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • 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.

@tulsiojha tulsiojha merged commit bf915e5 into release-v1.0.5 Jun 12, 2024
3 checks passed
@tulsiojha tulsiojha deleted the website/refactor branch June 12, 2024 13:47
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 and found some issues that need to be addressed.

Blocking issues:

  • Potential hard-coded URL found. (link)
  • Hard-coded URL found. (link)
Here's what I looked at during the review
  • 🟡 General issues: 21 issues found
  • 🔴 Security: 2 blocking issues, 1 other issue
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 6 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.

@@ -2,50 +2,308 @@

/* @import url('https://fonts.googleapis.com/css2?family=Familjen+Grotesk:ital,wght@0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap'); */

.range-slide-base{
:root {
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider organizing CSS variables by category.

To improve readability and maintainability, consider grouping related CSS variables together and adding comments to separate different categories (e.g., colors, typography, spacing).

Suggested change
:root {
:root {
/* Color Variables */
--shiki-color-text: oklch(37.53% 0 0);
--shiki-color-background: transparent;
}

"devops":{
"title":"DevOps",
"type":"page"
"--introduction--":{
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider using a consistent naming convention for separators.

Using a consistent naming convention for separators (e.g., --section--) can make the JSON structure more intuitive and easier to understand.

Suggested change
"--introduction--":{
"--section-introduction--":{

@@ -1,5 +1,7 @@
import { UndoRedo, DiffSourceToggleWrapper } from '@mdxeditor/editor';
import '@mdxeditor/editor/style.css';
import axios from 'axios';
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider handling axios errors more gracefully.

Instead of logging errors to the console, consider displaying a user-friendly error message or retrying the request.

Comment on lines -339 to 346
desc: 'Remote local environments blend local and remote development, allowing developers to work as if locally but on cloud-based infrastructure. This setup enables seamless access, consistent environments, collaboration across locations, resource efficiency, and scalable resources. It merges the convenience of local development with the power and flexibility of remote capabilities to enhance productivity.',
classNames: 'wb-pb-lg 3xl:wb-pb-md',
desc: "Kloudlite Remote Local environments refer to a hybrid development setup where remote Kubernetes-based environments are seamlessly integrated with local development containers. These local containers run on the developer's machine and are connected to the remote environments via a secure WireGuard network, enabling access to remote services as if they were local. This setup ensures development-production parity by synchronizing configurations and secrets, allowing developers to use their local IDEs for coding while maintaining a consistent and secure environment.",
classNames: 'wb-pb-2xl 3xl:wb-pb-xl',
},
{
title: 'How does Kloudlite Development Environments work?',
desc: 'Kloudlite establishes a WireGuard VPN mesh that connects all infrastructure running workloads with developer devices. With this network connection in place, developers can access environments directly from their local machines. They have the capability to clone environments, switch between them, and collaborate seamlessly without the need to worry about building and deploying applications.',
desc: `Kloudlite Development Environments work by linking your local machine to remote environment
where your applications run. Configs and Secrets are kept in sync between your local machine and the remote environment.
Local containers will be in the same wireguard network as remote environment.
These connect through a secure network, allowing you to access and work with all necessary services without installing them locally.
This setup enables developers to work efficiently, ensuring that what they build on their computers will function the same way when
deployed on the remote servers.`,
classNames: 'wb-pb-lg 3xl:wb-pb-md',
},
Copy link

Choose a reason for hiding this comment

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

suggestion: Update description for remote local environments

The description for remote local environments has been updated to provide more detailed information about the setup and benefits. This change improves clarity and helps users understand the functionality better.

Suggested change
desc: 'Remote local environments blend local and remote development, allowing developers to work as if locally but on cloud-based infrastructure. This setup enables seamless access, consistent environments, collaboration across locations, resource efficiency, and scalable resources. It merges the convenience of local development with the power and flexibility of remote capabilities to enhance productivity.',
classNames: 'wb-pb-lg 3xl:wb-pb-md',
desc: "Kloudlite Remote Local environments refer to a hybrid development setup where remote Kubernetes-based environments are seamlessly integrated with local development containers. These local containers run on the developer's machine and are connected to the remote environments via a secure WireGuard network, enabling access to remote services as if they were local. This setup ensures development-production parity by synchronizing configurations and secrets, allowing developers to use their local IDEs for coding while maintaining a consistent and secure environment.",
classNames: 'wb-pb-2xl 3xl:wb-pb-xl',
},
{
title: 'How does Kloudlite Development Environments work?',
desc: 'Kloudlite establishes a WireGuard VPN mesh that connects all infrastructure running workloads with developer devices. With this network connection in place, developers can access environments directly from their local machines. They have the capability to clone environments, switch between them, and collaborate seamlessly without the need to worry about building and deploying applications.',
desc: `Kloudlite Development Environments work by linking your local machine to remote environment
where your applications run. Configs and Secrets are kept in sync between your local machine and the remote environment.
Local containers will be in the same wireguard network as remote environment.
These connect through a secure network, allowing you to access and work with all necessary services without installing them locally.
This setup enables developers to work efficiently, ensuring that what they build on their computers will function the same way when
deployed on the remote servers.`,
classNames: 'wb-pb-lg 3xl:wb-pb-md',
},
desc: "Kloudlite Remote Local environments are a hybrid setup where local development containers on a developer's machine are integrated with remote Kubernetes environments via a secure WireGuard network. This allows access to remote services as if they were local, ensuring development-production parity by synchronizing configurations and secrets. Developers can use their local IDEs while maintaining a consistent and secure environment.",

};

const AvatarItem = ({ gravatarHash }: { gravatarHash?: string }) => {
Copy link

Choose a reason for hiding this comment

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

suggestion: Add AvatarItem component

The AvatarItem component has been added to display user avatars based on gravatar hashes. This is a useful addition for enhancing user profiles.

Suggested change
const AvatarItem = ({ gravatarHash }: { gravatarHash?: string }) => {
const AvatarItem = ({ gravatarHash = '' }: { gravatarHash?: string }) => {

@@ -11,14 +11,13 @@ function scrollbar() {
'@apply wb-bg-transparent': {},
},
'&::-webkit-scrollbar-thumb': {
'@apply wb-bg-black dark:wb-bg-black wb-rounded wb-cursor-pointer':
{},
'@apply wb-bg-surface-basic-hovered wb-rounded wb-cursor-pointer': {},
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 reverting to the original class names to maintain simplicity and consistency.

The new code introduces more specific class names (wb-bg-surface-basic-hovered and wb-bg-surface-basic-pressed), which increases complexity and reduces readability. The previous class names (wb-bg-black and wb-bg-surface-primary-default) were more consistent and easier to understand. Consider reverting to the original class names to maintain simplicity and consistency. If the new class names are necessary, please document the changes and their purpose to aid future developers.

'border-border-default dark:border-border-darktheme-default bg-surface-basic-default dark:bg-surface-darktheme-basic-default text-text-default dark:text-text-darktheme-default':
type === 'neutral',
'border-border-primary dark:border-border-darktheme-primary bg-surface-primary-subdued dark:bg-surface-darktheme-primary-subdued text-text-primary dark:text-text-darktheme-primary':
'border-border-default bg-surface-basic-default': type === 'neutral',
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 using a typeClasses object to map the type to the corresponding class names while retaining dark theme support.

The new code is more complex and less functional for a few reasons:

  1. Loss of Dark Theme Support: The removal of dark theme classes means the component no longer supports dark mode, which can negatively impact user experience for those who prefer or require it.

  2. Readability: The new code is less readable due to the removal of the clear separation of styles for different themes. This makes it harder to understand at a glance what styles are applied under different conditions.

  3. Maintainability: Removing the dark theme classes makes future changes to reintroduce or modify dark theme support more difficult. The original code was more maintainable with its clear definition of styles for both light and dark themes.

Consider using a typeClasses object to map the type to the corresponding class names while retaining dark theme support. This approach improves readability and maintainability:

const Badge = ({
  type = 'neutral',
  children,
  icon,
  className,
}: IBadge) => {
  const iconProps = { size: 12, color: 'currentColor' };

  const typeClasses = {
    neutral: 'border-border-default dark:border-border-darktheme-default bg-surface-basic-default dark:bg-surface-darktheme-basic-default text-text-default dark:text-text-darktheme-default',
    info: 'border-border-primary dark:border-border-darktheme-primary bg-surface-primary-subdued dark:bg-surface-darktheme-primary-subdued text-text-primary dark:text-text-darktheme-primary',
    success: 'border-border-success bg-surface-success-subdued text-text-success dark:border-border-darktheme-success dark:bg-surface-darktheme-success-subdued dark:text-text-darktheme-success',
    warning: 'border-border-warning bg-surface-warning-subdued text-text-warning dark:border-border-darktheme-warning dark:bg-surface-darktheme-warning-subdued dark:text-text-darktheme-warning',
    critical: 'border-border-critical bg-surface-critical-subdued text-text-critical dark:border-border-darktheme-critical dark:bg-surface-darktheme-critical-subdued dark:text-text-darktheme-critical',
  };

  return (
    <div
      className={cn(
        'flex gap-md items-center py-md px-2xl w-fit rounded-full bodySm border select-none pulsable',
        typeClasses[type],
        className
      )}
    >
      {!!icon && cloneElement(icon, iconProps)}
      {children}
    </div>
  );
};

)}
>
<AvatarBase color={color} size={size} image={props.image} />
{!noImage && (
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 simplify the code and improve readability.

The new code introduces additional complexity due to increased conditional logic and an expanded function signature. The added noImage prop makes the code harder to read and understand at a glance. To simplify the code while maintaining the same functionality, consider the following refactor:

  1. Extract class names into variables (buttonClassName and containerClassName) to make the JSX cleaner.
  2. Simplify conditional rendering for AvatarBase and the name/subtitle sections.
  3. Ensure consistent formatting and indentation for improved readability.

Here's a possible refactor:

import { ReactNode, forwardRef } from 'react';
import { AvatarBase, IAvatar } from '../atoms/avatar';
import { BounceIt } from '../bounce-it';
import { cn } from '../utils';

interface IProfile extends IAvatar {
  name?: ReactNode;
  subtitle?: ReactNode;
  responsive?: boolean;
  noImage?: boolean;
}

const Profile = forwardRef<HTMLButtonElement, IProfile>(
  ({ name, subtitle, color, responsive = true, size, noImage, ...props }, ref) => {
    const buttonClassName = cn(
      'flex py-sm px-md gap-lg items-center ring-offset-1 dark:ring-offset-0 outline-none transition-all rounded focus-visible:ring-2 focus-visible:ring-border-focus dark:focus-visible:ring-border-darktheme-focus'
    );

    const containerClassName = cn(
      'flex-col items-start',
      responsive ? 'hidden md:flex' : 'flex'
    );

    return (
      <BounceIt className="w-fit">
        <button {...props} ref={ref} className={buttonClassName}>
          {!noImage && <AvatarBase color={color} size={size} image={props.image} />}
          {(name || subtitle) && (
            <div className={containerClassName}>
              {name && (
                <div className="bodyMd-medium gap-y-md pulsable text-text-default dark:text-text-darktheme-default">
                  {name}
                </div>
              )}
              {subtitle && (
                <div className="bodySm text-text-subtle dark:text-text-darktheme-subtle">
                  {subtitle}
                </div>
              )}
            </div>
          )}
        </button>
      </BounceIt>
    );
  }
);

export default Profile;

This refactor maintains the same functionality while making the code easier to read and understand.

content="hello"
onClick={async () => {
try {
axios({
Copy link

Choose a reason for hiding this comment

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

🚨 issue (security): Potential hard-coded URL found.

Consider using environment variables or configuration files to manage URLs.

onClick={async () => {
try {
axios({
url: 'https://auth1.dev.kloudlite.io/api',
Copy link

Choose a reason for hiding this comment

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

🚨 issue (security): Hard-coded URL found.

It's recommended to use environment variables or configuration files to manage URLs.

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.

2 participants