Skip to content

refactor: GraphQL page redesign#388

Merged
kingston merged 40 commits into
mainfrom
matei/eng-475-graphql-page-redesign
Jan 13, 2025
Merged

refactor: GraphQL page redesign#388
kingston merged 40 commits into
mainfrom
matei/eng-475-graphql-page-redesign

Conversation

@matei-s

@matei-s matei-s commented Nov 21, 2024

Copy link
Copy Markdown
Contributor

DEPENDS ON #383

implemented the design for the models/graphql page

Notes

  • updated the "muted" and "muted-foreground" color tokens (for the light theme)
  • added a new MultiSwitchField component (pretty much a MultiCheckboxField with switches)
Screenshot 2024-12-17 at 09 52 51 Screenshot 2024-12-17 at 09 53 00

Summary by CodeRabbit

Release Notes

  • UI Improvements

    • Enhanced color palette for muted elements in light and dark themes.
    • Updated component styling with improved spacing and layout.
  • Component Updates

    • Introduced new MultiSwitchField component for more flexible role and option selection.
    • Replaced MultiCheckboxField with MultiSwitchField in GraphQL configuration pages.
    • Added Badge and Label components to improve visual presentation.
    • Refined layout and spacing across various model configuration sections.
  • Minor Enhancements

    • Updated import statements and code organization.
    • Adjusted icon styles in configuration interfaces.

@changeset-bot

changeset-bot Bot commented Nov 21, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 016add6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@halfdomelabs/project-builder-web Patch
@halfdomelabs/ui-components Patch
@halfdomelabs/project-builder-cli Patch
@halfdomelabs/project-builder-test Patch
@halfdomelabs/project-builder-lib Patch
@halfdomelabs/baseplate-plugin-storage Patch
@halfdomelabs/project-builder-common Patch
@halfdomelabs/project-builder-server Patch
@halfdomelabs/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@linear

linear Bot commented Nov 21, 2024

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Nov 21, 2024

Copy link
Copy Markdown

Walkthrough

This pull request introduces several UI and component improvements across the project, focusing on the Models/GraphQL page. The changes include updating color variables in CSS, introducing a new MultiSwitchField component, replacing MultiCheckboxField with MultiSwitchField for role selections, and adding new UI components like Badge and Label. The modifications aim to enhance the visual consistency and user experience of the interface, particularly in the model editing sections.

Changes

File Change Summary
packages/project-builder-web/src/index.css Updated color variables for muted and muted-foreground in both root and dark theme selectors.
packages/ui-components/src/components/MultiSwitchField/MultiSwitchField.tsx Added new MultiSwitchField component with root and controller implementations.
packages/ui-components/src/components/SwitchField/SwitchField.tsx Modified layout classes for container and label.
packages/ui-components/src/components/index.ts Added export for MultiSwitchField component.
packages/ui-components/src/utils/cn.ts Consolidated import statement for clsx library.
packages/project-builder-web/src/pages/data/models/edit/[id]/_components/* Updated multiple components with new UI components and layout adjustments.
packages/project-builder-web/src/pages/data/models/edit/[id]/graphql.page.tsx Integrated SectionList component for page structure.

Sequence Diagram

sequenceDiagram
    participant User
    participant MultiSwitchFieldRoot
    participant MultiSwitchFieldController
    participant Form

    User->>MultiSwitchFieldRoot: Interact with switches
    MultiSwitchFieldRoot->>MultiSwitchFieldController: Update selected options
    MultiSwitchFieldController->>Form: Sync form state
    Form-->>User: Reflect changes
Loading

This sequence diagram illustrates the interaction flow of the new MultiSwitchField component, showing how user interactions are processed and synchronized with the form state.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 1759bcc and 016add6.

📒 Files selected for processing (1)
  • packages/project-builder-web/src/pages/data/models/edit/[id]/_components/graphql/GraphQLObjectTypeSection.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/project-builder-web/src/pages/data/models/edit/[id]/_components/graphql/GraphQLObjectTypeSection.tsx

Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@matei-s matei-s marked this pull request as ready for review November 27, 2024 11:31
@matei-s matei-s requested a review from kingston November 27, 2024 11:31

@kingston kingston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall LGTM - but I guess we need to merge the other one. Can you attach a screenshot of it as well?

--foreground: 229 84% 5%;
--muted: 210 40% 96%;
--muted-foreground: 215 16% 47%;
--muted: 220 14% 96%;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why did we change these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Got it makes sense

@matei-s matei-s requested a review from kingston December 16, 2024 13:07
@kingston

Copy link
Copy Markdown
Collaborator

@matei-s can you attach a screenshot?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (7)
packages/ui-components/src/components/MultiSwitchField/MultiSwitchField.tsx (2)

19-26: Add JSDoc documentation for the interface.

Consider adding JSDoc documentation to describe the purpose and usage of each prop in the MultiSwitchFieldProps interface. This would improve developer experience and maintainability.

Example:

+/**
+ * Props for the MultiSwitchField component
+ * @template OptionType - The type of the option object
+ */
 export interface MultiSwitchFieldProps<OptionType>
   extends MultiSelectOptionProps<OptionType>,
     FieldProps {
+  /** Currently selected values */
   value?: string[];
+  /** Callback fired when the selection changes */
   onChange?: (value: string[]) => void;
+  /** Additional CSS classes */
   className?: string;
+  /** Whether the field is disabled */
   disabled?: boolean;
 }

133-134: Consider using type assertion with type predicate.

The type casting could be made more type-safe using a type predicate function.

-    const restProps = rest as MultiSwitchFieldProps<OptionType> &
-      AddOptionRequiredFields<OptionType>;
+    function isMultiSwitchFieldProps(
+      props: unknown
+    ): props is MultiSwitchFieldProps<OptionType> & AddOptionRequiredFields<OptionType> {
+      return true; // Add proper type checking here
+    }
+    const restProps = isMultiSwitchFieldProps(rest) ? rest : {};
packages/project-builder-web/src/pages/data/models/_constants.tsx (1)

13-13: Fix typo in description string

The description contains a typo: "value 'password'" should probably be "field 'password'".

-    description: "Hashes the input value of value 'password' using Argon2id",
+    description: "Hashes the input value of field 'password' using Argon2id",
packages/project-builder-web/src/pages/data/models/edit.id/_components/graphql/GraphQLObjectTypeSection.tsx (4)

117-144: Fix inconsistent button titles

The expand/collapse button titles use "fields" for all sections. This should be specific to each section type.

-  title={
-    shouldCollapseFields
-      ? 'Expand fields'
-      : 'Collapse fields'
-  }
+  title={
+    shouldCollapseFields
+      ? 'Expand field list'
+      : 'Collapse field list'
+  }

190-220: Fix inconsistent button titles for local relations

The expand/collapse button titles incorrectly use "fields" instead of "relations".

-  title={
-    shouldCollapseLocalRelations
-      ? 'Expand fields'
-      : 'Collapse fields'
-  }
+  title={
+    shouldCollapseLocalRelations
+      ? 'Expand local relations'
+      : 'Collapse local relations'
+  }

Line range hint 258-283: Remove commented out code

Remove the commented out code block as it's no longer needed and adds unnecessary noise to the codebase.


284-314: Fix inconsistent button titles for foreign relations

The expand/collapse button titles incorrectly use "fields" instead of "relations".

-  title={
-    shouldCollapseForeignRelations
-      ? 'Expand fields'
-      : 'Collapse fields'
-  }
+  title={
+    shouldCollapseForeignRelations
+      ? 'Expand foreign relations'
+      : 'Collapse foreign relations'
+  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 0e3f933 and 824a7f5.

📒 Files selected for processing (48)
  • .changeset/little-zebras-boil.md (1 hunks)
  • .changeset/violet-ads-float.md (1 hunks)
  • packages/project-builder-web/src/index.css (1 hunks)
  • packages/project-builder-web/src/index.tsx (1 hunks)
  • packages/project-builder-web/src/pages/_routes.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/_layout.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/_routes.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/enums/EnumsSidebarList.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/enums/hooks/useEnumForm.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/_components/ModelsSidebarList.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/_components/NewModelDialog.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/_constants.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/_hooks/useModelForm.ts (1 hunks)
  • packages/project-builder-web/src/pages/data/models/_routes.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/constants/built-in-transformers.ts (0 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/BadgeWithTypeLabel.tsx (2 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/ModelInfoEditDialog.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/ModelRelationsSection.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/ModelUniqueConstraintsSection.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/ModelAddFieldButton.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/ModelFieldDefaultValueInput.tsx (7 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/ModelFieldForm.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/ModelFieldTypeInput.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/badges/ModelFieldBadges.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/primary-key/ModelPrimaryKeyForm.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/relations/ModelRelationForm.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/unique-constraints/ModelUniqueConstraintBadge.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/unique-constraints/ModelUniqueConstraintForm.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/graphql/GraphQLMutationsSection.tsx (6 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/graphql/GraphQLObjectTypeSection.tsx (6 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/graphql/GraphQLQueriesSection.tsx (5 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/service/ServiceEmbeddedRelationForm.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/service/ServiceMethodFieldsSection.tsx (3 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/service/ServiceTransformerForm.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/service/ServiceTransformersSection.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_layout.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/_routes.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/graphql.page.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/index.page.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit.id/service.page.tsx (1 hunks)
  • packages/project-builder-web/src/pages/data/models/edit/_routes.tsx (0 hunks)
  • packages/project-builder-web/src/pages/data/models/edit/schema/schema.page.tsx (0 hunks)
  • packages/project-builder-web/src/pages/data/models/index.page.tsx (2 hunks)
  • packages/ui-components/src/components/InputField/InputField.tsx (3 hunks)
  • packages/ui-components/src/components/MultiSwitchField/MultiSwitchField.tsx (1 hunks)
  • packages/ui-components/src/components/SwitchField/SwitchField.tsx (2 hunks)
  • packages/ui-components/src/components/index.ts (1 hunks)
  • packages/ui-components/src/utils/cn.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • packages/project-builder-web/src/pages/data/models/edit/schema/schema.page.tsx
  • packages/project-builder-web/src/pages/data/models/edit/_routes.tsx
  • packages/project-builder-web/src/pages/data/models/constants/built-in-transformers.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/project-builder-web/src/pages/data/enums/EnumsSidebarList.tsx
  • packages/project-builder-web/src/pages/data/models/_hooks/useModelForm.ts
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/ModelInfoEditDialog.tsx
🚧 Files skipped from review as they are similar to previous changes (38)
  • .changeset/little-zebras-boil.md
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/ModelUniqueConstraintsSection.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/service/ServiceEmbeddedRelationForm.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/ModelAddFieldButton.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/unique-constraints/ModelUniqueConstraintBadge.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/service/ServiceTransformerForm.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/BadgeWithTypeLabel.tsx
  • packages/project-builder-web/src/pages/data/models/_components/ModelsSidebarList.tsx
  • packages/ui-components/src/components/index.ts
  • .changeset/violet-ads-float.md
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/badges/ModelFieldBadges.tsx
  • packages/project-builder-web/src/pages/_routes.tsx
  • packages/project-builder-web/src/pages/data/_layout.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/ModelRelationsSection.tsx
  • packages/ui-components/src/utils/cn.ts
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/unique-constraints/ModelUniqueConstraintForm.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/ModelFieldTypeInput.tsx
  • packages/project-builder-web/src/index.tsx
  • packages/project-builder-web/src/pages/data/enums/hooks/useEnumForm.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/ModelFieldDefaultValueInput.tsx
  • packages/project-builder-web/src/pages/data/models/_routes.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/ModelFieldForm.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/primary-key/ModelPrimaryKeyForm.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/relations/ModelRelationForm.tsx
  • packages/ui-components/src/components/InputField/InputField.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_layout.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/graphql/GraphQLQueriesSection.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_routes.tsx
  • packages/project-builder-web/src/pages/data/_routes.tsx
  • packages/ui-components/src/components/SwitchField/SwitchField.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/service/ServiceTransformersSection.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/index.page.tsx
  • packages/project-builder-web/src/pages/data/models/_components/NewModelDialog.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/graphql.page.tsx
  • packages/project-builder-web/src/pages/data/models/index.page.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/service/ServiceMethodFieldsSection.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/service.page.tsx
  • packages/project-builder-web/src/pages/data/models/edit.id/_components/graphql/GraphQLMutationsSection.tsx
🔇 Additional comments (9)
packages/ui-components/src/components/MultiSwitchField/MultiSwitchField.tsx (3)

1-18: LGTM! Well-organized imports with proper type definitions.

The imports are properly structured with clear separation between React types, form-related types, and utility functions.


142-144: LGTM! Clean component composition pattern.

The export cleanly combines the root component and controller using Object.assign, following React conventions.


1-144: Consider accessibility and form integration testing.

As this component is part of a larger form system and replaces checkbox functionality with switches:

  1. Ensure proper ARIA attributes are being passed through to the underlying SwitchField components
  2. Consider adding integration tests with react-hook-form to verify form state management
  3. Document the differences between this and MultiCheckboxField for other developers

Let's verify the form integration:

packages/project-builder-web/src/pages/data/models/_constants.tsx (4)

3-6: LGTM! Clean and well-organized imports.

The imports are logically grouped and properly scoped.


8-28: Well-implemented password transformer with proper security considerations!

The implementation correctly:

  • Prevents duplicate password transformers
  • Verifies the presence of a passwordHash field
  • Uses Argon2id for password hashing

25-25: Consider implementing getSummary method

The getSummary method returns an empty array. Consider adding meaningful summary information to help users understand the transformer's configuration.

✅ Verification successful

Based on the search results, I can now provide a final response:

The empty getSummary implementation is intentional for the password transformer

The empty getSummary implementation in the password transformer is by design. This transformer is a built-in configuration that handles password hashing using Argon2id, and its behavior is straightforward enough that it doesn't require additional summary information. The implementation matches other parts of the codebase where transformers provide summaries based on their specific needs - for example, the embedded relation transformer provides detailed summaries while simpler transformers like the password one don't need to.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if other transformers implement getSummary
ast-grep --pattern 'getSummary: () => $$$'

Length of output: 44


Script:

#!/bin/bash
# Let's try a broader search for getSummary implementations
rg "getSummary" -A 3

Length of output: 2280


Script:

#!/bin/bash
# Search for any transformer configurations
rg "transformer" -A 5 packages/project-builder-web/src/pages/data/models/

Length of output: 43232


Script:

#!/bin/bash
# Check the content of the file for more context
cat packages/project-builder-web/src/pages/data/models/_constants.tsx

Length of output: 2239


18-24: Verify password field validation

The allowNewTransformer checks for a 'passwordHash' field but should we also verify that a 'password' field exists since that's what will be transformed?

packages/project-builder-web/src/pages/data/models/edit.id/_components/graphql/GraphQLObjectTypeSection.tsx (2)

7-14: LGTM: Clean import restructuring

The changes align well with the UI redesign objectives, moving towards standardized UI components and consistent icon usage.

Also applies to: 17-21


96-105: Verify sticky header behavior with nested sticky elements

The section uses nested sticky positioning (top-2 on header, top-0 on table headers). Please verify that this works as intended across different scroll scenarios.

✅ Verification successful

Based on the search results, I can now provide a conclusive response about the sticky positioning behavior:

Sticky header implementation is correct and follows a consistent pattern

The sticky positioning is implemented correctly with appropriate z-index layering:

  1. Section headers use sticky top-2 with bg-background for proper background coverage
  2. Table headers use sticky top-0 with z-10 and bg-background
  3. Field list headers use sticky -top-0 with z-10 and bg-white

The different top values create a natural layering that prevents overlap, and each sticky element has the appropriate background color to maintain visual consistency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other sticky positioned elements that might conflict
rg -n 'sticky' --type tsx

Length of output: 53


Script:

#!/bin/bash
# Search for sticky positioned elements using ripgrep with broader file patterns
rg -n 'sticky' --type ts --type tsx --type jsx --type js

Length of output: 84


Script:

#!/bin/bash
# Find all TypeScript/React files that might contain sticky positioning
fd -e tsx -e ts -e jsx -e js -x grep -l "sticky"

Length of output: 861


Script:

#!/bin/bash
# Search for table headers with sticky positioning
rg -n 'top-0|sticky' --type ts --type tsx --type jsx --type js -A 2 -B 2

Length of output: 102


Script:

#!/bin/bash
# Let's examine the content of these files to understand the sticky positioning usage
for file in $(fd -e tsx -e ts -e jsx -e js -x echo {}) ; do
  echo "=== $file ==="
  grep -A 5 -B 5 'sticky\|top-[0-9]' "$file" 2>/dev/null
done

Length of output: 131070


Script:

#!/bin/bash
# Specifically check the related model edit components for sticky positioning patterns
cat "./packages/project-builder-web/src/pages/data/models/edit.id/_components/fields/ModelFieldsForm.tsx"

Length of output: 2349

Comment on lines +34 to +35
--muted: 220 14% 96%;
--muted-foreground: 220 9% 46%;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codebase verification

Update both light and dark theme color tokens for consistency

The verification reveals inconsistencies that need to be addressed:

  • The light theme muted colors in project-builder-web have been updated to use hue 220, but the dark theme still uses different hues (222 for muted, 215 for muted-foreground)
  • The base UI component library (ui-components/src/styles.css) is still using the old color values (210/215 hues)

To maintain design consistency:

  1. Update dark theme in project-builder-web to use hue 220
  2. Sync changes with the UI component library to ensure consistent theming across the application
🔗 Analysis chain

Consider documenting color token changes

The color adjustments align with the Figma design specs, making the muted colors more subtle by reducing saturation while maintaining a consistent hue of 220. However, the corresponding dark theme values (--muted and --muted-foreground) haven't been updated to match the same hue shift.

Let's verify the color token usage across the codebase:

Consider:

  1. Updating dark theme tokens to maintain hue consistency (220)
  2. Adding comments to document the color token changes and their purpose
  3. Creating a color token documentation file to track these design decisions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any hardcoded color values that might need updating
# Look for HSL/RGB values similar to the old muted colors

rg -g '*.{css,scss,tsx,jsx}' '(210 40% 96%|215 16% 47%)'

Length of output: 773


Script:

#!/bin/bash
# Let's check the dark theme values in both files to understand the color scheme better
rg -A 50 -B 5 '@media.*dark' packages/project-builder-web/src/index.css packages/ui-components/src/styles.css

Length of output: 111


Script:

#!/bin/bash
# Let's try a different approach to find dark theme values
# First, let's see the complete content of both CSS files
cat packages/project-builder-web/src/index.css packages/ui-components/src/styles.css

Length of output: 4448

Comment on lines +72 to +86
onChange={(isChecked) => {
if (isChecked) {
onChange?.(
options
.map(getOptionValue)
.filter(
(val) =>
(val === optionValue || value?.includes(val)) ??
false,
),
);
} else {
onChange?.(value?.filter((val) => val !== optionValue) ?? []);
}
}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify the onChange handler logic.

The current implementation is somewhat complex and could be made more readable and efficient.

Consider this simplified version:

-              onChange={(isChecked) => {
-                if (isChecked) {
-                  onChange?.(
-                    options
-                      .map(getOptionValue)
-                      .filter(
-                        (val) =>
-                          (val === optionValue || value?.includes(val)) ??
-                          false,
-                      ),
-                  );
-                } else {
-                  onChange?.(value?.filter((val) => val !== optionValue) ?? []);
-                }
-              }}
+              onChange={(isChecked) => {
+                const currentValues = value ?? [];
+                const newValues = isChecked
+                  ? [...currentValues, optionValue]
+                  : currentValues.filter((val) => val !== optionValue);
+                onChange?.(newValues);
+              }}
📝 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
onChange={(isChecked) => {
if (isChecked) {
onChange?.(
options
.map(getOptionValue)
.filter(
(val) =>
(val === optionValue || value?.includes(val)) ??
false,
),
);
} else {
onChange?.(value?.filter((val) => val !== optionValue) ?? []);
}
}}
onChange={(isChecked) => {
const currentValues = value ?? [];
const newValues = isChecked
? [...currentValues, optionValue]
: currentValues.filter((val) => val !== optionValue);
onChange?.(newValues);
}}

@matei-s

matei-s commented Dec 17, 2024

Copy link
Copy Markdown
Contributor Author

@matei-s can you attach a screenshot?

done!

@kingston kingston merged commit 4774215 into main Jan 13, 2025
@kingston kingston deleted the matei/eng-475-graphql-page-redesign branch January 13, 2025 08:54
@github-actions github-actions Bot mentioned this pull request Jan 17, 2025
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