diff --git a/packages/plugins/src/DocumentAssetsPlugin.ts b/packages/plugins/src/DocumentAssetsPlugin.ts index 5c6ed4f6..55e04d19 100644 --- a/packages/plugins/src/DocumentAssetsPlugin.ts +++ b/packages/plugins/src/DocumentAssetsPlugin.ts @@ -9,6 +9,7 @@ import remarkParse from 'remark-parse'; import remarkMdx from 'remark-mdx'; import remarkStringify from 'remark-stringify'; import { VFile } from 'vfile'; +import PluginError from './utils/PluginError.js'; interface DocumentAssetsPluginOptions { /** @@ -84,15 +85,16 @@ const DocumentAssetsPlugin: PluginType = { const resolvedSrcDir = path.resolve(srcDir); const resolvedOutputDir = path.resolve(outputDir); if (!resolvedOutputDir.startsWith(resolvedCwd)) { - throw new Error(`outputDir must be within the current working directory: ${outputDir}`); + throw new PluginError( + 'outputDir must be within the current working directory', + resolvedOutputDir + ); } for (const assetSubDir of assetSubDirs) { const resolvedAssetSubDir = path.resolve(resolvedSrcDir, assetSubDir); if (!resolvedAssetSubDir.startsWith(resolvedSrcDir)) { - console.log('ERROR 3'); - - throw new Error(`Asset subdirectory must be within srcDir: ${srcDir}`); + throw new PluginError('asset subdirectory must be within srcDir', resolvedAssetSubDir); } let globbedImageDirs; @@ -107,7 +109,7 @@ const DocumentAssetsPlugin: PluginType = { } } catch (err) { console.error(`Error globbing ${assetSubDir} in ${srcDir}:`, err); - throw err; + throw new PluginError(err.message, assetSubDir); } await fsExtra.ensureDir(outputDir); diff --git a/packages/site-components/src/PatternIndex/index.tsx b/packages/site-components/src/PatternIndex/index.tsx new file mode 100644 index 00000000..c0d6b83d --- /dev/null +++ b/packages/site-components/src/PatternIndex/index.tsx @@ -0,0 +1,315 @@ +import React, { useState, memo } from 'react'; +import classnames from 'clsx'; +import { + FlexItem, + FlowLayout, + FormField, + FormFieldLabel, + GridLayout, + GridItem, + Input +} from '@salt-ds/core'; +import { + Pagination, + P2, + P6, + Caption3, + Link, + useBreakpoint, + usePagination, + TileLink, + useImageComponent +} from '@jpmorganchase/mosaic-components'; +import { Dropdown, SelectionChangeHandler } from '@salt-ds/lab'; +import styles from './styles.css'; + +export type PatternItem = { + description: string; + owner: string; + title: string; + contentUrl?: string; + link: string; + tags: string[]; + source: 'FIGMA' | 'SOURCE' | 'STORYBOOK'; +}; + +export type PatternIndexProps = { + /** Additional class name for root class override */ + className?: string; + /** Number of items per page */ + itemsPerPage?: number; + /** Data view */ + view: PatternItem[]; +}; + +export type PatternRendererProps = { + /** Tile item */ + item: PatternItem; +}; + +const sourceOptions = ['All', 'Figma', 'Storybook', 'Source']; +const sortOrderOptions = ['A-Z', 'Z-A']; + +const PureIframe: React.FC<{ src: string; title: string }> = memo(({ src, title }) => ( +