Skip to content

Commit bc2b7f3

Browse files
committed
feat(ui): adjust menu ui
1 parent 5691818 commit bc2b7f3

File tree

6 files changed

+20
-29
lines changed

6 files changed

+20
-29
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"devDependencies": {
6060
"@evan-yang/eslint-config": "^1.0.9",
6161
"@iconify-json/carbon": "^1.1.16",
62-
"@iconify-json/ion": "^1.1.10",
6362
"@iconify-json/simple-icons": "^1.1.48",
6463
"@types/mapbox__rehype-prism": "^0.8.0",
6564
"@typescript-eslint/parser": "^5.57.1",

pnpm-lock.yaml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/main/MessageItem.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ export default (props: Props) => {
7474
}
7575

7676
const [menuList, setMenuList] = createSignal<MenuItem[]>([
77-
{ id: 'retry', label: 'Retry send', icon: 'i-ion:refresh-outline', role: 'all', action: handleRetryMessageItem },
77+
{ id: 'retry', label: 'Retry send', icon: 'i-carbon:restart', role: 'all', action: handleRetryMessageItem },
7878
{ id: 'raw', label: 'Show raw code', icon: 'i-carbon-code', role: 'system', action: () => setShowRawCode(!showRawCode()) },
7979
// TODO: Share message
80-
// { id: 'share', label: 'Share message', icon: 'i-ion:ios-share-alt' },
81-
{ id: 'edit', label: 'Edit message', icon: 'i-ion:md-create', role: 'user', action: handleEditMessageItem },
80+
// { id: 'share', label: 'Share message', icon: 'i-carbon:share' },
81+
{ id: 'edit', label: 'Edit message', icon: 'i-carbon:edit', role: 'user', action: handleEditMessageItem },
8282
{ id: 'copy', label: 'Copy message', icon: 'i-carbon-copy', role: 'all', action: handleCopyMessageItem },
8383
{ id: 'delete', label: 'Delete message', icon: 'i-carbon-trash-can', role: 'all', action: handleDeleteMessageItem },
8484
])
@@ -104,13 +104,12 @@ export default (props: Props) => {
104104
<div class="max-w-base flex gap-4 overflow-hidden">
105105
<div class={`shrink-0 w-7 h-7 rounded-md op-80 ${roleClass[props.message.role]}`} />
106106
<div id="menuList-wrapper" class={`sm:hidden block absolute bottom-2 right-4 z-10 op-70 cursor-pointer ${isEditing() && '!hidden'}`}>
107-
{/* TODO: hiden when clickOutside */}
108107
<DropDownMenu menuList={menuList()}>
109108
<div class="text-xl i-carbon:overflow-menu-horizontal" />
110109
</DropDownMenu>
111110
</div>
112111
<div class={`hidden sm:block absolute right-6 -top-4 ${!props.index && 'top-0'} ${isEditing() && '!hidden'}`}>
113-
<div class="op-0 group-hover:op-80 fcc space-x-2 !bg-base px-4 py-1 rounded-xl b border-base transition-opacity duration-400">
112+
<div class="op-0 group-hover:op-80 fcc space-x-2 !bg-base px-2 py-1 rounded-md border border-base transition-opacity">
114113
<For each={menuList()}>
115114
{item => (
116115
<Tooltip tip={item.label} handleChildClick={item.action}>

src/components/ui/base/DropdownMenu.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as menu from '@zag-js/menu'
22
import { normalizeProps, useMachine } from '@zag-js/solid'
3-
import { children, createEffect, createMemo, createUniqueId } from 'solid-js'
3+
import { Show, children, createEffect, createMemo, createUniqueId } from 'solid-js'
44
import { Dynamic, For, Portal, spread } from 'solid-js/web'
55
import type { JSX, JSXElement } from 'solid-js'
66

@@ -47,18 +47,20 @@ export const DropDownMenu = (props: Props) => {
4747
<div>
4848
<Dynamic component={resolvedChild} />
4949
<Portal>
50-
<div {...api().positionerProps}>
51-
<div {...api().contentProps} class="bg-base rounded-md shadow-md">
52-
<For each={props.menuList}>
53-
{item => (
54-
<div class="px-3 py-2 flex items-center space-x-2 hv-base" {...api().getItemProps({ id: item.id })}>
55-
{item.icon && <div class={item.icon} />}
56-
<div>{item.label}</div>
57-
</div>
58-
)}
59-
</For>
50+
<Show when={props.children}>
51+
<div {...api().positionerProps}>
52+
<div {...api().contentProps} class="bg-base text-sm border border-base rounded-md outline-none overflow-hidden shadow-md">
53+
<For each={props.menuList}>
54+
{item => (
55+
<div class="px-3 py-2 flex items-center space-x-2 hv-base" {...api().getItemProps({ id: item.id })}>
56+
{item.icon && <div class={item.icon} />}
57+
<div>{item.label}</div>
58+
</div>
59+
)}
60+
</For>
61+
</div>
6062
</div>
61-
</div>
63+
</Show>
6264
</Portal>
6365
</div>
6466
)

src/components/ui/base/Tooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const Tooltip = (props: Props) => {
4141
<Dynamic component={resolvedChild} />
4242
<Show when={api().isOpen}>
4343
<div {...api().positionerProps} class="transition-opacity duration-300">
44-
<div {...api().contentProps} class="px-2 py-1 text-sm text-white bg-dark-600 dark-bg-zinc-900 rounded-md shadow-sm op-80">{ props.tip }</div>
44+
<div {...api().contentProps} class="px-2 py-1 text-xs text-white bg-dark-600 dark-bg-zinc-900 rounded-md shadow-sm op-80">{ props.tip }</div>
4545
</div>
4646
</Show>
4747
</div>

unocss.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default defineConfig({
6363
'text-error': 'text-red-700 dark:text-red-400/80',
6464
'border-error': 'border border-red-700 dark:border-red-400/80',
6565
'text-info': 'text-gray-400 dark:text-gray-200',
66-
'menu-icon': 'cursor-pointer text-xl fg-base hover-text-emerald-600',
66+
'menu-icon': 'cursor-pointer text-base fg-base hover-text-emerald-600',
6767
'fc': 'flex justify-center',
6868
'fi': 'flex items-center',
6969
'fcc': 'fc items-center',

0 commit comments

Comments
 (0)