Skip to content

Commit 7eaed8e

Browse files
author
Hector Arce De Las Heras
committed
Addition of WordWrap Styles
This commit introduces WordWrap styles to the application. This change enhances the readability of text content by ensuring that long lines of text do not overflow their container, but instead wrap onto the next line.
1 parent afaf639 commit 7eaed8e

File tree

6 files changed

+46
-8
lines changed

6 files changed

+46
-8
lines changed

src/types/styles/animation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
export type AnimationType = {
22
transition?: string;
3+
transition_delay?: string;
4+
transition_duration?: string;
5+
transition_property?: string;
6+
transition_timing_function?: string;
37
};

src/types/styles/commonStyle.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { PaddingTypes } from './padding';
99
import { PointerTypes } from './pointer';
1010
import { PositionTypes } from './position';
1111
import { BoxShadowTypes } from './shadow';
12+
import { WordWrapTypes } from './wordWrap';
1213

1314
type BreakPointsStyleType = {
1415
[key in DeviceBreakpointsType]?: GenericStyleType & PseudoElementsType;
@@ -23,7 +24,8 @@ type GenericStyleType = PaddingTypes &
2324
MarginTypes &
2425
PositionTypes &
2526
PointerTypes &
26-
AnimationType;
27+
AnimationType &
28+
WordWrapTypes;
2729

2830
export type AfterOrBeforeType = { content?: string } & GenericStyleType;
2931

src/types/styles/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ export * from './icon';
2424
export * from './illustration';
2525
export * from './pointer';
2626
export * from './commonStyle';
27+
export * from './wordWrap';

src/types/styles/typography.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DeviceBreakpointsType } from '../breakpoints';
2+
import { WordWrapTypes } from './wordWrap';
23

34
/**
45
* @property font_variant variant for the Text component
@@ -17,16 +18,13 @@ type GenericDeviceTypographyType = {
1718
text_align?: string;
1819
text_decoration?: string;
1920
text_transform?: string;
20-
white_space?: string;
21-
word_break?: string;
22-
word_wrap?: string;
23-
text_overflow?: string;
2421
text_shadow?: string;
2522
text_indent?: string;
2623
text_justify?: string;
2724
color?: string;
2825
overflow?: string;
29-
} & TypographyCustomType;
26+
} & TypographyCustomType &
27+
WordWrapTypes;
3028

3129
export type TypographyTypes = GenericDeviceTypographyType & {
3230
[key in DeviceBreakpointsType]?: GenericDeviceTypographyType;

src/types/styles/wordWrap.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export type WordWrapTypes = {
2+
word_break?: string;
3+
word_wrap?: string;
4+
white_space?: string;
5+
text_overflow?: string;
6+
};

src/utils/getStyles/getStyles.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
PointerTypes,
1515
PositionTypes,
1616
TypographyTypes,
17+
WordWrapTypes,
1718
} from '@/types/styles';
1819
import { AnimationType } from '@/types/styles/animation';
1920

@@ -479,6 +480,20 @@ export const getPointerStyles = (prop?: PointerTypes): CSSProp => {
479480
`;
480481
};
481482

483+
export const getWordWrapStyles = (prop?: WordWrapTypes): CSSProp => {
484+
if (!prop) {
485+
return css``;
486+
}
487+
const { word_wrap, word_break, white_space, text_overflow } = prop;
488+
489+
return css`
490+
${word_wrap && `word-wrap: ${word_wrap};`}
491+
${word_break && `word-break: ${word_break};`}
492+
${white_space && `white-space: ${white_space};`}
493+
${text_overflow && `text-overflow: ${text_overflow};`}
494+
`;
495+
};
496+
482497
const getGenericStyles = (styles?: CommonStyleType): CSSProp => {
483498
return css`
484499
${getPaddingStyles(styles)}
@@ -490,6 +505,8 @@ const getGenericStyles = (styles?: CommonStyleType): CSSProp => {
490505
${getMarginStyles(styles)}
491506
${getPositionStyles(styles)}
492507
${getPointerStyles(styles)}
508+
${getWordWrapStyles(styles)}
509+
${getAnimationStyles(styles)}
493510
`;
494511
};
495512

@@ -560,9 +577,19 @@ export const getAnimationStyles = (prop?: AnimationType): CSSProp => {
560577
if (!prop) {
561578
return css``;
562579
}
563-
const { transition } = prop;
580+
const {
581+
transition,
582+
transition_delay,
583+
transition_duration,
584+
transition_property,
585+
transition_timing_function,
586+
} = prop;
564587

565588
return css`
566-
${transition && `display: ${transition};`}
589+
${transition && `transition: ${transition};`}
590+
${transition_delay && `transition-delay: ${transition_delay};`}
591+
${transition_duration && `transition-duration: ${transition_duration};`}
592+
${transition_property && `transition-property: ${transition_property};`}
593+
${transition_timing_function && `transition-timing-function: ${transition_timing_function};`}
567594
`;
568595
};

0 commit comments

Comments
 (0)