-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from askorama/feature/orm-1439
Feature/ORM-1439
- Loading branch information
Showing
26 changed files
with
299 additions
and
78 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { StoryObj, Meta } from "@storybook/html"; | ||
|
||
const meta = { | ||
title: "Internal/Search Results", | ||
component: "orama-search-results", | ||
} satisfies Meta; | ||
|
||
export default meta; | ||
type Story = StoryObj; | ||
|
||
const Template = (args) => ` | ||
<orama-search-results ${{ ...args }}></orama-search-results> | ||
`; | ||
|
||
export const Default: Story = { | ||
render: Template, | ||
args: {}, | ||
}; |
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
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 |
---|---|---|
|
@@ -92,3 +92,7 @@ | |
display: inline-flex; | ||
} | ||
} | ||
|
||
.sr-only { | ||
@include screen-reader-only(); | ||
} |
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
30 changes: 30 additions & 0 deletions
30
packages/ui-stencil/src/components/internal/orama-search-results/orama-search-results.scss
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,30 @@ | ||
.list { | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
.list-item { | ||
display: flex; | ||
gap: var(--spacing-m, $spacing-m); | ||
align-items: center; | ||
padding: var(--spacing-m, $spacing-m); | ||
border-radius: var(--radius-s, $radius-s); | ||
background-color: var(--background-color-secondary, background-color('secondary')); | ||
margin-top: var(--spacing-s, $spacing-s); | ||
} | ||
|
||
.collapsed { | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
// todo: should be based on available space | ||
width: 300px; | ||
} | ||
|
||
.results-empty { | ||
text-align: center; | ||
width: 80%; | ||
max-width: pxToRem(400); | ||
margin: $spacing-2xl auto $spacing-3xl; | ||
} |
48 changes: 48 additions & 0 deletions
48
packages/ui-stencil/src/components/internal/orama-search-results/orama-search-results.tsx
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,48 @@ | ||
import { Component, Host, h, Element, Prop } from '@stencil/core' | ||
|
||
export type SearchResultsProps = { | ||
items: { id: string; title: string; description: string; path?: string }[] | ||
searchTerm?: string | ||
} | ||
|
||
@Component({ | ||
tag: 'orama-search-results', | ||
styleUrl: 'orama-search-results.scss', | ||
}) | ||
export class SearchResults { | ||
@Element() el: HTMLUListElement | ||
|
||
@Prop() items: SearchResultsProps['items'] = [] | ||
@Prop() searchTerm: SearchResultsProps['searchTerm'] | ||
|
||
render() { | ||
if (!this.items.length) { | ||
return ( | ||
<div class="results-empty"> | ||
<orama-text as="h3" styledAs="span"> | ||
{`No results found ${this.searchTerm ? `for "${this.searchTerm}"` : ''}`} | ||
</orama-text> | ||
</div> | ||
) | ||
} | ||
|
||
return ( | ||
<Host> | ||
<ul class="list"> | ||
{this.items.map((item) => ( | ||
<li class="list-item" key={item.id}> | ||
<div> | ||
<orama-text as="h3" styledAs="p"> | ||
{item.title} | ||
</orama-text> | ||
<orama-text as="p" styledAs="span" class="collapsed"> | ||
{item.description} | ||
</orama-text> | ||
</div> | ||
</li> | ||
))} | ||
</ul> | ||
</Host> | ||
) | ||
} | ||
} |
Oops, something went wrong.