Skip to content

Commit 65c78df

Browse files
committed
External link用のDropdown menu追加
1 parent a7096aa commit 65c78df

2 files changed

Lines changed: 61 additions & 9 deletions

File tree

browser/main/HomePage/ArticleTopBar.js

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export default class ArticleTopBar extends React.Component {
3535
super(props)
3636

3737
this.state = {
38-
isTooltipHidden: true
38+
isTooltipHidden: true,
39+
isLinksDropdownOpen: false
3940
}
4041
}
4142

@@ -96,6 +97,28 @@ export default class ArticleTopBar extends React.Component {
9697
dispatch(toggleTutorial())
9798
}
9899

100+
handleLinksDropdownClick (e) {
101+
e.preventDefault()
102+
let linksButton = document.activeElement
103+
this.handleLinksDropdownClickHandler = e => {
104+
if (linksButton !== document.activeElement) {
105+
console.log('hide dropdown')
106+
document.removeEventListener('click', this.handleLinksDropdownClickHandler)
107+
this.setState({
108+
isLinksDropdownOpen: false
109+
})
110+
}
111+
}
112+
113+
if (!this.state.isLinksDropdownOpen) {
114+
document.removeEventListener('click', this.handleLinksDropdownClickHandler)
115+
document.addEventListener('click', this.handleLinksDropdownClickHandler)
116+
this.setState({
117+
isLinksDropdownOpen: true
118+
})
119+
}
120+
}
121+
99122
render () {
100123
let { status } = this.props
101124
return (
@@ -132,10 +155,23 @@ export default class ArticleTopBar extends React.Component {
132155
<div className='right'>
133156
<button onClick={e => this.handleTutorialButtonClick(e)}>?<span className='tooltip'>How to use</span>
134157
</button>
135-
<ExternalLink className='logo' href='http://b00st.io'>
158+
<a className='linksBtn' onClick={e => this.handleLinksDropdownClick(e)} href>
136159
<img src='../../resources/favicon-230x230.png' width='44' height='44'/>
137-
<span className='tooltip'>Boost official page</span>
138-
</ExternalLink>
160+
</a>
161+
{
162+
this.state.isLinksDropdownOpen
163+
? (
164+
<div className='links-dropdown'>
165+
<ExternalLink className='links-item' href='https://b00st.io'>
166+
<i className='fa fa-fw fa-home'/>Boost official page
167+
</ExternalLink>
168+
<ExternalLink className='links-item' href='https://github.com/BoostIO/boost-app-discussions/issues'>
169+
<i className='fa fa-fw fa-bullhorn'/> Discuss
170+
</ExternalLink>
171+
</div>
172+
)
173+
: null
174+
}
139175
</div>
140176

141177
{status.isTutorialOpen ? (

browser/styles/main/HomeContainer/components/ArticleTopBar.styl

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,33 @@ infoBtnActiveBgColor = #3A3A3A
147147
.tooltip
148148
opacity 1
149149

150-
&>.logo
150+
&>.linksBtn
151151
display block
152152
position absolute
153153
top 8px
154154
right 15px
155155
opacity 0.7
156-
.tooltip
157-
tooltip()
158-
margin-top 44px
159-
margin-left -120px
160156
&:hover
161157
opacity 1
162158
.tooltip
163159
opacity 1
160+
&>.links-dropdown
161+
position fixed
162+
z-index 50
163+
right 10px
164+
top 40px
165+
background-color transparentify(invBackgroundColor, 80%)
166+
padding 5px 0
167+
.links-item
168+
padding 0 10px
169+
height 33px
170+
width 100%
171+
display block
172+
line-height 33px
173+
text-decoration none
174+
color white
175+
&:hover
176+
background-color transparentify(lighten(invBackgroundColor, 30%), 80%)
177+
178+
179+

0 commit comments

Comments
 (0)