-
Notifications
You must be signed in to change notification settings - Fork 21
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
Changes from 50 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 a485dea
feat: make internal demo app functional (#1574)
diegopf 1877da6
refactor(components): remove warnings first batch (#1575)
victorcg88 4b57f19
fix(list-components): fix list components, migrate infinite-scroll di…
joseacabaneros 71c08db
refactor(v-deep): replace by :deep() (#1577)
victorcg88 46ff08b
test(vue-jest): update vue-jest dependency (#1581)
victorcg88 7875ff5
refactor(render-function): clear void calls (#1580)
victorcg88 b936ae5
fix(infinite-scroll): getting xBus from XPlugin instead useXBus
joseacabaneros f915731
refactor(animation-factory): fix Vue3 breaking changes (#1579)
victorcg88 059eecc
refactor: get rid of NoElement component and useNoElementRender compo…
joseacabaneros 875a6e2
refactor(base-switch): migrate component to vue3 (#1588)
victorcg88 335c370
test(auto-progress-bar): fix test after Vue3 update (#1582)
victorcg88 35968eb
refactor(base-switch): decommission of value prop (#1589)
victorcg88 5d4dec8
test(components): fix tests after Vue3 update BATCH 1
victorcg88 40f6f66
Merge branch 'main' into vue3-update-rc
diegopf 7ec2b97
fix: adjust to new vue render function API (#1596)
diegopf e64e3cb
fix(search): replace results state to append new results instead of p…
joseacabaneros f9e716a
test(components) fix tests after vue3 update (#1599)
albertjcuac 79e136f
refactor(staggered-fade-and-slide): use Vue native staggered transiti…
victorcg88 f6350c0
merge main branch
diegopf ed587b1
build: adjust rollup production build for Vue3 (#1603)
joseacabaneros fe6fffb
fix build for x-tailwindcss
diegopf b3cc3f5
fix(layout): avoid shared CSS classes between layouts with scoped (#1…
joseacabaneros aff3151
ci(linter): fix linter issues to pass the CI (#1606)
joseacabaneros 9320c57
feat: bump vue18n version (#1604)
diegopf b98a31e
feat(rollup): update replace config to align CSS injector with Vue 3 …
joseacabaneros eb7d377
feat: bump packages versions (#1611)
diegopf ada9f4a
Merge branch 'main' into vue3-update-rc
diegopf 701cfef
chore(release): publish
0f4bb97
test: adjust test to vue3 (#1608)
lauramargar 7778704
Merge remote-tracking branch 'origin/main' into vue3-update-rc
joseacabaneros 82a6e27
fix(history-queries-switch)!: migrate value to modelValue (#1618)
victorcg88 45fbfc3
Fix Vue3 unit tests (#1615)
joseacabaneros 0f35e7c
test: active and fix linter for tests (#1616)
joseacabaneros f81add6
test(e2e): fix e2e tests (#1617)
joseacabaneros 5a419b2
test(e2e-components): rewrite all e2e sheet components to accomplish …
joseacabaneros bc8374d
chore(release): publish
ad970ae
fix(scroll): scroll direction inconsistency (#1629)
victorcg88 56dc022
chore(release): publish
1aadc42
Merge remote-tracking branch 'origin/main' into vue3-update-rc
lauramargar fb4ae07
feat: add types for related prompts
victorcg88 0c59fc9
feat: add adapter for related prompts
victorcg88 45ae37d
feat: create related prompts module
victorcg88 89978e8
feat: integrate RelatedPrompts in demo app
victorcg88 7579245
Merge branch 'main' into feat/add-types-for-related-prompts
victorcg88 370647a
Merge branch 'feat/add-types-for-related-prompts' into feat/add-relat…
victorcg88 f9d5b10
Merge branch 'feat/add-related-prompts-adapter' into feat/related-pro…
victorcg88 976f943
test: test for RP module and doc for related-prompts-list
victorcg88 89485e4
Merge branch 'main' into feat/related-prompts-module
victorcg88 69e9976
remove styling classes and add prop to customize next queries button
victorcg88 3ed7870
Merge branch 'main' into feat/related-prompts-module
victorcg88 16778d4
add next query slot and remove tailwind use
victorcg88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/x-components/src/__stubs__/related-prompts-stubs.factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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 | ||
|
@@ -315,64 +326,111 @@ | |
: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-bg-neutral-10 x-flex x-flex-col x-gap-16 x-pt-24" | ||
:relatedPrompt="relatedPrompts[0]" | ||
nextQueryButtonClass="x-button x-button-lead x-button-sm x-button-outlined" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, IMO the |
||
> | ||
{{ '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> | ||
|
@@ -530,6 +588,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'; | ||
|
@@ -569,13 +630,16 @@ | |
NextQueriesList, | ||
NextQuery, | ||
NextQueryPreview, | ||
RelatedPromptsList, | ||
RelatedPrompt, | ||
OpenMainModal, | ||
PartialQueryButton, | ||
PartialResultsList, | ||
PredictiveLayer, | ||
PreselectedFilters, | ||
Promoted, | ||
PromotedsList, | ||
QueryPreview, | ||
QueryPreviewButton, | ||
QueryPreviewList, | ||
Recommendations, | ||
|
@@ -641,6 +705,9 @@ | |
nextQueriesList: { | ||
showOnlyAfterOffset: true | ||
}, | ||
relatedPromptsList: { | ||
showOnlyAfterOffset: true | ||
}, | ||
adapter: { | ||
useE2EAdapter: false | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/x-components/src/x-modules/related-prompts/components/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, maybe this background is another possible customizable style for customers, maybe we could add a
containerClass
in the component to handle this attribute, which could also be used to add the gap & other spacingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can already achieve this by attribute inheritance. Those classes will fall to the root element inside
RelatedPrompt
, just like is done here.