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

Feature/orm-1876 #55

Merged
merged 7 commits into from
Oct 28, 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
78 changes: 53 additions & 25 deletions apps/storybook/stories/public/orama-search-box.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@ const meta: Meta<Components.OramaSearchBox & { preset: keyof DemoIndexConfig }>
},
},
},
chatPlaceholder: {
searchPlaceholder: {
control: { type: 'text' },
table: {
type: {
summary: 'string',
},
defaultValue: { summary: '' },
},
},
searchPlaceholder: {
chatPlaceholder: {
control: { type: 'text' },
table: {
type: {
summary: 'string',
},
defaultValue: { summary: 'Search...' },
defaultValue: { summary: '' },
},
},
colorScheme: {
Expand All @@ -64,22 +66,37 @@ const meta: Meta<Components.OramaSearchBox & { preset: keyof DemoIndexConfig }>
}
export default meta

const Template = ({ preset, chatPlaceholder, searchPlaceholder, colorScheme, disableChat }) => {
const Template = ({
preset,
chatPlaceholder,
searchPlaceholder,
colorScheme,
disableChat,
suggestions,
open,
facetProperty,
themeConfig,
index,
sourceBaseUrl,
sourcesMap,
highlight,
resultMap,
}) => {
return html`<div>
<div style="width: 240px">
<orama-search-button>Search...</orama-search-button>
</div>
<orama-search-box
.open=${preset?.open}
.facetProperty=${preset?.facetProperty}
.resultMap=${preset?.resultMap}
.open=${open || preset?.open}
.facetProperty=${facetProperty || preset?.facetProperty}
.resultMap=${resultMap || preset?.resultMap}
.colorScheme=${colorScheme}
.themeConfig=${preset.themeConfig}
.index=${preset.index}
.themeConfig=${themeConfig || preset.themeConfig}
.index=${index || preset.index}
.instance=${preset.instance}
.suggestions=${preset?.suggestions}
.sourceBaseUrl=${preset?.sourceBaseUrl}
.sourcesMap=${preset?.sourcesMap}
.suggestions=${suggestions || preset?.suggestions}
.sourceBaseUrl=${sourceBaseUrl || preset?.sourceBaseUrl}
.sourcesMap=${sourcesMap || preset?.sourcesMap}
.disableChat=${disableChat}
.chatPlaceholder=${chatPlaceholder}
.searchPlaceholder=${searchPlaceholder}
Expand All @@ -91,20 +108,34 @@ const Template = ({ preset, chatPlaceholder, searchPlaceholder, colorScheme, dis
></orama-search-box></div>`
}

const TemplateAsEmbed = ({ preset, chatPlaceholder, searchPlaceholder, colorScheme, disableChat }) => {
const TemplateAsEmbed = ({
preset,
chatPlaceholder,
searchPlaceholder,
colorScheme,
disableChat,
open,
facetProperty,
resultMap,
themeConfig,
index,
sourceBaseURL,
suggestions,
sourcesMap,
}) => {
return html`<div style="height: 420px">
<orama-search-box
layout="embed"
.open=${preset?.open}
.facetProperty=${preset?.facetProperty}
.resultMap=${preset?.resultMap}
.open=${open || preset?.open}
.facetProperty=${facetProperty || preset?.facetProperty}
.resultMap=${resultMap || preset?.resultMap}
.colorScheme=${colorScheme}
.themeConfig=${preset.themeConfig}
.index=${preset.index}
.themeConfig=${themeConfig || preset.themeConfig}
.index=${index || preset.index}
.instance=${preset.instance}
.suggestions=${preset?.suggestions}
.sourceBaseUrl=${preset?.sourceBaseUrl}
.sourcesMap=${preset?.sourcesMap}
.suggestions=${suggestions || preset?.suggestions}
.sourceBaseUrl=${sourceBaseURL || preset?.sourceBaseUrl}
.sourcesMap=${sourcesMap || preset?.sourcesMap}
.disableChat=${disableChat}
.chatPlaceholder=${chatPlaceholder}
.searchPlaceholder=${searchPlaceholder}
Expand All @@ -119,13 +150,11 @@ const TemplateAsEmbed = ({ preset, chatPlaceholder, searchPlaceholder, colorSche

type Story = StoryObj<Components.OramaSearchBox & { preset: keyof DemoIndexConfig }>

export const SearchBox: Story = {
export const SearchBoxAsModal: Story = {
render: Template as any,
args: {
preset: 'orama',
colorScheme: 'light',
searchPlaceholder: 'Search...',
chatPlaceholder: 'Ask me anything...',
disableChat: false,
},
}
Expand All @@ -135,7 +164,6 @@ export const SearchBoxAsEmbed: Story = {
args: {
preset: 'orama',
colorScheme: 'light',
searchPlaceholder: 'Search...',
chatPlaceholder: 'Ask me anything...',
disableChat: false,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-stencil/src/components/internal/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface IconProps {
export const Icon: FunctionalComponent<IconProps> = ({ name, size = 24, color = 'black' }) => {
const getIconSvg = (iconName: string) => {
const icons: { [key: string]: string } = {
star: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
star: `<svg xmlns="http://www.w3.org/2000/svg" width=${size} height=${size} viewBox="0 0 16 16" fill="none">
<path d="M8.1875 0.6875L9.12531 3.22189C9.78366 5.00107 11.1864 6.40384 12.9656 7.06219L15.5 8L12.9656 8.93781C11.1864 9.59616 9.78366 10.9989 9.12531 12.7781L8.1875 15.3125L7.24969 12.7781C6.59134 10.9989 5.18857 9.59616 3.40939 8.93781L0.875 8L3.40939 7.06219C5.18857 6.40384 6.59134 5.00107 7.24969 3.22189L8.1875 0.6875Z" fill="url(#paint0_radial_1183_175)"/>
<defs>
<radialGradient id="paint0_radial_1183_175" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(16.5 -9.5) rotate(141.053) scale(24.2042)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class OramaChatButton {
type="button"
>
<span class="icon-star">
<Icon name="star" size={14} />
<Icon name="star" size={16} />
</span>
<span class="button-label">{this.label}</span>
<span class="icon-enter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
align-items: center;
gap: var(--spacing-m, $spacing-m);
padding: var(--radius-s, $spacing-s) var(--radius-l, $spacing-l);

list-style: none;
margin: 0;
overflow-x: auto;
Expand Down Expand Up @@ -80,6 +79,7 @@
-webkit-text-fill-color: transparent;
width: 100%;
border: 1px solid transparent;
font-family: inherit;

&:focus-visible {
outline: none;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.embed {
background-color: var(--background-color-secondary, background-color('secondary'));
background-color: var(--background-color-primary, background-color('primary'));
border: 1px solid var(--border-color-primary, border-color('primary'));
border-radius: var(--radius-m, $radius-m);
inset: 0;
Expand All @@ -14,6 +14,8 @@
flex-direction: column;

@media (--md-min) {
background-color: var(--background-color-secondary, background-color('secondary'));

orama-input {
padding: 0;
margin: 0;
Expand All @@ -24,4 +26,4 @@
border-radius: var(--radius-m, $radius-m) var(--radius-m, $radius-m) 0 0;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
display: flex;
flex-direction: column;
overflow: hidden;
width: 100%;

orama-input {
@media (--md-max) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

.section-active {
display: flex;
overflow: hidden;
}

.section-inactive {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,16 @@ export class SearchBox {

getSearchBox() {
return (
<Fragment>
<div
class={`${
this.windowWidth > 1024
? 'section-active'
: globalContext.currentTask === 'search'
? 'section-active'
: 'section-inactive'
}`}
>
<orama-search
class={`${this.windowWidth > 1024 ? 'section-active' : globalContext.currentTask === 'search' ? 'section-active' : 'section-inactive'}`}
placeholder={this?.searchPlaceholder || 'Search...'}
focusInput={globalContext.currentTask === 'search'}
sourceBaseUrl={this.sourceBaseUrl}
Expand All @@ -201,7 +208,7 @@ export class SearchBox {
/>
)}
</orama-search>
</Fragment>
</div>
)
}

Expand Down
4 changes: 4 additions & 0 deletions packages/ui-stencil/src/styles/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
TODO: We'll make this task automatic in the future
*/

@use 'sass:color';

/**
* * PRIMITIVE COLORS
*/
Expand Down Expand Up @@ -69,6 +71,8 @@ $semanticColors: (

$elementColors: (
'button-text': (
// TODO: example of how to use the color functions with semantic colors
// primary: color.adjust(text-color('primary', $semanticColors), $lightness: 10%),
primary: $purple100,
secondary: text-color('secondary', $semanticColors),
inactive: $gray500,
Expand Down
Loading