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(web): add some missing styling #1257

Merged
merged 8 commits into from
Oct 17, 2024
Merged

fix(web): add some missing styling #1257

merged 8 commits into from
Oct 17, 2024

Conversation

caichi-t
Copy link
Contributor

@caichi-t caichi-t commented Oct 10, 2024

Overview

This PR fixes some styling bugs.

What I've done

  • Fixing the gap of height when selecting rows on Asset table.
  • Fixing information card on item edit page.
  • Fixing text overflow bug when the field title is too long.
  • Fixing text overflow bug when the asset title is too long.
  • Showing folder and file icons on asset tree.

Summary by CodeRabbit

  • New Features

    • Introduced a new icon, folderOpen, enhancing the icon set.
    • Updated DownloadButton to include a smaller size option for improved styling.
    • Enhanced the UnzipFileList component with dynamic icons that reflect the expanded state of tree nodes.
  • Improvements

    • Streamlined rendering logic and styling in the AssetItem component for better user experience.
    • Improved styling and layout of the FieldModal title for a more polished appearance.
  • Style

    • Adjusted styling for various components to enhance visual consistency and usability.

@caichi-t caichi-t requested a review from nourbalaha as a code owner October 10, 2024 11:59
Copy link

netlify bot commented Oct 10, 2024

Deploy Preview for reearth-cms ready!

Name Link
🔨 Latest commit 95a214b
🔍 Latest deploy log https://app.netlify.com/sites/reearth-cms/deploys/67108fa3a9201800081c8a63
😎 Deploy Preview https://deploy-preview-1257--reearth-cms.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the web label Oct 10, 2024
@caichi-t caichi-t changed the title chore(web): styling fix(web): styling Oct 10, 2024
Copy link

coderabbitai bot commented Oct 15, 2024

Walkthrough

The changes introduced in this pull request encompass several components across the application. A new icon, FolderOpenOutlined, is added to the icon library, and the DownloadButton component in AssetListTable is updated with a new size prop. The UnzipFileList component sees enhancements in its tree structure with dynamic icons and a new styled component. The AssetItem component is refactored for better rendering logic and styling, while the SidebarWrapper component receives styling updates for various elements. Lastly, the FieldModal component's title styling is improved with a new styled component.

Changes

File Path Change Summary
web/src/components/atoms/Icon/icons.ts Added new icon folderOpen mapped to FolderOpenOutlined in the export object. Minor formatting adjustments made.
web/src/components/molecules/Asset/AssetListTable/index.tsx Updated DownloadButton component to include a new size prop set to "small".
web/src/components/molecules/Asset/AssetBody/UnzipFileList/index.tsx Updated switcherIcon prop to use dynamic icons based on expanded state. Added new styled component SwitcherIcon.
web/src/components/molecules/Common/Form/AssetItem/index.tsx Streamlined rendering logic, updated styling, and adjusted TypeScript types for better clarity and usability.
web/src/components/molecules/Content/Form/SidebarWrapper.tsx Updated styling for DataRow, DataTitle, and DataText components, removing negative margins and adjusting line-height.
web/src/components/molecules/Schema/FieldModal/index.tsx Replaced <h3> with a styled <p> for modal title. Updated FieldThumbnail to use new title styling.

Poem

In the garden of code, we hop and play,
New icons and buttons brighten the day.
With styles that dance and logic refined,
Our components now sparkle, perfectly aligned.
So here's to the changes, both big and small,
A joyful leap forward, let’s celebrate all! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (7)
web/src/components/molecules/Asset/Asset/AssetBody/UnzipFileList/index.tsx (2)

85-85: Good enhancement to the tree structure visualization.

The showLine prop update improves the tree's visual structure by explicitly showing leaf icons. This change supports the PR's objective of adding folder and file icons to the asset tree.

For improved readability, consider destructuring the showLine prop:

-showLine={{ showLeafIcon: true }}
+showLine={({ showLeafIcon: true })}

This minor change makes it clearer that we're passing an object to the showLine prop.


149-153: Good addition of the SwitcherIcon styled component.

This new component ensures consistent rendering of icons by preventing unwanted transformations. It's well-placed and follows the convention of defining styled components after the main component.

Consider adding a comment explaining why the !important rule is necessary:

const SwitcherIcon = styled(Icon)`
  svg {
+   /* Override default Tree component styles to ensure consistent icon rendering */
    transform: none !important;
  }
`;

This comment will help future developers understand the reasoning behind using !important.

web/src/components/molecules/Common/Form/AssetItem/index.tsx (2)

155-165: Improved asset link rendering logic

The updated rendering logic enhances clarity and explicitly handles removed assets. This change aligns with the PR objective of improving the information card on the item edit page.

Consider extracting the link URL to a constant or utility function to improve maintainability:

const getAssetUrl = (workspaceId: string, projectId: string, assetId: string) =>
  `/workspace/${workspaceId}/project/${projectId}/asset/${assetId}`;

// Usage
<Link to={getAssetUrl(workspaceId, projectId, value)} target="_blank">
  {/* ... */}
</Link>

Line range hint 252-275: Improved styling for AssetLinkedName and AssetName

These changes enhance the component's appearance and functionality:

  1. The AssetLinkedName now uses a disabled prop, which is more intuitive and follows common conventions.
  2. The AssetName styling addresses text overflow issues, aligning with the PR objectives.

Consider using CSS custom properties (variables) for the colors to improve maintainability:

const AssetLinkedName = styled(Button)<{ disabled?: boolean }>`
  --enabled-color: #1890ff;
  --disabled-color: #00000040;
  color: ${({ disabled }) => (disabled ? 'var(--disabled-color)' : 'var(--enabled-color)')};
  // ... rest of the styles
`;

This approach allows for easier theming and consistency across the application.

web/src/components/molecules/Asset/AssetListTable/index.tsx (1)

294-299: LGTM! Consider applying consistent formatting.

The addition of the size="small" prop to the DownloadButton component is a good styling improvement and aligns well with the PR objectives. This change makes the download button consistent with other buttons in the same context.

For better code consistency, consider aligning the props vertically:

 <DownloadButton
   displayDefaultIcon
   size="small"
   type="link"
-  selected={props.selectedRows}
+  selected={props.selectedRows}
 />

This formatting is consistent with other multi-prop components in the file and improves readability.

web/src/components/molecules/Schema/FieldModal/index.tsx (2)

156-160: Consider using a semantic heading element for the modal title

The change from <h3> to a styled <p> element (StyledTitle) for the modal title might affect the document's semantic structure. While the styling likely maintains the visual hierarchy, it's generally recommended to use heading elements (<h1> to <h6>) for titles to maintain proper document outline and accessibility.

Consider using a styled <h3> element instead of <p> to maintain semantic meaning while achieving the desired styling:

const StyledTitle = styled.h3`
  /* ... existing styles ... */
  margin: 0 20px 0 12px;
  font-weight: normal; // To match paragraph styling if needed
`;

This approach would preserve the semantic structure while allowing for custom styling.


395-401: Reconsider the use of overflow: auto for the title

The StyledTitle component includes an overflow: auto property, which might be unnecessary for a title element. Titles typically don't overflow, and if they do, it might indicate a design issue that should be addressed differently.

Consider removing the overflow: auto property:

const StyledTitle = styled.p`
  color: #000000d9;
  font-size: 16px;
  margin: 0 20px 0 12px;
  // Remove or replace the overflow property
  // overflow: auto;
  // If text truncation is needed, consider using:
  // white-space: nowrap;
  // overflow: hidden;
  // text-overflow: ellipsis;
`;

If there's a specific reason for including overflow: auto, please add a comment explaining the rationale. Otherwise, consider removing it or implementing a text truncation approach if long titles are a concern.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c7c79a4 and 804b188.

📒 Files selected for processing (6)
  • web/src/components/atoms/Icon/icons.ts (2 hunks)
  • web/src/components/molecules/Asset/Asset/AssetBody/UnzipFileList/index.tsx (2 hunks)
  • web/src/components/molecules/Asset/AssetListTable/index.tsx (1 hunks)
  • web/src/components/molecules/Common/Form/AssetItem/index.tsx (5 hunks)
  • web/src/components/molecules/Content/Form/SidebarWrapper.tsx (1 hunks)
  • web/src/components/molecules/Schema/FieldModal/index.tsx (2 hunks)
🧰 Additional context used
🔇 Additional comments (9)
web/src/components/molecules/Content/Form/SidebarWrapper.tsx (1)

99-101: Improved styling for better layout and consistency

