mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-11 03:28:59 +08:00
feat(FE): shared styled for custom styled components
This commit is contained in:
parent
b8a6a27fad
commit
314f95a914
@ -7,8 +7,8 @@
|
|||||||
"dev": "cross-env NODE_ENV=development webpack serve --progress",
|
"dev": "cross-env NODE_ENV=development webpack serve --progress",
|
||||||
"build": "webpack --config=webpack.config.prod.js --progress",
|
"build": "webpack --config=webpack.config.prod.js --progress",
|
||||||
"prettify": "prettier --write .",
|
"prettify": "prettier --write .",
|
||||||
"lint": "eslint . --debug",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix --debug",
|
"lint:fix": "eslint . --fix",
|
||||||
"cypress:open": "cypress open",
|
"cypress:open": "cypress open",
|
||||||
"cypress:run": "cypress run",
|
"cypress:run": "cypress run",
|
||||||
"jest": "jest",
|
"jest": "jest",
|
||||||
|
32
frontend/src/components/Styled/index.ts
Normal file
32
frontend/src/components/Styled/index.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { Col, ColProps, Row, RowProps } from 'antd';
|
||||||
|
import React from 'react';
|
||||||
|
import styled, {
|
||||||
|
css,
|
||||||
|
DefaultTheme,
|
||||||
|
FlattenSimpleInterpolation,
|
||||||
|
ThemedCssFunction,
|
||||||
|
} from 'styled-components';
|
||||||
|
|
||||||
|
import { IStyledClass } from './types';
|
||||||
|
|
||||||
|
const styledClass = (props: IStyledClass): FlattenSimpleInterpolation =>
|
||||||
|
props.styledClass;
|
||||||
|
|
||||||
|
interface IStyledCol extends ColProps, IStyledClass {}
|
||||||
|
const StyledCol = styled(Col)<IStyledCol>`
|
||||||
|
${styledClass}
|
||||||
|
`;
|
||||||
|
|
||||||
|
interface IStyledRow extends RowProps, IStyledClass {}
|
||||||
|
const StyledRow = styled(Row)<IStyledRow>`
|
||||||
|
${styledClass}
|
||||||
|
`;
|
||||||
|
|
||||||
|
interface IStyledDiv
|
||||||
|
extends React.HTMLAttributes<HTMLDivElement>,
|
||||||
|
IStyledClass {}
|
||||||
|
const StyledDiv = styled.div<IStyledDiv>`
|
||||||
|
${styledClass}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export { StyledCol, StyledDiv, StyledRow };
|
41
frontend/src/components/Styled/styles.ts
Normal file
41
frontend/src/components/Styled/styles.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { css, FlattenSimpleInterpolation } from 'styled-components';
|
||||||
|
|
||||||
|
const cssProprty = (key: string, value: any): FlattenSimpleInterpolation =>
|
||||||
|
key &&
|
||||||
|
value &&
|
||||||
|
css`
|
||||||
|
${key}: ${value};
|
||||||
|
`;
|
||||||
|
|
||||||
|
interface IFlexProps {
|
||||||
|
flexDirection?: string; // Need to replace this with exact css props. Not able to find any :(
|
||||||
|
flex?: number | string;
|
||||||
|
}
|
||||||
|
export const Flex = ({
|
||||||
|
flexDirection,
|
||||||
|
flex,
|
||||||
|
}: IFlexProps): FlattenSimpleInterpolation => css`
|
||||||
|
${cssProprty('flex-direction', flexDirection)}
|
||||||
|
${cssProprty('flex', flex)}
|
||||||
|
`;
|
||||||
|
|
||||||
|
interface IDisplayProps {
|
||||||
|
display?: string;
|
||||||
|
}
|
||||||
|
export const Display = ({
|
||||||
|
display,
|
||||||
|
}: IDisplayProps): FlattenSimpleInterpolation => css`
|
||||||
|
${cssProprty('display', display)}
|
||||||
|
`;
|
||||||
|
|
||||||
|
interface ISpacingProps {
|
||||||
|
margin?: string;
|
||||||
|
padding?: string;
|
||||||
|
}
|
||||||
|
export const Spacing = ({
|
||||||
|
margin,
|
||||||
|
padding,
|
||||||
|
}: ISpacingProps): FlattenSimpleInterpolation => css`
|
||||||
|
${cssProprty('margin', margin)}
|
||||||
|
${cssProprty('padding', padding)}
|
||||||
|
`;
|
5
frontend/src/components/Styled/types.ts
Normal file
5
frontend/src/components/Styled/types.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { FlattenSimpleInterpolation } from 'styled-components';
|
||||||
|
|
||||||
|
export interface IStyledClass {
|
||||||
|
styledClass: FlattenSimpleInterpolation[];
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
.trace-detail-content-spacing {
|
|
||||||
margin-right: 1rem;
|
|
||||||
}
|
|
@ -1,21 +1,24 @@
|
|||||||
import React, { useEffect, useMemo, useState } from 'react';
|
|
||||||
import { Col, Divider, Row, Typography, Space, Button } from 'antd';
|
|
||||||
import { FilterOutlined } from '@ant-design/icons';
|
import { FilterOutlined } from '@ant-design/icons';
|
||||||
|
import { Button, Col, Divider, Row, Space, Typography } from 'antd';
|
||||||
|
import { StyledCol, StyledDiv, StyledRow } from 'components/Styled';
|
||||||
|
import * as StyledStyles from 'components/Styled/styles';
|
||||||
import GanttChart from 'container/GantChart';
|
import GanttChart from 'container/GantChart';
|
||||||
import { getNodeById } from 'container/GantChart/utils';
|
import { getNodeById } from 'container/GantChart/utils';
|
||||||
import Timeline from 'container/Timeline';
|
import Timeline from 'container/Timeline';
|
||||||
import TraceFlameGraph from 'container/TraceFlameGraph';
|
import TraceFlameGraph from 'container/TraceFlameGraph';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import useUrlQuery from 'hooks/useUrlQuery';
|
||||||
import { spanServiceNameToColorMapping } from 'lib/getRandomColor';
|
import { spanServiceNameToColorMapping } from 'lib/getRandomColor';
|
||||||
import { getSortedData } from './utils';
|
import history from 'lib/history';
|
||||||
|
import { SPAN_DETAILS_LEFT_COL_WIDTH } from 'pages/TraceDetail/constants';
|
||||||
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
import { ITraceTree, PayloadProps } from 'types/api/trace/getTraceItem';
|
import { ITraceTree, PayloadProps } from 'types/api/trace/getTraceItem';
|
||||||
import { getSpanTreeMetadata } from 'utils/getSpanTreeMetadata';
|
import { getSpanTreeMetadata } from 'utils/getSpanTreeMetadata';
|
||||||
import { spanToTreeUtil } from 'utils/spanToTree';
|
import { spanToTreeUtil } from 'utils/spanToTree';
|
||||||
|
|
||||||
import SelectedSpanDetails from './SelectedSpanDetails';
|
import SelectedSpanDetails from './SelectedSpanDetails';
|
||||||
import useUrlQuery from 'hooks/useUrlQuery';
|
import * as styles from './styles';
|
||||||
import styles from './TraceGraph.module.css';
|
import { getSortedData } from './utils';
|
||||||
import history from 'lib/history';
|
|
||||||
import { SPAN_DETAILS_LEFT_COL_WIDTH } from 'pages/TraceDetail/constants';
|
|
||||||
import { INTERVAL_UNITS } from './utils';
|
import { INTERVAL_UNITS } from './utils';
|
||||||
|
|
||||||
const TraceDetail = ({ response }: TraceDetailProps): JSX.Element => {
|
const TraceDetail = ({ response }: TraceDetailProps): JSX.Element => {
|
||||||
@ -73,9 +76,21 @@ const TraceDetail = ({ response }: TraceDetailProps): JSX.Element => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row style={{ flex: 1 }}>
|
<StyledRow styledClass={[StyledStyles.Flex({ flex: 1 })]}>
|
||||||
<Col flex={'auto'} style={{ display: 'flex', flexDirection: 'column' }}>
|
<StyledCol
|
||||||
<Row className={styles['trace-detail-content-spacing']}>
|
flex={'auto'}
|
||||||
|
styledClass={[
|
||||||
|
StyledStyles.Flex({ flexDirection: 'column' }),
|
||||||
|
StyledStyles.Display({ display: 'flex' }),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<StyledRow
|
||||||
|
styledClass={[
|
||||||
|
StyledStyles.Spacing({
|
||||||
|
margin: '0 1rem 0 0',
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
<Col
|
<Col
|
||||||
flex={`${SPAN_DETAILS_LEFT_COL_WIDTH}px`}
|
flex={`${SPAN_DETAILS_LEFT_COL_WIDTH}px`}
|
||||||
style={{ alignItems: 'center', display: 'flex', flexDirection: 'column' }}
|
style={{ alignItems: 'center', display: 'flex', flexDirection: 'column' }}
|
||||||
@ -98,7 +113,7 @@ const TraceDetail = ({ response }: TraceDetailProps): JSX.Element => {
|
|||||||
intervalUnit={intervalUnit}
|
intervalUnit={intervalUnit}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</StyledRow>
|
||||||
<Row style={{ marginTop: '2rem' }}>
|
<Row style={{ marginTop: '2rem' }}>
|
||||||
<Col
|
<Col
|
||||||
flex={`${SPAN_DETAILS_LEFT_COL_WIDTH}px`}
|
flex={`${SPAN_DETAILS_LEFT_COL_WIDTH}px`}
|
||||||
@ -110,10 +125,14 @@ const TraceDetail = ({ response }: TraceDetailProps): JSX.Element => {
|
|||||||
>
|
>
|
||||||
{dayjs(traceMetaData.globalStart / 1e6).format('hh:mm:ssa MM/DD')}
|
{dayjs(traceMetaData.globalStart / 1e6).format('hh:mm:ssa MM/DD')}
|
||||||
</Col>
|
</Col>
|
||||||
<Col
|
<StyledCol
|
||||||
flex="auto"
|
flex="auto"
|
||||||
style={{ overflow: 'visible' }}
|
style={{ overflow: 'visible' }}
|
||||||
className={styles['trace-detail-content-spacing']}
|
styledClass={[
|
||||||
|
StyledStyles.Spacing({
|
||||||
|
margin: '0 1rem 0 0',
|
||||||
|
}),
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Timeline
|
<Timeline
|
||||||
globalTraceMetadata={globalTraceMetadata}
|
globalTraceMetadata={globalTraceMetadata}
|
||||||
@ -121,12 +140,16 @@ const TraceDetail = ({ response }: TraceDetailProps): JSX.Element => {
|
|||||||
intervalUnit={intervalUnit}
|
intervalUnit={intervalUnit}
|
||||||
setIntervalUnit={setIntervalUnit}
|
setIntervalUnit={setIntervalUnit}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</StyledCol>
|
||||||
<Divider style={{ height: '100%', margin: '0' }} />
|
<Divider style={{ height: '100%', margin: '0' }} />
|
||||||
</Row>
|
</Row>
|
||||||
<Row
|
<StyledRow
|
||||||
className={styles['trace-detail-content-spacing']}
|
styledClass={[
|
||||||
style={{ margin: '1.5rem 1rem 0.5rem' }}
|
styles.traceDetailContentSpacing,
|
||||||
|
StyledStyles.Spacing({
|
||||||
|
margin: '1.5rem 1rem 0.5rem',
|
||||||
|
}),
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Col flex={`${SPAN_DETAILS_LEFT_COL_WIDTH}px`}>
|
<Col flex={`${SPAN_DETAILS_LEFT_COL_WIDTH}px`}>
|
||||||
{/* <Search
|
{/* <Search
|
||||||
@ -150,12 +173,21 @@ const TraceDetail = ({ response }: TraceDetailProps): JSX.Element => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</StyledRow>
|
||||||
<div
|
<StyledDiv
|
||||||
className={styles['trace-detail-content-spacing']}
|
styledClass={[
|
||||||
|
styles.traceDetailContentSpacing,
|
||||||
|
StyledStyles.Spacing({
|
||||||
|
margin: '1.5rem 1rem 0.5rem',
|
||||||
|
}),
|
||||||
|
StyledStyles.Flex({
|
||||||
|
flexDirection: 'column',
|
||||||
|
}),
|
||||||
|
StyledStyles.Display({
|
||||||
|
display: 'flex',
|
||||||
|
}),
|
||||||
|
]}
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
overflowY: 'auto',
|
overflowY: 'auto',
|
||||||
@ -172,8 +204,8 @@ const TraceDetail = ({ response }: TraceDetailProps): JSX.Element => {
|
|||||||
spanId={spanId || ''}
|
spanId={spanId || ''}
|
||||||
intervalUnit={intervalUnit}
|
intervalUnit={intervalUnit}
|
||||||
/>
|
/>
|
||||||
</div>
|
</StyledDiv>
|
||||||
</Col>
|
</StyledCol>
|
||||||
<Col>
|
<Col>
|
||||||
<Divider style={{ height: '100%', margin: '0' }} type="vertical" />
|
<Divider style={{ height: '100%', margin: '0' }} type="vertical" />
|
||||||
</Col>
|
</Col>
|
||||||
@ -189,7 +221,7 @@ const TraceDetail = ({ response }: TraceDetailProps): JSX.Element => {
|
|||||||
>
|
>
|
||||||
<SelectedSpanDetails tree={getSelectedNode} />
|
<SelectedSpanDetails tree={getSelectedNode} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</StyledRow>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
5
frontend/src/container/TraceDetail/styles.ts
Normal file
5
frontend/src/container/TraceDetail/styles.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import * as StyledStyles from 'components/Styled/styles';
|
||||||
|
|
||||||
|
export const traceDetailContentSpacing = StyledStyles.Spacing({
|
||||||
|
margin: '0 1rem 0 0',
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user