Skip to content

Commit

Permalink
Added setToken and getName functions to Ui.Token.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdotdesign committed Jun 19, 2021
1 parent 3ce1baf commit 9825908
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions source/Enums/Token.mint
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ module Ui.Token {
}
}

/* Sets a given token. */
fun setToken (token : Ui.Token, tokens : Array(Ui.Token)) : Array(Ui.Token) {
try {
name =
getName(token)

tokens
|> Array.reject((item : Ui.Token) { getName(item) == name })
|> Array.push(token)
}
}

/* Gets the name of the token. */
fun getName (token : Ui.Token) : String {
case (token) {
Ui.Token::Schemed(name) => name
Ui.Token::Simple(name) => name
}
}

/* Resolves many tokens using the dark mode param. */
fun resolveMany (darkMode : Bool, tokens : Array(Ui.Token)) : String {
tokens
Expand Down

0 comments on commit 9825908

Please sign in to comment.