export const setBodyClass = api => {
	// Needs animation frame to make sure story component has been mounted
	window.requestAnimationFrame(() => {
		const currentStory = api.getCurrentStoryData();
		const isDocsOnly = currentStory.parameters.docsOnly === true || currentStory.parameters.hideStory === true;
		const isStoryOnly = !currentStory.parameters.docs;

		if (isDocsOnly) {
			document.body.classList.add('is-docs-only');
			api.navigate(`/docs/${currentStory.id}`);
		} else {
			document.body.classList.remove('is-docs-only');
		}

		if (isStoryOnly) {
			document.body.classList.add('is-story-only');
			api.navigate(`/story/${currentStory.id}`);
		} else {
			document.body.classList.remove('is-story-only');
		}
	});
};
