Skip to content

Commit

Permalink
Reuse text button styles
Browse files Browse the repository at this point in the history
  • Loading branch information
mrseanbaines committed Jul 5, 2020
1 parent 8e1156f commit 14bad4d
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 89 deletions.
14 changes: 0 additions & 14 deletions src/components/categories/categories.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,3 @@ export const Body = styled.div(({ theme }) => {
padding-top: 0;
`
})

export const NewCategory = styled.button(({ theme }) => {
return css`
padding: ${theme.space[2]} 0;
margin-top: ${theme.space[2]};
border: none;
width: 100%;
background: none;
text-align: center;
font-size: ${theme.fontSizes[2]};
cursor: pointer;
border-top: ${theme.borders.default};
`
})
5 changes: 4 additions & 1 deletion src/components/categories/categories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getCategoryItems } from 'store/categories/selectors'
import { fetchCategories } from 'store/categories/actions'
import { Category } from 'store/categories/types'
import { ForwardIcon } from 'icons'
import * as sc from 'styles/common'

import * as s from './categories.styles'

Expand Down Expand Up @@ -55,7 +56,9 @@ const Categories: React.FC = () => {
/>
))}

<s.NewCategory onClick={() => setCreateNewCategory(true)}>New Category</s.NewCategory>
<hr />

<sc.TextButton onClick={() => setCreateNewCategory(true)}>New Category</sc.TextButton>
</Layout>
</s.Wrapper>

Expand Down
12 changes: 0 additions & 12 deletions src/components/category/category.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,3 @@ export const CategoryColor = styled.button<CategoryColorProps>(({ theme, color }
cursor: pointer;
`
})

export const Submit = styled.button.attrs({ type: 'submit' })(({ theme }) => {
return css`
padding: ${theme.space[2]} 0;
border: none;
width: 100%;
background: none;
text-align: center;
font-size: ${theme.fontSizes[2]};
cursor: pointer;
`
})
3 changes: 2 additions & 1 deletion src/components/category/category.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'

import TextInput from 'components/text-input'
import { useFocusInput } from 'hooks'
import * as sc from 'styles/common'

import * as s from './category.styles'

Expand Down Expand Up @@ -30,7 +31,7 @@ const Category: React.FC<Props> = props => {
required
/>

{props.submitText && <s.Submit>{props.submitText}</s.Submit>}
{props.submitText && <sc.TextButton>{props.submitText}</sc.TextButton>}
</form>
</s.Wrapper>
)
Expand Down
15 changes: 0 additions & 15 deletions src/components/choose-category/choose-category.styles.ts

This file was deleted.

7 changes: 4 additions & 3 deletions src/components/choose-category/choose-category.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { ListItem } from 'components/list'
import { getCategoryItems } from 'store/categories/selectors'
import { Transaction } from 'store/transactions/types'
import { ForwardIcon } from 'icons'

import * as s from './choose-category.styles'
import * as sc from 'styles/common'

