Skip to content

Commit 1afcaaf

Browse files
refactor(styles): add RTL support and animations for Modal, Footer, and other components
1 parent 55ddeda commit 1afcaaf

File tree

7 files changed

+88
-14
lines changed

7 files changed

+88
-14
lines changed

src/components/Dialog/dialog.module.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ $root: dialog;
2222
box-sizing: border-box;
2323
position: fixed;
2424
z-index: 9999;
25-
transition:
26-
background-color var(--transition-speed-sm),
27-
color var(--transition-speed-sm);
25+
transition: background-color var(--transition-speed-sm),
26+
transform var(--transition-speed-sm),
27+
opacity var(--transition-speed-sm),
28+
color var(--transition-speed-sm);
2829
animation-timing-function: ease-in-out;
2930
}
3031

3132
&-children {
33+
flex: 1;
3234
display: flex;
3335
flex-direction: column;
3436
width: 100%;

src/components/Footer/footer.module.scss

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,60 @@ $root: footer;
99
padding: var(--footer-padding, var(--side-padding-sm));
1010
padding-top: 0;
1111
background-color: var(--footer-bg-color, transparent);
12-
transition:
13-
background-color var(--transition-speed-sm),
14-
box-shadow var(--transition-speed-sm);
12+
transition: background-color var(--transition-speed-sm),
13+
box-shadow var(--transition-speed-sm);
14+
15+
[dir="rtl"] & {
16+
flex-direction: row-reverse;
17+
}
1518

1619
&--shadow {
1720
box-shadow: var(--footer-box-shadow, 0px -4px 4px 0px rgba(0, 0, 0, 0.03));
1821
}
1922

2023
&--reverse {
2124
flex-direction: row-reverse;
25+
26+
[dir="rtl"] & {
27+
flex-direction: row;
28+
}
2229
}
2330

2431
&-children {
2532
width: 100%;
2633
display: flex;
2734
justify-content: space-between;
2835

36+
[dir="rtl"] & {
37+
flex-direction: row-reverse;
38+
}
39+
2940
.#{$root}--reverse & {
3041
flex-direction: row-reverse;
42+
43+
[dir="rtl"] & {
44+
flex-direction: row;
45+
}
3146
}
3247
}
3348

3449
&-left {
3550
display: flex;
3651
align-items: center;
3752
gap: var(--footer-left-gap, var(--footer-gap, 15px));
53+
54+
[dir="rtl"] & {
55+
flex-direction: row-reverse;
56+
}
3857
}
3958

4059
&-right {
4160
display: flex;
4261
align-items: center;
4362
gap: var(--footer-right-gap, var(--footer-gap, 15px));
63+
64+
[dir="rtl"] & {
65+
flex-direction: row-reverse;
66+
}
4467
}
4568
}

src/components/ListItem/list-item.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
box-sizing: border-box;
88
line-height: var(--list-item-line-height, var(--line-height, 1 rem));
99

10+
[dir="rtl"] & {
11+
flex-direction: row-reverse;
12+
}
13+
1014
&__center {
1115
flex-grow: 1;
1216
display: flex;

src/components/Modal/Modal.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import {cloneOrCreateElement} from "../../utils";
77
import {Dialog, DialogProps, dialogPropsKeys} from "../Dialog";
88
import {IconButton, IconButtonProps} from "../IconButton";
99

10-
import {ModalRadius} from "./types";
10+
import {ModalRadius, ModalAnimation} from "./types";
1111

1212
import styles from "./modal.module.scss";
1313

1414
export interface ModalProps extends DialogProps {
1515
radius?: ModalRadius;
1616
closeButton?: boolean | IconButtonProps | ReactElement;
1717
onClose?: () => void;
18+
animation?: ModalAnimation;
1819
}
1920

2021
export const modalPropsKeys = new Set<keyof ModalProps>(["radius", "closeButton", "onClose", ...dialogPropsKeys]);
@@ -30,6 +31,7 @@ const Modal: ForwardRefRenderFunction<HTMLDivElement, ModalProps> = (props, ref)
3031
className,
3132
overlayClassName,
3233
childrenClassName,
34+
animation = ModalAnimation.FadeScale,
3335
...other
3436
} = {...useComponentProps("modal"), ...props};
3537

@@ -73,6 +75,7 @@ const Modal: ForwardRefRenderFunction<HTMLDivElement, ModalProps> = (props, ref)
7375
{
7476
[styles["modal-content--fullscreen"]]: fullscreen,
7577
[styles[`modal-content--${radius}-radius`]]: radius,
78+
[styles[`modal-content--${animation}-animation`]]: animation,
7679
},
7780
className
7881
)}

src/components/Modal/modal.module.scss

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,38 @@ $root: modal;
1414
width: var(--modal-width, 90vw);
1515
max-width: var(--modal-max-width, 350px);
1616
max-height: var(--modal-max-height, 85vh);
17+
height: auto;
1718
padding: var(--modal-padding, 0);
1819
border-radius: var(--modal-border-radius, 10px);
1920
box-shadow: var(--modal-box-shadow, 0 0 4px rgba(0, 0, 0, 0.5));
2021
background-color: var(--modal-bg-color, var(--bg-primary-color));
21-
transition:
22-
background-color var(--transition-speed-sm),
23-
color var(--transition-speed-sm);
22+
transition: background-color var(--transition-speed-sm),
23+
transform var(--transition-speed-sm),
24+
opacity var(--transition-speed-sm),
25+
color var(--transition-speed-sm) !important;
2426

2527
&[data-state="open"] {
26-
animation-name: contentShow;
28+
&.#{$root}-content {
29+
&--fade-animation {
30+
animation-name: fadeIn;
31+
}
32+
33+
&--fadeScale-animation {
34+
animation-name: fadeScaleIn;
35+
}
36+
}
2737
}
2838

2939
&[data-state="closed"] {
30-
animation-name: contentHide;
40+
&.#{$root}-content {
41+
&--fade-animation {
42+
animation-name: fadeOut;
43+
}
44+
45+
&--fadeScale-animation {
46+
animation-name: fadeScaleIn;
47+
}
48+
}
3149
}
3250

3351
&--fullscreen {
@@ -74,7 +92,7 @@ $root: modal;
7492
}
7593
}
7694

77-
@keyframes contentShow {
95+
@keyframes fadeScaleIn {
7896
from {
7997
opacity: 0;
8098
transform: translate(-50%, -48%) scale(var(--modal-animation-content-scale, 0.96));
@@ -85,7 +103,7 @@ $root: modal;
85103
}
86104
}
87105

88-
@keyframes contentHide {
106+
@keyframes fadeScaleOut {
89107
from {
90108
opacity: 1;
91109
transform: translate(-50%, -50%) scale(1);
@@ -95,3 +113,21 @@ $root: modal;
95113
transform: translate(-50%, -48%) scale(var(--modal-animation-content-scale, 0.96));
96114
}
97115
}
116+
117+
@keyframes fadeIn {
118+
from {
119+
opacity: 0;
120+
}
121+
to {
122+
opacity: 1;
123+
}
124+
}
125+
126+
@keyframes fadeOut {
127+
from {
128+
opacity: 1;
129+
}
130+
to {
131+
opacity: 0;
132+
}
133+
}

src/components/Modal/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ export enum ModalRadius {
44
Medium = "medium",
55
Large = "large",
66
}
7+
8+
export enum ModalAnimation {
9+
Fade = "fade",
10+
FadeScale = "fadeScale",
11+
}

src/components/TextField/text-field.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ $root: text-field;
3030
width: 100%;
3131
color: inherit;
3232
font-size: inherit;
33+
font-weight: inherit;
3334
font-family: inherit;
3435
padding: 0;
3536
border: none;

0 commit comments

Comments
 (0)