Skip to content

Commit

Permalink
Lint fix + imports
Browse files Browse the repository at this point in the history
  • Loading branch information
m-rgba committed Dec 30, 2024
1 parent c2b0f22 commit b79d3c7
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {Box, Drawer} from '@mui/material';
import {Box} from '@mui/material';
import {MOON_200} from '@wandb/weave/common/css/color.styles';
import {Tag} from '@wandb/weave/components/Tag';
import {Icon} from '@wandb/weave/components/Icon';
import {Tailwind} from '@wandb/weave/components/Tailwind';
import React, {useState, useEffect, useCallback} from 'react';
import React, {useCallback, useEffect, useState} from 'react';

import {Button} from '../../../../../Button';
import {ResizableDrawer} from '../common/ResizableDrawer';
import {ChoiceView} from './ChoiceView';
import {Choice} from './types';
import {ResizableDrawer} from '../common/ResizableDrawer';
import {Icon} from '@wandb/weave/components/Icon';

type ChoicesDrawerProps = {
choices: Choice[];
Expand All @@ -28,7 +27,9 @@ export const ChoicesDrawer = ({
setSelectedChoiceIndex,
}: ChoicesDrawerProps) => {
const [width, setWidth] = useState(784);
const [maxAllowedWidth, setMaxAllowedWidth] = useState(window.innerWidth - 73);
const [maxAllowedWidth, setMaxAllowedWidth] = useState(
window.innerWidth - 73
);

useEffect(() => {
const handleResize = () => {
Expand All @@ -55,8 +56,8 @@ export const ChoicesDrawer = ({
position: 'sticky',
top: 0,
zIndex: 20,
pl: "16px",
pr: "8px",
pl: '16px',
pr: '8px',
height: 44,
width: '100%',
borderBottom: `1px solid ${MOON_200}`,
Expand All @@ -82,7 +83,9 @@ export const ChoicesDrawer = ({
variant="ghost"
icon="full-screen-mode-expand"
onClick={handleFullScreen}
tooltip={width === maxAllowedWidth ? "Exit full screen" : "Full screen"}
tooltip={
width === maxAllowedWidth ? 'Exit full screen' : 'Full screen'
}
/>
<Button
size="medium"
Expand All @@ -94,15 +97,22 @@ export const ChoicesDrawer = ({
</Box>
</Box>
<Tailwind>
<div className="flex flex-col pt-[8px] pb-[16px] px-[16px] mb-[72px] gap-[16px]">
<div className="mb-[72px] flex flex-col gap-[16px] px-[16px] pb-[16px] pt-[8px]">
{choices.map((c, index) => (
<div key={index}>
<div className="sticky top-[44px] flex items-center bg-white py-[8px] z-10">
<p className="text-[14px] font-semibold mr-auto">Trial {index + 1}</p>
<div className="sticky top-[44px] z-10 flex items-center bg-white py-[8px]">
<p className="mr-auto text-[14px] font-semibold">
Trial {index + 1}
</p>
{index === selectedChoiceIndex ? (
<div className="flex items-center gap-[2px]">
<Icon name="checkmark" className="ml-[4px] w-[16px] text-green-500" />
<span className="font-semibold text-sm">Response selected</span>
<Icon
name="checkmark"
className="ml-[4px] w-[16px] text-green-500"
/>
<span className="text-sm font-semibold">
Response selected
</span>
</div>
) : (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ export const MessagePanel = ({
<div
ref={contentRef}
className={classNames('w-full overflow-y-hidden', {
'max-h-[400px]': !isShowingMore && !editorHeight && !isNested && !hasToolCalls,
'max-h-full': isShowingMore || editorHeight || isNested || hasToolCalls,
'max-h-[400px]':
!isShowingMore && !editorHeight && !isNested && !hasToolCalls,
'max-h-full':
isShowingMore || editorHeight || isNested || hasToolCalls,
})}>
{messageHeader}
{isPlayground && editorHeight ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ export const ShowMoreButton = ({
}: ShowMoreButtonProps) => {
return (
<div
className={classNames(
'flex w-full items-center justify-center',
{
'pt-[4px]': isShowingMore,
[`absolute mt-[-32px] pt-[16px] pb-[4px] from-70% z-[1] rounded-b-xl bg-gradient-to-t ${
isUser ? 'from-[#f4fbe8]' : 'from-white'
} to-transparent`]: !isShowingMore,
}
)}>
className={classNames('flex w-full items-center justify-center', {
'pt-[4px]': isShowingMore,
[`absolute z-[1] mt-[-32px] rounded-b-xl bg-gradient-to-t from-70% pb-[4px] pt-[16px] ${
isUser ? 'from-[#f4fbe8]' : 'from-white'
} to-transparent`]: !isShowingMore,
})}>
<Button
variant="ghost"
size="small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ export const FunctionEditor: React.FC<FunctionEditorProps> = ({
flexDirection: 'column',
gap: '4px',
}}>
<Box sx={{display: 'flex', gap: '4px', fontSize: '14px', alignItems: 'center'}}>
<Box
sx={{
display: 'flex',
gap: '4px',
fontSize: '14px',
alignItems: 'center',
}}>
Functions
{!LLM_MAX_TOKENS[playgroundState.model]?.supports_function_calling && (
<Tooltip title="This model does not support functions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const StopSequenceEditor: React.FC<StopSequenceEditorProps> = ({
display: 'flex',
flexDirection: 'column',
gap: '4px',
width: '100%'
width: '100%',
}}>
<span style={{fontSize: '14px'}}>Stop sequences</span>
<Box
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Box, Drawer, DrawerProps} from '@mui/material';
import {MOON_200} from '@wandb/weave/common/css/color.styles';
import React, {useCallback, useEffect, useState} from 'react';

interface ResizableDrawerProps extends Omit<DrawerProps, 'onClose' | 'anchor'> {
Expand All @@ -22,12 +21,17 @@ export const ResizableDrawer: React.FC<ResizableDrawerProps> = ({
const [internalWidth, setInternalWidth] = useState(defaultWidth);
const [isResizing, setIsResizing] = useState(false);
// 73px = 57px sidebar + 16px padding
const [maxAllowedWidth, setMaxAllowedWidth] = useState(window.innerWidth - 73);
const [maxAllowedWidth, setMaxAllowedWidth] = useState(
window.innerWidth - 73
);

const setWidthValue = useCallback((newWidth: number) => {
setInternalWidth(newWidth);
externalSetWidth?.(newWidth);
}, [externalSetWidth]);
const setWidthValue = useCallback(
(newWidth: number) => {
setInternalWidth(newWidth);
externalSetWidth?.(newWidth);
},
[externalSetWidth]
);

useEffect(() => {
if (externalSetWidth) {
Expand Down Expand Up @@ -59,7 +63,9 @@ export const ResizableDrawer: React.FC<ResizableDrawerProps> = ({

const handleMouseMove = useCallback(
(e: MouseEvent) => {
if (!isResizing) return;
if (!isResizing) {
return;
}

const newWidth = window.innerWidth - e.clientX;
if (newWidth >= 120 && newWidth <= maxAllowedWidth) {
Expand All @@ -83,33 +89,33 @@ export const ResizableDrawer: React.FC<ResizableDrawerProps> = ({

return (
<Drawer
{...drawerProps}
anchor="right"
onClose={onClose}
{...drawerProps}
anchor="right"
onClose={onClose}
sx={{
'& .MuiDrawer-paper': {
mt: '60px',
width: `${internalWidth}px`,
position: 'fixed',
maxWidth: `${maxAllowedWidth}px`,
minWidth: '120px',
},
}}>
<Box
sx={{
'& .MuiDrawer-paper': {
mt: '60px',
width: `${internalWidth}px`,
position: 'fixed',
maxWidth: `${maxAllowedWidth}px`,
minWidth: '120px'
},
}}>
<Box
sx={{
position: 'absolute',
top: 0,
bottom: 0,
left: -4,
width: 8,
cursor: 'ew-resize',
'&:hover': {
backgroundColor: 'rgba(0, 0, 0, 0.1)',
},
}}
onMouseDown={handleMouseDown}
/>
{children}
position: 'absolute',
top: 0,
bottom: 0,
left: -4,
width: 8,
cursor: 'ew-resize',
'&:hover': {
backgroundColor: 'rgba(0, 0, 0, 0.1)',
},
}}
onMouseDown={handleMouseDown}
/>
{children}
</Drawer>
);
};

0 comments on commit b79d3c7

Please sign in to comment.