@superdispatch/ui-lab 0.21.12 → 0.21.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +13 -38
  3. package/.babelrc.js +0 -5
  4. package/.turbo/turbo-version.log +0 -28
  5. package/pkg/README.md +0 -10
  6. package/pkg/package.json +0 -34
  7. package/playroom.ts +0 -23
  8. package/src/alert/Alert.stories.tsx +0 -105
  9. package/src/alert/Alert.tsx +0 -108
  10. package/src/banner/Banner.stories.tsx +0 -64
  11. package/src/banner/Banner.tsx +0 -120
  12. package/src/box/Box.stories.tsx +0 -20
  13. package/src/box/Box.tsx +0 -252
  14. package/src/button/Button.stories.tsx +0 -717
  15. package/src/button/Button.tsx +0 -460
  16. package/src/button-area/ButtonArea.stories.tsx +0 -65
  17. package/src/button-area/ButtonArea.tsx +0 -88
  18. package/src/container/Container.tsx +0 -48
  19. package/src/description-item/DescriptionItem.stories.tsx +0 -163
  20. package/src/description-item/DescriptionItem.tsx +0 -104
  21. package/src/file-drop-zone/FileDropZone.stories.tsx +0 -44
  22. package/src/file-drop-zone/FileDropZone.tsx +0 -170
  23. package/src/file-list-item/FileListItem.stories.tsx +0 -37
  24. package/src/file-list-item/FileListItem.tsx +0 -145
  25. package/src/file-list-item/__tests__/FileListItem.spec.tsx +0 -339
  26. package/src/index.spec.ts +0 -43
  27. package/src/index.ts +0 -28
  28. package/src/linked-text/LinkeText.stories.tsx +0 -42
  29. package/src/linked-text/LinkedText.tsx +0 -47
  30. package/src/multiline-text/MultilineText.stories.tsx +0 -30
  31. package/src/multiline-text/MultilineText.ts +0 -16
  32. package/src/navbar/Navbar.stories.tsx +0 -135
  33. package/src/navbar/Navbar.tsx +0 -111
  34. package/src/navbar/NavbarAccordion.tsx +0 -171
  35. package/src/navbar/NavbarAvatar.tsx +0 -51
  36. package/src/navbar/NavbarBottomBar.tsx +0 -135
  37. package/src/navbar/NavbarContext.tsx +0 -23
  38. package/src/navbar/NavbarItem.tsx +0 -119
  39. package/src/navbar/NavbarList.tsx +0 -225
  40. package/src/navbar/NavbarMenu.tsx +0 -102
  41. package/src/sidebar/Sidebar.stories.tsx +0 -363
  42. package/src/sidebar/Sidebar.tsx +0 -73
  43. package/src/sidebar/SidebarBackButton.tsx +0 -33
  44. package/src/sidebar/SidebarContainer.tsx +0 -114
  45. package/src/sidebar/SidebarContent.tsx +0 -119
  46. package/src/sidebar/SidebarDivider.tsx +0 -15
  47. package/src/sidebar/SidebarMenuItem.tsx +0 -211
  48. package/src/sidebar/SidebarMenuItemAction.tsx +0 -27
  49. package/src/sidebar/SidebarMenuItemAvatar.tsx +0 -59
  50. package/src/sidebar/SidebarMenuItemContext.tsx +0 -33
  51. package/src/sidebar/SidebarSubheader.tsx +0 -38
  52. package/src/styled.d.ts +0 -12
  53. package/src/text-box/TextBox.stories.tsx +0 -108
  54. package/src/text-box/TextBox.tsx +0 -229
  55. package/src/utils/RuleNormalizer.ts +0 -24
  56. package/src/utils/mergeStyles.ts +0 -28
  57. package/tsconfig.json +0 -19
  58. /package/{pkg/dist-node → dist-node}/index.js +0 -0
  59. /package/{pkg/dist-node → dist-node}/index.js.map +0 -0
  60. /package/{pkg/dist-src → dist-src}/alert/Alert.js +0 -0
  61. /package/{pkg/dist-src → dist-src}/banner/Banner.js +0 -0
  62. /package/{pkg/dist-src → dist-src}/box/Box.js +0 -0
  63. /package/{pkg/dist-src → dist-src}/button/Button.js +0 -0
  64. /package/{pkg/dist-src → dist-src}/button-area/ButtonArea.js +0 -0
  65. /package/{pkg/dist-src → dist-src}/container/Container.js +0 -0
  66. /package/{pkg/dist-src → dist-src}/description-item/DescriptionItem.js +0 -0
  67. /package/{pkg/dist-src → dist-src}/file-drop-zone/FileDropZone.js +0 -0
  68. /package/{pkg/dist-src → dist-src}/file-list-item/FileListItem.js +0 -0
  69. /package/{pkg/dist-src → dist-src}/index.js +0 -0
  70. /package/{pkg/dist-src → dist-src}/linked-text/LinkedText.js +0 -0
  71. /package/{pkg/dist-src → dist-src}/multiline-text/MultilineText.js +0 -0
  72. /package/{pkg/dist-src → dist-src}/navbar/Navbar.js +0 -0
  73. /package/{pkg/dist-src → dist-src}/navbar/NavbarAccordion.js +0 -0
  74. /package/{pkg/dist-src → dist-src}/navbar/NavbarAvatar.js +0 -0
  75. /package/{pkg/dist-src → dist-src}/navbar/NavbarBottomBar.js +0 -0
  76. /package/{pkg/dist-src → dist-src}/navbar/NavbarContext.js +0 -0
  77. /package/{pkg/dist-src → dist-src}/navbar/NavbarItem.js +0 -0
  78. /package/{pkg/dist-src → dist-src}/navbar/NavbarList.js +0 -0
  79. /package/{pkg/dist-src → dist-src}/navbar/NavbarMenu.js +0 -0
  80. /package/{pkg/dist-src → dist-src}/sidebar/Sidebar.js +0 -0
  81. /package/{pkg/dist-src → dist-src}/sidebar/SidebarBackButton.js +0 -0
  82. /package/{pkg/dist-src → dist-src}/sidebar/SidebarContainer.js +0 -0
  83. /package/{pkg/dist-src → dist-src}/sidebar/SidebarContent.js +0 -0
  84. /package/{pkg/dist-src → dist-src}/sidebar/SidebarDivider.js +0 -0
  85. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItem.js +0 -0
  86. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItemAction.js +0 -0
  87. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItemAvatar.js +0 -0
  88. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItemContext.js +0 -0
  89. /package/{pkg/dist-src → dist-src}/sidebar/SidebarSubheader.js +0 -0
  90. /package/{pkg/dist-src → dist-src}/text-box/TextBox.js +0 -0
  91. /package/{pkg/dist-src → dist-src}/utils/RuleNormalizer.js +0 -0
  92. /package/{pkg/dist-src → dist-src}/utils/mergeStyles.js +0 -0
  93. /package/{pkg/dist-types → dist-types}/index.d.ts +0 -0
  94. /package/{pkg/dist-web → dist-web}/index.js +0 -0
  95. /package/{pkg/dist-web → dist-web}/index.js.map +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Super Dispatch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "@superdispatch/ui-lab",
