Skip to content

Commit c5d4edc

Browse files
authored
Merge pull request #42 from 1Byte-Software/develop
Update version 1.8.0
2 parents 9f37c86 + b47672f commit c5d4edc

File tree

28 files changed

+440
-38
lines changed

28 files changed

+440
-38
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.8.0]
9+
10+
### Added
11+
12+
- Added chart to `SummaryCard` component.
13+
- Added `Statistic` component.
14+
- Added `Grid.useBreakpoint()` hooks.
15+
- Added `sidebarMode` for sidebarProps for `DashboardTemplate`.
16+
- Support responsive for `DashboardTemplate`.
17+
- Added `LineChart` component.
18+
819
## [1.7.0]
920

1021
### Added

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "1byte-react-design",
3-
"version": "1.7.1",
3+
"version": "1.8.0",
44
"description": "A simple React UI library",
55
"main": "dist/index.js",
66
"module": "dist/index.js",

src/molecules/Grid/Grid.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { RdGridComponent } from './types';
2+
import { useBreakpoint } from './useBreakpoint';
3+
4+
export const Grid: RdGridComponent = {
5+
useBreakpoint: useBreakpoint,
6+
};

src/molecules/Grid/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './Col';
2+
export * from './Grid';
23
export * from './Row';
34
export * from './types';

src/molecules/Grid/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Col, GetProps, Row } from 'antd';
1+
import { Col, GetProps, Grid, Row } from 'antd';
22
import { ComponentToken as GridComponentTokenAntd } from 'antd/es/grid/style';
33

44
//#region Define Ant Design types
55
type ColPropsAntd = GetProps<typeof Col>;
66
type RowPropsAntd = GetProps<typeof Row>;
7+
type GridPropsAntd = GetProps<typeof Grid>;
78
//#endregion
89

910
//#region Define extended component tokens
@@ -13,11 +14,13 @@ type GridComponentTokenExtend = {};
1314
//#region Define extended types
1415
type ColPropsExtend = {};
1516
type RowPropsExtend = {};
17+
type GridPropsExtend = {};
1618
//#endregion
1719

1820
//#region Export types
1921
export type RdColProps = ColPropsAntd & ColPropsExtend;
2022
export type RdRowProps = RowPropsAntd & RowPropsExtend;
23+
export type RdGridProps = GridPropsAntd & GridPropsExtend;
2124

2225
export type RdGridComponentToken = GridComponentTokenAntd & GridComponentTokenExtend;
2326
//#endregion
@@ -29,4 +32,5 @@ export type RdColComponent = React.ForwardRefExoticComponent<
2932
export type RdRowComponent = React.ForwardRefExoticComponent<
3033
RdRowProps & React.RefAttributes<HTMLDivElement>
3134
>;
35+
export type RdGridComponent = RdGridProps;
3236
//#endregion
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { Grid } from 'antd';
2+
3+
export const useBreakpoint = Grid.useBreakpoint;

src/molecules/LineChart/index.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { LineConfig } from '@ant-design/plots';
2+
import { formatDate } from '../../utils/datetime';
3+
import { Empty } from '../Empty';
4+
import { LineChartWrapper } from './styles';
5+
import { LineChartProps } from './types';
6+
7+
export const LineChart: React.FC<LineChartProps> = props => {
8+
const { data, valueLabel = 'value' } = props;
9+
10+
if (!data?.length) return <Empty />;
11+
12+
const lineProps: LineConfig = {
13+
data,
14+
xField: 'date' as keyof LineChartProps['data'][0],
15+
yField: 'value' as keyof LineChartProps['data'][0],
16+
point: {
17+
shapeField: 'square',
18+
sizeField: 4,
19+
},
20+
interaction: {
21+
tooltip: {
22+
marker: false,
23+
},
24+
},
25+
style: {
26+
lineWidth: 2,
27+
},
28+
tooltip: {
29+
title: ({ date }) => {
30+
return formatDate(date);
31+
},
32+
items: [
33+
{
34+
channel: 'y',
35+
name: valueLabel,
36+
},
37+
],
38+
},
39+
};
40+
41+
return <LineChartWrapper {...lineProps} />;
42+
};

src/molecules/LineChart/styles.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Line } from '@ant-design/plots';
2+
import styled from '@emotion/styled'
3+
4+
export const LineChartWrapper = styled(Line)``;

src/molecules/LineChart/types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Line } from '@ant-design/plots/es/core/plots/line';
2+
import { GetProps } from 'antd';
3+
4+
export interface LineDataItem {
5+
date: Date | string;
6+
value: number;
7+
}
8+
9+
type LineChartPropsAntd = GetProps<Line>;
10+
11+
export interface LineChartProps extends Partial<LineChartPropsAntd> {
12+
data: LineDataItem[];
13+
valueLabel?: string;
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { forwardRef } from 'react';
2+
import { StatisticStyled } from './styles';
3+
import { Timer } from './Timer';
4+
import { RdStatisticComponent, RdStatisticCompoundedComponent } from './types';
5+
6+
export const InternalStatistic: RdStatisticComponent = forwardRef((props, ref) => {
7+
return <StatisticStyled {...props} ref={ref} />;
8+
});
9+
10+
export const Statistic: RdStatisticCompoundedComponent =
11+
InternalStatistic as RdStatisticCompoundedComponent;
12+
13+
Statistic.Timer = Timer;

0 commit comments

Comments
 (0)