From 2099f910f8918759f3d40888ebc718fdf4442cfe Mon Sep 17 00:00:00 2001 From: Zak Nesler Date: Sat, 1 Jun 2024 19:37:34 -0400 Subject: [PATCH] icon tweaks --- LICENSE | 2 +- ui/src/components/feed/feed-header.tsx | 2 +- ui/src/components/feed/feed-info.tsx | 20 ++- ui/src/components/feed/feed-item.tsx | 2 +- ui/src/components/feed/feed-list.tsx | 2 +- ui/src/components/layout/sidebar.tsx | 9 +- ui/src/components/menus/feed-menu.tsx | 39 ------ ui/src/components/menus/feeds-menu.tsx | 29 ----- ui/src/components/menus/menu-app.tsx | 69 +++++++++++ ui/src/components/menus/menu-feed.tsx | 28 +++++ ui/src/components/menus/menu.tsx | 18 ++- ui/src/components/menus/settings-menu.tsx | 43 ------- ui/src/components/nav/nav-row.tsx | 15 +-- ui/src/components/nav/nav-view-switcher.tsx | 2 +- ui/src/components/panels/list-panel.tsx | 23 ++-- ui/src/components/ui/button/icon-button.tsx | 42 +++++++ .../ui/{button.tsx => button/index.tsx} | 0 ui/src/components/ui/tooltip.tsx | 25 ++-- .../layout => constants/ui}/logo.tsx | 114 ++++++++++-------- ui/src/constants/ui/menu.ts | 18 +-- ui/src/constants/ui/tooltip.ts | 19 +++ ui/src/routes/404.tsx | 2 +- 22 files changed, 301 insertions(+), 222 deletions(-) delete mode 100644 ui/src/components/menus/feed-menu.tsx delete mode 100644 ui/src/components/menus/feeds-menu.tsx create mode 100644 ui/src/components/menus/menu-app.tsx create mode 100644 ui/src/components/menus/menu-feed.tsx delete mode 100644 ui/src/components/menus/settings-menu.tsx create mode 100644 ui/src/components/ui/button/icon-button.tsx rename ui/src/components/ui/{button.tsx => button/index.tsx} (100%) rename ui/src/{components/layout => constants/ui}/logo.tsx (66%) create mode 100644 ui/src/constants/ui/tooltip.ts diff --git a/LICENSE b/LICENSE index 5ce66e9e..b7c99401 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Zak Nesler +Copyright (c) 2024 Zachary Nesler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/ui/src/components/feed/feed-header.tsx b/ui/src/components/feed/feed-header.tsx index 7998005b..bded43a9 100644 --- a/ui/src/components/feed/feed-header.tsx +++ b/ui/src/components/feed/feed-header.tsx @@ -6,7 +6,7 @@ type FeedHeaderProps = { }; export const FeedHeader: Component = props => ( -
+

{props.title}

{props.subtitle} diff --git a/ui/src/components/feed/feed-info.tsx b/ui/src/components/feed/feed-info.tsx index 00e5e305..ab689cce 100644 --- a/ui/src/components/feed/feed-info.tsx +++ b/ui/src/components/feed/feed-info.tsx @@ -1,8 +1,11 @@ import { createQuery } from '@tanstack/solid-query'; +import { HiOutlineArrowPath } from 'solid-icons/hi'; import { type Component, Match, Switch, createSignal } from 'solid-js'; import { getFeed } from '~/api/feeds'; import { QUERY_KEYS } from '~/constants/query'; -import { MenuFeed } from '../menus/feed-menu'; +import { useRefreshFeed } from '~/hooks/queries/use-refresh-feed'; +import { FeedMenu } from '../menus/menu-feed'; +import { IconButton } from '../ui/button/icon-button'; import { FeedHeader } from './feed-header'; type FeedInfoProps = { @@ -10,7 +13,7 @@ type FeedInfoProps = { }; export const FeedInfo: Component = props => { - const [contextMenuOpen, setContextMenuOpen] = createSignal(false); + const refresh = useRefreshFeed(); const feed = createQuery(() => ({ queryKey: [QUERY_KEYS.FEEDS_VIEW, props.uuid], @@ -19,6 +22,8 @@ export const FeedInfo: Component = props => { refetchOnMount: false, })); + const [contextMenuOpen, setContextMenuOpen] = createSignal(false); + return ( @@ -30,10 +35,17 @@ export const FeedInfo: Component = props => { -
+
- refresh.refreshFeed(props.uuid)} + icon={HiOutlineArrowPath} + tooltip="Refresh feed" + class="size-6 rounded-md text-gray-500" + /> + + = props => ( : 'border-transparent dark:hover:bg-gray-800 hover:bg-gray-200 dark:hover:text-white hover:text-gray-900', )} > -
+
}> diff --git a/ui/src/components/feed/feed-list.tsx b/ui/src/components/feed/feed-list.tsx index 5e28c1e8..a7dd2760 100644 --- a/ui/src/components/feed/feed-list.tsx +++ b/ui/src/components/feed/feed-list.tsx @@ -20,7 +20,7 @@ export const FeedList = () => { } + icon={() => } open={allFeedsMenuOpen()} active={location.pathname === '/'} setOpen={setAllFeedsMenuOpen} diff --git a/ui/src/components/layout/sidebar.tsx b/ui/src/components/layout/sidebar.tsx index 60e1be86..f2b2533a 100644 --- a/ui/src/components/layout/sidebar.tsx +++ b/ui/src/components/layout/sidebar.tsx @@ -1,8 +1,7 @@ import { cx } from 'class-variance-authority'; import { type Component, createSignal } from 'solid-js'; import { FeedList } from '../feed/feed-list'; -import { MenuSettings } from '../menus/settings-menu'; -import { LogoSquare } from './logo'; +import { AppMenu } from '../menus/menu-app'; type SidebarProps = { class?: string; @@ -13,11 +12,7 @@ export const Sidebar: Component = props => { return (
-
- - -
- +
); diff --git a/ui/src/components/menus/feed-menu.tsx b/ui/src/components/menus/feed-menu.tsx deleted file mode 100644 index 47607d9d..00000000 --- a/ui/src/components/menus/feed-menu.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { HiSolidArrowPath, HiSolidPencilSquare, HiSolidTrash } from 'solid-icons/hi'; -import { type Component, mergeProps } from 'solid-js'; -import { useRefreshFeed } from '~/hooks/queries/use-refresh-feed'; -import { Menu, type MenuProps } from './menu'; - -type FeedMenuProps = MenuProps & { - uuid: string; -}; - -export const MenuFeed: Component = props => { - const local = mergeProps( - { - triggerClass: 'size-5 rounded', - triggerIconClass: 'size-4 text-gray-500', - } as MenuProps, - props, - ); - - const refresh = useRefreshFeed(); - - const handleRefresh = () => { - refresh.refreshFeed(props.uuid); - props.setOpen(false); - }; - - return ( - - - Refresh - - - Rename - - - Delete - - - ); -}; diff --git a/ui/src/components/menus/feeds-menu.tsx b/ui/src/components/menus/feeds-menu.tsx deleted file mode 100644 index 78720713..00000000 --- a/ui/src/components/menus/feeds-menu.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { HiSolidArrowPath } from 'solid-icons/hi'; -import { type Component, mergeProps } from 'solid-js'; -import { useRefreshFeeds } from '~/hooks/queries/use-refresh-feeds'; -import { Menu, type MenuProps } from './menu'; - -export const MenuFeeds: Component = props => { - const local = mergeProps( - { - triggerClass: 'size-5 rounded', - triggerIconClass: 'size-4 text-gray-500', - } as MenuProps, - props, - ); - - const refresh = useRefreshFeeds(); - - const handleRefreshFeeds = () => { - refresh.refreshFeeds(); - props.setOpen(false); - }; - - return ( - - - Refresh all feeds - - - ); -}; diff --git a/ui/src/components/menus/menu-app.tsx b/ui/src/components/menus/menu-app.tsx new file mode 100644 index 00000000..6a0f595d --- /dev/null +++ b/ui/src/components/menus/menu-app.tsx @@ -0,0 +1,69 @@ +import { Button as BaseButton } from '@kobalte/core/button'; +import { DropdownMenu, type DropdownMenuTriggerProps } from '@kobalte/core/dropdown-menu'; +import { + HiSolidArrowDownTray, + HiSolidArrowRightOnRectangle, + HiSolidChevronDown, + HiSolidCog6Tooth, + HiSolidPlus, +} from 'solid-icons/hi'; +import { TiCog } from 'solid-icons/ti'; +import { type Component, createSignal, mergeProps } from 'solid-js'; +import { Dynamic } from 'solid-js/web'; +import { LogoSquare } from '../../constants/ui/logo'; +import { CreateFeedModal } from '../modals/create-feed-modal'; +import { Menu, type MenuProps } from './menu'; + +export const AppMenu: Component = props => { + const [createFeedModalOpen, setCreateFeedModalOpen] = createSignal(false); + + const local = mergeProps( + { + triggerClass: 'size-6 rounded-md', + triggerIconClass: 'size-5', + triggerIcon: TiCog, + } as MenuProps, + props, + ); + + const handleAddFeed = () => { + setCreateFeedModalOpen(true); + }; + + return ( + <> + ( + ( + + + + + )} + /> + )} + > + + Add feed + + + Import/export + + + Settings + + + Sign out + + + + + + ); +}; diff --git a/ui/src/components/menus/menu-feed.tsx b/ui/src/components/menus/menu-feed.tsx new file mode 100644 index 00000000..5a50c8fd --- /dev/null +++ b/ui/src/components/menus/menu-feed.tsx @@ -0,0 +1,28 @@ +import { HiSolidPencilSquare, HiSolidTrash } from 'solid-icons/hi'; +import { type Component, mergeProps } from 'solid-js'; +import { Menu, type MenuProps } from './menu'; + +type FeedMenuProps = MenuProps & { + uuid: string; +}; + +export const FeedMenu: Component = props => { + const local = mergeProps( + { + triggerClass: 'size-5 rounded', + triggerIconClass: 'size-4', + } as MenuProps, + props, + ); + + return ( + + + Rename + + + Delete + + + ); +}; diff --git a/ui/src/components/menus/menu.tsx b/ui/src/components/menus/menu.tsx index 9a1ce90d..eb337a0d 100644 --- a/ui/src/components/menus/menu.tsx +++ b/ui/src/components/menus/menu.tsx @@ -7,7 +7,7 @@ import { import { type VariantProps, cx } from 'class-variance-authority'; import type { IconTypes } from 'solid-icons'; import { HiSolidEllipsisHorizontal } from 'solid-icons/hi'; -import { type ParentComponent, type Setter, splitProps } from 'solid-js'; +import { type JSX, type ParentComponent, type Setter, Show, splitProps } from 'solid-js'; import { Dynamic } from 'solid-js/web'; import * as menuClasses from '~/constants/ui/menu'; @@ -15,6 +15,7 @@ export type MenuProps = Omit & MenuContentProps & { open: boolean; setOpen: Setter; + trigger?: () => JSX.Element; triggerIcon?: IconTypes; triggerClass?: string; triggerIconClass?: string; @@ -26,6 +27,7 @@ const MenuRoot: ParentComponent = props => { 'children', 'open', 'setOpen', + 'trigger', 'triggerIcon', 'triggerClass', 'triggerIconClass', @@ -33,9 +35,16 @@ const MenuRoot: ParentComponent = props => { return ( - - - + + + + } + > + + {local.children} @@ -86,4 +95,5 @@ const MenuContent: ParentComponent = props => ( export const Menu = Object.assign(MenuRoot, { Item: MenuItem, Content: MenuContent, + Trigger: MenuTrigger, }); diff --git a/ui/src/components/menus/settings-menu.tsx b/ui/src/components/menus/settings-menu.tsx deleted file mode 100644 index 5ad2fe9c..00000000 --- a/ui/src/components/menus/settings-menu.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { HiSolidArrowDownTray, HiSolidArrowRightOnRectangle, HiSolidCog6Tooth, HiSolidPlus } from 'solid-icons/hi'; -import { TiCog } from 'solid-icons/ti'; -import { type Component, createSignal, mergeProps } from 'solid-js'; -import { CreateFeedModal } from '../modals/create-feed-modal'; -import { Menu, type MenuProps } from './menu'; - -export const MenuSettings: Component = props => { - const [createFeedModalOpen, setCreateFeedModalOpen] = createSignal(false); - - const local = mergeProps( - { - triggerClass: 'size-6 rounded-md', - triggerIconClass: 'size-5 text-gray-500', - triggerIcon: TiCog, - } as MenuProps, - props, - ); - - const handleAddFeed = () => { - setCreateFeedModalOpen(true); - }; - - return ( - <> - - - Add feed - - - Import/export - - - Settings - - - Sign out - - - - - - ); -}; diff --git a/ui/src/components/nav/nav-row.tsx b/ui/src/components/nav/nav-row.tsx index 8e01d898..0505ed54 100644 --- a/ui/src/components/nav/nav-row.tsx +++ b/ui/src/components/nav/nav-row.tsx @@ -6,9 +6,7 @@ import { HiOutlineQueueList, HiSolidArrowLeft, HiSolidXMark } from 'solid-icons/ import { type Component, type Setter, Show, createSignal } from 'solid-js'; import { Dynamic } from 'solid-js/web'; import { useQueryState } from '~/contexts/query-state-context'; -import { useViewport } from '~/hooks/use-viewport'; -import { LogoSquare } from '../layout/logo'; -import { MenuSettings } from '../menus/settings-menu'; +import { AppMenu } from '../menus/menu-app'; import { Tooltip } from '../ui/tooltip'; type NavRowProps = { @@ -21,18 +19,13 @@ type NavRowProps = { export const NavRow: Component = props => { const state = useQueryState(); - const viewport = useViewport(); const navigate = useNavigate(); const [settingsOpen, setSettingsOpen] = createSignal(false); return (
- - - - - +
@@ -42,7 +35,7 @@ export const NavRow: Component = props => { diff --git a/ui/src/components/nav/nav-view-switcher.tsx b/ui/src/components/nav/nav-view-switcher.tsx index a7fc1737..3f68ba3b 100644 --- a/ui/src/components/nav/nav-view-switcher.tsx +++ b/ui/src/components/nav/nav-view-switcher.tsx @@ -25,7 +25,7 @@ export const NavViewSwitcher = () => { class={cx( 'w-full rounded-md border border-transparent px-2 py-1.5 transition', 'group-focus:!border-gray-400 group-hover:border-gray-200/50 group-hover:bg-gray-50 group-focus:ring-[2px] group-focus:ring-gray-200', - 'dark:group-focus:!border-gray-600 dark:group-hover:bg-gray-800 dark:group-focus:ring-gray-800', + 'dark:group-focus:!border-gray-600 dark:group-hover:!border-gray-700 dark:group-hover:bg-gray-700 dark:group-focus:ring-gray-800', 'ui-group-selected:bg-white ui-group-selected:shadow', 'ui-group-selected:dark:bg-gray-900 ui-group-selected:shadow', )} diff --git a/ui/src/components/panels/list-panel.tsx b/ui/src/components/panels/list-panel.tsx index f176e34d..e65c07ed 100644 --- a/ui/src/components/panels/list-panel.tsx +++ b/ui/src/components/panels/list-panel.tsx @@ -2,6 +2,7 @@ import { createActiveElement } from '@solid-primitives/active-element'; import { createElementBounds } from '@solid-primitives/bounds'; import { useIsRouting } from '@solidjs/router'; import { cx } from 'class-variance-authority'; +import { HiOutlineArrowPath } from 'solid-icons/hi'; import { Match, Show, Switch, createEffect, createSignal } from 'solid-js'; import { Portal } from 'solid-js/web'; import { EntryList } from '~/components/entry/entry-list'; @@ -9,19 +10,21 @@ import { FeedHeader } from '~/components/feed/feed-header'; import { FeedInfo } from '~/components/feed/feed-info'; import { FeedList } from '~/components/feed/feed-list'; import { Panel } from '~/components/layout/panel'; -import { MenuFeeds } from '~/components/menus/feeds-menu'; import { NavRow } from '~/components/nav/nav-row'; import { NavViewSwitcher } from '~/components/nav/nav-view-switcher'; import { useQueryState } from '~/contexts/query-state-context'; +import { useRefreshFeeds } from '~/hooks/queries/use-refresh-feeds'; import { useViewport } from '~/hooks/use-viewport'; +import { IconButton } from '../ui/button/icon-button'; export const ListPanel = () => { const state = useQueryState(); const viewport = useViewport(); const isRouting = useIsRouting(); + const refresh = useRefreshFeeds(); + const [showFeedSelector, setShowFeedSelector] = createSignal(false); - const [allFeedsMenuOpen, setAllFeedsMenuOpen] = createSignal(false); const [container, setContainer] = createSignal(); const containerBounds = createElementBounds(container); @@ -61,7 +64,7 @@ export const ListPanel = () => {