Skip to content

Commit

Permalink
Merge pull request #67 from hhru/MOB-36523__support_shadows_generatio…
Browse files Browse the repository at this point in the history
…n_for_zpday

[MOB-36523] Добавляет генерацию теней для ZpDay
  • Loading branch information
timbaev authored Feb 13, 2024
2 parents b5fdf9d + 467a15d commit a3be34d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ struct BoxShadowToken {
let path: [String]
let dayTheme: Theme
let nightTheme: Theme
let zpDayTheme: Theme
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct BoxShadowTokensContextProviderError: Error, CustomStringConvertible {
// MARK: - Enumeration Cases

case nightValueNotFound(tokenName: String)
case zpValueNotFound(tokenName: String)
}

// MARK: - Instance Properties
Expand All @@ -21,6 +22,8 @@ struct BoxShadowTokensContextProviderError: Error, CustomStringConvertible {
switch code {
case .nightValueNotFound(let tokenName):
return "Night value for token '\(tokenName)' not found"
case .zpValueNotFound(let tokenName):
return "ZpDay value for token '\(tokenName)' not found"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ final class DefaultBoxShadowTokensContextProvider: BoxShadowTokensContextProvide
throw BoxShadowTokensContextProviderError(code: .nightValueNotFound(tokenName: dayTokenValue.name))
}

guard let zpDayTokenValue = tokenValues.zpDay.first(where: { $0.name == dayTokenValue.name }) else {
throw BoxShadowTokensContextProviderError(code: .nightValueNotFound(tokenName: dayTokenValue.name))
}

guard case let .boxShadow(zpDayValue) = zpDayTokenValue.type else {
throw BoxShadowTokensContextProviderError(code: .zpValueNotFound(tokenName: dayTokenValue.name))
}

return BoxShadowToken(
path: dayTokenValue.name.components(separatedBy: "."),
dayTheme: makeTheme(value: dayValue),
nightTheme: makeTheme(value: nightValue)
nightTheme: makeTheme(value: nightValue),
zpDayTheme: makeTheme(value: zpDayValue)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ final class DefaultColorTokensContextProvider: ColorTokensContextProvider {
theme: Theme
) throws -> ColorToken.Theme {
// Resolve theme data
let themeData: (tokenValues: [TokenValue], warningPrefix: String) = switch theme {
let themeData: (tokenValues: [TokenValue], warningPrefix: String)
switch theme {
case .night:
(tokenValues.hhNight, "Night")
themeData = (tokenValues.hhNight, "Night")

case .zpDay:
(tokenValues.zpDay, "ZpDay")
themeData = (tokenValues.zpDay, "ZpDay")

case .day, .undefined:
([], "")
themeData = ([], "")
}

// Resolve token and value
Expand Down

0 comments on commit a3be34d

Please sign in to comment.