@salutejs/plasma-new-hope 0.116.0-dev.0 → 0.116.1-canary.1345.10272475652.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
2
  import styled from '@emotion/styled';
3
3
  import type { ComponentProps } from 'react';
4
4
  import type { StoryObj, Meta } from '@storybook/react';
@@ -6,6 +6,7 @@ import { SSRProvider } from '@salutejs/plasma-core';
6
6
 
7
7
  import { PopupProvider, popupClasses } from '../Popup/Popup';
8
8
  import { Button } from '../Button/Button';
9
+ import { TextField } from '../TextField/TextField';
9
10
  import { WithTheme } from '../../../_helpers';
10
11
 
11
12
  import { Modal, modalClasses } from './Modal';
@@ -206,3 +207,116 @@ export const ModalDemo: StoryObj<StoryModalProps> = {
206
207
  },
207
208
  render: (args) => <StoryModalDemo {...args} />,
208
209
  };
210
+
211
+ const StyledModalAnimation = styled(Modal)`
212
+ /* stylelint-disable */
213
+ && .${popupClasses.root} {
214
+ animation: fadeIn 1s forwards;
215
+ }
216
+
217
+ &&.${popupClasses.endAnimation} .${popupClasses.root} {
218
+ animation: fadeOut 1s forwards;
219
+ }
220
+
221
+ && .${modalClasses.overlay} {
222
+ animation: overlayFadeIn 1s forwards;
223
+ }
224
+
225
+ &&.${popupClasses.endAnimation} .${modalClasses.overlay} {
226
+ animation: overlayFadeOut 1s forwards;
227
+ }
228
+ /* stylelint-enable */
229
+
230
+ @keyframes overlayFadeIn {
231
+ from {
232
+ opacity: 0;
233
+ }
234
+
235
+ to {
236
+ opacity: 1;
237
+ }
238
+ }
239
+
240
+ @keyframes overlayFadeOut {
241
+ from {
242
+ opacity: 1;
243
+ }
244
+
245
+ to {
246
+ opacity: 0;
247
+ }
248
+ }
249
+
250
+ @keyframes fadeIn {
251
+ from {
252
+ opacity: 0;
253
+ transform: translate(-50%, 100%);
254
+ }
255
+
256
+ to {
257
+ opacity: 1;
258
+ transform: translate(-50%, -50%);
259
+ }
260
+ }
261
+
262
+ @keyframes fadeOut {
263
+ from {
264
+ opacity: 1;
265
+ transform: translate(-50%, -50%);
266
+ }
267
+
268
+ to {
269
+ opacity: 0;
270
+ transform: translate(-50%, 100%);
271
+ }
272
+ }
273
+ `;
274
+
275
+ const StoryModalAnimationDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
276
+ const ref = useRef(null);
277
+ const [isOpen, setIsOpen] = useState(false);
278
+
279
+ const close = useCallback(() => {
280
+ setIsOpen(false);
281
+ }, []);
282
+
283
+ return (
284
+ <SSRProvider>
285
+ {/* <StyledWrapper> */}
286
+ <PopupProvider>
287
+ <Button view="default" text="Открыть новое модальное окно" onClick={() => setIsOpen(!isOpen)} />
288
+ <StyledModalAnimation
289
+ id="modal"
290
+ frame="theme-root"
291
+ withAnimation
292
+ onClose={() => setIsOpen(false)}
293
+ isOpen={isOpen}
294
+ placement={placement}
295
+ offset={[offsetX, offsetY]}
296
+ initialFocusRef={ref}
297
+ {...rest}
298
+ >
299
+ <Content>
300
+ <TextField value="Text" onChange={() => {}} />
301
+ <TextField ref={ref} value="Text2" onChange={() => {}} />
302
+ <Button text="Закрыть" onClick={close} />
303
+ </Content>
304
+ </StyledModalAnimation>
305
+ </PopupProvider>
306
+ {/* </StyledWrapper> */}
307
+ </SSRProvider>
308
+ );
309
+ };
310
+
311
+ export const ModalBottomAnimation: StoryObj<StoryModalProps> = {
312
+ args: {
313
+ placement: 'bottom',
314
+ withAnimation: true,
315
+ withBlur: false,
316
+ closeOnEsc: true,
317
+ closeOnOverlayClick: true,
318
+ offsetX: 0,
319
+ offsetY: 0,
320
+ },
321
+ render: (args) => <StoryModalAnimationDemo {...args} />,
322
+ };
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
2
  import styled from '@emotion/styled';
3
3
  import type { ComponentProps } from 'react';
