Skip to content

Commit

Permalink
chore: workflow ui (labring#3175)
Browse files Browse the repository at this point in the history
* chore: workflow ui

* fix

* change icon color config

* change popover to mymenu
  • Loading branch information
newfish-cmyk authored and Jiangween committed Dec 1, 2024
1 parent a597041 commit a6e8adf
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 365 deletions.
34 changes: 34 additions & 0 deletions packages/web/components/common/MyBox/IconButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { Flex, FlexProps } from '@chakra-ui/react';
import MyIcon from '../Icon';

type Props = FlexProps & {
icon: string;
onClick?: () => void;
hoverColor?: string;
};

const IconButton = ({ icon, onClick, hoverColor = 'primary.600', ...props }: Props) => {
return (
<Flex
mr={1}
p={1}
color={'myGray.500'}
rounded={'sm'}
alignItems={'center'}
bg={'transparent'}
transition={'background 0.1s'}
cursor={'pointer'}
_hover={{
bg: 'myGray.05',
color: hoverColor
}}
onClick={onClick}
{...props}
>
<MyIcon name={icon as any} w={'16px'} />
</Flex>
);
};

export default IconButton;
196 changes: 94 additions & 102 deletions packages/web/components/common/MyMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ export type Props = {
}[];
};

const typeMapStyle: Record<MenuItemType, { styles: MenuItemProps; iconColor?: string }> = {
primary: {
styles: {
const MyMenu = ({
width = 'auto',
trigger = 'hover',
size = 'sm',
offset,
Button,
menuList,
placement = 'bottom-start'
}: Props) => {
const typeMapStyle: Record<MenuItemType, MenuItemProps & { iconColor?: string }> = {
primary: {
_hover: {
backgroundColor: 'primary.50',
color: 'primary.600'
Expand All @@ -57,12 +65,10 @@ const typeMapStyle: Record<MenuItemType, { styles: MenuItemProps; iconColor?: st
_active: {
backgroundColor: 'primary.50',
color: 'primary.600'
}
},
iconColor: 'myGray.600'
},
iconColor: 'myGray.600'
},
gray: {
styles: {
gray: {
_hover: {
backgroundColor: 'myGray.05',
color: 'primary.600'
Expand All @@ -74,12 +80,10 @@ const typeMapStyle: Record<MenuItemType, { styles: MenuItemProps; iconColor?: st
_active: {
backgroundColor: 'myGray.05',
color: 'primary.600'
}
},
iconColor: 'myGray.400'
},
iconColor: 'myGray.400'
},
grayBg: {
styles: {
grayBg: {
_hover: {
backgroundColor: 'myGray.05',
color: 'primary.600'
Expand All @@ -91,12 +95,10 @@ const typeMapStyle: Record<MenuItemType, { styles: MenuItemProps; iconColor?: st
_active: {
backgroundColor: 'myGray.05',
color: 'primary.600'
}
},
iconColor: 'myGray.600'
},
iconColor: 'myGray.600'
},
danger: {
styles: {
danger: {
color: 'red.600',
_hover: {
background: 'red.1'
Expand All @@ -106,98 +108,88 @@ const typeMapStyle: Record<MenuItemType, { styles: MenuItemProps; iconColor?: st
},
_active: {
background: 'red.1'
}
},
iconColor: 'red.600'
}
};
const sizeMapStyle: Record<
MenuSizeType,
{
iconStyle: AvatarProps;
labelStyle: BoxProps;
dividerStyle: DividerProps;
menuItemStyle: MenuItemProps;
}
> = {
mini: {
iconStyle: {
w: '14px'
},
labelStyle: {
fontSize: 'mini'
},
dividerStyle: {
my: 0.5
},
menuItemStyle: {
py: 1.5,
px: 2
},
iconColor: 'red.600'
}
},
xs: {
iconStyle: {
w: '14px'
},
labelStyle: {
fontSize: 'sm'
},
dividerStyle: {
my: 0.5
},
menuItemStyle: {
py: 1.5,
px: 2
};
const sizeMapStyle: Record<
MenuSizeType,
{
iconStyle: AvatarProps;
labelStyle: BoxProps;
dividerStyle: DividerProps;
menuItemStyle: MenuItemProps;
}
},
sm: {
iconStyle: {
w: '1rem'
},
labelStyle: {
fontSize: 'sm'
},
dividerStyle: {
my: 1
},
menuItemStyle: {
py: 2,
px: 3,
_notLast: {
mb: 0.5
> = {
mini: {
iconStyle: {
w: '14px'
},
labelStyle: {
fontSize: 'mini'
},
dividerStyle: {
my: 0.5
},
menuItemStyle: {
py: 1.5,
px: 2
}
}
},
md: {
iconStyle: {
w: '2rem',
borderRadius: '6px'
},
labelStyle: {
fontSize: 'sm'
xs: {
iconStyle: {
w: '14px'
},
labelStyle: {
fontSize: 'sm'
},
dividerStyle: {
my: 0.5
},
menuItemStyle: {
py: 1.5,
px: 2
}
},
dividerStyle: {
my: 1
sm: {
iconStyle: {
w: '1rem'
},
labelStyle: {
fontSize: 'sm'
},
dividerStyle: {
my: 1
},
menuItemStyle: {
py: 2,
px: 3,
_notLast: {
mb: 0.5
}
}
},
menuItemStyle: {
py: 2,
px: 3,
_notLast: {
mb: 0.5
md: {
iconStyle: {
w: '2rem',
borderRadius: '6px'
},
labelStyle: {
fontSize: 'sm'
},
dividerStyle: {
my: 1
},
menuItemStyle: {
py: 2,
px: 3,
_notLast: {
mb: 0.5
}
}
}
}
};
};

const MyMenu = ({
width = 'auto',
trigger = 'hover',
size = 'sm',
offset,
Button,
menuList,
placement = 'bottom-start'
}: Props) => {
const { isPc } = useSystem();
const ref = useRef<HTMLDivElement>(null);
const closeTimer = useRef<any>();
Expand Down Expand Up @@ -301,7 +293,7 @@ const MyMenu = ({
fontSize={'sm'}
color={child.isActive ? 'primary.700' : 'myGray.600'}
whiteSpace={'pre-wrap'}
{...typeMapStyle[child.type || 'primary'].styles}
{...typeMapStyle[child.type || 'primary']}
{...sizeMapStyle[size].menuItemStyle}
{...child.menuItemStyles}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/web/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@
"core.module.template.AI support tool tip": "Models that support function calls can better use tool calls.",
"core.module.template.Basic Node": "Basic",
"core.module.template.Query extension": "Question Optimization",
"core.module.template.System Plugin": "System Plugin",
"core.module.template.System Plugin": "System",
"core.module.template.System input module": "System Input",
"core.module.template.Team app": "Team",
"core.module.template.Tool module": "Tool",
Expand Down
1 change: 0 additions & 1 deletion projects/app/src/components/Layout/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const Navbar = ({ unread }: { unread: number }) => {
w={'100%'}
userSelect={'none'}
pb={2}
bg={isSecondNavbarPage ? 'myGray.50' : 'transparent'}
>
{/* logo */}
<Box
Expand Down
6 changes: 3 additions & 3 deletions projects/app/src/components/core/app/VariableEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import ChatFunctionTip from './Tip';
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
import InputTypeConfig from '@/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodePluginIO/InputTypeConfig';
import MyIconButton from '@fastgpt/web/components/common/Icon/button';
import IconButton from '@fastgpt/web/components/common/MyBox/IconButton';

export const defaultVariable: VariableItemType = {
id: nanoid(),
Expand Down Expand Up @@ -220,7 +220,7 @@ const VariableEdit = ({
</Td>
<Td>
<Flex>
<MyIconButton
<IconButton
icon={'common/settingLight'}
onClick={() => {
const formattedItem = {
Expand All @@ -230,7 +230,7 @@ const VariableEdit = ({
reset(formattedItem);
}}
/>
<MyIconButton
<IconButton
icon={'delete'}
hoverColor={'red.500'}
onClick={() =>
Expand Down
Loading

0 comments on commit a6e8adf

Please sign in to comment.