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: enhanced widget card #32211

Merged
merged 30 commits into from
Apr 9, 2024
Merged

feat: enhanced widget card #32211

merged 30 commits into from
Apr 9, 2024

Conversation

jacquesikot
Copy link
Contributor

@jacquesikot jacquesikot commented Mar 28, 2024

Description

Tip

To update the explorer widgets and icons to match the new Anvil design system

How

  1. Update all the icons and thumbnails svg for widgets in the explorer
  2. Update the WidgetCard component to implement the new design
  3. Test functionality of widgets manually

Fixes #32330

Automation

/ok-to-test tags="@tag.Visual, @tag.MainContainer, @tag.Widget"

🔍 Cypress test results

Important

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/8598999945
Commit: 47cf5a8e0e14e986da31e02ba8f630fd27ce310f
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

Summary by CodeRabbit

  • New Features
    • Introduced a new UIEntityCard component for representing widgets in the editor sidebar with enhanced drag-and-drop functionality and improved visual layout including widget details.

@jacquesikot jacquesikot requested review from KelvinOm, hetunandu, a team and riodeuno and removed request for a team March 28, 2024 09:03
Copy link
Contributor

coderabbitai bot commented Mar 28, 2024

Walkthrough

The changes in this update involve significant enhancements to various widget components across the application. Importantly, the WidgetCard component has been revamped to better align with the latest design standards and accommodate new features such as thumbnails. Additionally, several widgets now include the ThumbnailSVG import and configuration, enhancing the visual representation and functionality of these widgets.

Changes

File Path Change Summary
.../Editor/widgetSidebar/UIEntityTagGroup.tsx Reordered import statements for WidgetCard and styled-components.
.../Editor/widgetSidebar/WidgetCard.tsx - Removed isThumbnail prop from Wrapper.
- Updated styles for Wrapper with new padding and margin values.
- Introduced ThumbnailWrapper component with specific styling.
- Simplified logic for determining className.
- Replaced IconWrapper with ThumbnailWrapper for rendering images based on thumbnail presence.
.../selectors/templatesSelectors.tsx Added a new thumbnail field to the object returned by getBuildingBlockExplorerCards selector.
.../widgets/AudioRecorderWidget/widget/index.tsx Updated widget properties to include ThumbnailSVG.
.../widgets/AudioWidget/widget/index.tsx Updated widget configuration to include ThumbnailSVG.
.../widgets/ButtonGroupWidget/widget/index.tsx Included ThumbnailSVG in widget configuration for ButtonGroupWidget.
.../widgets/ButtonWidget/widget/index.tsx Updated ButtonWidget class to include thumbnailSVG in widget properties.
.../widgets/CameraWidget/widget/index.tsx Updated widget configuration to include thumbnailSVG in CameraWidget.
.../widgets/CategorySliderWidget/widget/index.tsx Included ThumbnailSVG in the SliderOption interface within CategorySliderWidget.
.../widgets/ChartWidget/widget/index.tsx Included ThumbnailSVG in the widget's configuration in ChartWidget.
.../widgets/CheckboxGroupWidget/widget/index.tsx Included ThumbnailSVG in the return object of CheckboxGroupWidget class.
.../widgets/CheckboxWidget/widget/index.tsx Included ThumbnailSVG in the widget's properties.
.../widgets/CodeScannerWidget/widget/index.tsx Assigned ThumbnailSVG to thumbnailSVG in CodeScannerWidget class.
.../widgets/ContainerWidget/widget/index.tsx Included ThumbnailSVG in the return object of ContainerWidget.
.../widgets/CurrencyInputWidget/widget/index.tsx Included ThumbnailSVG in the widget's configuration in CurrencyInputWidget.
... ...

Assessment against linked issues

Objective Addressed Explanation
Enhance WidgetCard component to align with new design standards and accommodate building blocks. (#32330)

Possibly related issues

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@github-actions github-actions bot added the Enhancement New feature or request label Mar 28, 2024
@hetunandu
Copy link
Member

/build-deploy-preview

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/8464900525.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 32211.
recreate: .

Comment on lines 78 to 117
function UIEntityCard(props: CardProps) {
const { setDraggingNewWidget } = useWidgetDragResize();
const { deselectAll } = useWidgetSelection();
const isEditorPaneEnabled = useIsEditorPaneSegmentsEnabled();

const onDragStart = (e: any) => {
e.preventDefault();
e.stopPropagation();
AnalyticsUtil.logEvent("WIDGET_CARD_DRAG", {
widgetType: props.details.type,
widgetName: props.details.displayName,
});
setDraggingNewWidget &&
setDraggingNewWidget(true, {
...props.details,
widgetId: generateReactKey(),
});
if (!isEditorPaneEnabled) {
deselectAll();
}
};

const type = `${props.details.type.split("_").join("").toLowerCase()}`;
const className = `t--widget-card-draggable t--widget-card-draggable-${type} pt-2 gap-2 mt-2`;

return (
<Wrapper
className={className}
data-guided-tour-id={`widget-card-${type}`}
draggable
id={`widget-card-draggable-${type}`}
onDragStart={onDragStart}
>
<EntityIconWrapper height={THUMBNAIL_HEIGHT} width={THUMBNAIL_WIDTH}>
<img src={props.details.thumbnail ?? props.details.icon} />
</EntityIconWrapper>
<Text kind="body-s">{props.details.displayName}</Text>
{props.details.isBeta && <BetaLabel>Beta</BetaLabel>}
</Wrapper>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

The overall structure of the UIEntityCard component is well-organized, effectively rendering the widget's thumbnail, display name, and beta label. To further improve code readability, consider destructuring props.details at the beginning of the UIEntityCard function.

function UIEntityCard(props: CardProps) {
+  const { details } = props;
+  const { type, displayName, thumbnail, icon, isBeta } = details;
-  const { setDraggingNewWidget } = useWidgetDragResize();
+  const { setDraggingNewWidget } = useWidgetDragResize();

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.

Suggested change
function UIEntityCard(props: CardProps) {
const { setDraggingNewWidget } = useWidgetDragResize();
const { deselectAll } = useWidgetSelection();
const isEditorPaneEnabled = useIsEditorPaneSegmentsEnabled();
const onDragStart = (e: any) => {
e.preventDefault();
e.stopPropagation();
AnalyticsUtil.logEvent("WIDGET_CARD_DRAG", {
widgetType: props.details.type,
widgetName: props.details.displayName,
});
setDraggingNewWidget &&
setDraggingNewWidget(true, {
...props.details,
widgetId: generateReactKey(),
});
if (!isEditorPaneEnabled) {
deselectAll();
}
};
const type = `${props.details.type.split("_").join("").toLowerCase()}`;
const className = `t--widget-card-draggable t--widget-card-draggable-${type} pt-2 gap-2 mt-2`;
return (
<Wrapper
className={className}
data-guided-tour-id={`widget-card-${type}`}
draggable
id={`widget-card-draggable-${type}`}
onDragStart={onDragStart}
>
<EntityIconWrapper height={THUMBNAIL_HEIGHT} width={THUMBNAIL_WIDTH}>
<img src={props.details.thumbnail ?? props.details.icon} />
</EntityIconWrapper>
<Text kind="body-s">{props.details.displayName}</Text>
{props.details.isBeta && <BetaLabel>Beta</BetaLabel>}
</Wrapper>
);
function UIEntityCard(props: CardProps) {
const { details } = props;
const { type, displayName, thumbnail, icon, isBeta } = details;
const { setDraggingNewWidget } = useWidgetDragResize();
const { deselectAll } = useWidgetSelection();
const isEditorPaneEnabled = useIsEditorPaneSegmentsEnabled();
const onDragStart = (e: any) => {
e.preventDefault();
e.stopPropagation();
AnalyticsUtil.logEvent("WIDGET_CARD_DRAG", {
widgetType: props.details.type,
widgetName: props.details.displayName,
});
setDraggingNewWidget &&
setDraggingNewWidget(true, {
...props.details,
widgetId: generateReactKey(),
});
if (!isEditorPaneEnabled) {
deselectAll();
}
};
const type = `${props.details.type.split("_").join("").toLowerCase()}`;
const className = `t--widget-card-draggable t--widget-card-draggable-${type} pt-2 gap-2 mt-2`;
return (
<Wrapper
className={className}
data-guided-tour-id={`widget-card-${type}`}
draggable
id={`widget-card-draggable-${type}`}
onDragStart={onDragStart}
>
<EntityIconWrapper height={THUMBNAIL_HEIGHT} width={THUMBNAIL_WIDTH}>
<img src={props.details.thumbnail ?? props.details.icon} />
</EntityIconWrapper>
<Text kind="body-s">{props.details.displayName}</Text>
{props.details.isBeta && <BetaLabel>Beta</BetaLabel>}
</Wrapper>
);

Copy link

Deploy-Preview-URL: https://ce-32211.dp.appsmith.com

@KelvinOm KelvinOm requested a review from jsartisan March 28, 2024 14:24
@hetunandu hetunandu removed their request for review March 29, 2024 04:42
Copy link
Collaborator

@KelvinOm KelvinOm left a comment

Choose a reason for hiding this comment

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

Waiting for changes that will also work for Anvil.

@jacquesikot jacquesikot changed the title feat: enhanced widget card and theme matching with widget thumbnail feat: enhanced widget card Apr 4, 2024
@hetunandu hetunandu removed their request for review April 4, 2024 10:43
@jacquesikot
Copy link
Contributor Author

/build-deploy-preview

Copy link

github-actions bot commented Apr 4, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/8553363660.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 32211.
recreate: .

Comment on lines 105 to 115
data-guided-tour-id={`widget-card-${type}`}
draggable
id={`widget-card-draggable-${type}`}
// isThumbnail is used to add conditional styles for widget that renders thumbnail on widget card
isThumbnail={Boolean(props.details.thumbnail)}
onDragStart={onDragStart}
>
<IconWrapper
// if widget has a thumbnail, use thumbnail dimensions, else use icon dimensions
height={props.details.thumbnail ? THUMBNAIL_HEIGHT : ICON_SIZE}
width={props.details.thumbnail ? THUMBNAIL_WIDTH : ICON_SIZE}
>
<img src={props.details.thumbnail ?? props.details.icon} />
</IconWrapper>
<ThumbnailWrapper height={THUMBNAIL_HEIGHT} width={THUMBNAIL_WIDTH}>
<img src={props.details.thumbnail} />
</ThumbnailWrapper>
<Text kind="body-s">{props.details.displayName}</Text>
{props.details.isBeta && <BetaLabel>Beta</BetaLabel>}
</Wrapper>
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [99-112]

Simplifying the className logic enhances readability. However, ensure that the closing brace } in the className string is removed as it seems to be a typo.

-  const className = `t--widget-card-draggable t--widget-card-draggable-${type}
-  }`;
+  const className = `t--widget-card-draggable t--widget-card-draggable-${type}`;

Comment on lines +85 to +88
thumbnail:
buildingBlock.screenshotUrls.length > 1
? buildingBlock.screenshotUrls[1]
: buildingBlock.screenshotUrls[0],
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of the thumbnail field in the getBuildingBlockExplorerCards selector duplicates the logic used for the icon field. Consider refactoring to avoid code duplication and ensure consistency in thumbnail selection across different parts of the application.

-        thumbnail:
-          buildingBlock.screenshotUrls.length > 1
-            ? buildingBlock.screenshotUrls[1]
-            : buildingBlock.screenshotUrls[0],

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.

Suggested change
thumbnail:
buildingBlock.screenshotUrls.length > 1
? buildingBlock.screenshotUrls[1]
: buildingBlock.screenshotUrls[0],

Copy link

github-actions bot commented Apr 4, 2024

Deploy-Preview-URL: https://ce-32211.dp.appsmith.com

Copy link
Contributor

Choose a reason for hiding this comment

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

@jacquesikot You selected the wrong layout to export the thumbnail. The thumbnail should be square with 1px compensator at the bottom. Compare this with wds thumbnails.

@jacquesikot jacquesikot added the ok-to-test Required label for CI label Apr 8, 2024
@jsartisan
Copy link
Contributor

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Apr 8, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/8599073836.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 32211.
recreate: .

Copy link

github-actions bot commented Apr 8, 2024

Deploy-Preview-URL: https://ce-32211.dp.appsmith.com

@jacquesikot jacquesikot merged commit 0a5130c into release Apr 9, 2024
41 checks passed
@jacquesikot jacquesikot deleted the feat/new-widget-card branch April 9, 2024 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request ok-to-test Required label for CI Templates Product Issues related to Templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Enhancing Widget Card Design
4 participants