diff --git a/packages/x-components/src/__stubs__/index.ts b/packages/x-components/src/__stubs__/index.ts index 2a437254f3..aeab9517d3 100644 --- a/packages/x-components/src/__stubs__/index.ts +++ b/packages/x-components/src/__stubs__/index.ts @@ -15,3 +15,4 @@ export * from './results-stubs.factory'; export * from './search-response-stubs.factory'; export * from './semantic-queries-stubs.factory'; export * from './tagging-response-stubs.factory'; +export * from './related-prompts-stubs.factory'; diff --git a/packages/x-components/src/__stubs__/related-prompts-stubs.factory.ts b/packages/x-components/src/__stubs__/related-prompts-stubs.factory.ts new file mode 100644 index 0000000000..ce47147c43 --- /dev/null +++ b/packages/x-components/src/__stubs__/related-prompts-stubs.factory.ts @@ -0,0 +1,43 @@ +import { RelatedPrompt } from '@empathyco/x-types'; + +/** + * Creates a {@link @empathyco/x-types#RelatedPrompt | related prompts} stub. + * + * @param amount - Number of stubbed related prompts to create. + * + * @returns Array of related prompts stub. + * + * @internal + */ +export function getRelatedPromptsStub(amount = 12): RelatedPrompt[] { + return Array.from({ length: amount }, (_, index) => + createRelatedPromptStub(`Related Prompt ${index + 1}`) + ); +} + +/** + * Creates a related prompt stub with the provided options. + * + * @param suggestionText - The suggested text of the related prompt. + * + * @returns A related prompt. + */ +export function createRelatedPromptStub(suggestionText: string): RelatedPrompt { + return { + suggestionText, + nextQueries: createNextQueriesArrayStub(10), + modelName: 'RelatedPrompt', + type: Math.random() < 0.5 ? 'CURATED' : 'SYNTHETIC' + }; +} + +/** + * Creates an array of next queries. + * + * @param amount - Number of next queries to create. + * + * @returns Array of next queries. + */ +function createNextQueriesArrayStub(amount: number): string[] { + return Array.from({ length: amount }, (_, index) => `Next query ${index + 1}`); +} diff --git a/packages/x-components/src/adapter/mocked-responses.ts b/packages/x-components/src/adapter/mocked-responses.ts index 768ee3443a..23d8049ff3 100644 --- a/packages/x-components/src/adapter/mocked-responses.ts +++ b/packages/x-components/src/adapter/mocked-responses.ts @@ -10,7 +10,8 @@ import { createSimpleFacetStub, getFacetsStub, getRelatedTagsStub, - getResultsStub + getResultsStub, + getRelatedPromptsStub } from '../__stubs__/index'; export const mockedApiUrl = 'https://api.empathy.co'; @@ -198,6 +199,9 @@ export const mockedResponses = { }, 'related-tags': { relatedTags: getRelatedTagsStub() + }, + 'related-prompts': { + relatedPrompts: getRelatedPromptsStub() } }; diff --git a/packages/x-components/src/components/base-grid.vue b/packages/x-components/src/components/base-grid.vue index 6f57d626e4..967fcbc41a 100644 --- a/packages/x-components/src/components/base-grid.vue +++ b/packages/x-components/src/components/base-grid.vue @@ -219,7 +219,8 @@ } .x-base-grid__banner, - .x-base-grid__next-queries-group { + .x-base-grid__next-queries-group, + .x-base-grid__related-prompts-group { grid-column-start: 1; grid-column-end: -1; } diff --git a/packages/x-components/src/index.ts b/packages/x-components/src/index.ts index c32bee25e7..f215f3c1ba 100644 --- a/packages/x-components/src/index.ts +++ b/packages/x-components/src/index.ts @@ -26,6 +26,7 @@ export * from './x-modules/popular-searches'; export * from './x-modules/queries-preview'; export * from './x-modules/query-suggestions'; export * from './x-modules/recommendations'; +export * from './x-modules/related-prompts'; export * from './x-modules/related-tags'; export * from './x-modules/scroll'; export * from './x-modules/search'; diff --git a/packages/x-components/src/views/home/Home.vue b/packages/x-components/src/views/home/Home.vue index 9de9623b72..a8f42d5ab9 100644 --- a/packages/x-components/src/views/home/Home.vue +++ b/packages/x-components/src/views/home/Home.vue @@ -76,7 +76,7 @@
  • -
  • +
  • + +