4
4
  import type { StoryObj, Meta } from '@storybook/react';
@@ -6,6 +6,7 @@ import { SSRProvider } from '@salutejs/plasma-core';
6
6
 
7
7
  import { PopupProvider, popupClasses } from '../Popup/Popup';
8
8
  import { Button } from '../Button/Button';
9
+ import { TextField } from '../TextField/TextField';
9
10
  import { WithTheme } from '../../../_helpers';
10
11
 
11
12
  import { Modal, modalClasses } from './Modal';
@@ -206,3 +207,116 @@ export const ModalDemo: StoryObj<StoryModalProps> = {
206
207
  },
207
208
  render: (args) => <StoryModalDemo {...args} />,
208
209
  };
210
+
211
+ const StyledModalAnimation = styled(Modal)`
212
+ /* stylelint-disable */
213
+ && .${popupClasses.root} {
214
+ animation: fadeIn 1s forwards;
215
+ }
216
+
217
+ &&.${popupClasses.endAnimation} .${popupClasses.root} {
218
+ animation: fadeOut 1s forwards;
219
+ }
220
+
221
+ && .${modalClasses.overlay} {
222
+ animation: overlayFadeIn 1s forwards;
223
+ }
224
+
225
+ &&.${popupClasses.endAnimation} .${modalClasses.overlay} {
226
+ animation: overlayFadeOut 1s forwards;
227
+ }
228
+ /* stylelint-enable */
229
+
230
+ @keyframes overlayFadeIn {
231
+ from {
232
+ opacity: 0;
233
+ }
234
+
235
+ to {
236
+ opacity: 1;
237
+ }
238
+ }
239
+
240
+ @keyframes overlayFadeOut {
241
+ from {
242
+ opacity: 1;
243
+ }
244
+
245
+ to {
246
+ opacity: 0;
247
+ }
248
+ }
249
+
250
+ @keyframes fadeIn {
251
+ from {
252
+ opacity: 0;
253
+ transform: translate(-50%, 100%);
254
+ }
255
+
256
+ to {
257
+ opacity: 1;
258
+ transform: translate(-50%, -50%);
259
+ }
260
+ }
261
+
262
+ @keyframes fadeOut {
263
+ from {
264
+ opacity: 1;
265
+ transform: translate(-50%, -50%);
266
+ }
267
+
268
+ to {
269
+ opacity: 0;
270
+ transform: translate(-50%, 100%);
271
+ }
272
+ }
273
+ `;
274
+
275
+ const StoryModalAnimationDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
276
+ const ref = useRef(null);
277
+ const [isOpen, setIsOpen] = useState(false);
278
+
279
+ const close = useCallback(() => {
280
+ setIsOpen(false);
281
+ }, []);
282
+
283
+ return (
284
+ <SSRProvider>
285
+ {/* <StyledWrapper> */}
286
+ <PopupProvider>
287
+ <Button view="default" text="Открыть новое модальное окно" onClick={() => setIsOpen(!isOpen)} />
288
+ <StyledModalAnimation
289
+ id="modal"
290
+ frame="theme-root"
291
+ withAnimation
292
+ onClose={() => setIsOpen(false)}
293
+ isOpen={isOpen}
294
+ placement={placement}
295
+ offset={[offsetX, offsetY]}
296
+ initialFocusRef={ref}
297
+ {...rest}
298
+ >
299
+ <Content>
300
+ <TextField value="Text" onChange={() => {}} />
301
+ <TextField ref={ref} value="Text2" onChange={() => {}} />
302
+ <Button text="Закрыть" onClick={close} />
303
+ </Content>
304
+ </StyledModalAnimation>
305
+ </PopupProvider>
306
+ {/* </StyledWrapper> */}
307
+ </SSRProvider>
308
+ );
309
+ };
310
+
311
+ export const ModalBottomAnimation: StoryObj<StoryModalProps> = {
312
+ args: {
313
+ placement: 'bottom',
314
+ withAnimation: true,
315
+ withBlur: false,
316
+ closeOnEsc: true,
317
+ closeOnOverlayClick: true,
318
+ offsetX: 0,
319
+ offsetY: 0,
320
+ },
321
+ render: (args) => <StoryModalAnimationDemo {...args} />,
322
+ };
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
2
  import styled from '@emotion/styled';
3
3
  import type { ComponentProps } from 'react';
4
4
  import type { StoryObj, Meta } from '@storybook/react';
@@ -6,6 +6,7 @@ import { SSRProvider } from '@salutejs/plasma-core';
6
6
 
