{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "difficulty-adjustment", "title": "Difficulty adjustment", "description": "Difficulty epoch progress and projected change.", "registryDependencies": [ "dennisonbertram/bitcoin-ui/bitcoin-core", "dennisonbertram/bitcoin-ui/bitcoin-theme" ], "files": [ { "path": "components/bitcoin/difficulty-adjustment.tsx", "content": "import type { ComponentProps } from \"react\";\n\nimport { clampPercent, formatBlockHeight } from \"@/lib/bitcoin\";\nimport { componentClasses } from \"@/lib/utils\";\n\nimport { panelStyles, type BitcoinVisualProps } from \"./shared\";\n\nexport type DifficultyAdjustmentProps = Omit<\n ComponentProps<\"section\">,\n \"children\"\n> &\n BitcoinVisualProps & {\n currentHeight: number;\n epochStartHeight: number;\n projectedChange: number;\n remainingBlocks: number;\n estimatedTime?: string;\n };\n\nexport function DifficultyAdjustment({\n currentHeight,\n epochStartHeight,\n projectedChange,\n remainingBlocks,\n estimatedTime,\n unstyled,\n className,\n ...props\n}: DifficultyAdjustmentProps) {\n const elapsedBlocks = Math.max(0, currentHeight - epochStartHeight);\n const percent = clampPercent((elapsedBlocks / 2_016) * 100);\n const changeLabel = `${projectedChange >= 0 ? \"+\" : \"\"}${projectedChange.toFixed(2)}%`;\n\n return (\n = 0 ? \"up\" : \"down\"}\n data-unstyled={unstyled || undefined}\n aria-label=\"Difficulty adjustment\"\n className={componentClasses(\n unstyled,\n [panelStyles, \"grid gap-5 p-5\"],\n className,\n )}\n {...props}\n >\n \n
\n \n Difficulty epoch\n \n \n Block {formatBlockHeight(currentHeight)}\n

\n
\n = 0\n ? \"text-[var(--color-success)]\"\n : \"text-[var(--color-danger)]\",\n ],\n )}\n >\n {changeLabel}\n \n \n \n \n \n \n {new Intl.NumberFormat(\"en-US\").format(remainingBlocks)} blocks left\n {estimatedTime ? Est. {estimatedTime} : null}\n \n \n );\n}\n", "type": "registry:component" } ], "type": "registry:component" }