Skip to content

Commit

Permalink
feat: add authors block
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimds committed Nov 7, 2023
1 parent 817daf1 commit ef4505a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
31 changes: 31 additions & 0 deletions web/app/themes/awasqa/src/carbon-fields-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,37 @@ function get_issue_options()
<?php
});

Block::make('All Authors')
->set_icon('groups')
->add_fields(array(
Field::make('separator', 'crb_separator', __('All Authors', 'awasqa'))
))
->set_render_callback(function ($fields, $attributes, $inner_blocks) {
$user_ids = get_users(['orderby' => 'name', 'fields' => 'ID']);
$authors_data = [];
foreach ($user_ids as $author_id) {
$meta = get_user_meta($author_id);
$image_id = $meta['awasqa_profile_pic_id'][0] ?? null;
$image_url = $image_id ? wp_get_attachment_image_src($image_id) : null;
$name = Awasqa\Authors\awasqa_get_author_name($author_id);
$authors_data[] = [
"link" => get_author_posts_url($author_id),
"name" => $name,
"bio" => Awasqa\Authors\get_translated_author_bio($author_id),
"image_url" => $image_url[0] ?? null
];
}
?>
<ul class="awasqa-all-authors">
<?php foreach ($authors_data as $author_data) : ?>
<li>
<?= Awasqa\Authors\render_author_column($author_data, show_visit_link: true); ?>
</li>
<?php endforeach; ?>
</ul>
<?php
});

Block::make('Organisation Contact Details')
->set_icon('megaphone')
->add_fields(array(
Expand Down
20 changes: 20 additions & 0 deletions web/app/themes/awasqa/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,26 @@ h6::after {
flex-grow: 1;
height: 150px;
}
.awasqa-all-authors {
display: flex;
flex-direction: column;
gap: 2rem;
list-style: none;
padding: 0;
}
@media (min-width: 782px) {
.awasqa-all-authors {
flex-direction: row;
flex-wrap: wrap;
gap: 2rem;
list-style: none;
padding: 0;
}

.awasqa-all-authors li {
flex: 1 0 calc(33% - 4rem);
}
}
.awasqa-author-column p {
margin: 0 0 0.875rem 0;
}
Expand Down
1 change: 1 addition & 0 deletions web/app/themes/awasqa/styles/awasqa.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

@import "blocks/account-actions.css";
@import "blocks/account-details-form.css";
@import "blocks/all-authors.css";
@import "blocks/author-column.css";
@import "blocks/authors-column.css";
@import "blocks/authors.css";
Expand Down
21 changes: 21 additions & 0 deletions web/app/themes/awasqa/styles/blocks/all-authors.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.awasqa-all-authors {
display: flex;
flex-direction: column;
gap: 2rem;
list-style: none;
padding: 0;
}

@media (min-width: 782px) {
.awasqa-all-authors {
flex-direction: row;
flex-wrap: wrap;
gap: 2rem;
list-style: none;
padding: 0;

li {
flex: 1 0 calc(33% - 4rem);
}
}
}

0 comments on commit ef4505a

Please sign in to comment.