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

[WEB-4144] Tweak unavailable product styling on ProductTile #627

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

jamiehenson
Copy link
Member

@jamiehenson jamiehenson commented Jan 31, 2025

  • Tweaks the styling behaviour of ProductTiles for unavailable products, i.e. LiveObjects.
  • Adds a story to showcase static cards, i.e. ones that don't have a controller selected prop

Summary by CodeRabbit

  • Package Version

    • Updated package version from 15.3.4 to 15.3.5
  • Product Tile Improvements

    • Enhanced dynamic styling for product labels
    • Refined conditional rendering logic for product tile states
  • Documentation

    • Added new story for static product tiles
    • Updated storybook descriptions for better clarity on component usage

Copy link
Contributor

coderabbitai bot commented Jan 31, 2025

Walkthrough

This pull request involves a minor version update to the @ably/ui package from version 15.3.4 to 15.3.5. The changes include updates to the ProductLabel component's styling logic in the ProductTile component and enhancements to the component's storybook documentation. The modifications refine the dynamic styling and class name conditions while adding a new story to demonstrate static product tile rendering.

Changes

File Change Summary
package.json Version updated from "15.3.4" to "15.3.5"
src/core/ProductTile/ProductLabel.tsx - Added dynamicFontSize variable calculated from numericalSize
- Updated font size and padding styles for unavailable products
- Refined conditional logic for class names based on selected and unavailable states
src/core/ProductTile/ProductTile.stories.tsx - Added new StaticProductTiles story
- Updated descriptions for existing stories
- Enhanced documentation for selected prop usage

Assessment against linked issues

Objective Addressed Explanation
Update product identities in live components [WEB-4144] Insufficient context to fully determine objective completion

Possibly related PRs

Suggested labels

review

Suggested reviewers

  • aralovelace
  • kennethkalmer

Poem

🐰 A version hop, a tiny leap,
UI components now more neat,
Styling refined with rabbit's care,
Product tiles dancing everywhere,
CodeRabbit's magic, soft and sweet! 🎨


🪧 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.

Copy link
Contributor

@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

🧹 Nitpick comments (2)
src/core/ProductTile/ProductLabel.tsx (2)

32-38: Consider using CSS variables for dynamic values.

The inline styles for font size and padding could be moved to CSS variables for better maintainability and consistency.

-            style={{
-              fontSize: dynamicFontSize * 0.6,
-              padding: `${dynamicFontSize * 0.25}px ${dynamicFontSize * 0.5}px`,
-            }}
+            style={{
+              '--dynamic-font-size': `${dynamicFontSize}px`,
+            }}
+            className="[font-size:calc(var(--dynamic-font-size)*0.6)] [padding:calc(var(--dynamic-font-size)*0.25)_calc(var(--dynamic-font-size)*0.5)]"

62-73: Consider using an enum or constant for selected states.

The explicit checks for selected === true, selected === false, and selected === undefined could be simplified using an enum or constant to make the code more maintainable.

+const SelectedState = {
+  SELECTED: true,
+  UNSELECTED: false,
+  STATIC: undefined,
+} as const;

 {
-  "text-neutral-000 dark:text-neutral-1300":
-    selected === true && !unavailable,
+  "text-neutral-000 dark:text-neutral-1300":
+    selected === SelectedState.SELECTED && !unavailable,
 },
 {
-  "text-neutral-1000 dark:text-neutral-300":
-    selected === false && !unavailable,
+  "text-neutral-1000 dark:text-neutral-300":
+    selected === SelectedState.UNSELECTED && !unavailable,
 },
 {
-  "text-neutral-1300 dark:text-neutral-000":
-    selected === undefined && !unavailable,
+  "text-neutral-1300 dark:text-neutral-000":
+    selected === SelectedState.STATIC && !unavailable,
 },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7d11ce2 and 71374bd.

⛔ Files ignored due to path filters (1)
  • src/core/ProductTile/__snapshots__/ProductTile.stories.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • package.json (1 hunks)
  • src/core/ProductTile/ProductLabel.tsx (2 hunks)
  • src/core/ProductTile/ProductTile.stories.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🔇 Additional comments (4)
src/core/ProductTile/ProductLabel.tsx (2)

26-27: LGTM! Good refactoring.

Extracting the font size calculation into a reusable variable improves code readability and maintainability.


45-50: LGTM! Clear conditional styling.

The conditional class names for selected state are well-structured and easy to understand.

src/core/ProductTile/ProductTile.stories.tsx (2)

33-37: LGTM! Clear documentation update.

The updated description clearly explains the requirement for controlling the selected prop.


39-54: LGTM! Good addition of static tiles story.

The new story effectively demonstrates the default styling when selected is not controlled. The description is clear and helpful.

Copy link
Contributor

@aralovelace aralovelace left a comment

Choose a reason for hiding this comment

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

looks working for me, I just had 2 feedback, let me know what you think.

src/core/ProductTile/ProductLabel.tsx Show resolved Hide resolved
src/core/ProductTile/ProductTile.stories.tsx Show resolved Hide resolved
Copy link
Contributor

@aralovelace aralovelace left a comment

Choose a reason for hiding this comment

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

Thanks for the clarification and noted.

@jamiehenson jamiehenson merged commit d1c9f32 into main Jan 31, 2025
4 checks passed
@jamiehenson jamiehenson deleted the idents-touchup branch January 31, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants