import placeholderTwig from './paragraph.placeholder.twig';
import placeholderData from './paragraph.placeholder.yml';
import './paragraph.placeholder.js';

import { formatParagraphText, setPublishedStatus } from '.storybook/utils';

/**
 * Storybook Definition.
 */
export default {
  title: 'Layout Components/Placeholder',
};

export const placeholder = (args) => {
  // Create deep copy of data and merge args.
  let data = JSON.parse(JSON.stringify(placeholderData ?? {}));
  data = Object.assign(data, args);

  data.paragraph = setPublishedStatus(data.paragraph_is_published);

  return placeholderTwig({
    ...data,
    paragraph_field_body: formatParagraphText(data.paragraph_field_body)
  });
};
placeholder.args = placeholderData;
