Skip to content

Instantly share code, notes, and snippets.

@harmoniemand
Created July 6, 2017 09:59
Show Gist options
  • Save harmoniemand/9ad72496b15a7218a3dc4ab6e6aa42cb to your computer and use it in GitHub Desktop.
Save harmoniemand/9ad72496b15a7218a3dc4ab6e6aa42cb to your computer and use it in GitHub Desktop.
Modal Button
.modal-button {
background: rgb(250,250,250);
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
margin: 6px 8px;
padding: 0;
min-height: 28px;
max-height: 28px;
line-height: 28px;
overflow: hidden;
border-radius: 3px;
outline: none;
text-decoration: none;
border: 0;
font-size: 14px;
font-weight: 500;
display: inline-block;
&.modal {
.modal-button-container {
transform: translate(0, -28px);
}
}
.modal-button-container {
transition: all 0.3s;
.modal-button-label {
padding: 0 6px;
}
.modal-button-modal {
padding: 0 6px;
font-weight: bold;
color: rgb(250, 250, 250);
background: rgb(146, 25, 0);
}
}
}
module.exports = ['$timeout', function ($timeout) {
'use strict';
return {
restrict: 'A',
scope: {
mbLabel: "@",
mbModalText: "@",
mbClick: "="
},
template: require('template.html'),
link: function (scope, elem, attrs) {
elem.addClass('modal-button');
elem.on('mouseleave', function () {
$timeout(function () {
elem.removeClass('modal');
}, 2000);
});
elem.on('click', function () {
if (!elem.hasClass('modal')) {
elem.addClass('modal');
return;
}
if (angular.isFunction(scope.mbClick))
scope.mbClick();
elem.removeClass('modal');
});
}
};
}];
<div class="si-modal-button-container">
<div class="si-modal-button-label">{{mbLabel}}</div>
<div class="si-modal-button-modal">{{mbModalText}}</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment