Skip to content

Commit

Permalink
Update Color+Extensions.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelesantos committed Apr 10, 2024
1 parent 2cff510 commit 3ea1beb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/RefdsShared/Extension/Color+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ public extension Color {

init(hex: String) {
guard hex.count == 7 || hex.count == 6 else {
self.init(Color.accentColor)
let components = Color.accentColor.colorComponents
self.init(
.sRGB,
red: Double(components?.red ?? .zero) / 255,
green: Double(components?.green ?? .zero) / 255,
blue: Double(components?.blue ?? .zero) / 255,
opacity: Double(components?.alpha ?? .zero) / 255
)
return
}

Expand Down

0 comments on commit 3ea1beb

Please sign in to comment.