From ef4505a7e8deda57a16410562d1fb660e77d78d6 Mon Sep 17 00:00:00 2001 From: Joaquim d'Souza Date: Tue, 7 Nov 2023 13:05:56 +0100 Subject: [PATCH] feat: add authors block --- .../awasqa/src/carbon-fields-blocks.php | 31 +++++++++++++++++++ web/app/themes/awasqa/style.css | 20 ++++++++++++ web/app/themes/awasqa/styles/awasqa.css | 1 + .../awasqa/styles/blocks/all-authors.css | 21 +++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 web/app/themes/awasqa/styles/blocks/all-authors.css diff --git a/web/app/themes/awasqa/src/carbon-fields-blocks.php b/web/app/themes/awasqa/src/carbon-fields-blocks.php index 109505c..bf8f5dc 100644 --- a/web/app/themes/awasqa/src/carbon-fields-blocks.php +++ b/web/app/themes/awasqa/src/carbon-fields-blocks.php @@ -203,6 +203,37 @@ function get_issue_options() 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 + ]; + } + ?> + + set_icon('megaphone') ->add_fields(array( diff --git a/web/app/themes/awasqa/style.css b/web/app/themes/awasqa/style.css index e665a6f..d6039ca 100644 --- a/web/app/themes/awasqa/style.css +++ b/web/app/themes/awasqa/style.css @@ -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; } diff --git a/web/app/themes/awasqa/styles/awasqa.css b/web/app/themes/awasqa/styles/awasqa.css index 736edf3..7124366 100644 --- a/web/app/themes/awasqa/styles/awasqa.css +++ b/web/app/themes/awasqa/styles/awasqa.css @@ -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"; diff --git a/web/app/themes/awasqa/styles/blocks/all-authors.css b/web/app/themes/awasqa/styles/blocks/all-authors.css new file mode 100644 index 0000000..8aed25b --- /dev/null +++ b/web/app/themes/awasqa/styles/blocks/all-authors.css @@ -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); + } + } +} \ No newline at end of file