The changes to the DataRow component enhance the layout and spacing:

  1. The gap property ensures consistent spacing between child elements.
  2. The added padding improves vertical spacing within the row.
  3. The line-height property ensures consistent vertical alignment of text.

These improvements align well with the PR objectives of fixing styling issues and enhancing the overall appearance of components.

web/src/components/molecules/Asset/Asset/AssetBody/UnzipFileList/index.tsx (2)

77-79: Excellent improvement to the folder icons!

The dynamic switcherIcon implementation enhances the user experience by providing clear visual feedback on the expanded state of folders. This change aligns well with the PR's objective of improving visual representation in the asset tree.


Line range hint 1-154: Overall, excellent improvements to the UnzipFileList component!

The changes in this file significantly enhance the visual representation and user experience of the asset tree, aligning perfectly with the PR objectives. The dynamic folder icons, improved tree structure visualization, and consistent icon rendering all contribute to a more intuitive and visually appealing interface.

The code is well-structured, follows React best practices, and maintains good readability. Great job on these improvements!

web/src/components/atoms/Icon/icons.ts (2)

36-36: LGTM: New icon import added correctly.

The FolderOpenOutlined icon is imported correctly from @ant-design/icons. This addition aligns with the PR objective of adding folder icons to improve visual representation in the asset tree.


141-141: LGTM: New icon export added correctly.

The folderOpen icon is correctly exported and mapped to the FolderOpenOutlined component. This addition complements the new import and fulfills the PR objective of adding folder icons to the asset tree.

To ensure this new icon is being used as intended, let's verify its usage in the codebase:

✅ Verification successful

LGTM: New icon export added correctly.

The folderOpen icon is correctly exported and mapped to the FolderOpenOutlined component. This addition complements the new import and fulfills the PR objective of adding folder icons to the asset tree. Verified that the folderOpen icon is utilized in UnzipFileList/index.tsx as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new folderOpen icon in the codebase.

# Test: Search for usage of folderOpen icon
echo "Searching for usage of folderOpen icon:"
rg --type typescript --type typescriptreact 'folderOpen'

# Test: Check for any TODO comments related to folder icons
echo "Checking for any TODO comments related to folder icons:"
rg --type typescript --type typescriptreact 'TODO.*folder.*icon'

Length of output: 403


Script:

#!/bin/bash
# Description: Verify the usage of the new folderOpen icon in the codebase.

# Test: Search for usage of folderOpen icon in .ts and .tsx files
echo "Searching for usage of folderOpen icon in .ts and .tsx files:"
rg -g '*.ts' -g '*.tsx' 'folderOpen'

# Test: Check for any TODO comments related to folder icons in .ts and .tsx files
echo "Checking for any TODO comments related to folder icons in .ts and .tsx files:"
rg -g '*.ts' -g '*.tsx' 'TODO.*folder.*icon'

Length of output: 612

web/src/components/molecules/Common/Form/AssetItem/index.tsx (3)

151-152: LGTM: Improved icon and asset name display

The changes here align with the PR objectives:

  1. The folder icon enhances visual representation.
  2. Using the AssetName component likely improves styling consistency.

These modifications contribute to a better user interface.


186-187: LGTM: Improved asset button icon and internationalization

These changes enhance the user interface and maintainability:

  1. The link icon better represents the button's purpose of linking an asset.
  2. Using the t function for the button text ensures proper internationalization support.

228-229: LGTM: Improved AssetButton styling

The added padding and flex-flow properties enhance the button's appearance and layout. These changes contribute to the PR's objective of fixing styling bugs and improving the overall user interface.

web/src/components/molecules/Schema/FieldModal/index.tsx (1)

Line range hint 1-401: Overall assessment: Styling improvements with minor suggestions

The changes to the FieldModal component focus on enhancing the visual styling of the modal title. These modifications improve the appearance without altering the component's functionality. The introduction of the StyledTitle component allows for more precise control over the title's styling.

While these changes are generally positive, there are two minor suggestions to consider:

  1. Using a semantic heading element for the modal title to maintain proper document structure.
  2. Reconsidering the use of overflow: auto for the title styling.

These suggestions aim to further refine the component's structure and styling without impacting its current improvements.

@nourbalaha nourbalaha changed the title fix(web): styling fix(web): add some missing styling Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants