Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit a12f19e

Browse files
konstantinosG-derivKonstantinos-Gk
authored andcommitted
Konstantinos / Reusable component for number section (#4107)
* refactor: add new NumberSection component * chore: remove unused code --------- Co-authored-by: Konstantinos-Gk <[email protected]>
1 parent f699eef commit a12f19e

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import React from 'react'
2+
import { TString } from 'types/generics'
3+
import CommonHeaderSection from 'components/elements/common-header-section'
4+
5+
type NumberSectionProps = {
6+
id?: number
7+
first_title?: TString
8+
first_subtitle?: TString
9+
second_title?: TString
10+
second_subtitle?: TString
11+
third_title?: TString
12+
third_subtitle?: TString
13+
fourth_title?: TString
14+
fourth_subtitle?: TString
15+
flex?: 'columns' | 'rows'
16+
rows?: number
17+
columns?: number
18+
gap?: string
19+
}
20+
21+
const NumberSection = ({
22+
first_title,
23+
first_subtitle,
24+
second_title,
25+
second_subtitle,
26+
third_title,
27+
third_subtitle,
28+
fourth_title,
29+
fourth_subtitle,
30+
flex,
31+
rows,
32+
columns,
33+
gap,
34+
}: NumberSectionProps) => {
35+
const flexDirection = flex === 'columns' ? 'column' : 'row'
36+
const items = [
37+
{
38+
title: first_title,
39+
subtitle: first_subtitle,
40+
},
41+
{
42+
title: second_title,
43+
subtitle: second_subtitle,
44+
},
45+
{
46+
title: third_title,
47+
subtitle: third_subtitle,
48+
},
49+
{
50+
title: fourth_title,
51+
subtitle: fourth_subtitle,
52+
},
53+
]
54+
const styles = {
55+
container: {
56+
display: 'grid',
57+
flexDirection: flexDirection,
58+
flexWrap: 'wrap',
59+
gridTemplateRows: `repeat(${rows}, 1fr)`,
60+
gridTemplateColumns: `repeat(${columns}, 1fr)`,
61+
gap: gap,
62+
},
63+
}
64+
65+
return (
66+
<div style={styles.container as React.CSSProperties}>
67+
{items.map((item) => (
68+
<div key={item.title}>
69+
<CommonHeaderSection
70+
title={item.title}
71+
subtitle={item.subtitle}
72+
title_font_size="48px"
73+
subtitle_font_size="20px"
74+
bgcolor="white"
75+
margin="1.5rem 0 0 0"
76+
/>
77+
</div>
78+
))}
79+
</div>
80+
)
81+
}
82+
83+
export default NumberSection

src/pages/dmt5/_numbers.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Localize } from 'components/localization'
66
import device from 'themes/device'
77
import useRegion from 'components/hooks/use-region'
88

9+
// TO-DO (REBRANDING) Replace this component with NumberSection.
910
type NumbersContentType = {
1011
title: React.ReactElement
1112
subtitle: React.ReactElement

0 commit comments

Comments
 (0)