Skip to content

Commit 92f382c

Browse files
authored
Merge pull request #37 from 1Byte-Software/feat/add-summary-card
Feat/add summary card
2 parents 7abeaa0 + 4bda8a2 commit 92f382c

File tree

6 files changed

+93
-1
lines changed

6 files changed

+93
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ 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.7.0]
9+
10+
### Added
11+
12+
- Added `SummaryCard` component.
13+
814
## [1.6.7]
915

1016
### Refactor

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.6.7",
3+
"version": "1.7.0",
44
"description": "A simple React UI library",
55
"main": "dist/index.js",
66
"module": "dist/index.js",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Typography } from '../..';
2+
import { Space } from '../../molecules';
3+
import { SummaryCardWrapper } from './styles';
4+
import { RdSummaryCardProps } from './types';
5+
6+
export const SummaryCard: React.FC<RdSummaryCardProps> = props => {
7+
const {
8+
format = 'number',
9+
value,
10+
subValue = null,
11+
label = 'Total',
12+
subLabel = null,
13+
...cardProps
14+
} = props;
15+
16+
return (
17+
<SummaryCardWrapper {...cardProps}>
18+
<Space direction="vertical" block size={0}>
19+
<Typography.Text strong type="secondary">
20+
{label}
21+
</Typography.Text>
22+
<Space align="baseline">
23+
<Typography.Title level={1} disableMargin>
24+
{value}
25+
</Typography.Title>
26+
</Space>
27+
28+
{(subLabel || subValue) && (
29+
<Space>
30+
{subLabel && (
31+
<Typography.Text strong type="secondary">
32+
{subLabel}
33+
</Typography.Text>
34+
)}
35+
{subValue && <Typography.Text strong>{subValue}</Typography.Text>}
36+
</Space>
37+
)}
38+
</Space>
39+
</SummaryCardWrapper>
40+
);
41+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import styled from '@emotion/styled';
2+
import { Card } from '../../molecules';
3+
4+
export const SummaryCardWrapper = styled(Card)``;

src/organisms/SummaryCard/types.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { ReactNode } from 'react';
2+
import { RdCardProps } from '../../molecules';
3+
4+
export interface RdSummaryCardProps extends RdCardProps {
5+
/**
6+
* Determines the display format of values.
7+
*
8+
* - `"number"` → renders plain number format.
9+
* - `"currency"` → renders values as currency.
10+
*
11+
* @default "number"
12+
*/
13+
format?: 'number' | 'currency';
14+
15+
/**
16+
* The main numeric value to display.
17+
* Usually represents the total amount or main KPI.
18+
*/
19+
value: ReactNode;
20+
21+
/**
22+
* The secondary numeric value to display.
23+
* Typically represents today's or a breakdown value.
24+
*/
25+
subValue?: ReactNode;
26+
27+
/**
28+
* Label displayed above the main value.
29+
*
30+
* @default "Total"
31+
*/
32+
label?: string;
33+
34+
/**
35+
* Label displayed next to the sub value.
36+
*
37+
* @default "Today total"
38+
*/
39+
subLabel?: string;
40+
}

src/organisms/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './App';
22
export * from './ConfigProvider';
3+
export * from './SummaryCard'

0 commit comments

Comments
 (0)