-
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
Merged
Merged
fix: stickers panel #553
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,16 +111,22 @@ function StickerGrid({ | |
| icons, | ||
| onAdd, | ||
| addingSticker, | ||
| capSize = false, | ||
| }: { | ||
| icons: string[]; | ||
| onAdd: (iconName: string) => void; | ||
| addingSticker: string | null; | ||
| capSize?: boolean; | ||
| }) { | ||
| return ( | ||
| <div | ||
| className="grid gap-2" | ||
| style={{ | ||
| gridTemplateColumns: "repeat(auto-fill, 112px)", | ||
| 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) : {}), | ||
| }} | ||
| > | ||
| {icons.map((iconName) => ( | ||
|
|
@@ -129,6 +135,7 @@ function StickerGrid({ | |
| iconName={iconName} | ||
| onAdd={onAdd} | ||
| isAdding={addingSticker === iconName} | ||
| capSize={capSize} | ||
| /> | ||
| ))} | ||
| </div> | ||
|
|
@@ -148,7 +155,7 @@ function CollectionGrid({ | |
| onSelectCollection: (prefix: string) => void; | ||
| }) { | ||
| return ( | ||
| <div className="grid grid-cols-1 gap-2 h-full overflow-hidden"> | ||
| <div className="grid grid-cols-1 gap-2"> | ||
| {collections.map((collection) => ( | ||
| <CollectionItem | ||
| key={collection.prefix} | ||
|
|
@@ -198,6 +205,7 @@ function StickersContentView({ category }: { category: StickerCategory }) { | |
| searchStickers, | ||
| downloadSticker, | ||
| clearRecentStickers, | ||
| setSelectedCategory, | ||
| } = useStickersStore(); | ||
|
Comment on lines
206
to
209
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Good integration of setSelectedCategory; add
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 |
||
|
|
||
| const [addingSticker, setAddingSticker] = useState<string | null>(null); | ||
|
|
@@ -355,15 +363,23 @@ function StickersContentView({ category }: { category: StickerCategory }) { | |
|
|
||
| return ( | ||
| <div className="flex flex-col gap-5 mt-1 h-full"> | ||
| <div className="space-y-3"> | ||
| <div className="space-y-3 pl-2"> | ||
| <InputWithBack | ||
| isExpanded={isInCollection} | ||
| setIsExpanded={(expanded) => { | ||
| if (!expanded && isInCollection) { | ||
| setSelectedCollection(null); | ||
| } | ||
| }} | ||
| placeholder="Search icons..." | ||
| placeholder={ | ||
| category === "all" | ||
| ? "Search all stickers" | ||
| : category === "general" | ||
| ? "Search icons" | ||
| : category === "brands" | ||
| ? "Search brands" | ||
| : "Search Emojis" | ||
| } | ||
| value={localSearchQuery} | ||
| onChange={setLocalSearchQuery} | ||
| /> | ||
|
|
@@ -375,7 +391,7 @@ function StickersContentView({ category }: { category: StickerCategory }) { | |
| ref={scrollAreaRef} | ||
| onScrollCapture={handleScroll} | ||
| > | ||
| <div className="flex flex-col gap-4 h-full"> | ||
| <div className="flex flex-col gap-4 h-full px-2"> | ||
| {recentStickers.length > 0 && viewMode === "browse" && ( | ||
| <div className="h-full"> | ||
| <div className="flex items-center gap-2 mb-2"> | ||
|
|
@@ -401,6 +417,7 @@ function StickersContentView({ category }: { category: StickerCategory }) { | |
| icons={recentStickers.slice(0, 12)} | ||
| onAdd={handleAddSticker} | ||
| addingSticker={addingSticker} | ||
| capSize | ||
| /> | ||
| </div> | ||
| )} | ||
|
|
@@ -442,12 +459,32 @@ function StickersContentView({ category }: { category: StickerCategory }) { | |
| icons={iconsToDisplay} | ||
| onAdd={handleAddSticker} | ||
| addingSticker={addingSticker} | ||
| capSize | ||
| /> | ||
| </> | ||
| ) : searchQuery ? ( | ||
| <EmptyView | ||
| message={`No stickers found for "${searchQuery}"`} | ||
| /> | ||
| <div className="flex flex-col items-center justify-center py-8 gap-3"> | ||
| <EmptyView | ||
| message={`No stickers found for "${searchQuery}"`} | ||
| /> | ||
| {category !== "all" && ( | ||
| <Button | ||
| variant="outline" | ||
| onClick={() => { | ||
| const q = localSearchQuery || searchQuery; | ||
| if (q) { | ||
| setSearchQuery(q); | ||
| } | ||
| setSelectedCategory("all"); | ||
| if (q) { | ||
| searchStickers(q); | ||
| } | ||
| }} | ||
| > | ||
| Search in all icons | ||
| </Button> | ||
| )} | ||
| </div> | ||
| ) : null} | ||
| </div> | ||
| )} | ||
|
|
@@ -525,9 +562,10 @@ interface StickerItemProps { | |
| iconName: string; | ||
| onAdd: (iconName: string) => void; | ||
| isAdding?: boolean; | ||
| capSize?: boolean; | ||
| } | ||
|
|
||
| function StickerItem({ iconName, onAdd, isAdding }: StickerItemProps) { | ||
| function StickerItem({ iconName, onAdd, isAdding, capSize = false }: StickerItemProps) { | ||
| const [imageError, setImageError] = useState(false); | ||
| const [hostIndex, setHostIndex] = useState(0); | ||
|
|
||
|
|
@@ -561,6 +599,11 @@ function StickerItem({ iconName, onAdd, isAdding }: StickerItemProps) { | |
| width={64} | ||
| height={64} | ||
| className="w-full h-full object-contain" | ||
| style={ | ||
| capSize | ||
| ? { maxWidth: "var(--sticker-max, 160px)", maxHeight: "var(--sticker-max, 160px)" } | ||
| : undefined | ||
| } | ||
| onError={() => { | ||
| const next = hostIndex + 1; | ||
| if (next < ICONIFY_HOSTS.length) { | ||
|
|
@@ -598,6 +641,7 @@ function StickerItem({ iconName, onAdd, isAdding }: StickerItemProps) { | |
| rounded={true} | ||
| variant="card" | ||
| className="" | ||
| containerClassName="w-full" | ||
| isDraggable={false} | ||
| /> | ||
| {isAdding && ( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 anytype casting, bypassing TypeScript's type safety when a proper typed approach is available in the codebase.View Details
📝 Patch Details
Analysis
The code uses
as anytype casting for CSS custom properties on lines 128-129: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 asReact.CSSProperties. Theas anycasting bypasses TypeScript's type checking and could hide potential issues, while theReact.CSSPropertiesapproach 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 anycastings and instead cast the entire style object asReact.CSSProperties, following the pattern used elsewhere in the codebase: