Skip to content

chore: make cli-auth link visually responsive #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Coder Desktop/Coder Desktop/Views/LoginForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ struct LoginForm<S: Session>: View {
Text("Generate a session token at ")
.font(.subheadline)
.foregroundColor(.secondary)
Link(cliAuthURL.absoluteString, destination: cliAuthURL)
.font(.subheadline)
.foregroundColor(.blue)
ResponsiveLink(title: cliAuthURL.absoluteString, destination: cliAuthURL)
}
}
}.formStyle(.grouped).scrollDisabled(true).padding(.horizontal)
Expand Down
39 changes: 39 additions & 0 deletions Coder Desktop/Coder Desktop/Views/ResponsiveLink.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import SwiftUI

struct ResponsiveLink: View {
let title: String
let destination: URL

@State private var isHovered = false
@State private var isPressed = false
@Environment(\.openURL) private var openURL

var body: some View {
Text(title)
.font(.subheadline)
.foregroundColor(isPressed ? .red : .blue)
.underline(isHovered, color: isPressed ? .red : .blue)
.onHover { hovering in
isHovered = hovering
if hovering {
NSCursor.pointingHand.push()
} else {
NSCursor.pop()
}
}
.simultaneousGesture(
DragGesture(minimumDistance: 0)
.onChanged { _ in
withAnimation(.easeInOut(duration: 0.1)) {
isPressed = true
}
}
.onEnded { _ in
withAnimation(.easeInOut(duration: 0.1)) {
isPressed = false
}
openURL(destination)
}
)
}
}
Loading