Skip to content

Commit

Permalink
refactor: replace svg as customIcon component
Browse files Browse the repository at this point in the history
  • Loading branch information
lizable committed Aug 29, 2024
1 parent e90f19d commit 2d36af1
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 27 deletions.
2 changes: 1 addition & 1 deletion react/src/components/BAIStartBasicCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const BAIStartBasicCard: React.FC<BAIStartBasicCardProps> = ({
Button: {
defaultBorderColor: 'none',
defaultColor: secondary ? '#E8FAF6' : '#FFF6E8',
defaultBg: secondary ? '#00BD9B' : token.colorPrimary,
defaultBg: secondary ? '#00BD9B' : token.colorPrimaryBg,
defaultHoverColor: secondary ? '#00BD9B' : token.colorPrimary,
defaultHoverBorderColor: secondary ? '#00BD9B' : token.colorPrimary,
},
Expand Down
2 changes: 1 addition & 1 deletion react/src/components/MainLayout/WebUISider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const WebUISider: React.FC<WebUISiderProps> = (props) => {
{
label: 'Start', // t('webui.menu.Summary'),
icon: <PlayCircleOutlined style={{ color: token.colorPrimaryBg }} />,
key: 'summary', // 'summary',
key: 'start', // 'summary',
},
{
label: 'Dashboard',
Expand Down
5 changes: 5 additions & 0 deletions react/src/components/icons/BatchSession.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions react/src/components/icons/BatchSessionIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ReactComponent as logo } from './BatchSession.svg';
import Icon from '@ant-design/icons';
import { CustomIconComponentProps } from '@ant-design/icons/lib/components/Icon';

interface BatchSessionIconProps
extends Omit<CustomIconComponentProps, 'width' | 'height' | 'fill'> {}

const BatchSessionIcon: React.FC<BatchSessionIconProps> = (props) => {
return <Icon component={logo} {...props} />;
};

export default BatchSessionIcon;
File renamed without changes
12 changes: 12 additions & 0 deletions react/src/components/icons/ExampleStart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ReactComponent as logo } from './ExampleStart.svg';
import Icon from '@ant-design/icons';
import { CustomIconComponentProps } from '@ant-design/icons/lib/components/Icon';

interface ExampleStartIconProps
extends Omit<CustomIconComponentProps, 'width' | 'height' | 'fill'> {}

const ExampleStartIcon: React.FC<ExampleStartIconProps> = (props) => {
return <Icon component={logo} {...props} />;
};

export default ExampleStartIcon;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions react/src/components/icons/InteractiveSession.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ReactComponent as logo } from './InteractiveSession.svg';
import Icon from '@ant-design/icons';
import { CustomIconComponentProps } from '@ant-design/icons/lib/components/Icon';

interface InteractiveSessionIconProps
extends Omit<CustomIconComponentProps, 'width' | 'height' | 'fill'> {}

const InteractiveSessionIcon: React.FC<InteractiveSessionIconProps> = (
props,
) => {
return <Icon component={logo} {...props} />;
};

export default InteractiveSessionIcon;
File renamed without changes
12 changes: 12 additions & 0 deletions react/src/components/icons/ModelServiceIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ReactComponent as logo } from './ModelService.svg';
import Icon from '@ant-design/icons';
import { CustomIconComponentProps } from '@ant-design/icons/lib/components/Icon';

interface ModelServiceIconProps
extends Omit<CustomIconComponentProps, 'width' | 'height' | 'fill'> {}

const ModelServiceIcon: React.FC<ModelServiceIconProps> = (props) => {
return <Icon component={logo} {...props} />;
};

export default ModelServiceIcon;
7 changes: 7 additions & 0 deletions react/src/components/icons/URLStart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions react/src/components/icons/URLStartIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ReactComponent as logo } from './URLStart.svg';
import Icon from '@ant-design/icons';
import { CustomIconComponentProps } from '@ant-design/icons/lib/components/Icon';

interface URLStartIconProps
extends Omit<CustomIconComponentProps, 'width' | 'height' | 'fill'> {}

const URLStartIcon: React.FC<URLStartIconProps> = (props) => {
return <Icon component={logo} {...props} />;
};

export default URLStartIcon;
43 changes: 27 additions & 16 deletions react/src/pages/StartPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import BAIStartBasicCard from '../components/BAIStartBasicCard';
import Flex from '../components/Flex';
import BatchSessionIcon from '../components/icons/BatchSessionIcon';
import ExampleStartIcon from '../components/icons/ExampleStart';
import InteractiveSessionIcon from '../components/icons/InteractiveSession';
import ModelServiceIcon from '../components/icons/ModelServiceIcon';
import URLStartIcon from '../components/icons/URLStartIcon';
import { useWebUINavigate } from '../hooks';
import { FolderAddOutlined } from '@ant-design/icons';
import React from 'react';
Expand Down Expand Up @@ -30,12 +35,7 @@ const StartPage: React.FC<StartPageProps> = (props) => {
}}
/>
<BAIStartBasicCard
icon={
<img
src="/resources/icons/interactiveSession.svg"
alt="interactive session"
/>
}
icon={<InteractiveSessionIcon />}
title={
<div>
Start an
Expand All @@ -52,9 +52,7 @@ const StartPage: React.FC<StartPageProps> = (props) => {
}}
/>
<BAIStartBasicCard
icon={
<img src="/resources/icons/batchSession.svg" alt="batch session" />
}
icon={<BatchSessionIcon />}
title={
<div>
Start a<br />
Expand All @@ -75,9 +73,7 @@ const StartPage: React.FC<StartPageProps> = (props) => {
<Flex gap={16} wrap="wrap">
<BAIStartBasicCard
secondary
icon={
<img src="/resources/icons/modelService.svg" alt="model service" />
}
icon={<ModelServiceIcon />}
title={
<div>
Start a
Expand All @@ -94,9 +90,7 @@ const StartPage: React.FC<StartPageProps> = (props) => {
/>
<BAIStartBasicCard
secondary
icon={
<img src="/resources/icons/exampleStart.svg" alt="example start" />
}
icon={<ExampleStartIcon />}
title={
<div>
Start
Expand All @@ -111,7 +105,14 @@ const StartPage: React.FC<StartPageProps> = (props) => {
/>
<BAIStartBasicCard
secondary
icon={<img src="/resources/icons/URLStart.svg" alt="URL start" />}
icon={
// FIXME: workaround for displaying proper icon
<img
src="react/src/components/icons/URLStart.svg"
alt="URL start"
></img>
// <URLStartIcon />
}
title={
<div>
Start
Expand All @@ -125,6 +126,16 @@ const StartPage: React.FC<StartPageProps> = (props) => {
}}
/>
</Flex>
{/* <BAIStartSimpleCard
icon={<SessionsIcon />}
title={'Create a Session'}
footerButtonProps={{
onClick: () => {
webuiNavigate('/session/start');
},
children: 'Start Session',
}}
/> */}
</Flex>
);
};
Expand Down
4 changes: 0 additions & 4 deletions resources/icons/URLStart.svg

This file was deleted.

4 changes: 0 additions & 4 deletions resources/icons/batchSession.svg

This file was deleted.

1 change: 1 addition & 0 deletions resources/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"fontFamily": "'Ubuntu', Roboto, sans-serif",
"colorPrimary": "#FF7A00",
"colorLink": "#FF7A00",
"colorPrimaryText": "#E8FAF6",
"colorPrimaryBg": "#FF7A00",
"colorFillContent": "#FF9D00",
"colorInfoHover": "#FFE3B7",
Expand Down

0 comments on commit 2d36af1

Please sign in to comment.