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

Carousel #35

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,36 @@ export const ChatAssistentMessage: Story = {
description: 'The capital of France',
path: 'https://en.wikipedia.org/wiki/Paris',
},
{
title: 'Buenos Aires',
description: 'The capital of Argentina',
path: 'https://en.wikipedia.org/wiki/Buenos_Aires',
},
{
title: 'Brasília',
description: 'The capital of Brasil',
path: 'https://en.wikipedia.org/wiki/Brazil',
},
{
title: 'Recife',
description: 'Alternative capital of Brazil',
path: 'https://en.wikipedia.org/wiki/Recife',
},
{
title: 'Pernambuco',
description: 'A country inside Brazil',
path: 'https://en.wikipedia.org/wiki/Brasil',
},
{
title: 'Imbiribeira',
description: 'Neughbourhood of Recife',
path: 'https://en.wikipedia.org/wiki/imbiribeira',
},
{
title: 'Lagoa do Araça',
description: 'Neughbourhood of Recife',
path: 'https://en.wikipedia.org/wiki/imbiribeira',
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjborba can we add also the story for orama-sources?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do it! I did not bother because we can test it with the chat component. But I will create a task for that as I do not think it is a priority

],
// biome-ignore lint/suspicious/noExplicitAny: Enum is rasing error here...
status: 'done' as any,
Expand Down
69 changes: 69 additions & 0 deletions apps/storybook/stories/internal/orama-sources.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import type { StoryObj, Meta } from '@storybook/web-components'
import type { Components } from '@orama/wc-components'
import { html } from 'lit-html'

const meta: Meta<Components.OramaSources> = {
title: 'Components/Internal/Sources',
component: 'orama-sources',
tags: ['autodocs'],
}

export default meta
type Story = StoryObj<Components.OramaSources>

export const Sources: Story = {
render: ({ sources }) => {
return html`
<div style="background-color: black;
/* widht: 100%; */
max-width: 100%;
height: 400px;
padding: 20px 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
overflow: hidden">
<orama-sources style="width: 100%;" .sources=${sources}></orama-sources>
</div>`
},
args: {
sources: [
{
title: 'Paris',
description: 'The capital of France',
path: 'https://en.wikipedia.org/wiki/Paris',
},
{
title: 'Buenos Aires',
description: 'The capital of Argentina',
path: 'https://en.wikipedia.org/wiki/Buenos_Aires',
},
{
title: 'Brasília',
description: 'The capital of Brasil',
path: 'https://en.wikipedia.org/wiki/Brazil',
},
{
title: 'Recife',
description: 'Alternative capital of Brazil',
path: 'https://en.wikipedia.org/wiki/Recife',
},
{
title: 'Pernambuco',
description: 'A country inside Brazil',
path: 'https://en.wikipedia.org/wiki/Brasil',
},
{
title: 'Imbiribeira',
description: 'Neughbourhood of Recife',
path: 'https://en.wikipedia.org/wiki/imbiribeira',
},
{
title: 'Lagoa do Araça',
description: 'Neughbourhood of Recife',
path: 'https://en.wikipedia.org/wiki/imbiribeira',
},
],
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const OramaSearchBox = /*@__PURE__*/createReactComponent<JSX.OramaSearchB
export const OramaSearchButton = /*@__PURE__*/createReactComponent<JSX.OramaSearchButton, HTMLOramaSearchButtonElement>('orama-search-button');
export const OramaSearchResults = /*@__PURE__*/createReactComponent<JSX.OramaSearchResults, HTMLOramaSearchResultsElement>('orama-search-results');
export const OramaSlidingPanel = /*@__PURE__*/createReactComponent<JSX.OramaSlidingPanel, HTMLOramaSlidingPanelElement>('orama-sliding-panel');
export const OramaSources = /*@__PURE__*/createReactComponent<JSX.OramaSources, HTMLOramaSourcesElement>('orama-sources');
export const OramaText = /*@__PURE__*/createReactComponent<JSX.OramaText, HTMLOramaTextElement>('orama-text');
export const OramaTextarea = /*@__PURE__*/createReactComponent<JSX.OramaTextarea, HTMLOramaTextareaElement>('orama-textarea');
export const OramaToggler = /*@__PURE__*/createReactComponent<JSX.OramaToggler, HTMLOramaTogglerElement>('orama-toggler');
7 changes: 7 additions & 0 deletions packages/ui-stencil-vue/lib/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ export const OramaSlidingPanel = /*@__PURE__*/ defineContainer<JSX.OramaSlidingP
]);


export const OramaSources = /*@__PURE__*/ defineContainer<JSX.OramaSources>('orama-sources', undefined, [
'sources',
'sourceBaseURL',
'sourcesMap'
]);


