# ghostkit/3.3.3/gutenberg/blocks/tabs/transforms.js

Block Animations, Motion &amp; Scroll Effects – Ghost Kit, version 3.3.3. 54 lines.

- Page: https://pluginprobe.com/plugins/ghostkit/3.3.3/code/gutenberg/blocks/tabs/transforms.js
- Raw: https://pluginprobe.com/plugins/ghostkit/3.3.3/raw/gutenberg/blocks/tabs/transforms.js
- Modified: 2024-02-18T18:40:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ghostkit/3.3.3/code/gutenberg/blocks/tabs/transforms.js#L10-L20`.

```javascript
import { createBlock } from '@wordpress/blocks';

import getUniqueSlug from '../../utils/get-unique-slug';

export default {
	from: [
		{
			type: 'block',
			blocks: ['ghostkit/accordion'],
			transform(attrs, innerBlocks) {
				const tabsData = [];
				let tabActive = '';

				innerBlocks.forEach((item) => {
					const slug = getUniqueSlug(
						`tab-${item.attributes.heading}`,
						item.clientId
					);

					if (!tabActive && item.attributes.active) {
						tabActive = slug;
					}

					tabsData.push({
						slug,
						title: item.attributes.heading,
					});
				});

				if (!tabActive) {
					tabActive = tabsData[0].slug;
				}

				return createBlock(
					'ghostkit/tabs-v2',
					{
						tabsData,
						tabActive,
					},
					tabsData.map((tab, i) =>
						createBlock(
							'ghostkit/tabs-tab-v2',
							{
								slug: tab.slug,
							},
							innerBlocks[i] ? innerBlocks[i].innerBlocks : ''
						)
					)
				);
			},
		},
	],
};

```
