PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / blocks / tabs / save.js

save.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.3, at gutenberg/blocks/tabs/save.js

83 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import classnames from 'classnames/dedupe';
2
3 import metadata from './block.json';
4
5 const { name } = metadata;
6
7 import {
8 RichText,
9 useBlockProps,
10 useInnerBlocksProps,
11 } from '@wordpress/block-editor';
12 import { applyFilters } from '@wordpress/hooks';
13
14 /**
15 * Block Save Class.
16 *
17 * @param props
18 */
19 export default function BlockSave(props) {
20 const {
21 tabActive,
22 trigger,
23 buttonsVerticalAlign,
24 buttonsAlign,
25 tabsData = [],
26 } = props.attributes;
27
28 let className = classnames(
29 'ghostkit-tabs',
30 buttonsVerticalAlign && 'ghostkit-tabs-buttons-vertical',
31 trigger && `ghostkit-tabs-buttons-trigger-${trigger}`
32 );
33
34 className = applyFilters('ghostkit.blocks.className', className, {
35 ...{ name },
36 ...props,
37 });
38
39 const blockProps = useBlockProps.save({
40 className,
41 });
42 const innerBlockProps = useInnerBlocksProps.save({
43 className: 'ghostkit-tabs-content',
44 });
45
46 return (
47 <div {...blockProps}>
48 <div
49 className={classnames(
50 'ghostkit-tabs-buttons',
51 `ghostkit-tabs-buttons-align-${buttonsAlign}`
52 )}
53 role="tablist"
54 aria-orientation={
55 buttonsVerticalAlign ? 'vertical' : 'horizontal'
56 }
57 >
58 {tabsData.map((tabData) => (
59 <RichText.Content
60 tagName="button"
61 id={`${tabData.slug}-button`}
62 className={classnames(
63 'ghostkit-tabs-buttons-item',
64 tabActive === tabData.slug &&
65 'ghostkit-tabs-buttons-item-active'
66 )}
67 type="button"
68 role="tab"
69 data-tab={tabData.slug}
70 aria-controls={`${tabData.slug}-content`}
71 aria-selected={
72 tabActive === tabData.slug ? 'true' : false
73 }
74 key={`tab_button_${tabData.slug}`}
75 value={tabData.title}
76 />
77 ))}
78 </div>
79 <div {...innerBlockProps} />
80 </div>
81 );
82 }
83