Skip to content

Commit

Permalink
alignment control in table of content
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan-shafi committed May 15, 2024
1 parent 8dedfdb commit a4cd8e6
Show file tree
Hide file tree
Showing 9 changed files with 134,478 additions and 142 deletions.
2 changes: 1 addition & 1 deletion dist/blocks.build.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'bae0b410ff44e912e182');
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'ba4e21575ef57a7304ad');
134,310 changes: 134,309 additions & 1 deletion dist/blocks.build.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/blocks/table-of-contents/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
}
},
"supports": {
"reusable": false
"reusable": false,
"align": [
"wide",
"full"
]
}
}
2 changes: 1 addition & 1 deletion dist/priority.build.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '31d6cfe0d16ae931b73c');
<?php return array('dependencies' => array(), 'version' => 'bf4427955793c56378a0');
9 changes: 9 additions & 0 deletions dist/priority.build.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ That's it. You're done!

== Changelog ==

= 3.1.9 =

* NEW: Alignment option in table of content block.

= 3.1.8 =

* FIX: Slides per view not working properly in the frontend in image slider block.
Expand Down
6 changes: 3 additions & 3 deletions src/blocks/star-rating/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function ub_render_star_rating_block($attributes){
require_once dirname(dirname(__DIR__)) . '/common.php';

extract($attributes);

$stars = ub_generateStarDisplay($selectedStars, $starCount, $blockID,
'none', $starColor, $starColor, "", "ub_star_rating_filter-", $starSize);

Expand All @@ -24,7 +24,7 @@ function ub_render_star_rating_block($attributes){
('flex-' . $starAlign === 'left' ? 'start' : 'end')) . ';"' : '').'>
<div class="ub-star-inner-container">'.$stars.'</div>
</div>'.
($reviewText === '' || false === $isShowReviewText ? '' : '<div class="ub-review-text"' . ($blockID === '' ? ' style="text-align:' . $reviewTextAlign . ';"' : '') . '>' .
($reviewText === '' || false === $isShowReviewText ? '' : '<div class="ub-review-text"' . ($blockID === '' ? ' style="text-align:' . $reviewTextAlign . ';"' : '') . '>' .
$reviewText
. '</div>') .
'</div>';
Expand All @@ -39,4 +39,4 @@ function ub_register_star_rating_block() {
}
}

