Skip to content

Commit

Permalink
update connect icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Bulat committed Mar 6, 2024
1 parent 1ac9632 commit 2b633bb
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 29 deletions.
16 changes: 16 additions & 0 deletions src/library/Tabs/ConectionIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2024 @rossbulat/console authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import type { ApiStatus } from 'model/Api/types';
import DisconnectSVG from 'svg/Disconnect.svg?react';
import ConnectSVG from 'svg/Connect.svg?react';

export const ConnectionIcon = ({ status }: { status: ApiStatus }) => (
<div className={`connection ${status}`}>
{['ready', 'connected', 'connecting'].includes(status) ? (
<ConnectSVG />
) : (
<DisconnectSVG />
)}
</div>
);
14 changes: 3 additions & 11 deletions src/library/Tabs/Tab.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2024 @rossbulat/console authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable react/display-name */

import { useRef, useState } from 'react';
import { TabWrapper } from './Wrappers';
Expand All @@ -17,9 +16,8 @@ import {
DEFAULT_TAB_WIDTH_PX,
TAB_TRANSITION_DURATION_MS,
} from 'contexts/Tabs/defaults';
import DisconnectSVG from 'svg/Disconnect.svg?react';
import ConnectSVG from 'svg/Connect.svg?react';
import { useApi } from 'contexts/Api';
import { ConnectionIcon } from './ConectionIcon';

export const Tab = ({ index, id, name, initial = false }: TabProps) => {
const {
Expand Down Expand Up @@ -137,14 +135,8 @@ export const Tab = ({ index, id, name, initial = false }: TabProps) => {
{...attributes}
{...listeners}
/>
<div className={`connection`}>
{['ready', 'connected', 'connecting'].includes(apiStatus) ? (
<ConnectSVG />
) : (
<DisconnectSVG />
)}
</div>
<div className="name">{name}</div>
<ConnectionIcon status={apiStatus} />
<div className={`name ${apiStatus}`}>{name}</div>
<div className="fade" />

{tabs.length > 1 && (
Expand Down
36 changes: 20 additions & 16 deletions src/library/Tabs/TabOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faClose } from '@fortawesome/free-solid-svg-icons';
import type { TabProps } from './types';
import { DEFAULT_TAB_WIDTH_PX } from 'contexts/Tabs/defaults';
import DisconnectSVG from 'svg/Disconnect.svg?react';
import { useApi } from 'contexts/Api';
import { ConnectionIcon } from './ConectionIcon';

export const TabOverlay = ({ name }: TabProps) => (
<TabWrapper
className={`active hide-border`}
style={{ width: DEFAULT_TAB_WIDTH_PX }}
>
<div className="fade" />
<div className="connection">
<DisconnectSVG />
</div>
<div className="name">{name}</div>
export const TabOverlay = ({ id, name }: TabProps) => {
const { getApiStatus } = useApi();
const apiStatus = getApiStatus(id);

<button className="close">
<FontAwesomeIcon icon={faClose} transform="shrink-1" />
</button>
</TabWrapper>
);
return (
<TabWrapper
className={`active hide-border`}
style={{ width: DEFAULT_TAB_WIDTH_PX }}
>
<div className="fade" />
<ConnectionIcon status={apiStatus} />
<div className="name">{name}</div>

<button className="close">
<FontAwesomeIcon icon={faClose} transform="shrink-1" />
</button>
</TabWrapper>
);
};
9 changes: 8 additions & 1 deletion src/library/Tabs/Wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ export const TabWrapper = styled(motion.div)`
display: flex;
align-items: center;
&.connected,
&.ready {
> svg {
fill: var(--accent-color-secondary);
}
}
> svg {
width: var(--connection-icon-size);
height: var(--connection-icon-size);
Expand All @@ -120,7 +127,7 @@ export const TabWrapper = styled(motion.div)`
top: 0;
left: 0;
width: 100%;
padding: 0 0.75rem 0 1.5rem;
padding: 0 0.75rem 0 1.6rem;
display: flex;
align-items: center;
/* Handle text overflow */
Expand Down
2 changes: 1 addition & 1 deletion src/svg/Connect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2b633bb

Please sign in to comment.