-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEN-1844]: refactor "status" component (#1900)
This pull request includes several changes to the `frontend/webapp` components, mainly focusing on refactoring the `Status` component and its usage across different files. The changes also include adding new components `ActiveStatus` and `ConnectionStatus` to replace the existing `Status` component in various parts of the codebase. Refactoring and component updates: * [`frontend/webapp/components/main/header/index.tsx`](diffhunk://#diff-2c96f91ec30d2116981a9c0a562820ff9fd87c8292cb5dca11a45d6fb2ac6c04L6-R6): Replaced `Status` with `ConnectionStatus` for displaying connection status. [[1]](diffhunk://#diff-2c96f91ec30d2116981a9c0a562820ff9fd87c8292cb5dca11a45d6fb2ac6c04L6-R6) [[2]](diffhunk://#diff-2c96f91ec30d2116981a9c0a562820ff9fd87c8292cb5dca11a45d6fb2ac6c04L43-R43) * [`frontend/webapp/reuseable-components/data-card/data-card-fields/index.tsx`](diffhunk://#diff-ce146776b402d3e7c41f2ebb82b32a2b8636ec73200d70a6f30f0f08dc1da6d0L3-R3): Replaced `Status` with `ActiveStatus` for displaying active status and updated `MonitorsIcons` to support labels. [[1]](diffhunk://#diff-ce146776b402d3e7c41f2ebb82b32a2b8636ec73200d70a6f30f0f08dc1da6d0L3-R3) [[2]](diffhunk://#diff-ce146776b402d3e7c41f2ebb82b32a2b8636ec73200d70a6f30f0f08dc1da6d0L77-R80) * [`frontend/webapp/reuseable-components/data-tab/index.tsx`](diffhunk://#diff-afbf1606ee29d25bd9273d63b66a4746dbdd1cd8406ad651cfd123ac28f72006L5-R5): Replaced `Status` with `ActiveStatus` for displaying active status. [[1]](diffhunk://#diff-afbf1606ee29d25bd9273d63b66a4746dbdd1cd8406ad651cfd123ac28f72006L5-R5) [[2]](diffhunk://#diff-afbf1606ee29d25bd9273d63b66a4746dbdd1cd8406ad651cfd123ac28f72006L92-R92) * [`frontend/webapp/reuseable-components/status/index.tsx`](diffhunk://#diff-8828fa39eed82424bd382e5bd240ee5efc607723527e6dc649d92a3d0c32aed3L3-L100): Refactored the `Status` component to support new props and styles, and added exports for `ActiveStatus` and `ConnectionStatus`. * [`frontend/webapp/reuseable-components/status/active-status/index.tsx`](diffhunk://#diff-9485e5934f1643bf9cae8c13ff4ea216eb2e1767bb7ccdb7ed6b6ac3a41d8efeR1-R8): Added new `ActiveStatus` component to encapsulate the active status display logic. * [`frontend/webapp/reuseable-components/status/connection-status/index.tsx`](diffhunk://#diff-11d70e0e626f4e9e67f4ca7da05f0bba5a6b28cd20f0fd793daefcc719a7e61fR1-R8): Added new `ConnectionStatus` component to encapsulate the connection status display logic. * [`frontend/webapp/reuseable-components/status/instrument-status/index.tsx`](diffhunk://#diff-f9c075bcca116adc3ebceca4be3815854c4caefa7f7416907232cc09138275efL2-R18): Refactored `InstrumentStatus` to use the updated `Status` component for displaying instrumentation status. Overall, these changes aim to improve the consistency and maintainability of the status display components across the application.
- Loading branch information
1 parent
437271f
commit cf9e48f
Showing
14 changed files
with
119 additions
and
128 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
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
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
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
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
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
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,29 +1,29 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { hexPercentValues } from '@/styles'; | ||
import type { NotificationType } from '@/types'; | ||
|
||
interface Props { | ||
orientation?: 'horizontal' | 'vertical'; | ||
type?: NotificationType; // this is to apply coloring to the divider | ||
thickness?: number; | ||
length?: string; | ||
color?: string; | ||
margin?: string; | ||
} | ||
|
||
const StyledDivider = styled.div<{ | ||
$orientation?: Props['orientation']; | ||
$type?: Props['type']; | ||
$thickness?: Props['thickness']; | ||
$length?: Props['length']; | ||
$color?: Props['color']; | ||
$margin?: Props['margin']; | ||
}>` | ||
width: ${({ $orientation, $thickness, $length }) => ($orientation === 'vertical' ? `${$thickness}px` : $length || '100%')}; | ||
height: ${({ $orientation, $thickness, $length }) => ($orientation === 'horizontal' ? `${$thickness}px` : $length || '100%')}; | ||
margin: ${({ $orientation, $margin }) => $margin || ($orientation === 'horizontal' ? '8px 0' : '0 8px')}; | ||
background-color: ${({ $color, theme }) => $color || theme.colors.border}; | ||
background-color: ${({ $type, theme }) => (!!$type ? theme.text[$type] : theme.colors.border) + hexPercentValues['050']}; | ||
`; | ||
|
||
const Divider: React.FC<Props> = ({ orientation = 'horizontal', thickness = 1, length, color, margin }) => { | ||
return <StyledDivider $orientation={orientation} $thickness={thickness} $length={length} $color={color} $margin={margin} />; | ||
export const Divider: React.FC<Props> = ({ orientation = 'horizontal', type, thickness = 1, length, margin }) => { | ||
return <StyledDivider $orientation={orientation} $type={type} $thickness={thickness} $length={length} $margin={margin} />; | ||
}; | ||
|
||
export { Divider }; |
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
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
8 changes: 8 additions & 0 deletions
8
frontend/webapp/reuseable-components/status/active-status/index.tsx
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import { Status, type StatusProps } from '@/reuseable-components'; | ||
|
||
interface Props extends StatusProps {} | ||
|
||
export const ActiveStatus: React.FC<Props> = ({ isActive, ...props }) => { | ||
return <Status title={isActive ? 'Active' : 'Inactive'} isActive={isActive} {...props} />; | ||
}; |
8 changes: 8 additions & 0 deletions
8
frontend/webapp/reuseable-components/status/connection-status/index.tsx
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import { Status, type StatusProps } from '@/reuseable-components'; | ||
|
||
interface Props extends StatusProps {} | ||
|
||
export const ConnectionStatus: React.FC<Props> = ({ ...props }) => { | ||
return <Status size={14} family='primary' withIcon withBackground {...props} />; | ||
}; |
Oops, something went wrong.