Skip to content

Commit a9f71e9

Browse files
committed
fix: Styles
1 parent 8590988 commit a9f71e9

File tree

8 files changed

+95
-61
lines changed

8 files changed

+95
-61
lines changed

lib/cjs/styles/main.js

Lines changed: 24 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/esm/styles/main.js

Lines changed: 24 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/timeline/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { PropsWithChildren } from 'react';
22
import { ThemeProvider } from 'styled-components';
3-
import { DateFormat, defaultValues, Theme } from '../../config';
3+
import { defaultValues } from '../../config';
44
import { ConfigContext } from '../../context/config.context';
5+
import { DateFormat, Theme } from '../../interfaces';
56
import { TimelineWrapper, TimelineWrapperInner } from '../../styles/main';
67

78
interface TimelineProps {

src/config/index.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
export interface Theme {
2-
yearColor: string;
3-
lineColor: string;
4-
dotColor: string;
5-
borderDotColor: string;
6-
titleColor: string;
7-
subtitleColor: string;
8-
textColor: string;
9-
}
10-
11-
export type DateFormat = 'only-number' | 'short' | 'with-weekday' | 'full';
12-
13-
export interface DefaultValues {
14-
theme?: Theme;
15-
lang: string;
16-
dateFormat: DateFormat;
17-
}
1+
import { DefaultValues } from '../interfaces';
182

193
export const defaultValues: DefaultValues = {
204
theme: {

src/context/config.context.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createContext } from 'react';
2-
import { DefaultValues, defaultValues } from '../config';
2+
import { defaultValues } from '../config';
3+
import { DefaultValues } from '../interfaces';
34

45
export const ConfigContext = createContext<DefaultValues>(defaultValues);

src/helpers/transform-date.helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DateFormat } from '../config/index';
1+
import { DateFormat } from '../interfaces';
22

33
interface ITransformDate {
44
date: string;

src/interfaces/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export interface Theme {
2+
yearColor: string;
3+
lineColor: string;
4+
dotColor: string;
5+
borderDotColor: string;
6+
titleColor: string;
7+
subtitleColor: string;
8+
textColor: string;
9+
}
10+
11+
export type DateFormat = 'only-number' | 'short' | 'with-weekday' | 'full';
12+
13+
export interface DefaultValues {
14+
theme?: Theme;
15+
lang: string;
16+
dateFormat: DateFormat;
17+
}

src/styles/main.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import styled from 'styled-components';
2-
import { DateFormat } from '../config';
2+
import { DateFormat } from '../interfaces';
33

4-
// Timeline Component
54
export const TimelineWrapper = styled.div`
65
display: flex;
76
height: 100%;
@@ -14,7 +13,6 @@ export const TimelineWrapperInner = styled.div`
1413
width: 100%;
1514
`;
1615

17-
// Container component
1816
export const ContainerWrapper = styled.section`
1917
align-items: baseline;
2018
display: flex;
@@ -27,24 +25,37 @@ interface YearContentProps {
2725
readonly format: DateFormat;
2826
}
2927

30-
// YearContent component
28+
const minWidth = () => ({
29+
'only-number_es': '85',
30+
'only-number_en': '85',
31+
'only-number_de': '85',
32+
'only-number_zh': '85',
33+
short_es: '85',
34+
short_en: '90',
35+
short_de: '95',
36+
short_zh: '115',
37+
'with-weekday_es': '125',
38+
'with-weekday_en': '125',
39+
'with-weekday_de': '120',
40+
'with-weekday_zh': '120',
41+
full_es: '135',
42+
full_en: '135',
43+
full_de: '135',
44+
full_zh: '135',
45+
});
46+
3147
export const YearWrapper = styled.p<YearContentProps>`
3248
align-items: flex-end;
33-
color: ${(props) => props.theme.yearColor};
49+
color: ${({ theme }) => theme.yearColor};
3450
display: flex;
3551
flex-direction: column;
3652
font-size: 14px;
3753
font-weight: 400;
3854
height: max-content;
3955
margin: 0;
40-
min-width: ${(props) =>
41-
props.format === 'only-number'
42-
? '85px'
43-
: props.format === 'short'
44-
? '85px'
45-
: props.format === 'with-weekday'
46-
? '125px'
47-
: '230px'};
56+
max-width: 35%;
57+
min-width: ${({ format, lang }) => `${minWidth()[`${format}_${lang}`]}px`};
58+
text-align: end;
4859
`;
4960

5061
export const YearSpan = styled.span`
@@ -53,7 +64,6 @@ export const YearSpan = styled.span`
5364
padding: 0;
5465
`;
5566

56-
// Section component
5767
export const BodyWrapper = styled.article`
5868
padding-bottom: 20px;
5969
padding-left: 25px;
@@ -115,7 +125,6 @@ export const BodyInner = styled.ul`
115125
}
116126
`;
117127

118-
// Description component
119128
export const Subtitle = styled.div`
120129
color: ${(props) => props.theme.subtitleColor};
121130
font-size: 14px;

0 commit comments

Comments
 (0)