export interface Props {
onCategoryClick: (categoryId: Transaction['category']) => any
Expand All @@ -30,7 +29,9 @@ const ChooseCategory: React.FC<Props> = ({ onCategoryClick, onCreateCategoryClic

<ListItem title='Uncategorised' extra={<ForwardIcon />} onClick={() => onCategoryClick(null)} />

<s.NewCategory onClick={onCreateCategoryClick}>New Category</s.NewCategory>
<hr />

<sc.TextButton onClick={onCreateCategoryClick}>New Category</sc.TextButton>
</>
)
}
Expand Down
11 changes: 0 additions & 11 deletions src/components/login/login.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,3 @@ export const FormError = styled.p(({ theme }) => {
font-size: ${theme.fontSizes[0]};
`
})

export const Submit = styled.button(({ theme }) => {
return css`
border: none;
background: none;
text-align: center;
font-size: ${theme.fontSizes[2]};
cursor: pointer;
margin: 0 auto;
`
})
3 changes: 2 additions & 1 deletion src/components/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getIsAuthenticated } from 'store/auth/selectors'
import { getError } from 'store/errors/selectors'
import { LOGIN_FAIL } from 'store/auth/constants'
import { useFocusInput } from 'hooks'
import * as sc from 'styles/common'

import * as s from './login.styles'

Expand Down Expand Up @@ -63,7 +64,7 @@ const Login: React.FC = () => {

{error.id === LOGIN_FAIL && <s.FormError>{error.message}</s.FormError>}

<s.Submit type='submit'>Log in</s.Submit>
<sc.TextButton type='submit'>Log in</sc.TextButton>
</s.Form>
</s.Wrapper>
)
Expand Down
26 changes: 13 additions & 13 deletions src/components/overview/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Category } from 'store/categories/types'
import { getActiveDate } from 'store/view/selectors'
import { colors } from 'theme'
import { formatCurrency, groupByCategory } from 'utils'
import * as s from 'styles/common'
import * as sc from 'styles/common'

const Overview: React.FC = () => {
const activeDate = useSelector(getActiveDate)
Expand Down Expand Up @@ -49,13 +49,13 @@ const Overview: React.FC = () => {

return (
<>
<s.Wrapper>
<s.HeaderWrapper>
<sc.Wrapper>
<sc.HeaderWrapper>
{activeDate && (
<Header title='Overview' subtitle={format(new Date(activeDate), 'MMMM yyyy')} withDateSelect />
)}

<s.UpperSection>
<sc.UpperSection>
<ResponsiveContainer height={200}>
<PieChart>
<Pie
Expand All @@ -75,25 +75,25 @@ const Overview: React.FC = () => {
</PieChart>
</ResponsiveContainer>

<s.Total>
<s.TotalLabel>Total Categorised</s.TotalLabel>
<s.TotalAmount>{formatCurrency(total)}</s.TotalAmount>
</s.Total>
</s.UpperSection>
</s.HeaderWrapper>
<sc.Total>
<sc.TotalLabel>Total Categorised</sc.TotalLabel>
<sc.TotalAmount>{formatCurrency(total)}</sc.TotalAmount>
</sc.Total>
</sc.UpperSection>
</sc.HeaderWrapper>

<Layout>
{orderedItems.map(c => (
<div key={c.category?.id ?? 'Uncategorised'}>
<s.ListHeadingWrapper>
<sc.ListHeadingWrapper>
<ListHeading
withBadge
badgeColor={c.category?.color}
title={c.category?.name ?? 'Uncategorised'}
extra={formatCurrency(c.total)}
onClick={() => handleSetSelectedCategory(c.id)}
/>
</s.ListHeadingWrapper>
</sc.ListHeadingWrapper>

{selectedCategoryId === c.id &&
c.transactions.map(transaction => (
Expand All @@ -108,7 +108,7 @@ const Overview: React.FC = () => {
</div>
))}
</Layout>
</s.Wrapper>
</sc.Wrapper>

{selectedTransaction && (
<TransactionFlow transaction={selectedTransaction} exitFlow={() => setSelectedTransactionId(null)} />
Expand Down
10 changes: 5 additions & 5 deletions src/components/profile/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useDispatch } from 'react-redux'
import Layout from 'components/layout'
import Header from 'components/header'
import { logout } from 'store/auth/actions'
import * as s from 'styles/common'
import * as sc from 'styles/common'

const Profile: React.FC = () => {
const dispatch = useDispatch()
Expand All @@ -14,15 +14,15 @@ const Profile: React.FC = () => {
}

return (
<s.Wrapper>
<s.HeaderWrapper>
<sc.Wrapper>
<sc.HeaderWrapper>
<Header title='Profile' />
</s.HeaderWrapper>
</sc.HeaderWrapper>

<Layout>
<button onClick={handleLogout}>Log out</button>
</Layout>
</s.Wrapper>
</sc.Wrapper>
)
}

Expand Down
26 changes: 13 additions & 13 deletions src/components/transactions/transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Transaction } from 'store/transactions/types'
import { getTransactionItems } from 'store/transactions/selectors'
import { getActiveDate, getSelectedCategoryId, getMinAmount, getMaxAmount } from 'store/view/selectors'
import { formatCurrency, groupByDay } from 'utils'
import * as s from 'styles/common'
import * as sc from 'styles/common'

const Transactions: React.FC = () => {
const activeDate = useSelector(getActiveDate)
Expand Down Expand Up @@ -62,8 +62,8 @@ const Transactions: React.FC = () => {

return (
<>
<s.Wrapper>
<s.HeaderWrapper>
<sc.Wrapper>
<sc.HeaderWrapper>
{activeDate && (
<Header
title='Transactions'
Expand All @@ -73,27 +73,27 @@ const Transactions: React.FC = () => {
/>
)}

<s.UpperSection>
<s.Total>
<s.TotalLabel>Total Spent</s.TotalLabel>
<s.TotalAmount>{formatCurrency(total)}</s.TotalAmount>
</s.Total>
<sc.UpperSection>
<sc.Total>
<sc.TotalLabel>Total Spent</sc.TotalLabel>
<sc.TotalAmount>{formatCurrency(total)}</sc.TotalAmount>
</sc.Total>

<TextInput
type='search'
value={searchQuery}
placeholder='Search for a merchant'
onChange={({ target: { value } }) => setSearchQuery(value)}
/>
</s.UpperSection>
</s.HeaderWrapper>
</sc.UpperSection>
</sc.HeaderWrapper>

<Layout>
{transactionsByDay.map(day => (
<div key={day.date}>
<s.ListHeadingWrapper>
<sc.ListHeadingWrapper>
<ListHeading title={day.date} extra={formatCurrency(day.total)} />
</s.ListHeadingWrapper>
</sc.ListHeadingWrapper>

{day.transactions.map(transaction => (
<ListItem
Expand All @@ -108,7 +108,7 @@ const Transactions: React.FC = () => {
</div>
))}
</Layout>
</s.Wrapper>
</sc.Wrapper>

{selectedTransaction && (
<TransactionFlow transaction={selectedTransaction} exitFlow={() => setSelectedTransactionId(null)} />
Expand Down
13 changes: 13 additions & 0 deletions src/styles/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,16 @@ export const ListHeadingWrapper = styled.div(({ theme }) => {
top: 0;
`
})

export const TextButton = styled.button(({ theme }) => {
return css`
display: block;
border: none;
background: none;
text-align: center;
padding: ${theme.space[2]} 0;
font-size: ${theme.fontSizes[2]};
cursor: pointer;
margin: 0 auto;
`
})
5 changes: 5 additions & 0 deletions src/styles/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ const GlobalStyles = createGlobalStyle(({ theme }) => {
font-weight: ${theme.fontWeights.medium};
line-height: calc(1em + 2px);
}
hr {
border: none;
border-top: ${theme.borders.default};
}
`
})

Expand Down

0 comments on commit 14bad4d

Please sign in to comment.