From c8c799572f5caf43b780f95c2a37f0d08be81307 Mon Sep 17 00:00:00 2001 From: Ananth Venkatesh Date: Thu, 13 Feb 2025 00:11:07 -0500 Subject: [PATCH] feat: clarify ambiguous ux --- src/Clipboard.elm | 2 +- src/Main.elm | 26 +++++++++++++++----------- src/index.html | 7 +++++-- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/Clipboard.elm b/src/Clipboard.elm index 5097b8c..00d5525 100644 --- a/src/Clipboard.elm +++ b/src/Clipboard.elm @@ -1,4 +1,4 @@ port module Clipboard exposing (copyToClipboard) -port copyToClipboard : String -> Cmd msg +port copyToClipboard : ( String, String ) -> Cmd msg diff --git a/src/Main.elm b/src/Main.elm index a7b5494..788f4c5 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -97,7 +97,7 @@ type Msg | GotMesh (Result Http.Error Object3d) | GotTexture (Result WebGL.Texture.Error (Material.Texture Color.Color)) | Rotate Time.Posix - | Copy String + | Copy String String | Key String | Scroll String @@ -150,8 +150,8 @@ update msg model = Rotate time -> wrap { model | angle = canonicalize (model.angle + 2 * (2 + sin (toFloat (Time.posixToMillis time) / 1000))) } - Copy text -> - ( model, copyToClipboard text ) + Copy label text -> + ( model, copyToClipboard ( label, text ) ) Key key -> ( { model | last = key }, Cmd.none ) @@ -359,16 +359,20 @@ view model = ++ heading ) (column - [ spacing 20 + [ spacing 35 ] [ text "MacGregor House" - , row - [ spacing 20 - ] - [ btn "↓" (Scroll "one") - , linkBtn "Events" "https://calendar.google.com/calendar/embed?src=c_c9fb13003264d5becb74cf9ba42a087d8a4a180d927441994458a07ac146eb88%40group.calendar.google.com&ctz=America%2FNew_York" - , linkBtn "Space" "https://forms.gle/KxFAG65TQuPxdYak8" - , btn "iCal" (Copy "https://calendar.google.com/calendar/ical/c_c9fb13003264d5becb74cf9ba42a087d8a4a180d927441994458a07ac146eb88%40group.calendar.google.com/public/basic.ics") + , column [ spacing 15 ] + [ row + [ spacing 15 + ] + [ linkBtn "See events" "https://calendar.google.com/calendar/embed?src=c_c9fb13003264d5becb74cf9ba42a087d8a4a180d927441994458a07ac146eb88%40group.calendar.google.com&ctz=America%2FNew_York" + , linkBtn "Reserve space" "https://forms.gle/KxFAG65TQuPxdYak8" + ] + , row [ spacing 15 ] + [ btn "↓" (Scroll "one") + , btn "Copy iCal link" (Copy "iCal link" "https://calendar.google.com/calendar/ical/c_c9fb13003264d5becb74cf9ba42a087d8a4a180d927441994458a07ac146eb88%40group.calendar.google.com/public/basic.ics") + ] ] ] ) diff --git a/src/index.html b/src/index.html index 05625c4..453b42a 100644 --- a/src/index.html +++ b/src/index.html @@ -19,13 +19,16 @@ flags: [window.innerWidth, window.innerHeight], }); - app.ports.copyToClipboard.subscribe((text) => { - var textArea = document.createElement("textarea"); + app.ports.copyToClipboard.subscribe((tuple) => { + let label = tuple[0]; + let text = tuple[1]; + let textArea = document.createElement("textarea"); textArea.value = text; document.body.appendChild(textArea); textArea.select(); document.execCommand("copy"); document.body.removeChild(textArea); + alert(`Copied ${label} to clipboard`); }); app.ports.scrollTo.subscribe((id) => {