-
Notifications
You must be signed in to change notification settings - Fork 6
[Feature] Select component for Codex UI #279
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
039a26a
feat: added dropdown component
TheGeniusOfEternity 8f3d238
fix: name refactor, popover integration
TheGeniusOfEternity 0ea8af5
fix: remove redundant styles
TheGeniusOfEternity a2f9645
Merge remote-tracking branch 'origin/main' into dropdown-component-impl
TheGeniusOfEternity ccc9dd9
fix: renaming and toggle imlementation
TheGeniusOfEternity 3115d0c
fix: logic optimization, access improvements
TheGeniusOfEternity 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 hidden or 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 hidden or 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 hidden or 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,63 @@ | ||
| <template> | ||
| <Button | ||
| :icon="activeItem.icon" | ||
| trailing-icon="BracketsVertical" | ||
| secondary | ||
| @click="!isOpen ? togglePopover($event.currentTarget, {vertically: 'below', horizontally: 'left'}) : hide()" | ||
neSpecc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| > | ||
| {{ activeItem.title }} | ||
| </Button> | ||
| </template> | ||
| <script setup lang="ts"> | ||
| import type { ContextMenuItem as Item } from '../context-menu/ContextMenu.types'; | ||
| import { ContextMenu } from '../context-menu'; | ||
| import { onMounted, ref } from 'vue'; | ||
| import { usePopover, PopoverShowParams } from '../popover'; | ||
| import { Button } from '../button'; | ||
|
|
||
| const props = defineProps<{ | ||
| items: Item[]; | ||
| }>(); | ||
|
|
||
| const items = props.items; | ||
| const { showPopover, hide, isOpen } = usePopover(); | ||
|
|
||
| const togglePopover = (el: HTMLElement, align: PopoverShowParams['align']) => { | ||
| showPopover({ | ||
| targetEl: el, | ||
| with: { | ||
| component: ContextMenu, | ||
| props: { | ||
| items: items, | ||
| }, | ||
| }, | ||
| align, | ||
| }); | ||
| }; | ||
|
|
||
| /* Default item value for select on page load */ | ||
| const defaultValue: Item = { | ||
| title: 'Choose an option', | ||
neSpecc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| type: 'default', | ||
| onActivate: () => {}, | ||
| }; | ||
| const activeItem = ref(defaultValue); | ||
|
|
||
| /* Main function to update selected item */ | ||
| const updateActiveItem = (item: Item) => { | ||
| if (item.type === 'default' || !item.type) { | ||
neSpecc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| activeItem.value = Object.create(item); | ||
neSpecc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| activeItem.value.onActivate = () => {}; | ||
| hide(); | ||
| } | ||
| }; | ||
|
|
||
| onMounted(() => { | ||
| items.forEach((item) => { | ||
| if (item.type === 'default' || !item.type) { | ||
| item.onActivate = () => updateActiveItem(item); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| </script> | ||
This file contains hidden or 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,3 @@ | ||
| import Select from './Select.vue'; | ||
|
|
||
| export { Select }; |
This file contains hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.