7
7
  import { PopupProvider, popupClasses } from '../Popup/Popup';
8
8
  import { Button } from '../Button/Button';
9
+ import { TextField } from '../TextField/TextField';
9
10
  import { WithTheme } from '../../../_helpers';
10
11
 
11
12
  import { Modal, modalClasses } from './Modal';
@@ -206,3 +207,116 @@ export const ModalDemo: StoryObj<StoryModalProps> = {
206
207
  },
207
208
  render: (args) => <StoryModalDemo {...args} />,
208
209
  };
210
+
211
+ const StyledModalAnimation = styled(Modal)`
212
+ /* stylelint-disable */
213
+ && .${popupClasses.root} {
214
+ animation: fadeIn 1s forwards;
215
+ }
216
+
217
+ &&.${popupClasses.endAnimation} .${popupClasses.root} {
218
+ animation: fadeOut 1s forwards;
219
+ }
220
+
221
+ && .${modalClasses.overlay} {
222
+ animation: overlayFadeIn 1s forwards;
223
+ }
224
+
225
+ &&.${popupClasses.endAnimation} .${modalClasses.overlay} {
226
+ animation: overlayFadeOut 1s forwards;
227
+ }
228
+ /* stylelint-enable */
229
+
230
+ @keyframes overlayFadeIn {
231
+ from {
232
+ opacity: 0;
233
+ }
234
+
235
+ to {
236
+ opacity: 1;
237
+ }
238
+ }
239
+
240
+ @keyframes overlayFadeOut {
241
+ from {
242
+ opacity: 1;
243
+ }
244
+
245
+ to {
246
+ opacity: 0;
247
+ }
248
+ }
249
+
250
+ @keyframes fadeIn {
251
+ from {
252
+ opacity: 0;
253
+ transform: translate(-50%, 100%);
254
+ }
255
+
256
+ to {
257
+ opacity: 1;
258
+ transform: translate(-50%, -50%);
259
+ }
260
+ }
261
+
262
+ @keyframes fadeOut {
263
+ from {
264
+ opacity: 1;
265
+ transform: translate(-50%, -50%);
266
+ }
267
+
268
+ to {
269
+ opacity: 0;
270
+ transform: translate(-50%, 100%);
271
+ }
272
+ }
273
+ `;
274
+
275
+ const StoryModalAnimationDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
276
+ const ref = useRef(null);
277
+ const [isOpen, setIsOpen] = useState(false);
278
+
279
+ const close = useCallback(() => {
280
+ setIsOpen(false);
281
+ }, []);
282
+
283
+ return (
284
+ <SSRProvider>
285
+ {/* <StyledWrapper> */}
286
+ <PopupProvider>
287
+ <Button view="default" text="Открыть новое модальное окно" onClick={() => setIsOpen(!isOpen)} />
288
+ <StyledModalAnimation
289
+ id="modal"
290
+ frame="theme-root"
291
+ withAnimation
292
+ onClose={() => setIsOpen(false)}
293
+ isOpen={isOpen}
294
+ placement={placement}
295
+ offset={[offsetX, offsetY]}
296
+ initialFocusRef={ref}
297
+ {...rest}
298
+ >
299
+ <Content>
300
+ <TextField value="Text" onChange={() => {}} />
301
+ <TextField ref={ref} value="Text2" onChange={() => {}} />
302
+ <Button text="Закрыть" onClick={close} />
303
+ </Content>
304
+ </StyledModalAnimation>
305
+ </PopupProvider>
306
+ {/* </StyledWrapper> */}
307
+ </SSRProvider>
308
+ );
309
+ };
310
+
311
+ export const ModalBottomAnimation: StoryObj<StoryModalProps> = {
312
+ args: {
313
+ placement: 'bottom',
314
+ withAnimation: true,
315
+ withBlur: false,
316
+ closeOnEsc: true,
317
+ closeOnOverlayClick: true,
318
+ offsetX: 0,
319
+ offsetY: 0,
320
+ },
321
+ render: (args) => <StoryModalAnimationDemo {...args} />,
322
+ };
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
2
  import styled from '@emotion/styled';
3
3
  import type { ComponentProps } from 'react';
4
4
  import type { StoryObj, Meta } from '@storybook/react';
@@ -6,6 +6,7 @@ import { SSRProvider } from '@salutejs/plasma-core';
6
6
 
7
7
  import { PopupProvider, popupClasses } from '../Popup/Popup';
8
8
  import { Button } from '../Button/Button';
9
+ import { TextField } from '../TextField/TextField';
9
10
  import { WithTheme } from '../../../_helpers';