3
- "version": "0.21.12",
3
+ "version": "0.21.14",
4
+ "license": "MIT",
5
+ "files": [
6
+ "dist-*/",
7
+ "bin/"
8
+ ],
9
+ "pika": true,
10
+ "sideEffects": false,
4
11
  "repository": {
5
12
  "type": "git",
6
13
  "url": "https://github.com/superdispatch/ui.git"
7
14
  },
8
- "license": "MIT",
9
- "main": "src/index.ts",
10
- "module": "src/index.ts",
11
- "browser": "pkg/dist-web/index.js",
12
- "types": "src/index.ts",
13
- "scripts": {
14
- "version": "pika build"
15
- },
16
15
  "dependencies": {
17
16
  "@superdispatch/hooks": "^0.21.0",
18
- "@superdispatch/ui": "^0.21.8",
17
+ "@superdispatch/ui": "^0.21.14",
19
18
  "react-anchorme": "^2.2.1",
20
19
  "react-dropzone": "^11.3.4"
21
20
  },
@@ -28,32 +27,8 @@
28
27
  "access": "public",
29
28
  "directory": "pkg"
30
29
  },
31
- "@pika/pack": {
32
- "pipeline": [
33
- [
34
- "@pika/plugin-standard-pkg",
35
- {
36
- "exclude": [
37
- "**/*.spec.*",
38
- "**/*.stories.*",
39
- "**/*.playroom.*",
40
- "**/__tests__/**",
41
- "**/__testutils__/**"
42
- ]
43
- }
44
- ],
45
- [
46
- "@pika/plugin-build-web"
47
- ],
48
- [
49
- "@pika/plugin-build-node"
50
- ],
51
- [
52
- "@pika/plugin-build-types"
53
- ],
54
- [
55
- "@pika/plugin-bundle-types"
56
- ]
57
- ]
58
- }
30
+ "esnext": "dist-src/index.js",
31
+ "module": "dist-web/index.js",
32
+ "main": "dist-node/index.js",
33
+ "types": "dist-types/index.d.ts"
59
34
  }
