Skip to content

Commit 83643b8

Browse files
committed
feat(Root): tokenized
1 parent 7166186 commit 83643b8

File tree

6 files changed

+41
-37
lines changed

6 files changed

+41
-37
lines changed

src/components/Root/Root.css

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@
3636
z-index: 2;
3737
}
3838

39+
.Root__view--show-forward {
40+
animation: vkui-root-android-animation-show-forward 0.3s var(--android-easing);
41+
}
42+
43+
.Root__view--hide-back {
44+
animation: vkui-root-android-animation-hide-back 0.3s var(--android-easing)
45+
forwards;
46+
}
47+
3948
.Root__popout {
4049
position: fixed;
4150
left: 0;
@@ -138,20 +147,6 @@
138147
* Android
139148
*/
140149

141-
.Root--android {
142-
}
143-
144-
.Root--android .Root__view--show-forward,
145-
.Root--vkcom .Root__view--show-forward {
146-
animation: vkui-root-android-animation-show-forward 0.3s var(--android-easing);
147-
}
148-
149-
.Root--android .Root__view--hide-back,
150-
.Root--vkcom .Root__view--hide-back {
151-
animation: vkui-root-android-animation-hide-back 0.3s var(--android-easing)
152-
forwards;
153-
}
154-
155150
@keyframes vkui-root-android-animation-hide-back {
156151
from {
157152
transform: scale(1);

src/components/Root/Root.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import { render } from "@testing-library/react";
88
import View from "../View/View";
99
import ConfigProvider from "../ConfigProvider/ConfigProvider";
10-
import Root from "./Root";
10+
import { Root } from "./Root";
1111

1212
const views = [
1313
<View id="v1" key="1" activePanel="" />,

src/components/Root/Root.tsx

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from "react";
22
import { classNames } from "../../lib/classNames";
3-
import { getClassName } from "../../helpers/getClassName";
43
import { IOS } from "../../lib/platform";
54
import { ConfigProviderContext } from "../ConfigProvider/ConfigProviderContext";
65
import { SplitColContext } from "../SplitCol/SplitCol";
@@ -46,7 +45,7 @@ const warn = warnOnce("Root");
4645
/**
4746
* @see https://vkcom.github.io/VKUI/#/Root
4847
*/
49-
const Root: React.FC<RootProps> = ({
48+
export const Root: React.FC<RootProps> = ({
5049
popout = null,
5150
modal,
5251
children,
@@ -152,10 +151,11 @@ const Root: React.FC<RootProps> = ({
152151
return (
153152
<div
154153
{...restProps}
155-
// eslint-disable-next-line vkui/no-object-expression-in-arguments
156-
vkuiClass={classNames(getClassName("Root", platform), {
157-
"Root--transition": transition,
158-
})}
154+
vkuiClass={classNames(
155+
"Root",
156+
platform === IOS && "Root--ios",
157+
transition && "Root--transition"
158+
)}
159159
>
160160
{views.map((view) => {
161161
const viewId = getNavId(view.props, warn);
@@ -172,18 +172,26 @@ const Root: React.FC<RootProps> = ({
172172
key={viewId}
173173
ref={(e) => viewId && (viewNodes[viewId] = e)}
174174
onAnimationEnd={isTransitionTarget ? onAnimationEnd : undefined}
175-
// eslint-disable-next-line vkui/no-object-expression-in-arguments
176-
vkuiClass={classNames("Root__view", {
177-
"Root__view--hide-back":
178-
transition && viewId === prevView && isBack,
179-
"Root__view--hide-forward":
180-
transition && viewId === prevView && !isBack,
181-
"Root__view--show-back":
182-
transition && viewId === activeView && isBack,
183-
"Root__view--show-forward":
184-
transition && viewId === activeView && !isBack,
185-
"Root__view--active": !transition && viewId === activeView,
186-
})}
175+
vkuiClass={classNames(
176+
"Root__view",
177+
transition &&
178+
viewId === prevView &&
179+
isBack &&
180+
"Root__view--hide-back",
181+
transition &&
182+
viewId === prevView &&
183+
!isBack &&
184+
"Root__view--hide-forward",
185+
transition &&
186+
viewId === activeView &&
187+
isBack &&
188+
"Root__view--show-back",
189+
transition &&
190+
viewId === activeView &&
191+
!isBack &&
192+
"Root__view--show-forward",
193+
!transition && viewId === activeView && "Root__view--active"
194+
)}
187195
>
188196
<NavTransitionProvider
189197
entering={transition && viewId === activeView}
@@ -209,6 +217,3 @@ const Root: React.FC<RootProps> = ({
209217
</div>
210218
);
211219
};
212-
213-
// eslint-disable-next-line import/no-default-export
214-
export default Root;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "./styles/common.css";
77
/**
88
* Layout
99
*/
10-
export { default as Root } from "./components/Root/Root";
10+
export { Root } from "./components/Root/Root";
1111
export type { RootProps } from "./components/Root/Root";
1212
export { default as View } from "./components/View/View";
1313
export type { ViewProps } from "./components/View/View";

src/tokenized/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ export type { ChipsSelectProps } from "../components/ChipsSelect/ChipsSelect";
113113
export { SplitCol } from "../components/SplitCol/SplitCol";
114114
export type { SplitColProps } from "../components/SplitCol/SplitCol";
115115

116+
export { Root } from "../components/Root/Root";
117+
export type { RootProps } from "../components/Root/Root";
118+
116119
export { Headline } from "../components/Typography/Headline/Headline";
117120
export type { HeadlineProps } from "../components/Typography/Headline/Headline";
118121

styleguide/tokenized.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const tokenized = [
77
"Card",
88
"CardScroll",
99
"SegmentedControl",
10+
"Root",
1011
"Textarea",
1112
"Title",
1213
"UsersStack",

0 commit comments

Comments
 (0)