Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
feat(toolkit): User can have autoresize input when edit node and pipe…
Browse files Browse the repository at this point in the history
…line name (#948)

Because

- Improve UX

This commit

- User can have autoresize input when edit node and pipeline name
  • Loading branch information
EiffelFly committed Oct 11, 2023
1 parent c0c3e2d commit 4d2bbc5
Show file tree
Hide file tree
Showing 8 changed files with 346 additions and 194 deletions.
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@instill-ai/toolkit",
"version": "0.68.3-rc.4",
"version": "0.68.3-rc.15",
"description": "Instill AI's frontend toolkit",
"repository": "https://github.com/instill-ai/design-system.git",
"bugs": "https://github.com/instill-ai/design-system/issues",
Expand Down
57 changes: 57 additions & 0 deletions packages/toolkit/src/components/AutoresizeInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import cn from "clsx";
import { Nullable } from "../lib";

/*
Usage:
// You need to make sure all the padding and text styles are the same as
// the input element you're using.
const textStyle = "text-sm font-medium p-2"
const [value] = React.useState("")
<AutoresizeInputWrapper
value={field.value ?? ""}
className="min-w-[280px] max-w-[400px] h-12"
placeholderClassname={textStyle}
>
<input
className={cn(
"!absolute !bottom-0 !left-0 !right-0 !top-0 p-2",
textStyle
)}
value={value}
/>
</AutoresizeInputWrapper>
*/

export const AutoresizeInputWrapper = ({
placeholderClassname,
value,
className,
children,
}: {
value: Nullable<string>;
className?: string;
children: React.ReactNode;
placeholderClassname?: string;
}) => {
return (
<div className="flex">
<div className={cn("relative", className)}>
<div
className={cn(
"invisible !m-0 box-border h-full border-none",
placeholderClassname
)}
contentEditable={true}
suppressContentEditableWarning={true}
>
{value}
</div>
{children}
</div>
</div>
);
};
1 change: 1 addition & 0 deletions packages/toolkit/src/components/ImageWithFallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const ImageWithFallback = ({
onError={() => {
setError(true);
}}
className="flex-shrink-0"
/>
);
};
2 changes: 1 addition & 1 deletion packages/toolkit/src/components/Topbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Topbar = (props: TopbarProps) => {
return (
<div
className={cn(
"flex h-[var(--topbar-height)] flex-row border-b border-semantic-bg-line bg-semantic-bg-primary px-4",
"flex h-[var(--topbar-height)] box-content flex-row border-b border-semantic-bg-line bg-semantic-bg-primary px-4",
className
)}
>
Expand Down
1 change: 1 addition & 0 deletions packages/toolkit/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./AutoresizeInput";
export * from "./Breadcrumb";
export * from "./CopyToClipboardButton";
export * from "./CodeBlock";
Expand Down
Loading

1 comment on commit 4d2bbc5

@vercel
Copy link

@vercel vercel bot commented on 4d2bbc5 Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.