package/.babelrc.js DELETED
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- const createBabelConfig = require('../../config/createBabelConfig');
4
-
5
- module.exports = createBabelConfig();
@@ -1,28 +0,0 @@
1
- @superdispatch/ui-lab:version: cache hit, replaying output 45a0d783a7139ee5
2
- @superdispatch/ui-lab:version: $ pika build
3
- @superdispatch/ui-lab:version: @pika/pack v0.5.0
4
- @superdispatch/ui-lab:version: [1/8] Validating source...
5
- @superdispatch/ui-lab:version: [2/8] Preparing pipeline...
6
- @superdispatch/ui-lab:version:  ❇️ pkg/
7
- @superdispatch/ui-lab:version: [3/8] Running @pika/plugin-standard-pkg...
8
- @superdispatch/ui-lab:version: Browserslist: caniuse-lite is outdated. Please run:
9
- @superdispatch/ui-lab:version:  npx browserslist@latest --update-db
10
- @superdispatch/ui-lab:version:  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
11
- @superdispatch/ui-lab:version:  📝 pkg/dist-src/index.js [esnext]
12
- @superdispatch/ui-lab:version:  » Linting with standard-pkg...
13
- @superdispatch/ui-lab:version: [4/8] Running @pika/plugin-build-web...
14
- @superdispatch/ui-lab:version:  📝 pkg/dist-web/index.js [module]
15
- @superdispatch/ui-lab:version: [5/8] Running @pika/plugin-build-node...
16
- @superdispatch/ui-lab:version:  📝 pkg/dist-node/index.js [main]
17
- @superdispatch/ui-lab:version: [6/8] Running @pika/plugin-build-types...
18
- @superdispatch/ui-lab:version:  » no manual type definitions found, auto-generating...
19
- @superdispatch/ui-lab:version:  📝 pkg/dist-types/index.d.ts [types]
20
- @superdispatch/ui-lab:version: [7/8] Running @pika/plugin-bundle-types...
21
- @superdispatch/ui-lab:version: Circular dependency: pkg/dist-types/navbar/NavbarList.d.ts -> pkg/dist-types/navbar/NavbarAccordion.d.ts -> pkg/dist-types/navbar/NavbarList.d.ts
22
- @superdispatch/ui-lab:version: 'Context' is imported from external module 'react' but never used
23
- @superdispatch/ui-lab:version:  📝 pkg/dist-types/index.d.ts
24
- @superdispatch/ui-lab:version: [8/8] Finalizing package...
25
- @superdispatch/ui-lab:version:  » copying README.md...
26
- @superdispatch/ui-lab:version:  📝 pkg/package.json
27
- @superdispatch/ui-lab:version:  📦 pkg/
28
- @superdispatch/ui-lab:version: Done in 14.05s.
package/pkg/README.md DELETED
@@ -1,10 +0,0 @@
1
- ### `@superdispatch/ui-lab`
2
-
3
- [![npm](https://img.shields.io/npm/v/@superdispatch/ui-lab)](https://www.npmjs.com/package/@superdispatch/ui-lab)
4
- [![npm minzipped size](https://img.shields.io/bundlephobia/minzip/@superdispatch/ui-lab.svg)](https://bundlephobia.com/result?p=@superdispatch/ui-lab)
5
-
6
- #### Installation
7
-
8
- ```bash
9
- yarn add @superdispatch/ui-lab
10
- ```
package/pkg/package.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "name": "@superdispatch/ui-lab",
3
- "version": "0.21.12",
4
- "license": "MIT",
5
- "files": [
6
- "dist-*/",
7
- "bin/"
8
- ],
9
- "pika": true,
10
- "sideEffects": false,
11
- "repository": {
12
- "type": "git",
13
- "url": "https://github.com/superdispatch/ui.git"
14
- },
15
- "dependencies": {
16
- "@superdispatch/hooks": "^0.21.0",
17
- "@superdispatch/ui": "^0.21.8",
18
- "react-anchorme": "^2.2.1",
19
- "react-dropzone": "^11.3.4"
20
- },
21
- "peerDependencies": {
22
- "@babel/runtime": "^7.0.0",
23
- "react": "^17.0.2",
24
- "styled-components": "^5.2.1"
25
- },
26
- "publishConfig": {
27
- "access": "public",
28
- "directory": "pkg"
29
- },
30
- "esnext": "dist-src/index.js",
31
- "module": "dist-web/index.js",
32
- "main": "dist-node/index.js",
33
- "types": "dist-types/index.d.ts"
34
- }
package/playroom.ts DELETED
@@ -1,23 +0,0 @@
1
- export {
2
- Alert,
3
- Banner,
4
- Box,
5
- Button,
6
- ButtonArea,
7
- DescriptionItem,
8
- FileDropZone,
9
- FileListItem,
10
- LinkedText,
11
- MultilineText,
12
- Navbar,
13
- NavbarAvatar,
14
- NavbarMenu,
15
- Sidebar,
16
- SidebarContainer,
17
- SidebarDivider,
18
- SidebarMenuItem,
19
- SidebarMenuItemAction,
20
- SidebarMenuItemAvatar,
21
- SidebarSubheader,
22
- TextBox,
23
- } from './src';
@@ -1,105 +0,0 @@
1
- import { Meta } from '@storybook/react';
2
- import { Column, Columns, Inline, Stack } from '@superdispatch/ui';
3
- import { Button } from '../button/Button';
4
- import { Alert } from './Alert';
5
-
6
- export default {
7
- title: 'Lab/Alert',
8
- component: Alert,
9
- } as Meta;
10
-
11
- export const basic = () => (
12
- <Columns collapseBelow="tablet" space="xsmall">
13
- <Column>
14
- <Stack>
15
- <Alert severity="positive">
16
- <Inline verticalAlign="center">
17
- <span>This is an error alert — check it out!</span>
18
- <Button variant="neutral" size="small">
19
- Button
20
- </Button>
21
- </Inline>
22
- </Alert>
23
-
24
- <Alert severity="info">
25
- <Inline verticalAlign="center">
26
- <span>This is an error alert — check it out!</span>
27
- <Button variant="neutral" size="small">
28
- Button
29
- </Button>
30
- </Inline>
31
- </Alert>
32
-
33
- <Alert severity="caution">
34
- <Inline verticalAlign="center">
35
- <span>This is an error alert — check it out!</span>
36
- <Button variant="neutral" size="small">
37
- Button
38
- </Button>
39
- </Inline>
40
- </Alert>
41
-
42
- <Alert severity="critical">
43
- <Inline verticalAlign="center">
44
- <span>This is an error alert — check it out!</span>
45
- <Button variant="neutral" size="small">
46
- Button
47
- </Button>
48
- </Inline>
49
- </Alert>
50
- </Stack>
51
- </Column>
52
-
53
- <Column>
54
- <Stack>
55
- <Alert severity="positive">
56
- <Inline verticalAlign="center">
57
- <span>
58
- Uh-Oh! Your Super Carrier documents need review. please submit the
59
- following documents. Don’t worry! Be happy!
60
- </span>
61
- <Button variant="neutral" size="small">
62
- Button
63
- </Button>
64
- </Inline>
65
- </Alert>
66
-
67
- <Alert severity="info">
68
- <Inline verticalAlign="center">
69
- <span>
70
- Uh-Oh! Your Super Carrier documents need review. please submit the
71
- following documents. Don’t worry! Be happy!
72
- </span>
73
- <Button variant="neutral" size="small">
74
- Button
75
- </Button>
76
- </Inline>
77
- </Alert>
78
-
79
- <Alert severity="caution">
80
- <Inline verticalAlign="center">
81
- <span>
82
- Uh-Oh! Your Super Carrier documents need review. please submit the
83
- following documents. Don’t worry! Be happy!
84
- </span>
85
- <Button variant="neutral" size="small">
86
- Button
87
- </Button>
88
- </Inline>
89
- </Alert>
90
-
91
- <Alert severity="critical">
92
- <Inline verticalAlign="center">
93
- <span>
94
- Uh-Oh! Your Super Carrier documents need review. please submit the
95
- following documents. Don’t worry! Be happy!
96
- </span>
97
- <Button variant="neutral" size="small">
98
- Button
99
- </Button>
100
- </Inline>
101
- </Alert>
102
- </Stack>
103
- </Column>
104
- </Columns>
105
- );
@@ -1,108 +0,0 @@
1
- import { CheckCircle, Error, Info } from '@material-ui/icons';
2
- import {
3
- Alert as MaterialAlert,
4
- AlertProps as MaterialAlertProps,
5
- } from '@material-ui/lab';
6
- import { Color } from '@superdispatch/ui';
7
- import { forwardRef, ReactNode } from 'react';
8
- import styled, { css, SimpleInterpolation } from 'styled-components';
9
-
10
- function colorMixin(
11
- textColor: Color,
12
- backgroundColor: Color,
13
- buttonHoverColor: Color,
14
- ): readonly SimpleInterpolation[] {
15
- return css`
16
- color: ${textColor};
17
- background-color: ${backgroundColor};
18
-
19
- & .MuiAlert-icon {
20
- color: ${textColor};
21
- }
22
-
23
- & .MuiAlert-action {
24
- & .MuiIconButton-root {
25
- &:hover,
26
- &:active {
27
- color: ${buttonHoverColor};
28
- }
29
- }
30
- }
31
- `;
32
- }
33
-
34
- const StyledAlert = styled(MaterialAlert)`
35
- &.MuiAlert-outlinedSuccess {
36
- ${colorMixin(Color.Green500, Color.Green50, Color.Green400)};
37
- }
38
-
39
- &.MuiAlert-outlinedInfo {
40
- ${colorMixin(Color.Blue500, Color.Blue50, Color.Blue400)};
41
- }
42
-
43
- &.MuiAlert-outlinedWarning {
44
- ${colorMixin(Color.Yellow500, Color.Yellow50, Color.Yellow400)};
45
- }
46
-
47
- &.MuiAlert-outlinedError {
48
- ${colorMixin(Color.Red500, Color.Red50, Color.Red400)};
49
- }
50
-
51
- & .MuiAlert-icon {
52
- opacity: 1;
53
- padding: 8px 0;
54
- font-size: 24px;
55
- }
56
-
57
- & .MuiAlert-action {
58
- display: block;
59
- padding-top: 5px;
60
- margin-right: -3px;
61
-
62
- & .MuiIconButton-root {
63
- & .MuiSvgIcon-root {
64
- font-size: 24px;
65
- }
66
- }
67
- }
68
- `;
69
-
70
- export type AlertSeverityProp = 'positive' | 'info' | 'caution' | 'critical';
71
-
72
- export interface AlertProps {
73
- onClose?: () => void;
74
- children?: ReactNode;
75
- severity?: AlertSeverityProp;
76
- }
77
-
78
- function toMaterialSeverity(
79
- severity: AlertSeverityProp,
80
- ): MaterialAlertProps['severity'] {
81
- return severity === 'info'
82
- ? 'info'
83
- : severity === 'caution'
84
- ? 'warning'
85
- : severity === 'critical'
86
- ? 'error'
87
- : 'success';
88
- }
89
-
90
- const iconMapping: MaterialAlertProps['iconMapping'] = {
91
- success: <CheckCircle />,
92
- info: <Info />,
93
- error: <Error />,
94
- };
95
-
96
- export const Alert = forwardRef<HTMLDivElement, AlertProps>(
97
- ({ children, onClose, severity = 'positive' }, ref) => (
98
- <StyledAlert
99
- ref={ref}
100
- variant="outlined"
101
- iconMapping={iconMapping}
102
- severity={toMaterialSeverity(severity)}
103
- onClose={onClose}
104
- >
105
- {children}
106
- </StyledAlert>
107
- ),
108
- );
@@ -1,64 +0,0 @@
1
- import { Link } from '@material-ui/core';
2
- import { Meta } from '@storybook/react';
3
- import { Inline, Stack } from '@superdispatch/ui';
4
- import { UseState } from '@superdispatch/ui-docs';
5
- import { Button } from '../button/Button';
6
- import { TextBox } from '../text-box/TextBox';
7
- import { Banner } from './Banner';
8
-
9
- export default {
10
- title: 'Lab/Banner',
11
- component: Banner,
12
- } as Meta;
13
-
14
- export const basic = () => (
15
- <Stack>
16
- <UseState initialState={true}>
17
- {(open, setOpen) => (
18
- <Stack space="none">
19
- <Button
20
- size="small"
21
- variant="neutral"
22
- aria-label="Rate Button"
23
- onClick={() => {
24
- setOpen(!open);
25
- }}
26
- >
27
- {open ? 'Close' : 'Open'}
28
- </Button>
29
-
30
- <Banner
31
- in={open}
32
- border="top"
33
- mountOnEnter={true}
34
- unmountOnExit={true}
35
- >
36
- <Inline
37
- verticalAlign="center"
38
- horizontalAlign="center"
39
- space="small"
40
- >
41
- <Inline
42
- space="xxsmall"
43
- verticalAlign="center"
44
- horizontalAlign="center"
45
- >
46
- <TextBox color="inherit">
47
- Rate your recent experience with{' '}
48
- </TextBox>
49
- <Link
50
- color="inherit"
51
- target="_blank"
52
- rel="noreferrer"
53
- href="https://superdispatch.com/"
54
- >
55
- SuperDispatch
56
- </Link>
57
- </Inline>
58
- </Inline>
59
- </Banner>
60
- </Stack>
61
- )}
62
- </UseState>
63
- </Stack>
64
- );
@@ -1,120 +0,0 @@
1
- import { Color } from '@superdispatch/ui';
2
- import { forwardRef, useEffect, useState } from 'react';
3
- import { CSSTransition } from 'react-transition-group';
4
- // eslint-disable-next-line import/no-internal-modules
5
- import { CSSTransitionProps } from 'react-transition-group/CSSTransition';
6
- import styled, {
7
- css,
8
- Keyframes,
9
- keyframes,
10
- SimpleInterpolation,
11
- } from 'styled-components';
12
-
13
- function enterMixin(border: BorderPlacement): readonly SimpleInterpolation[] {
14
- return css`
15
- min-height: 56px;
16
- color: ${Color.Dark500};
17
- background-color: ${Color.White};
18
-
19
- border-${border}: 1px #dfe3e8 solid;
20
- `;
21
- }
22
-
23
- function enterAnimation(border: BorderPlacement): Keyframes {
24
- return keyframes`
25
- 0% {
26
- min-height: 0;
27
- color: ${Color.White};
28
- background-color: ${Color.Dark500};
29
- }
30
-
31
- 50% {
32
- min-height: 56px;
33
- color: ${Color.White};
34
- background-color: ${Color.Dark500};
35
- }
36
-
37
- 70% {
38
- min-height: 56px;
39
- color: ${Color.White};
40
- background-color: ${Color.Dark500};
41
- }
42
-
43
- 100% {
44
- ${enterMixin(border)}
45
- }
46
- `;
47
- }
48
-
49
- type BorderPlacement = 'top' | 'bottom';
50
-
51
- type CustomerTransitionProps = CSSTransitionProps<HTMLDivElement> & {
52
- className?: string;
53
- border?: BorderPlacement;
54
- };
55
-
56
- const CustomTransition = forwardRef<
57
- CSSTransition<HTMLDivElement>,
58
- CustomerTransitionProps
59
- >(({ children, ...props }, ref) => (
60
- <CSSTransition
61
- {...props}
62
- ref={ref}
63
- timeout={3000}
64
- classNames={props.className}
65
- >
66
- <div>{children}</div>
67
- </CSSTransition>
68
- ));
69
-
70
- const BannerContent = styled(CustomTransition)<CustomerTransitionProps>(
71
- ({ border = 'bottom' }) => {
72
- return css`
73
- height: 0;
74
- width: 100%;
75
- overflow: hidden;
76
-
77
- display: flex;
78
- align-items: center;
79
- justify-content: center;
80
-
81
- color: ${Color.White};
82
- background-color: ${Color.White};
83
-
84
- &-enter-active {
85
- animation: ${enterAnimation(border)} 2s 1s forwards;
86
- }
87
-
88
- &-enter-done {
89
- ${enterMixin(border)};
90
- }
91
-
92
- &-exit {
93
- ${enterMixin(border)};
94
- }
95
-
96
- &-exit-active {
97
- min-height: 0;
98
- transition: min-height 2s 1s;
99
- }
100
- `;
101
- },
102
- );
103
-
104
- type BannerProps = Omit<
105
- CustomerTransitionProps,
106
- 'timeout' | 'className' | 'classNames'
107
- >;
108
-
109
- export const Banner = forwardRef<CSSTransition<HTMLDivElement>, BannerProps>(
110
- ({ in: inProp, ...props }, ref) => {
111
- const [isIn, setIn] = useState(false);
112
-
113
- // transition is not triggered on initial render with `in: true`
114
- useEffect(() => {
115
- setIn(!!inProp);
116
- }, [inProp]);
117
-
118
- return <BannerContent ref={ref} in={isIn} {...props} />;
119
- },
120
- );
@@ -1,20 +0,0 @@
1
- import { Meta } from '@storybook/react';
2
- import { Box } from './Box';
3
-
4
- export default { title: 'Lab/Box', component: Box } as Meta;
5
-
6
- export const basic = () => (
7
- <Box
8
- display="inline-block"
9
- borderWidth="small"
10
- borderTopRightRadius="small"
11
- borderBottomRightRadius="small"
12
- borderColor={['Blue200', 'Green200', 'Purple200']}
13
- borderLeftWidth="large"
14
- borderLeftColor={['Blue300', 'Green300', 'Purple300']}
15
- padding={['large', 'medium', 'small']}
16
- backgroundColor={['Blue50', 'Green50', 'Purple50']}
17
- >
18
- Hey
19
- </Box>
20
- );