0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): use connector dark logo (#2694)

This commit is contained in:
wangsijie 2022-12-21 11:54:11 +08:00 committed by GitHub
parent caa75422ad
commit 1865b74272
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 22 deletions

View file

@ -0,0 +1,23 @@
import type { ConnectorResponse } from '@logto/schemas';
import { AppearanceMode } from '@logto/schemas';
import { useTheme } from '@/hooks/use-theme';
type Props = {
className?: string;
data: Pick<ConnectorResponse, 'logo' | 'logoDark'>;
};
const ConnectorLogo = ({ className, data }: Props) => {
const theme = useTheme();
return (
<img
className={className}
alt="logo"
src={theme === AppearanceMode.DarkMode && data.logoDark ? data.logoDark : data.logo}
/>
);
};
export default ConnectorLogo;

View file

@ -1,5 +1,5 @@
import type { ConnectorResponse } from '@logto/schemas'; import type { ConnectorResponse } from '@logto/schemas';
import { AppearanceMode, ConnectorType } from '@logto/schemas'; import { ConnectorType } from '@logto/schemas';
import { useState } from 'react'; import { useState } from 'react';
import { toast } from 'react-hot-toast'; import { toast } from 'react-hot-toast';
import { Trans, useTranslation } from 'react-i18next'; import { Trans, useTranslation } from 'react-i18next';
@ -14,6 +14,7 @@ import ActionMenu, { ActionMenuItem } from '@/components/ActionMenu';
import Button from '@/components/Button'; import Button from '@/components/Button';
import Card from '@/components/Card'; import Card from '@/components/Card';
import ConfirmModal from '@/components/ConfirmModal'; import ConfirmModal from '@/components/ConfirmModal';
import ConnectorLogo from '@/components/ConnectorLogo';
import CopyToClipboard from '@/components/CopyToClipboard'; import CopyToClipboard from '@/components/CopyToClipboard';
import DetailsSkeleton from '@/components/DetailsSkeleton'; import DetailsSkeleton from '@/components/DetailsSkeleton';
import Drawer from '@/components/Drawer'; import Drawer from '@/components/Drawer';
@ -96,11 +97,7 @@ const ConnectorDetails = () => {
{data && ( {data && (
<Card className={styles.header}> <Card className={styles.header}>
<div className={styles.logoContainer}> <div className={styles.logoContainer}>
<img <ConnectorLogo data={data} className={styles.logo} />
src={theme === AppearanceMode.DarkMode && data.logoDark ? data.logoDark : data.logo}
alt="logo"
className={styles.logo}
/>
</div> </div>
<div className={styles.metadata}> <div className={styles.metadata}>
<div> <div>

View file

@ -1,9 +1,10 @@
import type { ConnectorResponse } from '@logto/schemas'; import type { ConnectorResponse } from '@logto/schemas';
import { AppearanceMode, ConnectorType } from '@logto/schemas'; import { ConnectorType } from '@logto/schemas';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import Button from '@/components/Button'; import Button from '@/components/Button';
import ConnectorLogo from '@/components/ConnectorLogo';
import ItemPreview from '@/components/ItemPreview'; import ItemPreview from '@/components/ItemPreview';
import UnnamedTrans from '@/components/UnnamedTrans'; import UnnamedTrans from '@/components/UnnamedTrans';
import { import {
@ -73,15 +74,7 @@ const ConnectorName = ({ type, connectors, onClickSetup }: Props) => {
} }
icon={ icon={
<div className={styles.logoContainer}> <div className={styles.logoContainer}>
<img <ConnectorLogo className={styles.logo} data={connector} />
className={styles.logo}
alt="logo"
src={
theme === AppearanceMode.DarkMode && connector.logoDark
? connector.logoDark
: connector.logo
}
/>
</div> </div>
} }
/> />

View file

@ -6,6 +6,7 @@ import Modal from 'react-modal';
import useSWR from 'swr'; import useSWR from 'swr';
import Button from '@/components/Button'; import Button from '@/components/Button';
import ConnectorLogo from '@/components/ConnectorLogo';
import ModalLayout from '@/components/ModalLayout'; import ModalLayout from '@/components/ModalLayout';
import RadioGroup, { Radio } from '@/components/RadioGroup'; import RadioGroup, { Radio } from '@/components/RadioGroup';
import UnnamedTrans from '@/components/UnnamedTrans'; import UnnamedTrans from '@/components/UnnamedTrans';
@ -157,11 +158,11 @@ const CreateForm = ({ onClose, isOpen: isFormOpen, type }: Props) => {
className={classNames(styles.connectorGroup, styles[modalSize])} className={classNames(styles.connectorGroup, styles[modalSize])}
onChange={handleGroupChange} onChange={handleGroupChange}
> >
{groups.map(({ id, name, logo, description }) => ( {groups.map(({ id, name, logo, logoDark, description }) => (
<Radio key={id} value={id}> <Radio key={id} value={id}>
<div className={styles.connector}> <div className={styles.connector}>
<div className={styles.logo}> <div className={styles.logo}>
<img src={logo} alt="logo" /> <ConnectorLogo data={{ logo, logoDark }} />
</div> </div>
<div className={styles.content}> <div className={styles.content}>
<div className={classNames(styles.name)}> <div className={classNames(styles.name)}>

View file

@ -4,6 +4,7 @@ import CirclePlus from '@/assets/images/circle-plus.svg';
import Plus from '@/assets/images/plus.svg'; import Plus from '@/assets/images/plus.svg';
import ActionMenu from '@/components/ActionMenu'; import ActionMenu from '@/components/ActionMenu';
import type { Props as ButtonProps } from '@/components/Button'; import type { Props as ButtonProps } from '@/components/Button';
import ConnectorLogo from '@/components/ConnectorLogo';
import { DropdownItem } from '@/components/Dropdown'; import { DropdownItem } from '@/components/Dropdown';
import UnnamedTrans from '@/components/UnnamedTrans'; import UnnamedTrans from '@/components/UnnamedTrans';
import ConnectorPlatformIcon from '@/icons/ConnectorPlatformIcon'; import ConnectorPlatformIcon from '@/icons/ConnectorPlatformIcon';
@ -45,7 +46,7 @@ const AddButton = ({ options, onSelected, hasSelectedConnectors }: Props) => {
)} )}
isDropdownFullWidth={!hasSelectedConnectors} isDropdownFullWidth={!hasSelectedConnectors}
> >
{options.map(({ target, logo, name, connectors }) => ( {options.map(({ target, logo, logoDark, name, connectors }) => (
<DropdownItem <DropdownItem
key={target} key={target}
onClick={() => { onClick={() => {
@ -53,7 +54,7 @@ const AddButton = ({ options, onSelected, hasSelectedConnectors }: Props) => {
}} }}
> >
<div className={styles.title}> <div className={styles.title}>
<img src={logo} alt={target} className={styles.logo} /> <ConnectorLogo data={{ logo, logoDark }} className={styles.logo} />
<UnnamedTrans resource={name} className={styles.name} /> <UnnamedTrans resource={name} className={styles.name} />
{connectors.length > 1 && {connectors.length > 1 &&
connectors.map(({ platform }) => ( connectors.map(({ platform }) => (

View file

@ -1,5 +1,6 @@
import Draggable from '@/assets/images/draggable.svg'; import Draggable from '@/assets/images/draggable.svg';
import Minus from '@/assets/images/minus.svg'; import Minus from '@/assets/images/minus.svg';
import ConnectorLogo from '@/components/ConnectorLogo';
import IconButton from '@/components/IconButton'; import IconButton from '@/components/IconButton';
import UnnamedTrans from '@/components/UnnamedTrans'; import UnnamedTrans from '@/components/UnnamedTrans';
import ConnectorPlatformIcon from '@/icons/ConnectorPlatformIcon'; import ConnectorPlatformIcon from '@/icons/ConnectorPlatformIcon';
@ -12,12 +13,15 @@ type Props = {
onDelete: (connectorTarget: string) => void; onDelete: (connectorTarget: string) => void;
}; };
const SelectedConnectorItem = ({ data: { logo, target, name, connectors }, onDelete }: Props) => { const SelectedConnectorItem = ({
data: { logo, logoDark, target, name, connectors },
onDelete,
}: Props) => {
return ( return (
<div className={styles.item}> <div className={styles.item}>
<div className={styles.info}> <div className={styles.info}>
<Draggable className={styles.draggableIcon} /> <Draggable className={styles.draggableIcon} />
<img src={logo} alt={target} className={styles.logo} /> <ConnectorLogo data={{ logo, logoDark }} className={styles.logo} />
<UnnamedTrans resource={name} className={styles.name} /> <UnnamedTrans resource={name} className={styles.name} />
{connectors.length > 1 && {connectors.length > 1 &&
connectors.map(({ platform }) => ( connectors.map(({ platform }) => (