-
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 #7 from askorama/feature/orm-1453
feat: add toggler
- Loading branch information
Showing
14 changed files
with
206 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { StoryObj, Meta } from '@storybook/html' | ||
|
||
const meta: Meta = { | ||
title: 'Internal/Toggler', | ||
component: 'search-box-toggler' | ||
} satisfies Meta | ||
|
||
export default meta | ||
type Story = StoryObj | ||
|
||
// More on writing stories with args: https://storybook.js.org/docs/html/writing-stories/args | ||
export const OramaToggler: Story = { | ||
render: () => '<orama-toggler></orama-toggler>' | ||
} |
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
62 changes: 62 additions & 0 deletions
62
packages/ui-stencil/src/components/orama-toggler/orama-toggler.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,62 @@ | ||
:host { | ||
display: inline-flex; | ||
padding: var(--spacing-2xs, $spacing-2xs); | ||
align-items: center; | ||
|
||
border-radius: var(--radius-3xl, $radius-3xl); | ||
background: var(---background-color-fourth, background-color('fourth')); | ||
overflow: hidden; | ||
|
||
button { | ||
display: flex; | ||
align-items: center; | ||
gap: var(--spacing-xs, $spacing-xs); | ||
background-color: transparent; | ||
border: none; | ||
padding: var(--spacing-s, $spacing-s) var(--spacing-m, $spacing-m); | ||
color: var(--text-color-primary, text-color('primary')); | ||
cursor: pointer; | ||
position: relative; | ||
|
||
&.selected { | ||
color: var(--text-color-reverse, text-color('reverse')); | ||
transition: color 0.3s ease-in-out; | ||
z-index: 1; | ||
|
||
&::after { | ||
content: ''; | ||
position: absolute; | ||
inset: 0; | ||
background-color: var(--background-color-reverse, background-color('reverse')); | ||
padding: var(--spacing-s, $spacing-s) var(--spacing-m, $spacing-m); | ||
border-radius: var(--radius-3xl, $radius-3xl); | ||
z-index: -1; | ||
animation: slideToLeft 0.3s ease-in-out; | ||
} | ||
|
||
&:first-child::after { | ||
animation: slideToRight 0.3s ease-in-out; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// TODO: This is not ideal. If sizes changes, it will make a small glitch on the animation. | ||
// I'll leave it like that for now | ||
@keyframes slideToRight { | ||
from { | ||
transform: translateX(100%); | ||
} | ||
to { | ||
transform: translateX(0); | ||
} | ||
} | ||
|
||
@keyframes slideToLeft { | ||
from { | ||
transform: translateX(-100%); | ||
} | ||
to { | ||
transform: translateX(0); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/ui-stencil/src/components/orama-toggler/orama-toggler.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,34 @@ | ||
import { Component, Host, h } from '@stencil/core' | ||
import { globalContext } from '../../context/searchBoxContext' | ||
import '@phosphor-icons/webcomponents/PhMagnifyingGlass' | ||
import '@phosphor-icons/webcomponents/PhSparkle' | ||
|
||
@Component({ | ||
tag: 'orama-toggler', | ||
styleUrl: 'orama-toggler.scss', | ||
shadow: true, | ||
}) | ||
export class OramaToggler { | ||
render() { | ||
return ( | ||
<Host> | ||
<button | ||
type="button" | ||
class={{ selected: globalContext.selectedTab === 'search' }} | ||
onClick={() => (globalContext.selectedTab = 'search')} | ||
> | ||
<span>Search</span> | ||
<ph-magnifying-glass size={16} /> | ||
</button> | ||
<button | ||
type="button" | ||
class={{ selected: globalContext.selectedTab === 'chat' }} | ||
onClick={() => (globalContext.selectedTab = 'chat')} | ||
> | ||
<ph-sparkle size={16} /> | ||
<span>Ask AI</span> | ||
</button> | ||
</Host> | ||
) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/ui-stencil/src/components/orama-toggler/readme.md
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,23 @@ | ||
# orama-toggler | ||
|
||
|
||
|
||
<!-- Auto Generated Below --> | ||
|
||
|
||
## Dependencies | ||
|
||
### Used by | ||
|
||
- [search-box](../search-box) | ||
|
||
### Graph | ||
```mermaid | ||
graph TD; | ||
search-box --> orama-toggler | ||
style orama-toggler fill:#f9f,stroke:#333,stroke-width:4px | ||
``` | ||
|
||
---------------------------------------------- | ||
|
||
*Built with [StencilJS](https://stenciljs.com/)* |
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
Oops, something went wrong.