Skip to content

Commit

Permalink
Improve icon color readability on dark themes
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolemos committed Mar 21, 2019
1 parent 38725b8 commit 1ec0e57
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
11 changes: 7 additions & 4 deletions packages/components/src/components/cards/EventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,27 @@ export const EventCard = React.memo((props: EventCardProps) => {

const smallLeftColumn = false

const backgroundThemeColor =
(isSelected && 'backgroundColorLess2') ||
(isRead && 'backgroundColorDarker1') ||
'backgroundColor'

return (
<SpringAnimatedView
key={`event-card-${id}-inner`}
ref={itemRef}
style={[
styles.container,
{
backgroundColor:
(isSelected && springAnimatedTheme.backgroundColorLess2) ||
(isRead && springAnimatedTheme.backgroundColorDarker1) ||
springAnimatedTheme.backgroundColor,
backgroundColor: springAnimatedTheme[backgroundThemeColor],
},
]}
>
<EventCardHeader
key={`event-card-header-${id}`}
actionText={actionText}
avatarUrl={avatarUrl}
backgroundThemeColor={backgroundThemeColor}
cardIconColor={cardIconColor}
cardIconName={cardIconName}
date={event.created_at}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,29 @@ import {
getFullDateText,
getGitHubURLForUser,
GitHubIcon,
ThemeColors,
trimNewLinesAndSpaces,
} from '@devhub/core'
import { useCSSVariablesOrSpringAnimatedTheme } from '../../../hooks/use-css-variables-or-spring--animated-theme'
import { useReduxAction } from '../../../hooks/use-redux-action'
import { Platform } from '../../../libs/platform'
import * as actions from '../../../redux/actions'
import { contentPadding } from '../../../styles/variables'
import { getReadableColor } from '../../../utils/helpers/colors'
import { SpringAnimatedIcon } from '../../animated/spring/SpringAnimatedIcon'
import { SpringAnimatedText } from '../../animated/spring/SpringAnimatedText'
import { SpringAnimatedView } from '../../animated/spring/SpringAnimatedView'
import { ColumnHeaderItem } from '../../columns/ColumnHeaderItem'
import { Avatar } from '../../common/Avatar'
import { IntervalRefresh } from '../../common/IntervalRefresh'
import { Link } from '../../common/Link'
import { useTheme } from '../../context/ThemeContext'
import { cardStyles, getCardStylesForTheme } from '../styles'

export interface EventCardHeaderProps {
actionText: string
avatarUrl: string
backgroundThemeColor: keyof ThemeColors
cardIconColor?: string
cardIconName: GitHubIcon
date: MomentInput
Expand Down Expand Up @@ -62,6 +66,7 @@ export function EventCardHeader(props: EventCardHeaderProps) {
const {
actionText,
avatarUrl,
backgroundThemeColor,
cardIconColor,
cardIconName,
date,
Expand All @@ -76,6 +81,7 @@ export function EventCardHeader(props: EventCardHeaderProps) {
} = props

const springAnimatedTheme = useCSSVariablesOrSpringAnimatedTheme()
const theme = useTheme()

const saveItemsForLater = useReduxAction(actions.saveItemsForLater)

Expand Down Expand Up @@ -235,7 +241,13 @@ export function EventCardHeader(props: EventCardHeaderProps) {
cardIconName === 'star' && {
lineHeight: 14,
},
!!cardIconColor && { color: cardIconColor },
!!cardIconColor && {
color: getReadableColor(
cardIconColor,
theme[backgroundThemeColor],
0.3,
),
},
]}
size={16}
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,13 @@ export function NotificationCardHeader(props: NotificationCardHeaderProps) {
{
width: columnHeaderItemContentSize,
},
!!cardIconColor && { color: cardIconColor },
!!cardIconColor && {
color: getReadableColor(
cardIconColor,
theme[backgroundThemeColor],
0.3,
),
},
]}
size={16}
style={{
Expand Down

0 comments on commit 1ec0e57

Please sign in to comment.