UNPKG

bigblocks

Version:

Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React

15 lines 1.37 kB
{ "name": "social-utils-format", "type": "registry:component", "dependencies": [], "devDependencies": [], "registryDependencies": [], "files": [ { "path": "components/social/utils/format.ts", "type": "registry:component", "content": "// Social formatting utilities\n\n/**\n * Format a timestamp for social media display\n */\nexport function formatSocialTimestamp(timestamp: number): string {\n\tconst now = Date.now();\n\tconst diff = now - timestamp;\n\n\tconst minutes = Math.floor(diff / 60000);\n\tconst hours = Math.floor(diff / 3600000);\n\tconst days = Math.floor(diff / 86400000);\n\n\tif (minutes < 1) return \"now\";\n\tif (minutes < 60) return `${minutes}m`;\n\tif (hours < 24) return `${hours}h`;\n\tif (days < 7) return `${days}d`;\n\n\treturn new Date(timestamp).toLocaleDateString();\n}\n\n/**\n * Validate social content for posting\n */\nexport function validateSocialContent(\n\tcontent: string,\n\tmaxLength = 280,\n): { valid: boolean; message?: string } {\n\tif (!content || content.trim().length === 0) {\n\t\treturn { valid: false, message: \"Content cannot be empty\" };\n\t}\n\n\tif (content.length > maxLength) {\n\t\treturn { valid: false, message: `Content exceeds ${maxLength} characters` };\n\t}\n\n\treturn { valid: true };\n}\n", "target": "<%- config.aliases.components %>/format.tsx" } ] }