-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix: stickers panel #553
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: stickers panel #553
Conversation
👷 Deploy request for appcut pending review.Visit the deploys page to approve it
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughIntroduces a capSize layout mode for sticker grids/items, adds containerClassName customization to DraggableMediaItem, updates styling/padding, enhances sticker search with dynamic placeholders and an “Search in all icons” action, and integrates setSelectedCategory from the stickers store to switch categories programmatically. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant StickersContentView
participant StickersStore
participant StickerGrid
participant StickerItem
participant DraggableMediaItem
User->>StickersContentView: Type search / select category
StickersContentView->>StickersStore: get selectedCategory, setSelectedCategory?
alt capSize enabled
StickersContentView->>StickerGrid: render({ capSize: true })
StickerGrid->>StickerItem: render({ capSize: true })
StickerItem->>DraggableMediaItem: render({ containerClassName: "w-full", ... })
else capSize disabled
StickersContentView->>StickerGrid: render({ capSize: false })
StickerGrid->>StickerItem: render({ capSize: false })
end
sequenceDiagram
actor User
participant StickersContentView
participant StickersStore
participant SearchService
User->>StickersContentView: Click "Search in all icons"
StickersContentView->>StickersStore: setSelectedCategory("all")
StickersContentView->>SearchService: query across all categories
SearchService-->>StickersContentView: results
StickersContentView-->>User: Render results with updated placeholder
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@enkeii64 is attempting to deploy a commit to the OpenCut OSS Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
apps/web/src/components/ui/draggable-item.tsx (1)
140-146: Consider supporting containerClassName in the “compact” variant for API consistencyMinor API polish: letting consumers override the outer container class in both variants keeps the prop behavior consistent and future-proofs layout tweaks in list views.
Apply this diff:
- <div ref={dragRef} className="relative group w-full"> + <div + ref={dragRef} + className={cn("relative group w-full", containerClassName)} + >apps/web/src/components/editor/media-panel/views/stickers.tsx (2)
114-131: Removeas anyin inline styles; use CSS variables directly in style objectYou can set CSS custom properties in the style object without the
as anyescape hatch. This avoids the any type and aligns with our TS guidelines.Apply this diff:
style={{ - gridTemplateColumns: capSize - ? "repeat(auto-fill, minmax(var(--sticker-min, 96px), var(--sticker-max, 160px)))" - : "repeat(auto-fit, minmax(var(--sticker-min, 96px), 1fr))", - ["--sticker-min" as any]: "96px", - ...(capSize ? ({ ["--sticker-max"]: "160px" } as any) : {}), + gridTemplateColumns: capSize + ? "repeat(auto-fill, minmax(var(--sticker-min, 96px), var(--sticker-max, 160px)))" + : "repeat(auto-fit, minmax(var(--sticker-min, 96px), 1fr))", + "--sticker-min": "96px", + ...(capSize ? { "--sticker-max": "160px" } : {}), }}
366-386: Nit: uncapitalize “Emojis” in the placeholder for consistencyOther placeholders use sentence case (“icons”, “brands”). Keep “emojis” consistent.
Apply this diff:
placeholder={ category === "all" ? "Search all stickers" : category === "general" ? "Search icons" : category === "brands" ? "Search brands" - : "Search Emojis" + : "Search emojis" }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
apps/web/src/components/editor/media-panel/views/stickers.tsx(11 hunks)apps/web/src/components/ui/draggable-item.tsx(3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.{jsx,tsx}: Don't useaccessKeyattribute on any HTML element.
Don't setaria-hidden="true"on focusable elements.
Don't add ARIA roles, states, and properties to elements that don't support them.
Don't use distracting elements like<marquee>or<blink>.
Only use thescopeprop on<th>elements.
Don't assign non-interactive ARIA roles to interactive HTML elements.
Make sure label elements have text content and are associated with an input.
Don't assign interactive ARIA roles to non-interactive HTML elements.
Don't assigntabIndexto non-interactive HTML elements.
Don't use positive integers fortabIndexproperty.
Don't include "image", "picture", or "photo" in img alt prop.
Don't use explicit role property that's the same as the implicit/default role.
Make static elements with click handlers use a valid role attribute.
Always include atitleelement for SVG elements.
Give all elements requiring alt text meaningful information for screen readers.
Make sure anchors have content that's accessible to screen readers.
AssigntabIndexto non-interactive HTML elements witharia-activedescendant.
Include all required ARIA attributes for elements with ARIA roles.
Make sure ARIA properties are valid for the element's supported roles.
Always include atypeattribute for button elements.
Make elements with interactive roles and handlers focusable.
Give heading elements content that's accessible to screen readers (not hidden witharia-hidden).
Always include alangattribute on the html element.
Always include atitleattribute for iframe elements.
AccompanyonClickwith at least one of:onKeyUp,onKeyDown, oronKeyPress.
AccompanyonMouseOver/onMouseOutwithonFocus/onBlur.
Include caption tracks for audio and video elements.
Use semantic elements instead of role attributes in JSX.
Make sure all anchors are valid and navigable.
Ensure all ARIA properties (aria-*) are valid.
Use valid, non-abstract ARIA roles for elements with...
Files:
apps/web/src/components/ui/draggable-item.tsxapps/web/src/components/editor/media-panel/views/stickers.tsx
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Don't use TypeScript enums.
Don't export imported variables.
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
Don't use TypeScript namespaces.
Don't use non-null assertions with the!postfix operator.
Don't use parameter properties in class constructors.
Don't use user-defined types.
Useas constinstead of literal types and type annotations.
Use eitherT[]orArray<T>consistently.
Initialize each enum member value explicitly.
Useexport typefor types.
Useimport typefor types.
Make sure all enum members are literal values.
Don't use TypeScript const enum.
Don't declare empty interfaces.
Don't let variables evolve into any type through reassignments.
Don't use the any type.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use implicit any type on variable declarations.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use the TypeScript directive @ts-ignore.
Use consistent accessibility modifiers on class properties and methods.
Use function types instead of object types with call signatures.
Don't use void type outside of generic or return types.
**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
Use either T[] or Array consistently
Don't use the any type
Files:
apps/web/src/components/ui/draggable-item.tsxapps/web/src/components/editor/media-panel/views/stickers.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.{js,jsx,ts,tsx}: Don't use the return value of React.render.
Don't use consecutive spaces in regular expression literals.
Don't use theargumentsobject.
Don't use primitive type aliases or misleading types.
Don't use the comma operator.
Don't write functions that exceed a given Cognitive Complexity score.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use uselessthisaliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names that aren't base 10 or use underscore separators.
Remove redundant terms from logical expressions.
Use while loops instead of...
Files:
apps/web/src/components/ui/draggable-item.tsxapps/web/src/components/editor/media-panel/views/stickers.tsx
**/*.{tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)
**/*.{tsx,jsx}: Always include a title element for icons unless there's text beside the icon
Always include a type attribute for button elements
Accompany onClick with at least one of: onKeyUp, onKeyDown, or onKeyPress
Accompany onMouseOver/onMouseOut with onFocus/onBlur
Don't import React itself
Don't define React components inside other components
Don't use both children and dangerouslySetInnerHTML on the same element
Don't insert comments as text nodes
Use <>...</> instead of ...
Files:
apps/web/src/components/ui/draggable-item.tsxapps/web/src/components/editor/media-panel/views/stickers.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/ultracite.mdc)
**/*.{ts,tsx,js,jsx}: Don't use the comma operator
Use for...of statements instead of Array.forEach
Don't initialize variables to undefined
Use .flatMap() instead of map().flat() when possible
Don't assign a value to itself
Avoid unused imports and variables
Don't use await inside loops
Don't hardcode sensitive data like API keys and tokens
Don't use the delete operator
Don't use global eval()
Use String.slice() instead of String.substr() and String.substring()
Don't use else blocks when the if block breaks early
Put default function parameters and optional function parameters last
Use new when throwing an error
Use String.trimStart() and String.trimEnd() over String.trimLeft() and String.trimRight()
Files:
apps/web/src/components/ui/draggable-item.tsxapps/web/src/components/editor/media-panel/views/stickers.tsx
🧬 Code Graph Analysis (2)
apps/web/src/components/ui/draggable-item.tsx (6)
apps/web/src/lib/utils.ts (1)
cn(6-8)apps/web/src/components/ui/card.tsx (5)
props(20-26)props(56-58)props(32-38)props(8-14)props(44-50)apps/web/src/components/ui/drawer.tsx (2)
props(58-66)props(69-77)apps/web/src/components/ui/resizable.tsx (1)
props(7-18)apps/web/src/components/ui/dialog.tsx (1)
props(67-78)apps/web/src/components/ui/hover-card.tsx (1)
props(15-26)
apps/web/src/components/editor/media-panel/views/stickers.tsx (1)
apps/web/src/components/ui/input-with-back.tsx (1)
InputWithBack(17-86)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Vade Review
🔇 Additional comments (5)
apps/web/src/components/ui/draggable-item.tsx (2)
24-24: LGTM: New containerClassName prop is backward-compatible and scoped to the card variantDefault remains unchanged when omitted. The prop gives the stickers view precise width control without disturbing existing consumers.
Also applies to: 40-41
100-103: Container class fallback behavior looks correct for the new layout needsUsing containerClassName ?? "w-28 h-28" preserves the old fixed size unless an override is provided (e.g., w-full from stickers). This is the right trade-off to allow cap-based sizing.
apps/web/src/components/editor/media-panel/views/stickers.tsx (3)
158-168: LGTM: One-column collections gridThe switch to a single-column grid improves readability and aligns with the “All collections” scroll behavior.
420-421: LGTM: capSize usage yields consistent item sizing in recents and search resultsThe grid + item constraints, combined with containerClassName="w-full", produce a clean, predictable layout across varying panel widths.
Also applies to: 459-463
568-569: StickerItem capSize plumbing looks solid
- Prop threading to the image style is correct; the CSS variable is defined at the grid level and inherited.
- Forcing DraggableMediaItem container to w-full aligns with the capped sizing model.
Also applies to: 602-606, 645-645
| downloadSticker, | ||
| clearRecentStickers, | ||
| setSelectedCategory, | ||
| } = useStickersStore(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Good integration of setSelectedCategory; add type="button" and align wording with “All Collections”
- The store setter is correctly wired to enable switching to the All tab.
- Add
type="button"to the new Button to satisfy the button-type guideline and avoid accidental form submission if placed inside a form. - Optional: Align the CTA text with the PR language (“All Collections”) for consistency.
Apply this diff:
- {category !== "all" && (
+ {category !== "all" && (
<Button
variant="outline"
+ type="button"
onClick={() => {
const q = localSearchQuery || searchQuery;
if (q) {
setSearchQuery(q);
}
setSelectedCategory("all");
if (q) {
searchStickers(q);
}
}}
>
- Search in all icons
+ Search in all collections
</Button>
)}Also applies to: 470-486
🤖 Prompt for AI Agents
In apps/web/src/components/editor/media-panel/views/stickers.tsx around lines
206-209 (and similarly at lines 470-486), the new Button that triggers
setSelectedCategory is missing an explicit type and the CTA text differs from
the PR language; update the Button element(s) to include type="button" to
prevent accidental form submission and change the button label text to "All
Collections" to match the PR wording, preserving the existing onClick handler
that calls setSelectedCategory.
| ["--sticker-min" as any]: "96px", | ||
| ...(capSize ? ({ ["--sticker-max"]: "160px" } as any) : {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CSS custom properties are using as any type casting, bypassing TypeScript's type safety when a proper typed approach is available in the codebase.
View Details
📝 Patch Details
diff --git a/apps/web/src/components/editor/media-panel/views/stickers.tsx b/apps/web/src/components/editor/media-panel/views/stickers.tsx
index 7d3e073..e4ddcef 100644
--- a/apps/web/src/components/editor/media-panel/views/stickers.tsx
+++ b/apps/web/src/components/editor/media-panel/views/stickers.tsx
@@ -125,9 +125,9 @@ function StickerGrid({
gridTemplateColumns: capSize
? "repeat(auto-fill, minmax(var(--sticker-min, 96px), var(--sticker-max, 160px)))"
: "repeat(auto-fit, minmax(var(--sticker-min, 96px), 1fr))",
- ["--sticker-min" as any]: "96px",
- ...(capSize ? ({ ["--sticker-max"]: "160px" } as any) : {}),
- }}
+ "--sticker-min": "96px",
+ ...(capSize ? { "--sticker-max": "160px" } : {}),
+ } as React.CSSProperties}
>
{icons.map((iconName) => (
<StickerItem
Analysis
The code uses as any type casting for CSS custom properties on lines 128-129:
[\"--sticker-min\" as any]: \"96px\",
...(capSize ? ({ [\"--sticker-max\"]: \"160px\" } as any) : {}),However, examining other files in the codebase (like sidebar.tsx), there's a more type-safe pattern being used where CSS custom properties are properly typed by casting the entire style object as React.CSSProperties. The as any casting bypasses TypeScript's type checking and could hide potential issues, while the React.CSSProperties approach maintains type safety for the style object structure.
This inconsistency in typing patterns could lead to maintenance issues and reduced type safety across the codebase.
Recommendation
Remove the individual as any castings and instead cast the entire style object as React.CSSProperties, following the pattern used elsewhere in the codebase:
style={{
gridTemplateColumns: capSize
? "repeat(auto-fill, minmax(var(--sticker-min, 96px), var(--sticker-max, 160px)))"
: "repeat(auto-fit, minmax(var(--sticker-min, 96px), 1fr))",
"--sticker-min": "96px",
...(capSize ? { "--sticker-max": "160px" } : {}),
} as React.CSSProperties}
Description
Nothing was broken to be "unusable", but improvements have been made:
Fixes # (issue)
None.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Screenshots (if applicable)
Checklist:
Additional context
None.