feat: clarify ambiguous ux

This commit is contained in:
Ananth Venkatesh 2025-02-13 00:11:07 -05:00
parent c3c0a908a2
commit c8c799572f
Signed by: ananthv
GPG key ID: 4BB578E748CFE4FF
3 changed files with 21 additions and 14 deletions

View file

@ -1,4 +1,4 @@
port module Clipboard exposing (copyToClipboard)
port copyToClipboard : String -> Cmd msg
port copyToClipboard : ( String, String ) -> Cmd msg

View file

@ -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
, 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")
, 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")
, btn "Copy iCal link" (Copy "iCal link" "https://calendar.google.com/calendar/ical/c_c9fb13003264d5becb74cf9ba42a087d8a4a180d927441994458a07ac146eb88%40group.calendar.google.com/public/basic.ics")
]
]
]
)

View file

@ -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) => {