import { kebabCase } from '@knapsack/utils'; import type { ThemeDefinition } from '@knapsack/types'; export const themeDefinitionToAttributes = ({ collectionsParentKey, themeDefinition = {}, }: { collectionsParentKey: string; themeDefinition: ThemeDefinition; }) => { // No collectionsParentKey means *they have not configured collections* if (!collectionsParentKey) return {}; return Object.fromEntries( Object.entries(themeDefinition) .filter(([_, modeId]) => !!modeId) .map(([collectionId, modeId]) => { return [ kebabCase(`data-${collectionsParentKey}-${collectionId}`), modeId, ]; }), ); };