Skip to content

Commit

Permalink
added Edit icon and messages. Next Step Edit Functions. WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Priscila Oliveira authored and Priscila Oliveira committed Jan 13, 2018
1 parent 3865ab0 commit 838de39
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 24 deletions.
39 changes: 39 additions & 0 deletions src/components/Icon/img/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/components/Icon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const iconNames = [
'heart-empty',
'add',
'loading',
'image'
'image',
'edit'
]

export const icons = iconNames.reduce((acc, curr) => ({
Expand Down
54 changes: 33 additions & 21 deletions src/containers/Preferences/Content.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Img from 'components/Img'
import EmptyState from 'components/EmptyState'
import { grey400 } from 'material-ui/styles/colors'
import messages from './messages'
import { LItem, PrimaryText } from './ContentStyles'
import { LItem, PrimaryText, BGItem } from './ContentStyles'

const iconButtonElement = (
<IconButton
Expand All @@ -25,14 +25,6 @@ const iconButtonElement = (
</IconButton>
)

const rightIconMenu = func => (
<IconMenu iconButtonElement={iconButtonElement}>
<MenuItem onClick={func}>
<FormattedMessage {...messages['randomQuotes.containers.preferences.delete']} />
</MenuItem>
</IconMenu>
)

const getExtractQuoteContent = (onRemove, content) => (
content.length > 0 ? (
<GridList cols={1} cellHeight='auto'>
Expand All @@ -51,7 +43,16 @@ const getExtractQuoteContent = (onRemove, content) => (
/>
</PrimaryText>
}
rightIconButton={rightIconMenu(() => onRemove(quote.id))}
rightIconButton={
<IconMenu iconButtonElement={iconButtonElement}>
<MenuItem onClick={() => onRemove(quote.id)}>
<FormattedMessage {...messages['randomQuotes.containers.preferences.edit']} />
</MenuItem>
<MenuItem onClick={() => onRemove(quote.id)}>
<FormattedMessage {...messages['randomQuotes.containers.preferences.delete']} />
</MenuItem>
</IconMenu>
}
/>
<Divider />
</div>
Expand All @@ -72,7 +73,7 @@ const getExtractBackgroundContent = (onRemove, content) => (
content.length > 0 ? (
<GridList cols={2} cellHeight={130}>
{content.map(background => (
<GridTile
<BGItem
key={background.id}
title={background.name}
subtitle={
Expand All @@ -82,19 +83,30 @@ const getExtractBackgroundContent = (onRemove, content) => (
/>
}
actionIcon={
<IconButton onClick={() => onRemove(background.id)} className='btn'>
<span className='btn'>
<Icon
name='garbage'
cursor='pointer'
sm
/>
</span>
</IconButton>
<div>
<IconButton onClick={() => onRemove(background.id)} className='btn'>
<span className='btn'>
<Icon
name='edit'
cursor='pointer'
sm
/>
</span>
</IconButton>
<IconButton onClick={() => onRemove(background.id)} className='btn'>
<span className='btn'>
<Icon
name='garbage'
cursor='pointer'
sm
/>
</span>
</IconButton>
</div>
}
>
<Img url={background.url} />
</GridTile>
</BGItem>
))}
</GridList>
) : (
Expand Down
11 changes: 10 additions & 1 deletion src/containers/Preferences/ContentStyles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import glamorous from 'glamorous'
import { ListItem } from 'material-ui/List'
import { GridTile } from 'material-ui/GridList'
import { white, grey400 } from 'material-ui/styles/colors'

const LItem = glamorous(props => (
Expand All @@ -20,8 +21,16 @@ const PrimaryText = glamorous.div({
}
})

const BGItem = glamorous(props => (
<GridTile
titleStyle={{ width: 100 }}
subtitleStyle={{ width: 100 }}
{...props}
/>
))()

export {
LItem,
PrimaryText
PrimaryText,
BGItem
}
7 changes: 6 additions & 1 deletion src/containers/Preferences/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Header = ({
}) => (
category === 'general' ? (
<Account cols={6} cellHeight='auto'>
<GridItem cols={5} align='middle' justify='left'>
<GridItem cols={3} align='middle' justify='left'>
<User>
<Avatar src={user.photoURL} />
<Info>
Expand All @@ -32,6 +32,11 @@ const Header = ({
</Info>
</User>
</GridItem>
<GridItem cols={2} align='middle' justify='center'>
<Action onClick={onLogout} className='btn'>
{intl.formatMessage(messages['randomQuotes.containers.preferences.editAccount'])}
</Action>
</GridItem>
<GridItem cols={1} align='middle' justify='center'>
<Action onClick={onLogout} className='btn'>
{intl.formatMessage(messages['randomQuotes.containers.preferences.logout'])}
Expand Down
8 changes: 8 additions & 0 deletions src/containers/Preferences/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ export default defineMessages({
id: 'randomQuotes.containers.preferences.delete',
defaultMessage: 'Delete'
},
'randomQuotes.containers.preferences.edit': {
id: 'randomQuotes.containers.preferences.edit',
defaultMessage: 'Edit'
},
'randomQuotes.containers.preferences.editAccount': {
id: 'randomQuotes.containers.preferences.editAccount',
defaultMessage: 'Edit account'
},
'randomQuotes.containers.preferences.logout': {
id: 'randomQuotes.containers.preferences.logout',
defaultMessage: 'Logout'
Expand Down

0 comments on commit 838de39

Please sign in to comment.