From 770290045ab705ae3a47dca58db864ce0b4e164b Mon Sep 17 00:00:00 2001 From: Samrath <102617759+samrathreddy@users.noreply.github.com> Date: Sat, 5 Jul 2025 00:20:29 +0530 Subject: [PATCH] feat: Converting empty state svg to component (#1562) --- .../mail/components/icons/empty-state-svg.tsx | 191 ++++++++++++++++++ apps/mail/components/mail/mail-list.tsx | 9 +- apps/mail/components/mail/thread-display.tsx | 8 +- 3 files changed, 195 insertions(+), 13 deletions(-) create mode 100644 apps/mail/components/icons/empty-state-svg.tsx diff --git a/apps/mail/components/icons/empty-state-svg.tsx b/apps/mail/components/icons/empty-state-svg.tsx new file mode 100644 index 000000000..ef2cd422a --- /dev/null +++ b/apps/mail/components/icons/empty-state-svg.tsx @@ -0,0 +1,191 @@ +import { useTheme } from 'next-themes'; + +interface EmptyStateSVGProps { + width?: number; + height?: number; + className?: string; +} + +interface EmptyStateBaseProps extends EmptyStateSVGProps { + isDarkTheme?: boolean; +} + +const EmptyStateBase = ({ width = 200, height = 200, className, isDarkTheme = true }: EmptyStateBaseProps) => { + // Theme-specific values + const viewBox = isDarkTheme ? "0 0 192 192" : "0 0 192 198"; + const bgFill = isDarkTheme ? "#141414" : "#FAFAFA"; + const bgOpacity = isDarkTheme ? "0.25" : "1"; + const borderColor = isDarkTheme ? "white" : "#DBDBDB"; + const borderOpacity = isDarkTheme ? "0.15" : "1"; + const borderWidth = isDarkTheme ? "1" : "0.5"; + + // Icon-specific elements - only light theme uses these + const filterElements = !isDarkTheme ? ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) : null; + + // Configure fill colors for elements + const clipFill = isDarkTheme ? "white" : "white"; + const envelopeLetterFill = isDarkTheme ? "white" : "#B0B0B0"; + const envelopeLetterOpacity = isDarkTheme ? "0.3" : "1"; + const lineColors = !isDarkTheme + ? ["#E7E7E7", "#F0F0F0", "#F6F6F6", "#FAFAFA"] + : [ + "white", "white", "white", "white" + ]; + const lineOpacities = isDarkTheme + ? ["0.1", "0.075", "0.05", "0.025"] + : ["1", "1", "1", "1"]; + + // Paint definitions + const paint0Stop0Color = isDarkTheme ? "white" : "white"; + const paint0Stop0Opacity = isDarkTheme ? "0.1" : "1"; + const paint0Stop1Color = isDarkTheme ? "white" : "white"; + const paint0Stop1Opacity = isDarkTheme ? "0.05" : "1"; + + const paint1Stop0Color = "white"; + const paint1Stop0Opacity = "0.1"; + const paint1Stop1Color = "#323232"; + const paint1Stop1Opacity = "0"; + + const paint2Stop0Color = isDarkTheme ? "white" : "white"; + const paint2Stop0Opacity = isDarkTheme ? "0.1" : "1"; + const paint2Stop1Color = isDarkTheme ? "white" : "white"; + const paint2Stop1Opacity = isDarkTheme ? "0.05" : "1"; + + return ( + + {/* Main background circle */} + {isDarkTheme ? ( + + ) : ( + + )} + + {/* Border */} + {isDarkTheme ? ( + + ) : ( + + )} + + {/* Envelope shape - shadow layer */} + + + + + + {/* Main envelope */} + + + + + {/* Envelope details */} + + + + + + {/* Envelope content lines */} + + + + + + + {/* Envelope border */} + + + + {/* Gradients and clips */} + + {filterElements} + + {/* Gradients for coloring */} + + + + + + + + + + + + + + + + + + {/* Clip paths */} + + + + + + + + + ); +}; + +export const EmptyState = (props: EmptyStateSVGProps) => { + return ; +}; + +export const EmptyStateLight = (props: EmptyStateSVGProps) => { + return ; +}; + +export const EmptyStateIcon = ({ width = 200, height = 200, className }: EmptyStateSVGProps) => { + const { resolvedTheme } = useTheme(); + + // Explicitly check for 'dark' theme, use light theme as fallback for all other cases + return resolvedTheme === 'dark' ? ( + + ) : ( + + ); +}; \ No newline at end of file diff --git a/apps/mail/components/mail/mail-list.tsx b/apps/mail/components/mail/mail-list.tsx index ff53f96e9..3a508c15e 100644 --- a/apps/mail/components/mail/mail-list.tsx +++ b/apps/mail/components/mail/mail-list.tsx @@ -6,6 +6,7 @@ import { getMainSearchTerm, parseNaturalLanguageSearch, } from '@/lib/utils'; +import { EmptyStateIcon } from '../icons/empty-state-svg'; import { Archive2, ExclamationCircle, @@ -983,13 +984,7 @@ export const MailList = memo( ) : !items || items.length === 0 ? (
- Empty Inbox +

It's empty here

diff --git a/apps/mail/components/mail/thread-display.tsx b/apps/mail/components/mail/thread-display.tsx index e125ebf4b..976d6ad10 100644 --- a/apps/mail/components/mail/thread-display.tsx +++ b/apps/mail/components/mail/thread-display.tsx @@ -14,6 +14,7 @@ import { Trash, X, } from '../icons/icons'; +import { EmptyStateIcon } from '../icons/empty-state-svg'; import { DropdownMenu, DropdownMenuContent, @@ -752,12 +753,7 @@ export function ThreadDisplay() { {!id ? (

- Empty Thread +

It's empty here