Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ import { UserCoin } from '@/layouts/setting/tabs/account/components/user-coin'
import { useLazyLoad } from '@/layouts/setting/tabs/wallpapers/hooks/use-lazy-load'
import type { GalleryAsset } from '@/services/hooks/gallery/get-gallery-assets.hook'

interface GalleryPinterestItemProps {
interface GalleryPhotoItemProps {
asset: GalleryAsset
isSelected: boolean
onClick: () => void
}

export function GalleryPinterestItem({
asset,
isSelected,
onClick,
}: GalleryPinterestItemProps) {
export function GalleryPhotoItem({ asset, isSelected, onClick }: GalleryPhotoItemProps) {
const [loaded, setLoaded] = useState(false)
const [error, setError] = useState(false)
const imgRef = useRef<HTMLImageElement>(null)
Expand All @@ -39,13 +35,13 @@ export function GalleryPinterestItem({
className={`break-inside-avoid relative rounded-2xl cursor-pointer group overflow-hidden bg-base-200/50 ${itemOutlineStyle} transition-all duration-200 active:scale-98`}
>
{!loaded && (
<div className="flex items-center justify-center w-full min-h-40 bg-base-300">
<div className="flex items-center justify-center w-full min-h-28 bg-base-300/30">
<div className="w-5 h-5 border-2 rounded-full border-primary/30 border-t-primary animate-spin" />
</div>
)}

{error && (
<div className="flex flex-col items-center justify-center w-full min-h-35 bg-error/10">
<div className="flex flex-col items-center justify-center w-full min-h-28 bg-error/10">
<Icon name="alert" className="text-error" />
<p className="mt-1 text-[10px] text-muted">خطا در بارگذاری</p>
</div>
Expand Down
20 changes: 10 additions & 10 deletions src/components/gallery/gallery-picker-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
type GalleryAssetType,
} from '@/services/hooks/gallery/get-gallery-assets.hook'
import { GalleryAssetPurchaseModal } from './gallery-asset-purchase-modal'
import { GalleryPinterestItem } from './gallery-pinterest-item'
import { GalleryPhotoItem } from './gallery-photo-item'
import { GalleryBookmarkIconItem } from './gallery-bookmark-icon-item'

interface GalleryPickerModalProps {
Expand Down Expand Up @@ -93,7 +93,7 @@ export function GalleryPickerModal({
direction="rtl"
closeOnBackdropClick={true}
>
<div className="flex flex-col w-full gap-4 p-1">
<div className="flex flex-col w-full gap-4 p-1 h-[70vh]">
{categories.length > 0 && (
<div className="flex items-center gap-1.5 overflow-y-hidden h-12 overflow-x-auto no-scrollbar">
<Chip
Expand All @@ -116,14 +116,14 @@ export function GalleryPickerModal({
</div>
)}

<div className="flex-1 pr-1 overflow-y-auto">
<div className="flex-1 pr-1">
{isLoading ? (
type === 'BOOKMARK_ICON' ? (
type === 'BOOKMARK_ICON' || type === 'AVATAR' ? (
<div className="grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5">
{[...Array(10)].map((_, idx) => (
{[...Array(15)].map((_, idx) => (
<div
key={idx}
className="w-full aspect-square rounded-2xl bg-base-300 animate-pulse"
className="w-full aspect-square rounded-2xl skeleton"
/>
))}
</div>
Expand All @@ -132,9 +132,9 @@ export function GalleryPickerModal({
{[...Array(8)].map((_, idx) => (
<div
key={idx}
className="w-full rounded-2xl bg-base-300 animate-pulse break-inside-avoid"
className="w-full rounded-2xl skeleton break-inside-avoid"
style={{
height: `${(idx % 3) * 60 + 160}px`,
height: `${(idx % 3) * 35 + 110}px`,
}}
/>
))}
Expand All @@ -149,7 +149,7 @@ export function GalleryPickerModal({
/>
<p className="text-sm font-medium">هیچ تصویری پیدا نشد</p>
</div>
) : type === 'BOOKMARK_ICON' ? (
) : type === 'BOOKMARK_ICON' || type === 'AVATAR' ? (
<div className="grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5">
{assets.map((asset) => (
<GalleryBookmarkIconItem
Expand All @@ -163,7 +163,7 @@ export function GalleryPickerModal({
) : (
<div className="gap-3 space-y-3 columns-2 sm:columns-3 md:columns-4">
{assets.map((asset) => (
<GalleryPinterestItem
<GalleryPhotoItem
key={asset.id}
asset={asset}
isSelected={selectedAssetId === asset.id}
Expand Down
2 changes: 1 addition & 1 deletion src/components/gallery/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './gallery-picker-modal'
export * from './gallery-asset-purchase-modal'
export * from './gallery-pinterest-item'
export * from './gallery-photo-item'
export * from './gallery-bookmark-icon-item'
Loading