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

Navigation/Breadcrumbs in filerunner, pull Nav into a component #92

Open
wants to merge 78 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
5204871
add breadcrumbs and open file button to filerunner
bdsqqq Mar 6, 2023
cc0c32f
remove px to align with content in filebrowser
bdsqqq Mar 6, 2023
a5f32a6
extract Nav/breadcrumbs into a component, we can name this better later
bdsqqq Mar 6, 2023
2bcacb1
expose `actions` from breadcrumbs (buttons in the right)
bdsqqq Mar 7, 2023
dd8f73a
use breadcrumbs component (still need to refactor filebrowser's menu …
bdsqqq Mar 7, 2023
e52655c
experimenting with Split button in filerunner
bdsqqq Mar 7, 2023
2168258
added a TODO, need to validate this with mark or theo
bdsqqq Mar 7, 2023
9146f84
a React.ReactNode shouldn't be inside a template literal
bdsqqq Mar 7, 2023
9814c7f
solves TS warnings, there's probably a better way to do it
bdsqqq Mar 7, 2023
b46f872
put form & submit button in a div to prevent unwanted dividers
bdsqqq Mar 7, 2023
c8452d1
allow splitButton as actionItem
bdsqqq Mar 7, 2023
e761d68
use Nav actions to render `open file` split button
bdsqqq Mar 7, 2023
bd1b353
run hook button in Nav actions
bdsqqq Mar 7, 2023
a6ec460
add missing prop
bdsqqq Mar 8, 2023
7a63679
unused import sorry
bdsqqq Mar 8, 2023
fc81751
add button from ping + used it in an implementation of splitButton
bdsqqq Mar 8, 2023
2f0062b
replace ping button styles with styles from captain
bdsqqq Mar 8, 2023
4fd7cfe
a bit more styling in the splitdropdown button, still a bit more to go
bdsqqq Mar 9, 2023
5abbdb0
Update button styling, add variants, export type for `ListItemWithIco…
bdsqqq Mar 9, 2023
409122f
Igor/nav in filerunner (#97)
bdsqqq Mar 10, 2023
973008d
Igor/scared of fucking up main (#98)
bdsqqq Mar 10, 2023
9f2c2fc
buttons inside dropdowns look weird with shadows, made shadows the de…
bdsqqq Mar 12, 2023
3d8f832
changing this in 2 places was kind of annoying, pulled it to a component
bdsqqq Mar 12, 2023
c01368a
uhhhh, that component exploded everything for some reason, copy pasti…
bdsqqq Mar 12, 2023
2addfd9
w -> min-w to prevent children overflowing weirdly
bdsqqq Mar 12, 2023
f27f6e5
removing this span makes the button height not break for some reason??
bdsqqq Mar 12, 2023
c5f9302
consume icons correctly, a bit of styling
bdsqqq Mar 12, 2023
ebbcf6b
breadcrumb button types extend actual Button types
bdsqqq Mar 12, 2023
daa885c
filebrowser provide icon to breadcrumbs actions correctly
bdsqqq Mar 12, 2023
5b550d6
remove unused draft of spltbutton
bdsqqq Mar 12, 2023
4c5977b
rename SplitButtonDropdown to something not silly
bdsqqq Mar 12, 2023
43306b2
update prop type to include icons
bdsqqq Mar 12, 2023
06b8c3d
fix mismatched icon types
bdsqqq Mar 12, 2023
50cfa93
add Igor todo
bdsqqq Mar 12, 2023
7b547e5
add disabled styles to primary button
bdsqqq Mar 12, 2023
086fdb5
horizontally align filerruner to filebrwoser content
bdsqqq Mar 12, 2023
af4c00d
adding this span back, no consequences since were consuming icons pro…
bdsqqq Mar 12, 2023
03d9a0d
base size for icon buttons being h-4 prevents annoying shift caused b…
bdsqqq Mar 12, 2023
c7b2645
take hover style from three dots menu in App
bdsqqq Mar 12, 2023
e0a837f
remove arbitrary stuff I was too tired to make nice, actually made it…
bdsqqq Mar 12, 2023
78334f4
add slight bg change on button hover
bdsqqq Mar 12, 2023
e4b5c28
hover/focus tweaks
markflorkowski Mar 12, 2023
e0de972
Merge branch 'igor/navigation-in-filerunner' of https://github.com/pi…
markflorkowski Mar 12, 2023
7f6d3e6
fixed-height buttons, remove dividers on file browser
markflorkowski Mar 12, 2023
53faba4
remove unused imports
markflorkowski Mar 12, 2023
4b1a976
add wells to file browser
markflorkowski Mar 13, 2023
9177f5e
fix mismatched icon types
bdsqqq Mar 13, 2023
c323bf2
start <App /> NavMenu migration to ButtonDropdown Component
bdsqqq Mar 13, 2023
5fd8c9c
support ButtonLinks in dropdowns
bdsqqq Mar 13, 2023
dd93cfa
types and back compat for Links vs Buttons in dropdowns
bdsqqq Mar 13, 2023
22e1d46
explicitelly use links on the App NavMenu dropdown
bdsqqq Mar 13, 2023
12b185c
"finish" <App /> NavMenu migration to ButtonDropdown Component
bdsqqq Mar 13, 2023
f25817c
prevent clipping of actions with long names
bdsqqq Mar 13, 2023
02a6db8
Merge branch 'main' into igor/navigation-in-filerunner
markflorkowski Mar 23, 2023
79a244f
Merge branch 'main' into igor/navigation-in-filerunner
markflorkowski Mar 23, 2023
ad7fc82
some fixes
markflorkowski Mar 28, 2023
bfa0416
more fixes
markflorkowski Mar 28, 2023
75cfbeb
commetns
markflorkowski Mar 28, 2023
3d04b51
more fixes
markflorkowski Mar 28, 2023
30a8843
openFile
markflorkowski Mar 28, 2023
a03ae02
update warning message
markflorkowski Mar 28, 2023
38da977
removed disabled from ButtonStyle, apply disabled style based on aria…
bdsqqq Apr 20, 2023
e929b9b
a tags don't have a 'disabled' attribute
bdsqqq Apr 20, 2023
d1ef3ca
add TODO
bdsqqq Apr 20, 2023
663321e
make ovewritting tailwind classes not suck
bdsqqq Apr 20, 2023
8c31488
not having a span with no way to pass classes to makes styling this e…
bdsqqq Apr 20, 2023
f1b653c
actually use buttom component in filebrowser folders section
bdsqqq Apr 20, 2023
6cfb92a
add indigo button variant color
bdsqqq Apr 22, 2023
ea55111
button was missing `disabled` prop
bdsqqq Apr 22, 2023
a3a0d79
indigo disabled classes -> aria-disabled
bdsqqq Apr 22, 2023
1e2f247
`Save Changes` button uses an actual <Button />
bdsqqq Apr 22, 2023
edf09d2
add cursor-not-allowed when button is disabled
bdsqqq Apr 22, 2023
4847b96
file-form-modal button -> <Button />
bdsqqq Apr 22, 2023
99dd830
filebrowser buttons -> <Button />
bdsqqq Apr 22, 2023
3a93d35
folder-form-modal buttons -> <Button />
bdsqqq Apr 22, 2023
003a488
white button doesn't turn gray on hover, add transition to buttons
bdsqqq Apr 22, 2023
1f88cd4
center empty state vertically; max-w and center text
bdsqqq May 13, 2023
b4e77a3
fix: only center empty states, otherwise breaks hooks list
bdsqqq May 13, 2023
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
2 changes: 2 additions & 0 deletions apps/cli/cli-core/src/open-folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const getCommand = () => {
throw new Error("Idk what os this is");
};

// TODO: IGOR add openFile, or a flag to create file instead of dir if it doesn't exist. Trying to "Open .config file" in fileRunner brought me here 💀
// Ripped from https://www.npmjs.com/package/open-file-explorer
export async function openInExplorer(path: string) {
// Create the directory if it doesn't exist
Expand All @@ -31,3 +32,4 @@ export async function openInExplorer(path: string) {

return await promisifiedExecFile(getCommand(), [path]);
}

92 changes: 27 additions & 65 deletions apps/cli/cli-web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { classNames } from "./utils/classnames";
import { useFileRoute } from "./utils/useRoute";
import { FileRunner } from "./components/filerunner";
import { cliApi } from "./utils/api";
import { ButtonDropdown } from "./components/common/button";

const SubscriptionsHelper = () => {
useConnectionStateToasts();
Expand Down Expand Up @@ -121,70 +122,31 @@ export default function AppCore() {

const NavMenu = () => {
return (
<Menu as="div" className="relative inline-block text-left">
<div>
<Menu.Button className="flex items-center rounded-sm text-gray-50 hover:text-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-100">
<span className="sr-only">{`Open options`}</span>
<EllipsisVerticalIcon className="h-5 w-5" aria-hidden="true" />
</Menu.Button>
</div>

<Transition
as={Fragment}
enter="transition ease-out duration-100"
enterFrom="transform opacity-0 scale-95"
enterTo="transform opacity-100 scale-100"
leave="transition ease-in duration-75"
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
<Menu.Items className="absolute right-0 z-10 mt-2 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none">
<div className="py-1">
<Menu.Item>
{({ active }) => (
<a
href="https://discord.gg/4wD3CNdsf6"
className={classNames(
active ? "bg-gray-100 text-indigo-700" : "text-gray-700",
"flex flex-row items-center justify-start gap-2 px-4 py-2 text-sm"
)}
>
<QuestionMarkCircleIcon className="h-4" aria-hidden="true" />
{`Support`}
</a>
)}
</Menu.Item>
<Menu.Item>
{({ active }) => (
<a
href="https://github.com/pingdotgg/sample_hooks/issues/new"
className={classNames(
active ? "bg-gray-100 text-indigo-700" : "text-gray-700",
"flex flex-row items-center justify-start gap-2 px-4 py-2 text-sm"
)}
>
<ArchiveBoxIcon className="h-4" aria-hidden="true" />
{`File an Issue`}
</a>
)}
</Menu.Item>
<Menu.Item>
{({ active }) => (
<a
href="https://docs.webhookthing.com"
className={classNames(
active ? "bg-gray-100 text-indigo-700" : "text-gray-700",
"flex flex-row items-center justify-start gap-2 px-4 py-2 text-sm"
)}
>
<BookOpenIcon className="h-4" aria-hidden="true" />
{`Documentation`}
</a>
)}
</Menu.Item>
</div>
</Menu.Items>
</Transition>
</Menu>
<ButtonDropdown
label={`Open options`}
srlabel={true}
variant="text"
icon={<EllipsisVerticalIcon className="h-5 w-5" aria-hidden="true" />}
items={[
{
name: "Support",
href: "https://discord.gg/4wD3CNdsf6",
icon: <QuestionMarkCircleIcon />,
type: "link",
},
{
name: "File an issue",
href: "https://github.com/pingdotgg/sample_hooks/issues/new",
icon: <ArchiveBoxIcon />,
type: "link",
},
{
name: "Documentation",
href: "https://docs.webhookthing.com",
icon: <BookOpenIcon className="h-5 w-5 flex-shrink-0" />,
type: "link",
},
]}
/>
);
};
170 changes: 170 additions & 0 deletions apps/cli/cli-web/src/components/breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import { FolderIcon, HomeIcon } from "@heroicons/react/20/solid";
import { Link } from "wouter";
import { Tooltip } from "./common/tooltip";
import Button, {
ButtonDropdown,
ButtonLink,
ButtonProps,
SplitButtonDropdown,
type ListItemWithIcon,
} from "./common/button";

import { classNames } from "../utils/classnames";

const pathArrToUrl = (pathArr: string[], nav?: string) => {
const url = nav ? `${pathArr.concat(nav).join("/")}` : `${pathArr.join("/")}`;

// make sure we always have a leading slash
if (!url.startsWith("/")) return `/${url}`;
return url;
};

export const Nav = (input: { path: string; actions?: ActionItems }) => {
const { path, actions } = input;

const pathArr = path.split("/").slice(1);

return (
<nav
className="flex items-center justify-between pb-4"
aria-label="Breadcrumb"
>
<Breadcrumbs path={path} pathArr={pathArr} />
{actions && <Actions items={actions} />}
</nav>
);
};

const Breadcrumbs = (input: { path: string; pathArr: string[] }) => {
const { path, pathArr } = input;

return (
<ol role="list" className="flex items-center">
<li className="flex-items-center">
<Link
href="/"
className={classNames(
"flex items-center text-gray-400",
path.length > 1 ? "hover:text-indigo-600" : "cursor-default"
)}
>
<HomeIcon className="h-5 flex-shrink-0" aria-hidden="true" />
<span className="sr-only">{`root`}</span>
</Link>
</li>
{path.length > 1 &&
pathArr.map((page, i) => (
<li key={page}>
<div className="flex items-center">
<svg
className="h-5 flex-shrink-0 text-gray-300"
fill="currentColor"
viewBox="0 0 20 20"
aria-hidden="true"
>
<path d="M5.555 17.776l8-16 .894.448-8 16-.894-.448z" />
</svg>
<Link
href={pathArrToUrl(pathArr.slice(0, pathArr.indexOf(page) + 1))}
className={classNames(
"text-sm font-medium text-gray-400 ",
i !== pathArr.length - 1
? "hover:text-indigo-600"
: "cursor-default"
)}
aria-current={page ? "page" : undefined}
>
<Tooltip content={page}>
<FolderIcon
className={classNames(
"inline h-5",
i === pathArr.length - 1
? "hidden"
: pathArr.join().length > 48
? ""
: "sm:hidden"
)}
aria-hidden="true"
/>
</Tooltip>
<p
className={classNames(
i === pathArr.length - 1
? "inline truncate"
: pathArr.join().length > 48
? "hidden"
: "hidden sm:inline"
)}
>
{page}
</p>
</Link>
</div>
</li>
))}
</ol>
);
};

type ActionsItemCommon = {
label: string;
srlabel?: boolean;
};

type ActionsItemButton = ActionsItemCommon &
ButtonProps & {
type: "button";
onClick?: React.MouseEventHandler<HTMLButtonElement>;
};

type ActionsItemSplitButton = ActionsItemCommon &
ButtonProps & {
type: "splitButton";
items: ListItemWithIcon[];
onClick?: React.MouseEventHandler<HTMLButtonElement>;
};

type ActionsItemDropdownButton = ActionsItemCommon &
ButtonProps & {
type: "dropdownButton";
items: ListItemWithIcon[];
};

type ActionsItemLink = ActionsItemCommon &
ButtonProps & {
type: "link";
href?: string;
};

type ActionsItem =
| ActionsItemLink
| ActionsItemButton
| ActionsItemSplitButton
| ActionsItemDropdownButton;

// TODO: some better way to have icons here, ping code had `dropdownItemWithIcon`
export type ActionItems = ActionsItem[];

const Actions = (input: { items: ActionItems }) => {
return (
<div className="flex flex-row gap-1">
{input.items.map((item, i) => {
if (item.type === "link")
return (
<ButtonLink key={`${i}-breadcrumb}`} {...item}>
{item.label}
</ButtonLink>
);
if (item.type === "button")
return (
<Button key={`${i}-breadcrumb}`} {...item}>
{item.label}
</Button>
);
if (item.type === "splitButton")
return <SplitButtonDropdown {...item} />;
if (item.type === "dropdownButton") return <ButtonDropdown {...item} />;
})}
</div>
);
};
Loading