Adds option to have a column sticky. #11.

This commit is contained in:
mateuswetah 2022-09-30 11:22:34 -03:00
parent 10df0202a3
commit 81bffd5e0a
18 changed files with 2249 additions and 138 deletions

View File

@ -5,7 +5,7 @@ Tags: museums, libraries, archives, GLAM, collections, repository, tainacan, blo
Requires at least: 5.0
Tested up to: 6.0
Requires PHP: 5.6
Stable tag: 0.1.16
Stable tag: 0.1.18
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -58,6 +58,12 @@ License details: https://github.com/tainacan/blocksy-tainacan/blob/master/LICENS
== Changelog ==
= 0.1.18 =
* Fixes compatibility with Metadata Sections
= 0.1.17 =
* Makes document gallery compatible with latest features from Tainacan 0.19
= 0.1.16 =
* Fixes trailing commas that were causing errors on PHP < 7.3

View File

@ -4,7 +4,7 @@ Plugin Name: Tainacan Support for Blocksy
Plugin URI: https://tainacan.org/
Description: Tainacan plugin support for Blocksy theme
Author: tainacan
Version: 0.1.16
Version: 0.1.18
Text Domain: tainacan-blocksy
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -15,7 +15,7 @@ if (! defined('WP_DEBUG') ) {
}
/** Theme/plugin version */
const TAINACAN_BLOCKSY_VERSION = '0.1.16';
const TAINACAN_BLOCKSY_VERSION = '0.1.18';
const TAINACAN_BLOCKSY_IS_CHILD_THEME = false;
/* Tools to define our next constants */

View File

@ -133,7 +133,7 @@ if ( !function_exists('tainacan_blocksy_custom_post_types_supported_list') ) {
// This should only happen if we have Tainacan plugin installed
if ( defined ('TAINACAN_VERSION') ) {
return array_filter( $potential_post_types, function($post_type) {
return !in_array($post_type, [ 'tainacan-metadatum', 'tainacan-filter' ]);
return !in_array($post_type, [ 'tainacan-metadatum', 'tainacan-filter', 'tainacan-metasection' ]);
});
}
return $potential_post_types;

View File

@ -0,0 +1,30 @@
<?php
if (! isset($prefix)) {
$prefix = '';
}
if (! isset($enabled)) {
$enabled = 'no';
}
$options = [
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => [
$prefix . 'page_structure_type' => 'type-gm|type-mg',
$prefix . 'document_attachments_structure' => 'gallery-type-2'
],
'options' => [
$prefix . 'document_attachments_affix' => [
'label' => __( 'Document and Attachments column fixed on scroll', 'tainacan-blocksy' ),
'desc' => __( 'Toggle to set the column fixed on top, even after page scroll. This option is only available if using two columns layout and Document and Attachments are merged', 'tainacan-blocksy'),
'type' => 'ct-switch',
'value' => $enabled,
'setting' => [ 'transport' => 'postMessage' ],
'sync' => blocksy_sync_single_post_container([
'prefix' => $prefix,
])
]
]
]
];

View File

@ -25,6 +25,9 @@ $options = [
blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/document-attachments-columns.php', [
'prefix' => $prefix
], false),
blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/document-attachments-affix.php', [
'prefix' => $prefix
], false),
blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/hide-download-button.php', [
'prefix' => $prefix,
'enabled' => 'no'

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "tainacan-blocksy",
"version": "0.1.16",
"version": "0.1.18",
"description": "A Blocksy plugin/child theme compatible with Tainacan",
"main": "index.js",
"scripts": {

View File

@ -16,6 +16,9 @@
--tainacan-block-gray4: var(--color, rgba(44, 62, 80, 0.9));
--tainacan-block-gray5: var(--headingColor, rgba(44, 62, 80, 1));
--background-color: var(--paletteColor7);
// Previous Blocksy variables
--maxSiteWidth: var(--normal-container-max-width);
}
// Grid mixin for display: grid compatibility

View File

@ -329,7 +329,7 @@ body:not(.tainacan-admin-page) {
.page.has-page-header-style-boxed {
.theme-items-list:not(.is-fullscreen) {
grid-template-columns: 1fr minmax(auto, 1300px) 1fr;
grid-template-columns: 1fr minmax(auto, var(--maxSiteWidth,1300px)) 1fr;
}
.tainacan-collection-header .tainacan-collection-header__box {
width: var(--maxSiteWidth, 1290px);

View File

@ -7,7 +7,7 @@
max-width: var(--block-max-width);
align-self: flex-start;
align-self: start;
margin-bottom: 2.25rem;
margin-bottom: 2.5rem;
}
.tainacan-item-single {
@ -209,7 +209,7 @@
display: block;
max-height: 1px;
width: 45%;
background: #e0e5eb;
background: var(--formBorderInitialColor, #e0e5eb);
content: none;
color: transparent;
margin: 0.875rem auto;
@ -217,8 +217,9 @@
}
.tainacan-compound-group {
padding-top: 0.5em;
margin-bottom: .75rem;
padding-left: 1.5rem;
border-left: 1px solid #e0e5eb;
border-left: 1px solid var(--formBorderInitialColor, #e0e5eb);
.label {
margin: 0;
@ -273,7 +274,7 @@
display: block;
max-height: 1px;
width: calc(100% - 40px);
background: #e0e5eb;
background: var(--formBorderInitialColor, #e0e5eb);
content: none;
color: transparent;
margin: 0.5em 0 0.5em 40px;
@ -349,7 +350,7 @@
transition: border 0.3s ease;
}
.swiper-slide-metadata {
.swiper-slide-metadata__name {
display: block;
margin-top: 0.5rem;
font-family: var(--fontFamily);
@ -387,6 +388,12 @@
}
}
// Document and attachments fixed column
.tainacan-item-single--affix-column .tainacan-item-section.tainacan-item-section--gallery {
position: sticky;
top: 2rem;
}
// Document Download button -------------------------------------
.tainacan-item-file-download {
position: absolute;

View File

@ -15,6 +15,7 @@
--tainacan-block-gray4: var(--color, rgba(44, 62, 80, 0.9));
--tainacan-block-gray5: var(--headingColor, rgba(44, 62, 80, 1));
--background-color: var(--paletteColor7);
--maxSiteWidth: var(--normal-container-max-width);
}
/* Remaining imports */
@ -355,7 +356,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
}
.page.has-page-header-style-boxed .theme-items-list:not(.is-fullscreen) {
grid-template-columns: 1fr minmax(auto, 1300px) 1fr;
grid-template-columns: 1fr minmax(auto, var(--maxSiteWidth, 1300px)) 1fr;
}
.page.has-page-header-style-boxed .tainacan-collection-header .tainacan-collection-header__box {
@ -380,7 +381,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
max-width: var(--block-max-width);
align-self: flex-start;
align-self: start;
margin-bottom: 2.25rem;
margin-bottom: 2.5rem;
}
.tainacan-item-single-page .tainacan-item-single {
@ -595,7 +596,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
display: block;
max-height: 1px;
width: 45%;
background: #e0e5eb;
background: var(--formBorderInitialColor, #e0e5eb);
content: none;
color: transparent;
margin: 0.875rem auto;
@ -603,8 +604,9 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
.tainacan-item-single-page .tainacan-item-single .tainacan-item-section__metadata .tainacan-compound-group {
padding-top: 0.5em;
margin-bottom: .75rem;
padding-left: 1.5rem;
border-left: 1px solid #e0e5eb;
border-left: 1px solid var(--formBorderInitialColor, #e0e5eb);
}
.tainacan-item-single-page .tainacan-item-single .tainacan-item-section__metadata .tainacan-compound-group .label {
@ -664,7 +666,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
display: block;
max-height: 1px;
width: calc(100% - 40px);
background: #e0e5eb;
background: var(--formBorderInitialColor, #e0e5eb);
content: none;
color: transparent;
margin: 0.5em 0 0.5em 40px;
@ -737,7 +739,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
transition: border 0.3s ease;
}
.tainacan-item-single-page .tainacan-media-component .tainacan-media-component__swiper-thumbs .swiper-slide-metadata {
.tainacan-item-single-page .tainacan-media-component .tainacan-media-component__swiper-thumbs .swiper-slide-metadata__name {
display: block;
margin-top: 0.5rem;
font-family: var(--fontFamily);
@ -773,6 +775,11 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
margin: 0 auto;
}
.tainacan-item-single-page .tainacan-item-single--affix-column .tainacan-item-section.tainacan-item-section--gallery {
position: sticky;
top: 2rem;
}
.tainacan-item-single-page .tainacan-item-file-download {
position: absolute;
opacity: 0;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -21,10 +21,12 @@ if ($page_structure_type == 'type-gm' || $page_structure_type == 'type-mg') {
$column_metadata_width = 100 - $column_documents_attachments_width;
if ($page_structure_type == 'type-gm') {
$template_columns_style = 'grid-template-columns: ' . $column_documents_attachments_width . '% calc(' . $column_metadata_width . '% - 48px)';
$template_columns_style = 'grid-template-columns: ' . $column_documents_attachments_width . '% calc(' . $column_metadata_width . '% - 48px);';
} else {
$template_columns_style = 'grid-template-columns: ' . $column_metadata_width . '% calc(' . $column_documents_attachments_width . '% - 48px)';
$template_columns_style = 'grid-template-columns: ' . $column_metadata_width . '% calc(' . $column_documents_attachments_width . '% - 48px);';
}
$column_documents_attachments_affix = get_theme_mod( $prefix . '_document_attachments_affix', 'no') === 'yes';
}
do_action( 'tainacan-blocksy-single-item-top' );
@ -51,6 +53,9 @@ add_action( 'blocksy:hero:before', function() use ( $page_structure_type, $prefi
$extra_classes = 'has-content-style-' . $content_style;
}
if ( $column_documents_attachments_affix )
$extra_classes .= ' has-column-affix';
$media_component_style = '';
$media_component_color_palette = get_theme_mod($prefix . '_document_attachments_colors',
[
@ -74,7 +79,7 @@ add_action( 'blocksy:hero:before', function() use ( $page_structure_type, $prefi
});
?>
<div class="<?php echo esc_attr('tainacan-item-single tainacan-item-single--layout-'. $page_structure_type) ?>" style="<?php echo esc_attr($template_columns_style) ?>">
<div class="<?php echo esc_attr('tainacan-item-single tainacan-item-single--layout-'. $page_structure_type . ($column_documents_attachments_affix ? ' tainacan-item-single--affix-column' : '')) ?>" style="<?php echo esc_attr($template_columns_style) ?>">
<?php
if ($page_structure_type !== 'type-gtm') {
tainacan_blocksy_get_template_part( 'template-parts/tainacan-item-single-document' );

View File

@ -1,74 +1,13 @@
<?php
$prefix = blocksy_manager()->screen->get_prefix();
// Galley mode is a shortname for when documents and attachments are displayed merged in the same list
$is_gallery_mode = get_theme_mod($prefix . '_document_attachments_structure', 'gallery-type-1') == 'gallery-type-2';
$hide_file_name_main = get_theme_mod( $prefix . '_hide_files_name_main', 'yes') == 'yes';
$hide_file_caption_main = get_theme_mod( $prefix . '_hide_files_caption_main', 'yes') == 'yes';
$hide_file_description_main = get_theme_mod( $prefix . '_hide_files_description_main', 'yes') == 'yes';
$hide_download_button = get_theme_mod( $prefix . '_hide_download_button', 'no' ) == 'yes';
$disable_gallery_lightbox = get_theme_mod( $prefix . '_disable_gallery_lightbox', 'no') == 'yes';
global $post;
if ( tainacan_has_document() && !$is_gallery_mode ) : ?>
<section class="tainacan-item-section tainacan-item-section--document">
<?php if ( get_theme_mod($prefix . '_display_section_labels', 'yes') == 'yes' && get_theme_mod($prefix . '_section_document_label', __( 'Document', 'tainacan-blocksy' )) != '' ) : ?>
<h2 class="tainacan-single-item-section" id="tainacan-item-document-label">
<?php echo esc_html( get_theme_mod($prefix . '_section_document_label', __( 'Document', 'tainacan-blocksy' ) ) ); ?>
</h2>
<?php endif; ?>
<div class="tainacan-item-section__document">
<?php if ( function_exists('tainacan_the_media_component') ) {
$media_items_main = array();
$class_slide_metadata = '';
if ($hide_file_name_main)
$class_slide_metadata .= ' hide-name';
if ($hide_file_description_main)
$class_slide_metadata .= ' hide-description';
if ($hide_file_caption_main)
$class_slide_metadata .= ' hide-caption';
if ( tainacan_has_document() ) {
$is_document_type_attachment = tainacan_get_the_document_type() === 'attachment';
$media_items_main[] =
tainacan_get_the_media_component_slide(array(
'after_slide_metadata' => (( !$hide_download_button && tainacan_the_item_document_download_link() != '' ) ?
('<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>')
: ''),
'media_content' => tainacan_get_the_document(),
'media_content_full' => $is_document_type_attachment ? tainacan_get_the_document(0, 'full') : ('<div class="attachment-without-image">' . tainacan_get_the_document(0, 'full') . '</div>'),
'media_title' => $is_document_type_attachment ? get_the_title(tainacan_get_the_document_raw()) : '',
'media_description' => $is_document_type_attachment ? get_the_content(tainacan_get_the_document_raw()) : '',
'media_caption' => $is_document_type_attachment ? wp_get_attachment_caption(tainacan_get_the_document_raw()) : '',
'media_type' => tainacan_get_the_document_type(),
'class_slide_metadata' => $class_slide_metadata
));
}
tainacan_the_media_component(
'tainacan-item-document_id-' . $post->ID,
[],
$media_items_main,
array(
'swiper_main_options' => array(
'navigation' => array(
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-document_id-' . $post->ID . '-main',
'prevEl' => '.swiper-navigation-prev_' . 'tainacan-item-document_id-' . $post->ID . '-main',
)
),
'disable_lightbox' => $disable_gallery_lightbox,
)
);
if ( function_exists('tainacan_the_item_gallery') ) { //if (version_compare(TAINACAN_VERSION, '0.19RC') >= 0) {
tainacan_blocksy_get_template_part( 'template-parts/tainacan-item-single-document_new' );
} else if ( function_exists('tainacan_get_the_media_component') ) { //if (version_compare(TAINACAN_VERSION, '0.18RC') >= 0) {
tainacan_blocksy_get_template_part( 'template-parts/tainacan-item-single-document_old' );
} else {
tainacan_the_document();
if ( !$hide_download_button && function_exists('tainacan_the_item_document_download_link') && tainacan_the_item_document_download_link() != '' ) {
echo '<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>';
}
} ?>
?>
<div style="text-aling: center; max-width: 600px; margin: 2em auto; width: 100%; font-style: italic;">
<p><?php __('It seems that you are using a legacy vesion of the Tainacan plugin. Please update in order to use the latest features for displaying item media.', 'tainacan-blocksy') ?></p>
</div>
</section>
<?php endif; ?>
<?php
}
?>

View File

@ -0,0 +1,47 @@
<?php
$prefix = blocksy_manager()->screen->get_prefix();
// Galley mode is a shortname for when documents and attachments are displayed merged in the same list
$is_gallery_mode = get_theme_mod( $prefix . '_document_attachments_structure', 'gallery-type-1' ) == 'gallery-type-2';
$hide_file_name = get_theme_mod( $prefix . '_hide_files_name', 'no') == 'yes';
$hide_file_name_main = get_theme_mod( $prefix . '_hide_files_name_main', 'yes') == 'yes';
$hide_file_caption_main = get_theme_mod( $prefix . '_hide_files_caption_main', 'yes') == 'yes';
$hide_file_description_main = get_theme_mod( $prefix . '_hide_files_description_main', 'yes') == 'yes';
$hide_download_button = get_theme_mod( $prefix . '_hide_download_button', 'no' ) == 'yes';
$disable_gallery_lightbox = get_theme_mod( $prefix . '_disable_gallery_lightbox', 'no') == 'yes';
$hide_file_name_lightbox = get_theme_mod( $prefix . '_hide_files_name_lightbox', 'no') == 'yes';
$hide_file_caption_lightbox = get_theme_mod( $prefix . '_hide_files_caption_lightbox', 'no') == 'yes';
$hide_file_description_lightbox = get_theme_mod( $prefix . '_hide_files_description_lightbox', 'no') == 'yes';
$has_light_dark_color_scheme = get_theme_mod( $prefix . '_gallery_color_scheme', 'dark' ) == 'light';
global $post;
if ( tainacan_has_document() && !$is_gallery_mode ) : ?>
<section class="tainacan-item-section tainacan-item-section--document">
<?php if ( get_theme_mod($prefix . '_display_section_labels', 'yes') == 'yes' && get_theme_mod($prefix . '_section_document_label', __( 'Document', 'tainacan-blocksy' )) != '' ) : ?>
<h2 class="tainacan-single-item-section" id="tainacan-item-document-label">
<?php echo esc_html( get_theme_mod($prefix . '_section_document_label', __( 'Document', 'tainacan-blocksy' ) ) ); ?>
</h2>
<?php endif; ?>
<?php
tainacan_the_item_gallery([
'blockId' => 'tainacan-item-document_id-' . $post->ID,
'layoutElements' => array( 'main' => true, 'thumbnails' => false ),
'mediaSources' => array( 'document' => true, 'attachments' => false, 'metadata' => false),
'hideFileNameMain' => $hide_file_name_main,
'hideFileCaptionMain' => $hide_file_caption_main,
'hideFileDescriptionMain' => $hide_file_description_main,
'hideFileNameThumbnails' => $hide_file_name,
'hideFileCaptionThumbnails' => true,
'hideFileDescriptionThumbnails' => true,
'showDownloadButtonMain' => !$hide_download_button,
'showArrowsAsSVG' => false,
'hideFileNameLightbox' => $hide_file_name_lightbox,
'hideFileCaptionLightbox' => $hide_file_caption_lightbox,
'hideFileDescriptionLightbox' => $hide_file_description_lightbox,
'openLightboxOnClick' => $is_gallery_mode ? !$disable_gallery_lightbox : true,
'lightboxHasLightBackground' => $has_light_dark_color_scheme
]);
?>
</section>
<?php endif; ?>

View File

@ -0,0 +1,74 @@
<?php
$prefix = blocksy_manager()->screen->get_prefix();
// Galley mode is a shortname for when documents and attachments are displayed merged in the same list
$is_gallery_mode = get_theme_mod($prefix . '_document_attachments_structure', 'gallery-type-1') == 'gallery-type-2';
$hide_file_name_main = get_theme_mod( $prefix . '_hide_files_name_main', 'yes') == 'yes';
$hide_file_caption_main = get_theme_mod( $prefix . '_hide_files_caption_main', 'yes') == 'yes';
$hide_file_description_main = get_theme_mod( $prefix . '_hide_files_description_main', 'yes') == 'yes';
$hide_download_button = get_theme_mod( $prefix . '_hide_download_button', 'no' ) == 'yes';
$disable_gallery_lightbox = get_theme_mod( $prefix . '_disable_gallery_lightbox', 'no') == 'yes';
global $post;
if ( tainacan_has_document() && !$is_gallery_mode ) : ?>
<section class="tainacan-item-section tainacan-item-section--document">
<?php if ( get_theme_mod($prefix . '_display_section_labels', 'yes') == 'yes' && get_theme_mod($prefix . '_section_document_label', __( 'Document', 'tainacan-blocksy' )) != '' ) : ?>
<h2 class="tainacan-single-item-section" id="tainacan-item-document-label">
<?php echo esc_html( get_theme_mod($prefix . '_section_document_label', __( 'Document', 'tainacan-blocksy' ) ) ); ?>
</h2>
<?php endif; ?>
<div class="tainacan-item-section__document">
<?php if ( function_exists('tainacan_the_media_component') ) {
$media_items_main = array();
$class_slide_metadata = '';
if ($hide_file_name_main)
$class_slide_metadata .= ' hide-name';
if ($hide_file_description_main)
$class_slide_metadata .= ' hide-description';
if ($hide_file_caption_main)
$class_slide_metadata .= ' hide-caption';
if ( tainacan_has_document() ) {
$is_document_type_attachment = tainacan_get_the_document_type() === 'attachment';
$media_items_main[] =
tainacan_get_the_media_component_slide(array(
'after_slide_metadata' => (( !$hide_download_button && tainacan_the_item_document_download_link() != '' ) ?
('<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>')
: ''),
'media_content' => tainacan_get_the_document(),
'media_content_full' => $is_document_type_attachment ? tainacan_get_the_document(0, 'full') : ('<div class="attachment-without-image">' . tainacan_get_the_document(0, 'full') . '</div>'),
'media_title' => $is_document_type_attachment ? get_the_title(tainacan_get_the_document_raw()) : '',
'media_description' => $is_document_type_attachment ? get_the_content(tainacan_get_the_document_raw()) : '',
'media_caption' => $is_document_type_attachment ? wp_get_attachment_caption(tainacan_get_the_document_raw()) : '',
'media_type' => tainacan_get_the_document_type(),
'class_slide_metadata' => $class_slide_metadata
));
}
tainacan_the_media_component(
'tainacan-item-document_id-' . $post->ID,
[],
$media_items_main,
array(
'swiper_main_options' => array(
'navigation' => array(
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-document_id-' . $post->ID . '-main',
'prevEl' => '.swiper-navigation-prev_' . 'tainacan-item-document_id-' . $post->ID . '-main',
)
),
'disable_lightbox' => $disable_gallery_lightbox,
)
);
} else {
tainacan_the_document();
if ( !$hide_download_button && function_exists('tainacan_the_item_document_download_link') && tainacan_the_item_document_download_link() != '' ) {
echo '<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>';
}
} ?>
</div>
</section>
<?php endif; ?>