Skip to content

Commit

Permalink
Merge pull request #18 from helsingborg-stad/fix/column-and-size-fixes
Browse files Browse the repository at this point in the history
feat: Sizes, placeholder, notice and columns
  • Loading branch information
Anna authored Dec 14, 2023
2 parents 5a156b9 + b1adb69 commit 8d6f271
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
Binary file modified languages/modularity-like-sv_SE.mo
Binary file not shown.
12 changes: 8 additions & 4 deletions languages/modularity-like-sv_SE.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ msgstr ""
"Project-Id-Version: Modularity Like Posts 1.1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/modularity-"
"like\n"
"POT-Creation-Date: 2023-06-16 13:43+0200\n"
"PO-Revision-Date: 2023-06-16 13:44+0200\n"
"POT-Creation-Date: 2023-11-27 12:14+0100\n"
"PO-Revision-Date: 2023-11-27 12:15+0100\n"
"Last-Translator: \n"
"Language-Team: Svenska\n"
"Language: sv_SE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.3.1\n"
"X-Generator: Poedit 3.4.1\n"
"X-Domain: modularity-like\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-KeywordsList: __;esc_html__\n"
Expand Down Expand Up @@ -104,7 +104,7 @@ msgstr "Länken har kopierats!"
msgid "Something went wrong, link: "
msgstr ""
"Kunde inte kopiera länken automatiskt! Men du kan markera den, högerklicka "
"och välja \"kopiera\" istället:"
"och välja \"kopiera\" istället: "

#: source/php/Module/LikedPosts.php:35
msgid "Close"
Expand All @@ -122,6 +122,10 @@ msgstr "Listans namn"
msgid "List excerpt"
msgstr "Listans ingress"

#: source/php/Module/LikedPosts.php:39
msgid "No liked posts were found"
msgstr "Inga gillade inlägg hittades"

#~ msgctxt "Admin page title"
#~ msgid "Modularity Like"
#~ msgstr "Modularity Gilla"
Expand Down
12 changes: 10 additions & 2 deletions source/js/front/getPosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class GetPosts {
let items = {};
const urlParams = new URLSearchParams(window.location.search);
const encodedLikedPosts = urlParams.get('liked-posts');

if (encodedLikedPosts) {
items = this.handleEndpoints(decodeLikedPosts(encodedLikedPosts));
} else {
Expand All @@ -39,7 +38,16 @@ class GetPosts {
}
if (urls.length > 0) {
this.fetchPosts(urls);
}
}

if (!this.posts && urls.length <= 0) {
[...document.querySelectorAll('[data-js-like-preloader]')].forEach(preloader => {
preloader.remove();
});
[...document.querySelectorAll('[data-js-no-posts-notice]')].forEach(notice => {
notice.classList.remove('u-display--none');
})
}
}

fetchPosts(urls) {
Expand Down
2 changes: 2 additions & 0 deletions source/js/front/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Render {
filteredPosts &&
filteredPosts.forEach((post) => {
const childElement = document.createElement('div');
childElement.classList.add(postColumns);
const html = this.components[`${component}`].html
.replace('{LIKE_POST_TITLE}', post.title?.rendered)
.replace('{LIKE_POST_CONTENT}', this.handleExcerpt(post, component))
Expand Down Expand Up @@ -91,6 +92,7 @@ class Render {
let amount;
let excerpt = post.excerpt?.rendered ? post.excerpt.rendered : post.content?.rendered ? post.content.rendered : '';
excerpt = excerpt.replace(/<[^>]*>/g, '');
excerpt = excerpt.replace(/\s+/g, ' ');

switch (component) {
case 'collection':
Expand Down
1 change: 1 addition & 0 deletions source/php/Module/LikedPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function data(): array
'shareLinkLabel' => __('Share your link', 'modularity-like'),
'shareLinkName' => __('List name', 'modularity-like'),
'shareLinkExcerpt' => __('List excerpt', 'modularity-like'),
'noPostsFound' => __('No liked posts were found', 'modularity-like')
];
$data['id'] = uniqid();

Expand Down
18 changes: 14 additions & 4 deletions source/php/Module/views/partials/collection.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@
'js-like-emblem-url' => $emblem
]
])
@for ($i = 0; $i < 4; $i++)
<div class="liked-posts__preloader u-preloader u-preloader__opacity--7 u-rounded {{ $postColumns }}"
style="height:170px;width:100%;"></div>
@endfor
<div class="liked-posts__preloader u-preloader u-preloader__opacity--7 u-rounded o-grid--12"
style="height:170px;width:100%;" data-js-like-preloader></div>
@notice([
'message' => [
'title' => $labels['noPostsFound'],
],
'classList' => [
'u-display--none'
],
'attributeList' => [
'data-js-no-posts-notice' => ''
]
])
@endnotice
@endcollection
2 changes: 1 addition & 1 deletion views/js/object/collection.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@collection__item([
'link' => '{LIKE_POST_LINK}',
'classList' => ['c-collection__item--post', '{LIKE_POST_CLASSES}', 'u-height--auto'],
'classList' => ['c-collection__item--post', 'u-height--100'],
'attributeList' => ['data-observe-resizes' => ''],
'bordered' => true,
])
Expand Down

0 comments on commit 8d6f271

Please sign in to comment.