add_action('init', 'ub_register_star_rating_block');
add_action('init', 'ub_register_star_rating_block');
264 changes: 134 additions & 130 deletions src/blocks/table-of-contents/block.json
Original file line number Diff line number Diff line change
@@ -1,132 +1,136 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "ub/table-of-contents-block",
"title": "Table of Contents",
"category": "ultimateblocks",
"description": "Give visitors a better naviation of your post with a Table of Contents.",
"keywords": [
"Table of Contents",
"Ultimate Blocks"
],
"attributes": {
"blockID": {
"type": "string",
"default": ""
},
"title": {
"type": "string",
"default": ""
},
"allowedHeaders": {
"type": "array",
"default": [
true,
true,
true,
true,
true,
true
]
},
"links": {
"type": "string",
"default": ""
},
"gaps": {
"type": "array",
"default": []
},
"allowToCHiding": {
"type": "boolean",
"default": false
},
"hideOnMobile": {
"type": "boolean",
"default": false
},
"showList": {
"type": "boolean",
"default": true
},
"numColumns": {
"type": "number",
"default": 1
},
"listStyle": {
"type": "string",
"default": "bulleted"
},
"enableSmoothScroll": {
"type": "boolean",
"default": false
},
"titleAlignment": {
"type": "string",
"default": "left"
},
"allowToLatin": {
"type": "boolean",
"default": false
},
"removeDiacritics": {
"type": "boolean",
"default": false
},
"scrollOption": {
"type": "string",
"default": "auto"
},
"scrollOffset": {
"type": "number",
"default": 0
},
"scrollTarget": {
"type": "string",
"default": ""
},
"scrollTargetType": {
"type": "string",
"default": "id"
},
"titleColor": {
"type": "string",
"default": ""
},
"titleBackgroundColor": {
"type": "string",
"default": ""
},
"listColor": {
"type": "string",
"default": ""
},
"listBackgroundColor": {
"type": "string",
"default": ""
},
"listIconColor": {
"type": "string",
"default": ""
},
"showText": {
"type": "string",
"default": "show"
},
"hideText": {
"type": "string",
"default": "hide"
},
"padding": {
"type": "object",
"default": {}
},
"margin": {
"type": "object",
"default": {}
}
},
"supports": {
"reusable": false
}
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "ub/table-of-contents-block",
"title": "Table of Contents",
"category": "ultimateblocks",
"description": "Give visitors a better naviation of your post with a Table of Contents.",
"keywords": [
"Table of Contents",
"Ultimate Blocks"
],
"attributes": {
"blockID": {
"type": "string",
"default": ""
},
"title": {
"type": "string",
"default": ""
},
"allowedHeaders": {
"type": "array",
"default": [
true,
true,
true,
true,
true,
true
]
},
"links": {
"type": "string",
"default": ""
},
"gaps": {
"type": "array",
"default": []
},
"allowToCHiding": {
"type": "boolean",
"default": false
},
"hideOnMobile": {
"type": "boolean",
"default": false
},
"showList": {
"type": "boolean",
"default": true
},
"numColumns": {
"type": "number",
"default": 1
},
"listStyle": {
"type": "string",
"default": "bulleted"
},
"enableSmoothScroll": {
"type": "boolean",
"default": false
},
"titleAlignment": {
"type": "string",
"default": "left"
},
"allowToLatin": {
"type": "boolean",
"default": false
},
"removeDiacritics": {
"type": "boolean",
"default": false
},
"scrollOption": {
"type": "string",
"default": "auto"
},
"scrollOffset": {
"type": "number",
"default": 0
},
"scrollTarget": {
"type": "string",
"default": ""
},
"scrollTargetType": {
"type": "string",
"default": "id"
},
"titleColor": {
"type": "string",
"default": ""
},
"titleBackgroundColor": {
"type": "string",
"default": ""
},
"listColor": {
"type": "string",
"default": ""
},
"listBackgroundColor": {
"type": "string",
"default": ""
},
"listIconColor": {
"type": "string",
"default": ""
},
"showText": {
"type": "string",
"default": "show"
},
"hideText": {
"type": "string",
"default": "hide"
},
"padding": {
"type": "object",
"default": {}
},
"margin": {
"type": "object",
"default": {}
}
},
"supports": {
"reusable": false,
"align": [
"wide",
"full"
]
}
}
17 changes: 12 additions & 5 deletions src/blocks/table-of-contents/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,20 @@ function ub_makeListItem($num, $item, $listStyle, $blockID, $currentGaps){
else if ($scrollTargetType === 'class'){
$targetType = '.';
}

return '<div class="wp-block-ub-table-of-contents-block ub_table-of-contents' . (isset($className) ? ' ' . esc_attr($className) : '')
. (!$showList ? ' ub_table-of-contents-collapsed' : '' ) .
$classes = array( 'wp-block-ub-table-of-contents-block', 'ub_table-of-contents' );
if(!$showList){
$classes[] = 'ub_table-of-contents-collapsed';
}
$block_wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => implode( ' ', $classes ),
'id' => $blockID === '' ? '' : 'ub_table-of-contents-' . $blockID . '',
)
);
return '<div ' . $block_wrapper_attributes .
'" data-showtext="' . ($showText ?: __('show', 'ultimate-blocks') ) . '" data-hidetext="' . ($hideText ?: __('hide', 'ultimate-blocks'))
. '" data-scrolltype="' . $scrollOption . '"' . ($scrollOption === 'fixedamount' ? ' data-scrollamount="' . $scrollOffset . '"' : '')
. ($scrollOption === 'namedelement' ? ' data-scrolltarget="' . $targetType . $scrollTarget . '"' : '')
. ($blockID === '' ? '' : ' id="ub_table-of-contents-' . $blockID . '"') . ' data-initiallyhideonmobile="' . json_encode($hideOnMobile) . '"
. ($scrollOption === 'namedelement' ? ' data-scrolltarget="' . $targetType . $scrollTarget . '"' : '') . ' data-initiallyhideonmobile="' . json_encode($hideOnMobile) . '"
data-initiallyshow="' . json_encode($showList) . '">'.
(('<div class="ub_table-of-contents-header-container"><div class="ub_table-of-contents-header">
<div class="ub_table-of-contents-title">'. $title . '</div>' .
Expand Down

0 comments on commit a4cd8e6

Please sign in to comment.