mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-15 08:22:43 +00:00
Working dropdown component on the Share Page
This commit is contained in:
@@ -29,12 +29,6 @@ const SharePage = createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState : function() {
|
|
||||||
return {
|
|
||||||
showDropdown : false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidMount : function() {
|
componentDidMount : function() {
|
||||||
document.addEventListener('keydown', this.handleControlKeys);
|
document.addEventListener('keydown', this.handleControlKeys);
|
||||||
},
|
},
|
||||||
@@ -57,28 +51,6 @@ const SharePage = createClass({
|
|||||||
this.props.brew.shareId;
|
this.props.brew.shareId;
|
||||||
},
|
},
|
||||||
|
|
||||||
handleDropdown : function(show){
|
|
||||||
this.setState({
|
|
||||||
showDropdown : show
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
renderDropdown : function(){
|
|
||||||
if(!this.state.showDropdown) return null;
|
|
||||||
|
|
||||||
return <div className='dropdown'>
|
|
||||||
<a href={`/source/${this.processShareId()}`} className='item'>
|
|
||||||
view
|
|
||||||
</a>
|
|
||||||
<a href={`/download/${this.processShareId()}`} className='item'>
|
|
||||||
download
|
|
||||||
</a>
|
|
||||||
<a href={`/new/${this.processShareId()}`} className='item'>
|
|
||||||
clone to new
|
|
||||||
</a>
|
|
||||||
</div>;
|
|
||||||
},
|
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
return <div className='sharePage sitePage'>
|
return <div className='sharePage sitePage'>
|
||||||
<Meta name='robots' content='noindex, nofollow' />
|
<Meta name='robots' content='noindex, nofollow' />
|
||||||
@@ -90,12 +62,20 @@ const SharePage = createClass({
|
|||||||
<Nav.section>
|
<Nav.section>
|
||||||
{this.props.brew.shareId && <>
|
{this.props.brew.shareId && <>
|
||||||
<PrintLink shareId={this.processShareId()} />
|
<PrintLink shareId={this.processShareId()} />
|
||||||
<Nav.item icon='fas fa-code' color='red' className='source'
|
<Nav.dropdown>
|
||||||
onMouseEnter={()=>this.handleDropdown(true)}
|
<Nav.item color='red' icon='fas fa-code'>
|
||||||
onMouseLeave={()=>this.handleDropdown(false)}>
|
source
|
||||||
source
|
</Nav.item>
|
||||||
{this.renderDropdown()}
|
<Nav.item color='blue' href={`/source/${this.processShareId()}`}>
|
||||||
</Nav.item>
|
view
|
||||||
|
</Nav.item>
|
||||||
|
<Nav.item color='blue' href={`/download/${this.processShareId()}`}>
|
||||||
|
download
|
||||||
|
</Nav.item>
|
||||||
|
<Nav.item color='blue' href={`/new/${this.processShareId()}`}>
|
||||||
|
clone to new
|
||||||
|
</Nav.item>
|
||||||
|
</Nav.dropdown>
|
||||||
</>}
|
</>}
|
||||||
<RecentNavItem brew={this.props.brew} storageKey='view' />
|
<RecentNavItem brew={this.props.brew} storageKey='view' />
|
||||||
<Account />
|
<Account />
|
||||||
|
|||||||
@@ -2,49 +2,4 @@
|
|||||||
.content{
|
.content{
|
||||||
overflow-y : hidden;
|
overflow-y : hidden;
|
||||||
}
|
}
|
||||||
.source.navItem{
|
|
||||||
position : relative;
|
|
||||||
.dropdown{
|
|
||||||
position : absolute;
|
|
||||||
top : 28px;
|
|
||||||
left : 0px;
|
|
||||||
z-index : 10000;
|
|
||||||
width : 100%;
|
|
||||||
h4{
|
|
||||||
display : block;
|
|
||||||
box-sizing : border-box;
|
|
||||||
padding : 5px 0px;
|
|
||||||
background-color : #333;
|
|
||||||
font-size : 0.8em;
|
|
||||||
color : #bbb;
|
|
||||||
text-align : center;
|
|
||||||
border-top : 1px solid #888;
|
|
||||||
&:nth-of-type(1){ background-color: darken(@teal, 20%); }
|
|
||||||
&:nth-of-type(2){ background-color: darken(@purple, 30%); }
|
|
||||||
}
|
|
||||||
.item{
|
|
||||||
.animate(background-color);
|
|
||||||
position : relative;
|
|
||||||
display : block;
|
|
||||||
width : 100%;
|
|
||||||
vertical-align : middle;
|
|
||||||
padding : 13px 5px;
|
|
||||||
box-sizing : border-box;
|
|
||||||
background-color : #333;
|
|
||||||
color : white;
|
|
||||||
text-decoration : none;
|
|
||||||
border-top : 1px solid #888;
|
|
||||||
&:hover{
|
|
||||||
background-color : @blue;
|
|
||||||
}
|
|
||||||
.title{
|
|
||||||
display : inline-block;
|
|
||||||
overflow : hidden;
|
|
||||||
width : 100%;
|
|
||||||
text-overflow : ellipsis;
|
|
||||||
white-space : nowrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -68,6 +68,46 @@ const Nav = {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
dropdown : createClass({
|
||||||
|
getInitialState : function() {
|
||||||
|
return {
|
||||||
|
showDropdown : false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
handleDropdown : function(show){
|
||||||
|
this.setState({
|
||||||
|
showDropdown : show
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
renderDropdown : function(dropdownChildren){
|
||||||
|
if(!this.state.showDropdown) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='navDropdown'>
|
||||||
|
{dropdownChildren}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
render : function () {
|
||||||
|
const dropdownChildren = React.Children.map(this.props.children, (child, i) => {
|
||||||
|
// Ignore the first child
|
||||||
|
if (i < 1) return;
|
||||||
|
return child;
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<div className='navDropdownContainer'
|
||||||
|
onMouseEnter={()=>this.handleDropdown(true)}
|
||||||
|
onMouseLeave={()=>this.handleDropdown(false)}>
|
||||||
|
{this.props.children[0]}
|
||||||
|
{this.renderDropdown(dropdownChildren)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -78,4 +78,23 @@ nav{
|
|||||||
.navSection:last-child .navItem{
|
.navSection:last-child .navItem{
|
||||||
border-left : 1px solid #666;
|
border-left : 1px solid #666;
|
||||||
}
|
}
|
||||||
|
.navDropdownContainer{
|
||||||
|
position: relative;
|
||||||
|
.navDropdown {
|
||||||
|
position : absolute;
|
||||||
|
top : 28px;
|
||||||
|
left : 0px;
|
||||||
|
z-index : 10000;
|
||||||
|
width : 100%;
|
||||||
|
.navItem{
|
||||||
|
position : relative;
|
||||||
|
display : block;
|
||||||
|
width : 100%;
|
||||||
|
vertical-align : middle;
|
||||||
|
padding : 8px 5px;
|
||||||
|
border : 1px solid #888;
|
||||||
|
border-bottom : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user