-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: activeColor and inactiveColor to match icon colors (#3592)
- Loading branch information
Showing
4 changed files
with
180 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import color from 'color'; | ||
import type { InternalTheme } from 'src/types'; | ||
|
||
import type { black, white } from '../../styles/themes/v2/colors'; | ||
|
||
type BaseProps = { | ||
defaultColor: typeof black | typeof white; | ||
theme: InternalTheme; | ||
}; | ||
|
||
export const getActiveTintColor = ({ | ||
activeColor, | ||
defaultColor, | ||
theme, | ||
}: BaseProps & { | ||
activeColor: string | undefined; | ||
}) => { | ||
if (typeof activeColor === 'string') { | ||
return activeColor; | ||
} | ||
|
||
if (theme.isV3) { | ||
return theme.colors.onSecondaryContainer; | ||
} | ||
|
||
return defaultColor; | ||
}; | ||
|
||
export const getInactiveTintColor = ({ | ||
inactiveColor, | ||
defaultColor, | ||
theme, | ||
}: BaseProps & { | ||
inactiveColor: string | undefined; | ||
}) => { | ||
if (typeof inactiveColor === 'string') { | ||
return inactiveColor; | ||
} | ||
|
||
if (theme.isV3) { | ||
return theme.colors.onSurfaceVariant; | ||
} | ||
|
||
return color(defaultColor).alpha(0.5).rgb().string(); | ||
}; | ||
|
||
export const getLabelColor = ({ | ||
tintColor, | ||
hasColor, | ||
focused, | ||
defaultColor, | ||
theme, | ||
}: BaseProps & { | ||
tintColor: string; | ||
hasColor: boolean; | ||
focused: boolean; | ||
}) => { | ||
if (hasColor) { | ||
return tintColor; | ||
} | ||
|
||
if (focused) { | ||
return theme.colors.onSurface; | ||
} | ||
|
||
if (theme.isV3) { | ||
return theme.colors.onSurfaceVariant; | ||
} | ||
|
||
return defaultColor; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters