diff --git a/frontend/webapp/components/common/card-details/index.tsx b/frontend/webapp/components/common/card-details/index.tsx index e7654b42d..752e3bca0 100644 --- a/frontend/webapp/components/common/card-details/index.tsx +++ b/frontend/webapp/components/common/card-details/index.tsx @@ -1,8 +1,9 @@ import React from 'react'; import styled from 'styled-components'; -import { ConfiguredFields } from '@/components'; import { Text } from '@/reuseable-components'; -interface CardDetailsProps { +import { ConfiguredFields } from '@/components'; + +interface Props { title?: string; data: { title: string; @@ -11,19 +12,6 @@ interface CardDetailsProps { }[]; } -const CardDetails: React.FC = ({ data, title = 'Details' }) => { - return ( - - - {title} - - - - ); -}; - -export { CardDetails }; - const Container = styled.div` display: flex; flex-direction: column; @@ -37,3 +25,14 @@ const Container = styled.div` `; const TitleWrapper = styled.div``; + +export const CardDetails: React.FC = ({ title = 'Details', data }) => { + return ( + + + {title} + + + + ); +}; diff --git a/frontend/webapp/components/common/configured-fields/index.tsx b/frontend/webapp/components/common/configured-fields/index.tsx index 0070c5a44..e268efc7c 100644 --- a/frontend/webapp/components/common/configured-fields/index.tsx +++ b/frontend/webapp/components/common/configured-fields/index.tsx @@ -1,17 +1,18 @@ import React, { Fragment } from 'react'; import styled from 'styled-components'; import { Text, Status, Tooltip } from '@/reuseable-components'; -import Image from 'next/image'; +import { MonitorsLegend } from '@/components/overview'; +import theme from '@/styles/theme'; -type TypeDetail = { +interface Detail { title: string; tooltip?: string; value: string; -}; +} -type ConfiguredFieldsProps = { - details: TypeDetail[]; -}; +interface Props { + details: Detail[]; +} const ListContainer = styled.div` display: flex; @@ -22,7 +23,7 @@ const ListContainer = styled.div` const ListItem = styled.div``; const ItemTitle = styled(Text)` - color: #b8b8b8; + color: ${({ theme }) => theme.text.grey}; font-size: 10px; line-height: 16px; `; @@ -33,7 +34,7 @@ const ItemValue = styled(Text)` line-height: 18px; `; -export const ConfiguredFields: React.FC = ({ details }) => { +export const ConfiguredFields: React.FC = ({ details }) => { const parseValue = (value: string) => { let str = ''; @@ -44,11 +45,8 @@ export const ConfiguredFields: React.FC = ({ details }) = if (Array.isArray(parsed)) { str = parsed .map((item) => { - if (typeof item === 'object' && item !== null) { - return `${item.key}: ${item.value}`; - } - - return item; + if (typeof item === 'object' && item !== null) return `${item.key}: ${item.value}`; + else return item; }) .join(', '); } @@ -78,6 +76,17 @@ export const ConfiguredFields: React.FC = ({ details }) = )); }; + const renderValue = (title: string, value: string) => { + switch (title) { + case 'Status': + return ; + case 'Monitors': + return ; + default: + return {parseValue(value)}; + } + }; + return ( {details.map((detail, index) => ( @@ -85,8 +94,7 @@ export const ConfiguredFields: React.FC = ({ details }) = {detail.title} - - {detail.title === 'Status' ? : {parseValue(detail.value)}} + {renderValue(detail.title, detail.value)} ))} diff --git a/frontend/webapp/components/overview/monitors-legend/index.tsx b/frontend/webapp/components/overview/monitors-legend/index.tsx index 1c4c0eee8..16989bedf 100644 --- a/frontend/webapp/components/overview/monitors-legend/index.tsx +++ b/frontend/webapp/components/overview/monitors-legend/index.tsx @@ -1,43 +1,51 @@ import React from 'react'; import Image from 'next/image'; -import theme from '@/styles/theme'; import styled from 'styled-components'; import { MONITORS_OPTIONS } from '@/utils'; import { Text } from '@/reuseable-components'; -const List = styled.div` +interface Props { + size?: number; + color?: string; + signals?: string[]; +} + +const List = styled.div<{ $size: number }>` display: flex; align-items: center; - gap: 12px; + gap: ${({ $size }) => $size}px; `; -const ListItem = styled.div` +const ListItem = styled.div<{ $size: number }>` display: flex; align-items: center; - gap: 4px; + gap: ${({ $size }) => $size / 3}px; `; -const MonitorTitle = styled(Text)` - color: ${({ theme }) => theme.text.grey}; - font-size: 12px; +const MonitorTitle = styled(Text)<{ $size: number; $color?: string }>` + color: ${({ $color, theme }) => $color || theme.text.grey}; + font-size: ${({ $size }) => $size}px; font-weight: 300; line-height: 150%; `; -const MonitorsLegend = () => { +export const MonitorsLegend: React.FC = ({ size = 12, color, signals }) => { return ( - - {MONITORS_OPTIONS.map(({ id, value }) => ( - - {value} + + {MONITORS_OPTIONS.map(({ id, value }) => { + const ok = !signals || !signals.length || signals.find((str) => str.toLowerCase() === id); + + if (!ok) return null; - - {value} - - - ))} + return ( + + {value} + + {value} + + + ); + })} ); }; - -export { MonitorsLegend };