export const OramaText = /*@__PURE__*/ defineContainer<JSX.OramaText>('orama-text', undefined, [
'as',
'styledAs',
Expand Down
19 changes: 19 additions & 0 deletions packages/ui-stencil/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ export namespace Components {
"closed": () => void;
"open": boolean;
}
interface OramaSources {
"sourceBaseURL"?: string;
"sources": any;
"sourcesMap"?: SourcesMap;
}
interface OramaText {
/**
* optionally change text alignment
Expand Down Expand Up @@ -378,6 +383,12 @@ declare global {
prototype: HTMLOramaSlidingPanelElement;
new (): HTMLOramaSlidingPanelElement;
};
interface HTMLOramaSourcesElement extends Components.OramaSources, HTMLStencilElement {
}
var HTMLOramaSourcesElement: {
prototype: HTMLOramaSourcesElement;
new (): HTMLOramaSourcesElement;
};
interface HTMLOramaTextElement extends Components.OramaText, HTMLStencilElement {
}
var HTMLOramaTextElement: {
Expand Down Expand Up @@ -418,6 +429,7 @@ declare global {
"orama-search-button": HTMLOramaSearchButtonElement;
"orama-search-results": HTMLOramaSearchResultsElement;
"orama-sliding-panel": HTMLOramaSlidingPanelElement;
"orama-sources": HTMLOramaSourcesElement;
"orama-text": HTMLOramaTextElement;
"orama-textarea": HTMLOramaTextareaElement;
"orama-toggler": HTMLOramaTogglerElement;
Expand Down Expand Up @@ -551,6 +563,11 @@ declare namespace LocalJSX {
"closed"?: () => void;
"open"?: boolean;
}
interface OramaSources {
"sourceBaseURL"?: string;
"sources"?: any;
"sourcesMap"?: SourcesMap;
}
interface OramaText {
/**
* optionally change text alignment
Expand Down Expand Up @@ -610,6 +627,7 @@ declare namespace LocalJSX {
"orama-search-button": OramaSearchButton;
"orama-search-results": OramaSearchResults;
"orama-sliding-panel": OramaSlidingPanel;
"orama-sources": OramaSources;
"orama-text": OramaText;
"orama-textarea": OramaTextarea;
"orama-toggler": OramaToggler;
Expand Down Expand Up @@ -640,6 +658,7 @@ declare module "@stencil/core" {
"orama-search-button": LocalJSX.OramaSearchButton & JSXBase.HTMLAttributes<HTMLOramaSearchButtonElement>;
"orama-search-results": LocalJSX.OramaSearchResults & JSXBase.HTMLAttributes<HTMLOramaSearchResultsElement>;
"orama-sliding-panel": LocalJSX.OramaSlidingPanel & JSXBase.HTMLAttributes<HTMLOramaSlidingPanelElement>;
"orama-sources": LocalJSX.OramaSources & JSXBase.HTMLAttributes<HTMLOramaSourcesElement>;
"orama-text": LocalJSX.OramaText & JSXBase.HTMLAttributes<HTMLOramaTextElement>;
"orama-textarea": LocalJSX.OramaTextarea & JSXBase.HTMLAttributes<HTMLOramaTextareaElement>;
"orama-toggler": LocalJSX.OramaToggler & JSXBase.HTMLAttributes<HTMLOramaTogglerElement>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,105 +36,6 @@
pointer-events: none;
}

.sources-outer-wrapper {
overflow: hidden;
position: relative;
margin: 0 var(--spacing-s, $spacing-s) var(--spacing-m, $spacing-m) var(--spacing-l, $spacing-l);

&::after {
content: '';
pointer-events: none;
position: absolute;
right: 0;
top: 0;
bottom: 0;
width: 20%;
background: linear-gradient(90deg, transparent 50%, var(--background-color-primary, background-color('primary')) 100%);
}
}

.source-next {
position: absolute;
left: 0;
top: 0;
bottom: 0;
}

.carousel-arrow {
position: absolute;
display: flex;
justify-content: center;
top: 0;
bottom: 0;
margin-block: auto;
height: fit-content;
width: 48px;
background-color: white;
border: none;
font-size: 3rem;
padding: 0;
cursor: pointer;
opacity: 0.5;
transition: opacity 100ms;
z-index: 1;
}

.carousel-arrow:hover,
.carousel-arrow:focus {
opacity: 1;
}

.carousel-arrow--prev {
left: 0;
}

.carousel-arrow--next {
right: 0;
}

.sources-wrapper {
display: flex;
overflow-x: auto;
scrollbar-width: none;
position: relative;

overflow-x: scroll;
scroll-behavior: smooth;
scroll-snap-type: x mandatory;
}

.source {
position: relative;
overflow: hidden;
width: pxToRem(195);
margin-right: var(--spacing-s, $spacing-s);
flex-grow: 0;
flex-shrink: 0;
text-decoration: none;
padding: var(--spacing-m, $spacing-m);
border-radius: var(--radius-s, $radius-s);
background: var(--background-color-secondary, background-color('secondary'));
transition: background 0.2s ease-in-out;
// scroll-snap-align: start;

.source-title,
.source-subtitle {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

&:last-of-type {
margin-right: var(--spacing-l, $spacing-l);
}

@media (hover: hover) {
&:hover {
background: var(--background-color-tertiary, background-color('tertiary'));
}
}
}

.sr-only {
@include screen-reader-only();
}
Expand Down
Loading
Loading