Skip to content

Commit

Permalink
Merge 34ffcff into 1fc8493
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Sep 26, 2018
2 parents 1fc8493 + 34ffcff commit 2baf52c
Show file tree
Hide file tree
Showing 10 changed files with 1,800 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
2.0b4 (unreleased)
^^^^^^^^^^^^^^^^^^

- Adiciona funcionalidade de preview de imagens em links.
[rodfersou]

- Adiciona suporte para processamento de recursos estáticos usando o `webpack`_.
[rodfersou]

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions webpack/app/brasilgovportal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BugFix from './js/bugfix.js';
import SearchSuggestions from './js/search_suggestions.js';
import TipPreview from './js/tippreview.js';


// https://hacks.mozilla.org/2015/04/es6-in-depth-iterators-and-the-for-of-loop/
Expand All @@ -9,10 +10,14 @@ jQuery.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
$(() => {
new BugFix();
new SearchSuggestions();
if ($('[data-tippreview-enabled="true"]').length > 0) {
new TipPreview();
}
});


export default {
BugFix,
SearchSuggestions,
TipPreview,
}
1 change: 1 addition & 0 deletions webpack/app/brasilgovportal.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import 'scss/sprite';
@import 'scss/tippreview';
Binary file added webpack/app/img/preview.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions webpack/app/js/tippreview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import tippy from 'tippy.js';


export default class TipPreview {
constructor() {
this.$template = $('<div>');
this.$template.html(
`<div class="tippreview">
<div class="tippreview-image">
<img src="" alt="" />
</div>
<div class="tippreview-title">
Page title
</div>
</div>`
);

// don't show preview on edit tab
if ($('#contentview-edit.selected').length > 0) {
return;
}

// Change this option when style the tooltip
this.dontHide = false;

this.createTooltip();
}
createTooltip() {
tippy('[data-tippreview-enabled="true"]', {
animation: 'shift-toward',
arrow: true,
theme: 'light',
html: this.$template[0],
onShow: this.onShow.bind(this),
// prevent tooltip from displaying over button
popperOptions: {
modifiers: {
preventOverflow: {
enabled: false
},
hide: {
enabled: false
}
}
}
});
}
onShow(tip) {
if (this.dontHide) {
tip.hide = function() {};
}

let $a = $(tip.reference);

let $image = $('.tippreview-image > img', this.$template);
$image.attr('src', $a.attr('data-tippreview-image'));

let $title = $('.tippreview-title', this.$template);
$title.html($a.attr('data-tippreview-title'));
}
}
39 changes: 39 additions & 0 deletions webpack/app/scss/_tippreview.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@import '~tippy.js/dist/themes/light';


/* tip preview */
.tippreview {
position: relative;

display: flex;

.tippreview-image {
width: 6rem;
height: 6rem;
}
.tippreview-image > img {
width: 6rem;
height: 6rem;
object-fit: cover;
}
.tippreview-title {
font-weight: bold;

width: 12rem;
margin: 1rem;

text-align: left;
}
&::after {
font-size: 1.2rem;
font-weight: bold;

position: absolute;
top: 0;
right: 0;

display: block;

content: '🡵';
}
}
3 changes: 2 additions & 1 deletion webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"repository": {},
"license": "GPL-2.0",
"dependencies": {
"sc.recipe.staticresources": "simplesconsultoria/sc.recipe.staticresources"
"sc.recipe.staticresources": "simplesconsultoria/sc.recipe.staticresources#1.0b1",
"tippy.js": "^2.5.0"
}
}
1 change: 1 addition & 0 deletions webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ childProcess.execSync(`rm -f ${path}/brasilgovportal-*`);

module.exports = {
entry: [
`./app/img/preview.png`,
'./app/brasilgovportal.scss',
'./app/brasilgovportal.js',
],
Expand Down

0 comments on commit 2baf52c

Please sign in to comment.