-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 💄 style: Update CustomLogo * 💄 style: Replace ProviderAvatar * 💄 style: Fix ProviderIcon in ActionForm
- Loading branch information
1 parent
a6e963f
commit dd7c8df
Showing
4 changed files
with
102 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,125 @@ | ||
import { LobeChatProps } from '@lobehub/ui/brand'; | ||
import Image from 'next/image'; | ||
import { memo } from 'react'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
import type { DivProps, SvgProps } from '@lobehub/ui'; | ||
import type { LobeChatProps } from '@lobehub/ui/brand'; | ||
import { createStyles, useTheme } from 'antd-style'; | ||
import Image, { ImageProps } from 'next/image'; | ||
import { ReactNode, memo } from 'react'; | ||
import { Flexbox, FlexboxProps } from 'react-layout-kit'; | ||
|
||
import { BRANDING_LOGO_URL, BRANDING_NAME } from '@/const/branding'; | ||
|
||
interface ProductLogoProps { | ||
className?: string; | ||
extra?: string; | ||
size?: number; | ||
type?: LobeChatProps['type']; | ||
} | ||
const useStyles = createStyles(({ css }) => { | ||
return { | ||
extraTitle: css` | ||
font-weight: 300; | ||
white-space: nowrap; | ||
`, | ||
}; | ||
}); | ||
|
||
const CustomLogo = memo<ProductLogoProps>(({ size = 32, className, type }) => { | ||
const textNode = ( | ||
const CustomTextLogo = memo<FlexboxProps & { size: number }>(({ size, style, ...rest }) => { | ||
return ( | ||
<Flexbox | ||
className={className} | ||
height={size} | ||
style={{ | ||
fontSize: size / 1.5, | ||
fontWeight: 'bold', | ||
fontWeight: 'bolder', | ||
userSelect: 'none', | ||
...style, | ||
}} | ||
{...rest} | ||
> | ||
{BRANDING_NAME} | ||
</Flexbox> | ||
); | ||
}); | ||
|
||
const CustomImageLogo = memo<Omit<ImageProps, 'alt' | 'src'> & { size: number }>( | ||
({ size, ...rest }) => { | ||
return ( | ||
<Image | ||
alt={BRANDING_NAME} | ||
height={size} | ||
src={BRANDING_LOGO_URL} | ||
unoptimized={true} | ||
width={size} | ||
{...rest} | ||
/> | ||
); | ||
}, | ||
); | ||
|
||
const imageNode = ( | ||
<Image | ||
alt={BRANDING_NAME} | ||
className={className} | ||
const Divider = memo<SvgProps & DivProps & { size?: number }>( | ||
({ size = '1em', style, ...rest }) => ( | ||
<svg | ||
fill="none" | ||
height={size} | ||
src={BRANDING_LOGO_URL} | ||
unoptimized={true} | ||
shapeRendering="geometricPrecision" | ||
stroke="currentColor" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
style={{ flex: 'none', lineHeight: 1, ...style }} | ||
viewBox="0 0 24 24" | ||
width={size} | ||
/> | ||
); | ||
{...rest} | ||
> | ||
<path d="M16.88 3.549L7.12 20.451" /> | ||
</svg> | ||
), | ||
); | ||
|
||
const CustomLogo = memo<LobeChatProps>(({ extra, size = 32, className, style, type, ...rest }) => { | ||
const theme = useTheme(); | ||
const { styles } = useStyles(); | ||
let logoComponent: ReactNode; | ||
|
||
switch (type) { | ||
case '3d': | ||
case 'flat': { | ||
logoComponent = <CustomImageLogo size={size} style={style} {...rest} />; | ||
break; | ||
} | ||
case 'mono': { | ||
logoComponent = ( | ||
<CustomImageLogo size={size} style={{ filter: 'grayscale(100%)', ...style }} {...rest} /> | ||
); | ||
break; | ||
} | ||
case 'text': { | ||
return textNode; | ||
logoComponent = <CustomTextLogo size={size} style={style} {...rest} />; | ||
break; | ||
} | ||
|
||
case 'combine': { | ||
return ( | ||
<Flexbox align={'center'} gap={4} horizontal> | ||
{imageNode} | ||
{textNode} | ||
</Flexbox> | ||
logoComponent = ( | ||
<> | ||
<CustomImageLogo size={size} /> | ||
<CustomTextLogo size={size} style={{ marginLeft: Math.round(size / 4) }} /> | ||
</> | ||
); | ||
} | ||
|
||
default: | ||
case 'flat': | ||
case 'mono': | ||
case '3d': { | ||
return ( | ||
<Image | ||
alt={BRANDING_NAME} | ||
className={className} | ||
height={size} | ||
src={BRANDING_LOGO_URL} | ||
unoptimized={true} | ||
width={size} | ||
/> | ||
); | ||
if (!extra) | ||
logoComponent = ( | ||
<Flexbox align={'center'} flex={'none'} horizontal {...rest}> | ||
{logoComponent} | ||
</Flexbox> | ||
); | ||
|
||
break; | ||
} | ||
} | ||
|
||
if (!extra) return logoComponent; | ||
|
||
const extraSize = Math.round((size / 3) * 1.9); | ||
|
||
return ( | ||
<Flexbox align={'center'} className={className} flex={'none'} horizontal {...rest}> | ||
{logoComponent} | ||
<Divider size={extraSize} style={{ color: theme.colorFill }} /> | ||
<div className={styles.extraTitle} style={{ fontSize: extraSize }}> | ||
{extra} | ||
</div> | ||
</Flexbox> | ||
); | ||
}); | ||
|
||
export default CustomLogo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 0 additions & 118 deletions
118
src/features/Conversation/Error/APIKeyForm/ProviderAvatar.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters