mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 13:32:45 +00:00
Merge pull request #2442 from Gazook89/Delete-Recent-Items
Add Ability to Remove Brews from Recent Items
This commit is contained in:
@@ -115,8 +115,36 @@
|
|||||||
color : white;
|
color : white;
|
||||||
text-decoration : none;
|
text-decoration : none;
|
||||||
border-top : 1px solid #888;
|
border-top : 1px solid #888;
|
||||||
|
overflow : clip;
|
||||||
|
.clear{
|
||||||
|
display : none;
|
||||||
|
position : absolute;
|
||||||
|
top : 50%;
|
||||||
|
transform : translateY(-50%);
|
||||||
|
right : 0px;
|
||||||
|
width : 20px;
|
||||||
|
height : 100%;
|
||||||
|
background-color : #333;
|
||||||
|
opacity : 70%;
|
||||||
|
border-radius : 3px;
|
||||||
|
&:hover {
|
||||||
|
opacity : 100%;
|
||||||
|
}
|
||||||
|
i {
|
||||||
|
text-align : center;
|
||||||
|
font-size : 10px;
|
||||||
|
margin : 0;
|
||||||
|
height :100%;
|
||||||
|
width :100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
&:hover{
|
&:hover{
|
||||||
background-color : @blue;
|
background-color : @blue;
|
||||||
|
|
||||||
|
.clear{
|
||||||
|
display : grid;
|
||||||
|
place-content : center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.title{
|
.title{
|
||||||
display : inline-block;
|
display : inline-block;
|
||||||
|
|||||||
@@ -119,6 +119,25 @@ const RecentItems = createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeItem : function(url, evt){
|
||||||
|
evt.preventDefault();
|
||||||
|
|
||||||
|
let edited = JSON.parse(localStorage.getItem(EDIT_KEY) || '[]');
|
||||||
|
let viewed = JSON.parse(localStorage.getItem(VIEW_KEY) || '[]');
|
||||||
|
|
||||||
|
edited = edited.filter((item)=>{ return (item.url !== url);});
|
||||||
|
viewed = viewed.filter((item)=>{ return (item.url !== url);});
|
||||||
|
|
||||||
|
localStorage.setItem(EDIT_KEY, JSON.stringify(edited));
|
||||||
|
localStorage.setItem(VIEW_KEY, JSON.stringify(viewed));
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
edit : edited,
|
||||||
|
view : viewed
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
renderDropdown : function(){
|
renderDropdown : function(){
|
||||||
if(!this.state.showDropdown) return null;
|
if(!this.state.showDropdown) return null;
|
||||||
|
|
||||||
@@ -127,6 +146,7 @@ const RecentItems = createClass({
|
|||||||
return <a href={brew.url} className='item' key={`${brew.id}-${i}`} target='_blank' rel='noopener noreferrer' title={brew.title || '[ no title ]'}>
|
return <a href={brew.url} className='item' key={`${brew.id}-${i}`} target='_blank' rel='noopener noreferrer' title={brew.title || '[ no title ]'}>
|
||||||
<span className='title'>{brew.title || '[ no title ]'}</span>
|
<span className='title'>{brew.title || '[ no title ]'}</span>
|
||||||
<span className='time'>{Moment(brew.ts).fromNow()}</span>
|
<span className='time'>{Moment(brew.ts).fromNow()}</span>
|
||||||
|
<div className='clear' title='Remove from Recents' onClick={(e)=>{this.removeItem(`${brew.url}`, e);}}><i className='fas fa-times'></i></div>
|
||||||
</a>;
|
</a>;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user