Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
feat(ui): mark items with autopay enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
korhaliv committed Mar 24, 2019
1 parent 887a298 commit 805d0fe
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/components/Autopay/AutopayCardView.js
Expand Up @@ -5,6 +5,7 @@ import { themeGet } from 'styled-system'
import { Box, Flex } from 'rebass'
import { Card, Heading } from 'components/UI'
import AutopayAddButton from './AutopayAddButton'
import AutopayLimitBadge from './AutopayLimitBadge'

const CardWithBg = styled(Card)`
position: relative;
Expand Down Expand Up @@ -47,7 +48,7 @@ const TextOverlay = styled(Overlay)`
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
`

const AutopayCardView = ({ merchant: { image, nickname, pubkey }, onClick, ...rest }) => (
const AutopayCardView = ({ merchant: { image, nickname, pubkey, isActive }, onClick, ...rest }) => (
<Box {...rest} onClick={() => onClick(`${pubkey}`)}>
<CardWithBg mb="12px" src={image}>
<GradientOverlay />
Expand All @@ -57,7 +58,7 @@ const AutopayCardView = ({ merchant: { image, nickname, pubkey }, onClick, ...re
</Heading.h1>
</TextOverlay>
<Overlay alignItems="flex-end" justifyContent="center" mt="12px">
<AutopayAddButton />
{isActive ? <AutopayLimitBadge /> : <AutopayAddButton />}
</Overlay>
</CardWithBg>
</Box>
Expand Down
35 changes: 35 additions & 0 deletions app/components/Autopay/AutopayLimitBadge.js
@@ -0,0 +1,35 @@
import React from 'react'
import { Card, Flex, Box } from 'rebass'
import { themeGet } from 'styled-system'
import styled, { withTheme } from 'styled-components'
import { tint } from 'polished'
import Check from 'components/Icon/Check'

const Gradient = styled(Card)`
background: linear-gradient(
to bottom,
${props => tint(0.2, props.theme.colors[props.bg])},
${props => props.theme.colors[props.bg]}
);
`

const AutopayLimitBadge = props => {
return (
<Gradient
bg="lightningOrange"
borderRadius="50%"
boxShadow={`0 0 24px 0 ${themeGet('colors.lightningOrange')(props)}`}
css={{ height: '35px' }}
width={35}
{...props}
>
<Flex alignItems="center" css={{ height: '100%' }} justifyContent="center">
<Box color="white">
<Check height={20} width={20} />
</Box>
</Flex>
</Gradient>
)
}

export default withTheme(AutopayLimitBadge)
10 changes: 7 additions & 3 deletions app/reducers/autopay.js
Expand Up @@ -137,12 +137,16 @@ autopaySelectors.selectedMerchant = createSelector(
autopaySelectors.filteredMerchants = createSelector(
autopaySelectors.merchants,
autopaySelectors.searchQuery,
(merchants, searchQuery) => {
autopaySelectors.autopayList,
(merchants, searchQuery, autopayList) => {
const addIsActive = m => ({ ...m, isActive: [m.pubkey] in autopayList })
if (!searchQuery) {
return merchants
return merchants.map(addIsActive)
}
const cleanedSearchQuery = searchQuery.toLowerCase()
return merchants.filter(m => m.nickname.toLowerCase().includes(cleanedSearchQuery))
return merchants
.filter(m => m.nickname.toLowerCase().includes(cleanedSearchQuery))
.map(addIsActive)
}
)

Expand Down

0 comments on commit 805d0fe

Please sign in to comment.