10
11
 
11
12
  import { Modal, modalClasses } from './Modal';
@@ -206,3 +207,116 @@ export const ModalDemo: StoryObj<StoryModalProps> = {
206
207
  },
207
208
  render: (args) => <StoryModalDemo {...args} />,
208
209
  };
210
+
211
+ const StyledModalAnimation = styled(Modal)`
212
+ /* stylelint-disable */
213
+ && .${popupClasses.root} {
214
+ animation: fadeIn 1s forwards;
215
+ }
216
+
217
+ &&.${popupClasses.endAnimation} .${popupClasses.root} {
218
+ animation: fadeOut 1s forwards;
219
+ }
220
+
221
+ && .${modalClasses.overlay} {
222
+ animation: overlayFadeIn 1s forwards;
223
+ }
224
+
225
+ &&.${popupClasses.endAnimation} .${modalClasses.overlay} {
226
+ animation: overlayFadeOut 1s forwards;
227
+ }
228
+ /* stylelint-enable */
229
+
230
+ @keyframes overlayFadeIn {
231
+ from {
232
+ opacity: 0;
233
+ }
234
+
235
+ to {
236
+ opacity: 1;
237
+ }
238
+ }
239
+
240
+ @keyframes overlayFadeOut {
241
+ from {
242
+ opacity: 1;
243
+ }
244
+
245
+ to {
246
+ opacity: 0;
247
+ }
248
+ }
249
+
250
+ @keyframes fadeIn {
251
+ from {
252
+ opacity: 0;
253
+ transform: translate(-50%, 100%);
254
+ }
255
+
256
+ to {
257
+ opacity: 1;
258
+ transform: translate(-50%, -50%);
259
+ }
260
+ }
261
+
262
+ @keyframes fadeOut {
263
+ from {
264
+ opacity: 1;
265
+ transform: translate(-50%, -50%);
266
+ }
267
+
268
+ to {
269
+ opacity: 0;
270
+ transform: translate(-50%, 100%);
271
+ }
272
+ }
273
+ `;
274
+
275
+ const StoryModalAnimationDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
276
+ const ref = useRef(null);
277
+ const [isOpen, setIsOpen] = useState(false);
278
+
279
+ const close = useCallback(() => {
280
+ setIsOpen(false);
281
+ }, []);
282
+
283
+ return (
284
+ <SSRProvider>
285
+ {/* <StyledWrapper> */}
286
+ <PopupProvider>
287
+ <Button view="default" text="Открыть новое модальное окно" onClick={() => setIsOpen(!isOpen)} />
288
+ <StyledModalAnimation
289
+ id="modal"
290
+ frame="theme-root"
291
+ withAnimation
292
+ onClose={() => setIsOpen(false)}
293
+ isOpen={isOpen}
294
+ placement={placement}
295
+ offset={[offsetX, offsetY]}
296
+ initialFocusRef={ref}
297
+ {...rest}
298
+ >
299
+ <Content>
300
+ <TextField value="Text" onChange={() => {}} />
301
+ <TextField ref={ref} value="Text2" onChange={() => {}} />
302
+ <Button text="Закрыть" onClick={close} />
303
+ </Content>
304
+ </StyledModalAnimation>
305
+ </PopupProvider>
306
+ {/* </StyledWrapper> */}
307
+ </SSRProvider>
308
+ );
309
+ };
310
+
311
+ export const ModalBottomAnimation: StoryObj<StoryModalProps> = {
312
+ args: {
313
+ placement: 'bottom',
314
+ withAnimation: true,
315
+ withBlur: false,
316
+ closeOnEsc: true,
317
+ closeOnOverlayClick: true,
318
+ offsetX: 0,
319
+ offsetY: 0,
320
+ },
321
+ render: (args) => <StoryModalAnimationDemo {...args} />,
322
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salutejs/plasma-new-hope",
3
- "version": "0.116.0-dev.0",
3
+ "version": "0.116.1-canary.1345.10272475652.0",
4
4
  "description": "Salute Design System blueprint",
5
5
  "main": "cjs/index.js",
6
6
  "module": "es/index.js",
@@ -80,7 +80,7 @@
80
80
  "@rollup/plugin-babel": "^6.0.4",
81
81
  "@rollup/plugin-commonjs": "^25.0.4",
82
82
  "@rollup/plugin-node-resolve": "^15.1.0",
83
- "@salutejs/plasma-sb-utils": "0.163.0-dev.0",
83
+ "@salutejs/plasma-sb-utils": "0.163.1-canary.1345.10272475652.0",
84
84
  "@storybook/addon-docs": "^7.6.17",
85
85
  "@storybook/addon-essentials": "^7.6.17",
86
86
  "@storybook/addons": "^7.6.17",
@@ -110,7 +110,7 @@
110
110
  "@linaria/core": "5.0.2",
111
111
  "@linaria/react": "5.0.3",
112
112
  "@popperjs/core": "2.11.8",
113
- "@salutejs/plasma-core": "1.165.0-dev.0",
113
+ "@salutejs/plasma-core": "1.165.1-canary.1345.10272475652.0",
114
114
  "dayjs": "1.11.11",
115
115
  "focus-visible": "5.2.0",
116
116
  "lodash.throttle": "4.1.1",
@@ -118,5 +118,5 @@
118
118
  "react-popper": "2.3.0",
119
119
  "storeon": "3.1.5"
120
120
  },
121
- "gitHead": "ac63304dc70b686ed89486476d6f911e0797da31"
121
+ "gitHead": "6b23a3ccb23f7d974d848d55e736c097f21e59fe"
122
122
  }
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import type { ComponentProps } from 'react';
4
4
  import type { StoryObj, Meta } from '@storybook/react';
@@ -6,6 +6,7 @@ import { SSRProvider } from '@salutejs/plasma-core';
6
6
 
7
7
  import { PopupProvider, popupClasses } from '../Popup/Popup';
8
8
  import { Button } from '../Button/Button';
9
+ import { TextField } from '../TextField/TextField';
9
10
  import { WithTheme } from '../../../_helpers';
10
11
 
11
12
  import { Modal, modalClasses } from './Modal';
@@ -206,3 +207,116 @@ export const ModalDemo: StoryObj<StoryModalProps> = {
206
207
  },
207
208
  render: (args) => <StoryModalDemo {...args} />,
208
209
  };
210
+
211
+ const StyledModalAnimation = styled(Modal)`
212
+ /* stylelint-disable */
213
+ && .${popupClasses.root} {
214
+ animation: fadeIn 1s forwards;
215
+ }
216
+
217
+ &&.${popupClasses.endAnimation} .${popupClasses.root} {
218
+ animation: fadeOut 1s forwards;
219
+ }
220
+
221
+ && .${modalClasses.overlay} {
222
+ animation: overlayFadeIn 1s forwards;
223
+ }
224
+
225
+ &&.${popupClasses.endAnimation} .${modalClasses.overlay} {
226
+ animation: overlayFadeOut 1s forwards;
227
+ }
228
+ /* stylelint-enable */
229
+
230
+ @keyframes overlayFadeIn {
231
+ from {
232
+ opacity: 0;
233
+ }
234
+
235
+ to {
236
+ opacity: 1;
237
+ }
238
+ }
239
+
240
+ @keyframes overlayFadeOut {
241
+ from {
242
+ opacity: 1;
243
+ }
244
+
245
+ to {
246
+ opacity: 0;
247
+ }
248
+ }
249
+
250
+ @keyframes fadeIn {
251
+ from {
252
+ opacity: 0;
253
+ transform: translate(-50%, 100%);
254
+ }
255
+
256
+ to {
257
+ opacity: 1;
258
+ transform: translate(-50%, -50%);
259
+ }
260
+ }
261
+
262
+ @keyframes fadeOut {
263
+ from {
264
+ opacity: 1;
265
+ transform: translate(-50%, -50%);
266
+ }
267
+
268
+ to {
269
+ opacity: 0;
270
+ transform: translate(-50%, 100%);
271
+ }
272
+ }
273
+ `;
274
+
275
+ const StoryModalAnimationDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
276
+ const ref = useRef(null);
277
+ const [isOpen, setIsOpen] = useState(false);
278
+
279
+ const close = useCallback(() => {
280
+ setIsOpen(false);
281
+ }, []);
282
+
283
+ return (
284
+ <SSRProvider>
285
+ {/* <StyledWrapper> */}
286
+ <PopupProvider>
287
+ <Button view="default" text="Открыть новое модальное окно" onClick={() => setIsOpen(!isOpen)} />
288
+ <StyledModalAnimation
289
+ id="modal"
290
+ frame="theme-root"
291
+ withAnimation
292
+ onClose={() => setIsOpen(false)}
293
+ isOpen={isOpen}
294
+ placement={placement}
295
+ offset={[offsetX, offsetY]}
296
+ initialFocusRef={ref}
297
+ {...rest}
298
+ >
299
+ <Content>
300
+ <TextField value="Text" onChange={() => {}} />
301
+ <TextField ref={ref} value="Text2" onChange={() => {}} />
302
+ <Button text="Закрыть" onClick={close} />
303
+ </Content>
304
+ </StyledModalAnimation>
305
+ </PopupProvider>
306
+ {/* </StyledWrapper> */}
307
+ </SSRProvider>
308
+ );
309
+ };
310
+
311
+ export const ModalBottomAnimation: StoryObj<StoryModalProps> = {
312
+ args: {
313
+ placement: 'bottom',
314
+ withAnimation: true,
315
+ withBlur: false,
316
+ closeOnEsc: true,
317
+ closeOnOverlayClick: true,
318
+ offsetX: 0,
319
+ offsetY: 0,
320
+ },
321
+ render: (args) => <StoryModalAnimationDemo {...args} />,
322
+ };
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import type { ComponentProps } from 'react';
4
4
  import type { StoryObj, Meta } from '@storybook/react';
@@ -6,6 +6,7 @@ import { SSRProvider } from '@salutejs/plasma-core';
6
6
 
7
7
  import { PopupProvider, popupClasses } from '../Popup/Popup';
8
8
  import { Button } from '../Button/Button';
9
+ import { TextField } from '../TextField/TextField';
9
10
  import { WithTheme } from '../../../_helpers';
10
11
 
11
12
  import { Modal, modalClasses } from './Modal';
@@ -206,3 +207,116 @@ export const ModalDemo: StoryObj<StoryModalProps> = {
206
207
  },
207
208
  render: (args) => <StoryModalDemo {...args} />,
208
209
  };
210
+
211
+ const StyledModalAnimation = styled(Modal)`
212
+ /* stylelint-disable */
213
+ && .${popupClasses.root} {
214
+ animation: fadeIn 1s forwards;
215
+ }
216
+
217
+ &&.${popupClasses.endAnimation} .${popupClasses.root} {
218
+ animation: fadeOut 1s forwards;
219
+ }
220
+
221
+ && .${modalClasses.overlay} {
222
+ animation: overlayFadeIn 1s forwards;
223
+ }
224
+
225
+ &&.${popupClasses.endAnimation} .${modalClasses.overlay} {
226
+ animation: overlayFadeOut 1s forwards;
227
+ }
228
+ /* stylelint-enable */
229
+
230
+ @keyframes overlayFadeIn {
231
+ from {
232
+ opacity: 0;
233
+ }
234
+
235
+ to {
236
+ opacity: 1;
237
+ }
238
+ }
239
+
240
+ @keyframes overlayFadeOut {
241
+ from {
242
+ opacity: 1;
243
+ }
244
+
245
+ to {
246
+ opacity: 0;
247
+ }
248
+ }
249
+
250
+ @keyframes fadeIn {
251
+ from {
252
+ opacity: 0;
253
+ transform: translate(-50%, 100%);
254
+ }
255
+
256
+ to {
257
+ opacity: 1;
258
+ transform: translate(-50%, -50%);
259
+ }
260
+ }
261
+
262
+ @keyframes fadeOut {
263
+ from {
264
+ opacity: 1;
265
+ transform: translate(-50%, -50%);
266
+ }
267
+
268
+ to {
269
+ opacity: 0;
270
+ transform: translate(-50%, 100%);
271
+ }
272
+ }
273
+ `;
274
+
275
+ const StoryModalAnimationDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
276
+ const ref = useRef(null);
277
+ const [isOpen, setIsOpen] = useState(false);
278
+
279
+ const close = useCallback(() => {
280
+ setIsOpen(false);
281
+ }, []);
282
+
283
+ return (
284
+ <SSRProvider>
285
+ {/* <StyledWrapper> */}
286
+ <PopupProvider>
287
+ <Button view="default" text="Открыть новое модальное окно" onClick={() => setIsOpen(!isOpen)} />
288
+ <StyledModalAnimation
289
+ id="modal"
290
+ frame="theme-root"
291
+ withAnimation
292
+ onClose={() => setIsOpen(false)}
293
+ isOpen={isOpen}
294
+ placement={placement}
295
+ offset={[offsetX, offsetY]}
296
+ initialFocusRef={ref}
297
+ {...rest}
298
+ >
299
+ <Content>
300
+ <TextField value="Text" onChange={() => {}} />
301
+ <TextField ref={ref} value="Text2" onChange={() => {}} />
302
+ <Button text="Закрыть" onClick={close} />
303
+ </Content>
304
+ </StyledModalAnimation>
305
+ </PopupProvider>
306
+ {/* </StyledWrapper> */}
307
+ </SSRProvider>
308
+ );
309
+ };
310
+
311
+ export const ModalBottomAnimation: StoryObj<StoryModalProps> = {
312
+ args: {
313
+ placement: 'bottom',
314
+ withAnimation: true,
315
+ withBlur: false,
316
+ closeOnEsc: true,
317
+ closeOnOverlayClick: true,
318
+ offsetX: 0,
319
+ offsetY: 0,
320
+ },
321
+ render: (args) => <StoryModalAnimationDemo {...args} />,
322
+ };
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import type { ComponentProps } from 'react';
4
4
  import type { StoryObj, Meta } from '@storybook/react';
@@ -6,6 +6,7 @@ import { SSRProvider } from '@salutejs/plasma-core';
6
6
 
7
7
  import { PopupProvider, popupClasses } from '../Popup/Popup';
8
8
  import { Button } from '../Button/Button';
9
+ import { TextField } from '../TextField/TextField';
9
10
  import { WithTheme } from '../../../_helpers';
10
11
 
11
12
  import { Modal, modalClasses } from './Modal';
@@ -206,3 +207,116 @@ export const ModalDemo: StoryObj<StoryModalProps> = {
206
207
  },
207
208
  render: (args) => <StoryModalDemo {...args} />,
208
209
  };
210
+
211
+ const StyledModalAnimation = styled(Modal)`
212
+ /* stylelint-disable */
213
+ && .${popupClasses.root} {
214
+ animation: fadeIn 1s forwards;
215
+ }
216
+
217
+ &&.${popupClasses.endAnimation} .${popupClasses.root} {
218
+ animation: fadeOut 1s forwards;
219
+ }
220
+
221
+ && .${modalClasses.overlay} {
222
+ animation: overlayFadeIn 1s forwards;
223
+ }
224
+
225
+ &&.${popupClasses.endAnimation} .${modalClasses.overlay} {
226
+ animation: overlayFadeOut 1s forwards;
227
+ }
228
+ /* stylelint-enable */
229
+
230
+ @keyframes overlayFadeIn {
231
+ from {
232
+ opacity: 0;
233
+ }
234
+
235
+ to {
236
+ opacity: 1;
237
+ }
238
+ }
239
+
240
+ @keyframes overlayFadeOut {
241
+ from {
242
+ opacity: 1;
243
+ }
244
+
245
+ to {
246
+ opacity: 0;
247
+ }
248
+ }
249
+
250
+ @keyframes fadeIn {
251
+ from {
252
+ opacity: 0;
253
+ transform: translate(-50%, 100%);
254
+ }
255
+
256
+ to {
257
+ opacity: 1;
258
+ transform: translate(-50%, -50%);
259
+ }
260
+ }
261
+
262
+ @keyframes fadeOut {
263
+ from {
264
+ opacity: 1;
265
+ transform: translate(-50%, -50%);
266
+ }
267
+
268
+ to {
269
+ opacity: 0;
270
+ transform: translate(-50%, 100%);
271
+ }
272
+ }
273
+ `;
274
+
275
+ const StoryModalAnimationDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
276
+ const ref = useRef(null);
277
+ const [isOpen, setIsOpen] = useState(false);
278
+
279
+ const close = useCallback(() => {
280
+ setIsOpen(false);
281
+ }, []);
282
+
283
+ return (
284
+ <SSRProvider>
285
+ {/* <StyledWrapper> */}
286
+ <PopupProvider>
287
+ <Button view="default" text="Открыть новое модальное окно" onClick={() => setIsOpen(!isOpen)} />
288
+ <StyledModalAnimation
289
+ id="modal"
290
+ frame="theme-root"
291
+ withAnimation
292
+ onClose={() => setIsOpen(false)}
293
+ isOpen={isOpen}
294
+ placement={placement}
295
+ offset={[offsetX, offsetY]}
296
+ initialFocusRef={ref}
297
+ {...rest}
298
+ >
299
+ <Content>
300
+ <TextField value="Text" onChange={() => {}} />
301
+ <TextField ref={ref} value="Text2" onChange={() => {}} />
302
+ <Button text="Закрыть" onClick={close} />
303
+ </Content>
304
+ </StyledModalAnimation>
305
+ </PopupProvider>
306
+ {/* </StyledWrapper> */}
307
+ </SSRProvider>
308
+ );
309
+ };
310
+
311
+ export const ModalBottomAnimation: StoryObj<StoryModalProps> = {
312
+ args: {
313
+ placement: 'bottom',
314
+ withAnimation: true,
315
+ withBlur: false,
316
+ closeOnEsc: true,
317
+ closeOnOverlayClick: true,
318
+ offsetX: 0,
319
+ offsetY: 0,
320
+ },
321
+ render: (args) => <StoryModalAnimationDemo {...args} />,
322
+ };
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import type { ComponentProps } from 'react';
4
4
  import type { StoryObj, Meta } from '@storybook/react';
@@ -6,6 +6,7 @@ import { SSRProvider } from '@salutejs/plasma-core';
6
6
 
7
7
  import { PopupProvider, popupClasses } from '../Popup/Popup';
8
8
  import { Button } from '../Button/Button';
9
+ import { TextField } from '../TextField/TextField';
9
10
  import { WithTheme } from '../../../_helpers';
10
11
 
11
12
  import { Modal, modalClasses } from './Modal';
@@ -206,3 +207,116 @@ export const ModalDemo: StoryObj<StoryModalProps> = {
206
207
  },
207
208
  render: (args) => <StoryModalDemo {...args} />,
208
209
  };
210
+
211
+ const StyledModalAnimation = styled(Modal)`
212
+ /* stylelint-disable */
213
+ && .${popupClasses.root} {
214
+ animation: fadeIn 1s forwards;
215
+ }
216
+
217
+ &&.${popupClasses.endAnimation} .${popupClasses.root} {
218
+ animation: fadeOut 1s forwards;
219
+ }
220
+
221
+ && .${modalClasses.overlay} {
222
+ animation: overlayFadeIn 1s forwards;
223
+ }
224
+
225
+ &&.${popupClasses.endAnimation} .${modalClasses.overlay} {
226
+ animation: overlayFadeOut 1s forwards;
227
+ }
228
+ /* stylelint-enable */
229
+
230
+ @keyframes overlayFadeIn {
231
+ from {
232
+ opacity: 0;
233
+ }
234
+
235
+ to {
236
+ opacity: 1;
237
+ }
238
+ }
239
+
240
+ @keyframes overlayFadeOut {
241
+ from {
242
+ opacity: 1;
243
+ }
244
+
245
+ to {
246
+ opacity: 0;
247
+ }
248
+ }
249
+
250
+ @keyframes fadeIn {
251
+ from {
252
+ opacity: 0;
253
+ transform: translate(-50%, 100%);
254
+ }
255
+
256
+ to {
257
+ opacity: 1;
258
+ transform: translate(-50%, -50%);
259
+ }
260
+ }
261
+
262
+ @keyframes fadeOut {
263
+ from {
264
+ opacity: 1;
265
+ transform: translate(-50%, -50%);
266
+ }
267
+
268
+ to {
269
+ opacity: 0;
270
+ transform: translate(-50%, 100%);
271
+ }
272
+ }
273
+ `;
274
+
275
+ const StoryModalAnimationDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
276
+ const ref = useRef(null);
277
+ const [isOpen, setIsOpen] = useState(false);
278
+
279
+ const close = useCallback(() => {
280
+ setIsOpen(false);
281
+ }, []);
282
+
283
+ return (
284
+ <SSRProvider>
285
+ {/* <StyledWrapper> */}
286
+ <PopupProvider>
287
+ <Button view="default" text="Открыть новое модальное окно" onClick={() => setIsOpen(!isOpen)} />
288
+ <StyledModalAnimation
289
+ id="modal"
290
+ frame="theme-root"
291
+ withAnimation
292
+ onClose={() => setIsOpen(false)}
293
+ isOpen={isOpen}
294
+ placement={placement}
295
+ offset={[offsetX, offsetY]}
296
+ initialFocusRef={ref}
297
+ {...rest}
298
+ >
299
+ <Content>
300
+ <TextField value="Text" onChange={() => {}} />
301
+ <TextField ref={ref} value="Text2" onChange={() => {}} />
302
+ <Button text="Закрыть" onClick={close} />
303
+ </Content>
304
+ </StyledModalAnimation>
305
+ </PopupProvider>
306
+ {/* </StyledWrapper> */}
307
+ </SSRProvider>
308
+ );
309
+ };
310
+
311
+ export const ModalBottomAnimation: StoryObj<StoryModalProps> = {
312
+ args: {
313
+ placement: 'bottom',
314
+ withAnimation: true,
315
+ withBlur: false,
316
+ closeOnEsc: true,
317
+ closeOnOverlayClick: true,
318
+ offsetX: 0,
319
+ offsetY: 0,
320
+ },
321
+ render: (args) => <StoryModalAnimationDemo {...args} />,
322
+ };