Skip to content

Commit 270c7d0

Browse files
chore: make cli-auth link visually responsive (#58)
1 parent 393d240 commit 270c7d0

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

Coder Desktop/Coder Desktop/Views/LoginForm.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ struct LoginForm<S: Session>: View {
131131
Text("Generate a session token at ")
132132
.font(.subheadline)
133133
.foregroundColor(.secondary)
134-
Link(cliAuthURL.absoluteString, destination: cliAuthURL)
135-
.font(.subheadline)
136-
.foregroundColor(.blue)
134+
ResponsiveLink(title: cliAuthURL.absoluteString, destination: cliAuthURL)
137135
}
138136
}
139137
}.formStyle(.grouped).scrollDisabled(true).padding(.horizontal)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import SwiftUI
2+
3+
struct ResponsiveLink: View {
4+
let title: String
5+
let destination: URL
6+
7+
@State private var isHovered = false
8+
@State private var isPressed = false
9+
@Environment(\.openURL) private var openURL
10+
11+
var body: some View {
12+
Text(title)
13+
.font(.subheadline)
14+
.foregroundColor(isPressed ? .red : .blue)
15+
.underline(isHovered, color: isPressed ? .red : .blue)
16+
.onHover { hovering in
17+
isHovered = hovering
18+
if hovering {
19+
NSCursor.pointingHand.push()
20+
} else {
21+
NSCursor.pop()
22+
}
23+
}
24+
.simultaneousGesture(
25+
DragGesture(minimumDistance: 0)
26+
.onChanged { _ in
27+
withAnimation(.easeInOut(duration: 0.1)) {
28+
isPressed = true
29+
}
30+
}
31+
.onEnded { _ in
32+
withAnimation(.easeInOut(duration: 0.1)) {
33+
isPressed = false
34+
}
35+
openURL(destination)
36+
}
37+
)
38+
}
39+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy