Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create related prompts module #1642

Merged
merged 52 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c6b28e5
feat(x-installer): update to vue3 and adapt x-installer (#1572)
victorcg88 Jul 23, 2024
a485dea
feat: make internal demo app functional (#1574)
diegopf Jul 24, 2024
1877da6
refactor(components): remove warnings first batch (#1575)
victorcg88 Jul 26, 2024
4b57f19
fix(list-components): fix list components, migrate infinite-scroll di…
joseacabaneros Jul 26, 2024
71c08db
refactor(v-deep): replace by :deep() (#1577)
victorcg88 Jul 30, 2024
46ff08b
test(vue-jest): update vue-jest dependency (#1581)
victorcg88 Jul 31, 2024
7875ff5
refactor(render-function): clear void calls (#1580)
victorcg88 Jul 31, 2024
b936ae5
fix(infinite-scroll): getting xBus from XPlugin instead useXBus
joseacabaneros Aug 5, 2024
f915731
refactor(animation-factory): fix Vue3 breaking changes (#1579)
victorcg88 Aug 5, 2024
059eecc
refactor: get rid of NoElement component and useNoElementRender compo…
joseacabaneros Aug 6, 2024
875a6e2
refactor(base-switch): migrate component to vue3 (#1588)
victorcg88 Aug 6, 2024
335c370
test(auto-progress-bar): fix test after Vue3 update (#1582)
victorcg88 Aug 7, 2024
35968eb
refactor(base-switch): decommission of value prop (#1589)
victorcg88 Aug 9, 2024
5d4dec8
test(components): fix tests after Vue3 update BATCH 1
victorcg88 Aug 9, 2024
40f6f66
Merge branch 'main' into vue3-update-rc
diegopf Aug 13, 2024
7ec2b97
fix: adjust to new vue render function API (#1596)
diegopf Aug 14, 2024
e64e3cb
fix(search): replace results state to append new results instead of p…
joseacabaneros Aug 14, 2024
f9e716a
test(components) fix tests after vue3 update (#1599)
albertjcuac Aug 19, 2024
79e136f
refactor(staggered-fade-and-slide): use Vue native staggered transiti…
victorcg88 Aug 19, 2024
f6350c0
merge main branch
diegopf Aug 21, 2024
ed587b1
build: adjust rollup production build for Vue3 (#1603)
joseacabaneros Aug 27, 2024
fe6fffb
fix build for x-tailwindcss
diegopf Aug 27, 2024
b3cc3f5
fix(layout): avoid shared CSS classes between layouts with scoped (#1…
joseacabaneros Aug 30, 2024
aff3151
ci(linter): fix linter issues to pass the CI (#1606)
joseacabaneros Sep 3, 2024
9320c57
feat: bump vue18n version (#1604)
diegopf Sep 3, 2024
b98a31e
feat(rollup): update replace config to align CSS injector with Vue 3 …
joseacabaneros Sep 5, 2024
eb7d377
feat: bump packages versions (#1611)
diegopf Sep 5, 2024
ada9f4a
Merge branch 'main' into vue3-update-rc
diegopf Sep 5, 2024
701cfef
chore(release): publish
Sep 5, 2024
0f4bb97
test: adjust test to vue3 (#1608)
lauramargar Sep 13, 2024
7778704
Merge remote-tracking branch 'origin/main' into vue3-update-rc
joseacabaneros Sep 16, 2024
82a6e27
fix(history-queries-switch)!: migrate value to modelValue (#1618)
victorcg88 Sep 23, 2024
45fbfc3
Fix Vue3 unit tests (#1615)
joseacabaneros Sep 24, 2024
0f35e7c
test: active and fix linter for tests (#1616)
joseacabaneros Sep 24, 2024
f81add6
test(e2e): fix e2e tests (#1617)
joseacabaneros Sep 24, 2024
5a419b2
test(e2e-components): rewrite all e2e sheet components to accomplish …
joseacabaneros Sep 25, 2024
bc8374d
chore(release): publish
Sep 25, 2024
ad970ae
fix(scroll): scroll direction inconsistency (#1629)
victorcg88 Oct 3, 2024
56dc022
chore(release): publish
Oct 4, 2024
1aadc42
Merge remote-tracking branch 'origin/main' into vue3-update-rc
lauramargar Oct 7, 2024
fb4ae07
feat: add types for related prompts
victorcg88 Oct 21, 2024
0c59fc9
feat: add adapter for related prompts
victorcg88 Oct 21, 2024
45ae37d
feat: create related prompts module
victorcg88 Oct 21, 2024
89978e8
feat: integrate RelatedPrompts in demo app
victorcg88 Oct 22, 2024
7579245
Merge branch 'main' into feat/add-types-for-related-prompts
victorcg88 Oct 27, 2024
370647a
Merge branch 'feat/add-types-for-related-prompts' into feat/add-relat…
victorcg88 Oct 28, 2024
f9d5b10
Merge branch 'feat/add-related-prompts-adapter' into feat/related-pro…
victorcg88 Oct 28, 2024
976f943
test: test for RP module and doc for related-prompts-list
victorcg88 Oct 28, 2024
89485e4
Merge branch 'main' into feat/related-prompts-module
victorcg88 Oct 28, 2024
69e9976
remove styling classes and add prop to customize next queries button
victorcg88 Oct 31, 2024
3ed7870
Merge branch 'main' into feat/related-prompts-module
victorcg88 Oct 31, 2024
16778d4
add next query slot and remove tailwind use
victorcg88 Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/x-components/src/__stubs__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
@@ -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}`);
}
6 changes: 5 additions & 1 deletion packages/x-components/src/adapter/mocked-responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
createSimpleFacetStub,
getFacetsStub,
getRelatedTagsStub,
getResultsStub
getResultsStub,
getRelatedPromptsStub
} from '../__stubs__/index';

export const mockedApiUrl = 'https://api.empathy.co';
Expand Down Expand Up @@ -198,6 +199,9 @@ export const mockedResponses = {
},
'related-tags': {
relatedTags: getRelatedTagsStub()
},
'related-prompts': {
relatedPrompts: getRelatedPromptsStub()
}
};

Expand Down
3 changes: 2 additions & 1 deletion packages/x-components/src/components/base-grid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions packages/x-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
170 changes: 118 additions & 52 deletions packages/x-components/src/views/home/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</label>
</li>
<li class="x-test-controls__item">
<label for="nextQueriesPreview.maxItemsToRender">
<label for="nextQueriesList.showOnlyAfterOffset">
next-queries-list - showOnlyAfterOffset
<input
v-model="controls.nextQueriesList.showOnlyAfterOffset"
Expand All @@ -86,6 +86,17 @@
/>
</label>
</li>
<li class="x-test-controls__item">
<label for="relatedPromptsList.showOnlyAfterOffset">
related-prompts-list - showOnlyAfterOffset
<input
v-model="controls.relatedPromptsList.showOnlyAfterOffset"
id="relatedPromptsList.showOnlyAfterOffset"
type="checkbox"
data-test="rp-preview-show-after-offset"
/>
</label>
</li>
<li class="x-test-controls__item">
<label for="adapter.e2eAdapter">
Use mocked adapter
Expand Down Expand Up @@ -315,64 +326,110 @@
:show-only-after-offset="controls.nextQueriesList.showOnlyAfterOffset"
class="x-mot-next-queries-list"
>
<BaseVariableColumnGrid
style="--x-size-min-width-grid-item: 150px"
class="x-gap-12"
:animation="resultsAnimation"
:columns="x.device === 'mobile' ? 2 : 4"
<RelatedPromptsList
:show-only-after-offset="controls.relatedPromptsList.showOnlyAfterOffset"
class="x-mot-related-prompt-list"
>
<template #result="{ item: result }">
<MainScrollItem :item="result">
<Result :result="result" data-test="search-result" />
</MainScrollItem>
</template>
<BaseVariableColumnGrid
style="--x-size-min-width-grid-item: 150px"
class="x-gap-12"
:animation="resultsAnimation"
:columns="x.device === 'mobile' ? 2 : 4"
>
<template #result="{ item: result }">
<MainScrollItem :item="result">
<Result :result="result" data-test="search-result" />
</MainScrollItem>
</template>

<template #banner="{ item: banner }">
<Banner :banner="banner" />
</template>
<template #banner="{ item: banner }">
<Banner :banner="banner" />
</template>

<template #promoted="{ item: promoted }">
<Promoted :promoted="promoted" />
</template>
<template #promoted="{ item: promoted }">
<Promoted :promoted="promoted" />
</template>

<template #next-queries-group="{ item: { nextQueries } }">
<NextQueryPreview
:suggestion="nextQueries[0]"
:max-items-to-render="controls.nextQueriesPreview.maxItemsToRender"
#default="{ results }"
class="x-pt-24"
>
<h1 class="x-title2">Others clients have searched</h1>
<NextQuery
class="x-suggestion x-text1 x-text1-lg"
<template #next-queries-group="{ item: { nextQueries } }">
<NextQueryPreview
:suggestion="nextQueries[0]"
data-test="next-query-preview-name"
:max-items-to-render="controls.nextQueriesPreview.maxItemsToRender"
#default="{ results }"
class="x-pt-24"
>
<span class="x-font-bold">{{ nextQueries[0].query }}</span>
</NextQuery>
<div class="x-mb-24">
<SlidingPanel :resetOnContentChange="false">
<div class="x-flex x-flex-row x-gap-8">
<Result
v-for="result in results"
:key="result.id"
:result="result"
style="max-width: 180px"
data-test="next-query-preview-result"
/>
</div>
</SlidingPanel>
</div>
<NextQuery
:suggestion="nextQueries[0]"
data-test="view-all-results"
class="x-button x-button-outlined x-rounded-full x-mx-auto x-mt-8 x-mb-24"
<h1 class="x-title2">Others clients have searched</h1>
<NextQuery
class="x-suggestion x-text1 x-text1-lg"
:suggestion="nextQueries[0]"
data-test="next-query-preview-name"
>
<span class="x-font-bold">{{ nextQueries[0].query }}</span>
</NextQuery>
<div class="x-mb-24">
<SlidingPanel :resetOnContentChange="false">
<div class="x-flex x-flex-row x-gap-8">
<Result
v-for="result in results"
:key="result.id"
:result="result"
style="max-width: 180px"
data-test="next-query-preview-result"
/>
</div>
</SlidingPanel>
</div>
<NextQuery
:suggestion="nextQueries[0]"
data-test="view-all-results"
class="x-button x-button-outlined x-rounded-full x-mx-auto x-mt-8 x-mb-24"
>
{{ 'View all results' }}
</NextQuery>
</NextQueryPreview>
</template>

<template #related-prompts-group="{ item: { relatedPrompts } }">
<RelatedPrompt
class="x-flex x-flex-col x-pt-24"
:relatedPrompt="relatedPrompts[0]"
>
{{ 'View all results' }}
</NextQuery>
</NextQueryPreview>
</template>
</BaseVariableColumnGrid>
<template #header="{ suggestionText }">
<h2 class="x-title2">{{ suggestionText }}</h2>
</template>
<template #selected-query="{ selectedQuery }">
<QueryPreview
:queryPreviewInfo="{ query: selectedQuery }"
#default="{ totalResults, results }"
>
<SlidingPanel>
<template #header>
<QueryPreviewButton
:queryPreviewInfo="{ query: selectedQuery }"
class="x-button x-button-lead x-button-tight x-title3 x-title3-sm desktop:x-title3-md"
>
{{ selectedQuery }}
({{ totalResults }})
<ArrowRightIcon class="x-icon-lg" />
</QueryPreviewButton>
</template>

<div
class="x-transform-style-3d x-flex x-gap-16 x-pr-8 x-pt-8 desktop:x-pt-16"
>
<Result
v-for="result in results"
:key="result.id"
:result="result"
class="x-w-[calc(38vw-16px)] x-min-w-[142px] desktop:x-w-[216px]"
/>
</div>
</SlidingPanel>
</QueryPreview>
</template>
</RelatedPrompt>
</template>
</BaseVariableColumnGrid>
</RelatedPromptsList>
</NextQueriesList>
</BannersList>
</PromotedsList>
Expand Down Expand Up @@ -530,6 +587,9 @@
import { QueryPreviewInfo } from '../../x-modules/queries-preview/store/types';
import QueryPreviewButton from '../../x-modules/queries-preview/components/query-preview-button.vue';
import DisplayEmitter from '../../components/display-emitter.vue';
import RelatedPromptsList from '../../x-modules/related-prompts/components/related-prompts-list.vue';
import RelatedPrompt from '../../x-modules/related-prompts/components/related-prompt.vue';
import QueryPreview from '../../x-modules/queries-preview/components/query-preview.vue';
import Aside from './aside.vue';
import PredictiveLayer from './predictive-layer.vue';
import Result from './result.vue';
Expand Down Expand Up @@ -569,13 +629,16 @@
NextQueriesList,
NextQuery,
NextQueryPreview,
RelatedPromptsList,
RelatedPrompt,
OpenMainModal,
PartialQueryButton,
PartialResultsList,
PredictiveLayer,
PreselectedFilters,
Promoted,
PromotedsList,
QueryPreview,
QueryPreviewButton,
QueryPreviewList,
Recommendations,
Expand Down Expand Up @@ -641,6 +704,9 @@
nextQueriesList: {
showOnlyAfterOffset: true
},
relatedPromptsList: {
showOnlyAfterOffset: true
},
adapter: {
useE2EAdapter: false
}
Expand Down
3 changes: 3 additions & 0 deletions packages/x-components/src/views/home/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export interface HomeControls {
nextQueriesList: {
showOnlyAfterOffset: boolean;
};
relatedPromptsList: {
showOnlyAfterOffset: boolean;
};
adapter: {
useE2EAdapter: boolean;
};
Expand Down
5 changes: 4 additions & 1 deletion packages/x-components/src/wiring/events.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { UrlXEvents } from '../x-modules/url/events.types';
import { XModuleName } from '../x-modules/x-modules.types';
import { SemanticQueriesXEvents } from '../x-modules/semantic-queries/events.types';
import { ExperienceControlsXEvents } from '../x-modules/experience-controls/events.types';
import { RelatedPromptsXEvents } from '../x-modules/related-prompts/events.types';
import { WireMetadata } from './wiring.types';
/* eslint-disable max-len */
/**.
Expand Down Expand Up @@ -51,6 +52,7 @@ import { WireMetadata } from './wiring.types';
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/search/events.types.ts | SearchXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/tagging/events.types.ts | TaggingXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/url/events.types.ts | UrlXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/related-prompts/events.types.ts | RelatedPromptsXEvents}
*
* @public
*/
Expand All @@ -73,7 +75,8 @@ export interface XEventsTypes
SemanticQueriesXEvents,
TaggingXEvents,
ExperienceControlsXEvents,
UrlXEvents {
UrlXEvents,
RelatedPromptsXEvents {
/**
* The provided number of columns of a grid has changed.
* Payload: the columns number.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as RelatedPrompt } from './related-prompt.vue';
export { default as RelatedPromptsList } from './related-prompts-list.vue';
Loading
Loading