Some scrolling tweaks

This commit is contained in:
Gregory Schier
2024-03-20 17:27:47 -07:00
parent 23c4971127
commit aa3bfd78c4
3 changed files with 13 additions and 10 deletions

View File

@@ -13,7 +13,7 @@ export function BasicAuth<T extends HttpRequest | GrpcRequest>({ request }: Prop
const updateGrpcRequest = useUpdateGrpcRequest(request.id); const updateGrpcRequest = useUpdateGrpcRequest(request.id);
return ( return (
<VStack className="my-2" space={2}> <VStack className="py-2 overflow-y-auto h-full" space={2}>
<Input <Input
useTemplating useTemplating
autocompleteVariables autocompleteVariables

View File

@@ -16,7 +16,7 @@ export function Banner({ children, className, color = 'gray' }: Props) {
color === 'gray' && 'border-gray-500/60 bg-gray-300/10 text-gray-800', color === 'gray' && 'border-gray-500/60 bg-gray-300/10 text-gray-800',
color === 'warning' && 'border-orange-500/60 bg-orange-300/10 text-orange-800', color === 'warning' && 'border-orange-500/60 bg-orange-300/10 text-orange-800',
color === 'danger' && 'border-red-500/60 bg-red-300/10 text-red-800', color === 'danger' && 'border-red-500/60 bg-red-300/10 text-red-800',
color === 'success' && 'border-green-500/60 bg-green-300/10 text-green-800', color === 'success' && 'border-violet-500/60 bg-violet-300/10 text-violet-800',
)} )}
> >
{children} {children}

View File

@@ -32,6 +32,7 @@ export type PairEditorProps = {
allowFileValues?: boolean; allowFileValues?: boolean;
nameValidate?: InputProps['validate']; nameValidate?: InputProps['validate'];
valueValidate?: InputProps['validate']; valueValidate?: InputProps['validate'];
noScroll?: boolean;
}; };
export type Pair = { export type Pair = {
@@ -57,6 +58,7 @@ export const PairEditor = memo(function PairEditor({
nameValidate, nameValidate,
valueType, valueType,
onChange, onChange,
noScroll,
pairs: originalPairs, pairs: originalPairs,
valueAutocomplete, valueAutocomplete,
valueAutocompleteVariables, valueAutocompleteVariables,
@@ -95,7 +97,7 @@ export const PairEditor = memo(function PairEditor({
[onChange], [onChange],
); );
const handleMove = useCallback<FormRowProps['onMove']>( const handleMove = useCallback<PairEditorRowProps['onMove']>(
(id, side) => { (id, side) => {
const dragIndex = pairs.findIndex((r) => r.id === id); const dragIndex = pairs.findIndex((r) => r.id === id);
setHoveredIndex(side === 'above' ? dragIndex : dragIndex + 1); setHoveredIndex(side === 'above' ? dragIndex : dragIndex + 1);
@@ -103,7 +105,7 @@ export const PairEditor = memo(function PairEditor({
[pairs], [pairs],
); );
const handleEnd = useCallback<FormRowProps['onEnd']>( const handleEnd = useCallback<PairEditorRowProps['onEnd']>(
(id: string) => { (id: string) => {
if (hoveredIndex === null) return; if (hoveredIndex === null) return;
setHoveredIndex(null); setHoveredIndex(null);
@@ -162,7 +164,8 @@ export const PairEditor = memo(function PairEditor({
className={classNames( className={classNames(
className, className,
'@container', '@container',
'pb-2 grid overflow-auto max-h-full', 'pb-2 mb-auto',
!noScroll && 'overflow-y-auto max-h-full',
// Move over the width of the drag handle // Move over the width of the drag handle
'-ml-3', '-ml-3',
// Pad to make room for the drag divider // Pad to make room for the drag divider
@@ -174,7 +177,7 @@ export const PairEditor = memo(function PairEditor({
return ( return (
<Fragment key={p.id}> <Fragment key={p.id}>
{hoveredIndex === i && <DropMarker />} {hoveredIndex === i && <DropMarker />}
<FormRow <PairEditorRow
pairContainer={p} pairContainer={p}
className="py-1" className="py-1"
isLast={isLast} isLast={isLast}
@@ -207,7 +210,7 @@ enum ItemTypes {
ROW = 'pair-row', ROW = 'pair-row',
} }
type FormRowProps = { type PairEditorRowProps = {
className?: string; className?: string;
pairContainer: PairContainer; pairContainer: PairContainer;
forceFocusPairId?: string | null; forceFocusPairId?: string | null;
@@ -233,7 +236,7 @@ type FormRowProps = {
| 'allowFileValues' | 'allowFileValues'
>; >;
const FormRow = memo(function FormRow({ function PairEditorRow({
allowFileValues, allowFileValues,
className, className,
forceFocusPairId, forceFocusPairId,
@@ -254,7 +257,7 @@ const FormRow = memo(function FormRow({
valuePlaceholder, valuePlaceholder,
valueValidate, valueValidate,
valueType, valueType,
}: FormRowProps) { }: PairEditorRowProps) {
const { id } = pairContainer; const { id } = pairContainer;
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
const prompt = usePrompt(); const prompt = usePrompt();
@@ -480,7 +483,7 @@ const FormRow = memo(function FormRow({
)} )}
</div> </div>
); );
}); }
const newPairContainer = (initialPair?: Pair): PairContainer => { const newPairContainer = (initialPair?: Pair): PairContainer => {
const id = initialPair?.id ?? uuid(); const id = initialPair?.id ?? uuid();