@@ -212,13 +212,42 @@ defmodule Money.Input.Visualizer.InputView do
212212 "<p class=\" mi-desc\" >The HEEx call site that renders the money_input above. " ,
213213 "Tweak the form controls and the code refreshes — copy straight into a " ,
214214 "LiveView template.</p>" ,
215- "<pre class=\" mi-code\" >" ,
215+ "<div class=\" mi-code-wrap\" >" ,
216+ "<pre class=\" mi-code\" id=\" money-input-heex\" >" ,
216217 Render . escape ( money_code ) ,
217218 "</pre>" ,
219+ copy_button ( "#money-input-heex" , "Copy HEEx call to clipboard" ) ,
220+ "</div>" ,
218221 "</section>"
219222 ]
220223 end
221224
225+ # Clipboard-icon button anchored to a `.mi-card`. The card itself
226+ # provides the positioning context; the script in render.ex
227+ # handles the click via the `data-mi-copy-target` attribute.
228+ defp copy_button ( target_selector , label ) do
229+ [
230+ "<button type=\" button\" class=\" mi-copy-btn\" " ,
231+ "data-mi-copy-target=\" " ,
232+ Render . escape ( target_selector ) ,
233+ "\" aria-label=\" " ,
234+ Render . escape ( label ) ,
235+ "\" title=\" " ,
236+ Render . escape ( label ) ,
237+ "\" >" ,
238+ # Clipboard icon (visible at rest).
239+ "<svg class=\" mi-copy-icon-clipboard\" viewBox=\" 0 0 24 24\" aria-hidden=\" true\" >" ,
240+ "<rect x=\" 9\" y=\" 3\" width=\" 6\" height=\" 3\" rx=\" 1\" />" ,
241+ "<path d=\" M9 4.5H6.5A1.5 1.5 0 0 0 5 6v13.5A1.5 1.5 0 0 0 6.5 21h11a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H15\" />" ,
242+ "</svg>" ,
243+ # Checkmark icon (shown briefly after a successful copy).
244+ "<svg class=\" mi-copy-icon-check\" viewBox=\" 0 0 24 24\" aria-hidden=\" true\" >" ,
245+ "<polyline points=\" 5 12 10 17 19 7\" />" ,
246+ "</svg>" ,
247+ "</button>"
248+ ]
249+ end
250+
222251 defp build_money_call ( locale , default_currency , picker , preferred ) do
223252 attrs =
224253 [
0 commit comments