-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Utilise Navigation and Tooltip APIs (fixes #83).
- Loading branch information
1 parent
54def7a
commit 38b4d32
Showing
6 changed files
with
219 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Adapt from 'core/js/adapt'; | ||
import drawer from 'core/js/drawer'; | ||
import NavigationButtonView from 'core/js/views/NavigationButtonView'; | ||
import tooltips from 'core/js/tooltips'; | ||
import LanguagePickerDrawerView from './languagePickerDrawerView'; | ||
|
||
export default class LanguagePickerNavigationButton extends NavigationButtonView { | ||
|
||
attributes() { | ||
const attributes = super.attributes(); | ||
return Object.assign(attributes, { | ||
'data-tooltip-id': 'languagepicker' | ||
}); | ||
} | ||
|
||
static get template() { | ||
return 'languagePickerNavigationButton.jsx'; | ||
} | ||
|
||
events() { | ||
return { | ||
click: 'onClick' | ||
}; | ||
} | ||
|
||
initialize(options) { | ||
super.initialize(options); | ||
this.drawerModel = options.drawerModel; | ||
this.setupEventListeners(); | ||
tooltips.register({ | ||
_id: 'languagepicker', | ||
...this.model.get('_navTooltip') | ||
}); | ||
} | ||
|
||
setupEventListeners() { | ||
this.listenTo(Adapt, { | ||
remove: this.remove | ||
}); | ||
} | ||
|
||
onClick(event) { | ||
drawer.openCustomView(new LanguagePickerDrawerView({ model: this.drawerModel }).$el, false, this.model.get('_drawerPosition')); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import { classes, compile } from 'core/js/reactHelpers'; | ||
|
||
export default function LanguagePickerNavigationButton(props) { | ||
const { | ||
text, | ||
_iconClasses | ||
} = props; | ||
return ( | ||
<React.Fragment> | ||
<span | ||
className={classes([ | ||
'icon', | ||
_iconClasses | ||
])} | ||
aria-hidden="true" | ||
/> | ||
<span | ||
className="nav__btn-label" | ||
aria-hidden="true" | ||
dangerouslySetInnerHTML={{ __html: compile(text, props) }} | ||
/> | ||
</React.Fragment> | ||
); | ||
} |