react-align 1.1.2

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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/dist/Grid/GridArea/index.d.ts +19 -0
  4. package/dist/Grid/GridItem/index.d.ts +26 -0
  5. package/dist/Grid/GridSection/index.d.ts +13 -0
  6. package/dist/Grid/GridWrapper/index.d.ts +12 -0
  7. package/dist/Icon/icons.d.ts +14 -0
  8. package/dist/Icon/index.d.ts +12 -0
  9. package/dist/context.d.ts +7 -0
  10. package/dist/index.d.ts +6 -0
  11. package/dist/index.js +8 -0
  12. package/dist/react-align.cjs.development.js +727 -0
  13. package/dist/react-align.cjs.development.js.map +1 -0
  14. package/dist/react-align.cjs.production.min.js +2 -0
  15. package/dist/react-align.cjs.production.min.js.map +1 -0
  16. package/dist/react-align.esm.js +716 -0
  17. package/dist/react-align.esm.js.map +1 -0
  18. package/package.json +80 -0
  19. package/src/Grid/GridArea/index.tsx +177 -0
  20. package/src/Grid/GridItem/index.tsx +252 -0
  21. package/src/Grid/GridSection/index.tsx +46 -0
  22. package/src/Grid/GridWrapper/index.tsx +39 -0
  23. package/src/Grid/grid.css +78 -0
  24. package/src/Grid/interfaces.ts +5 -0
  25. package/src/Icon/Icons/alignCenter.svg +4 -0
  26. package/src/Icon/Icons/alignCenterV.svg +4 -0
  27. package/src/Icon/Icons/alignEnd.svg +4 -0
  28. package/src/Icon/Icons/alignEndV.svg +4 -0
  29. package/src/Icon/Icons/alignStart.svg +4 -0
  30. package/src/Icon/Icons/alignStartV.svg +4 -0
  31. package/src/Icon/Icons/horizontalExtend.svg +8 -0
  32. package/src/Icon/Icons/horizontalNormal.svg +7 -0
  33. package/src/Icon/Icons/moveArrows.svg +10 -0
  34. package/src/Icon/Icons/verticalExtend.svg +8 -0
  35. package/src/Icon/Icons/verticalNormal.svg +7 -0
  36. package/src/Icon/icons.ts +25 -0
  37. package/src/Icon/index.tsx +45 -0
  38. package/src/context.tsx +6 -0
  39. package/src/index.tsx +8 -0
  40. package/src/stories/GridArea.stories.tsx +28 -0
@@ -0,0 +1,78 @@
1
+ /* Default component styles */
2
+ .wrapper {
3
+ height: 100%;
4
+ display: flex;
5
+ justify-content: space-between;
6
+ }
7
+
8
+ .section {
9
+ display: flex;
10
+ flex-direction: column;
11
+ justify-content: space-between;
12
+ }
13
+
14
+ .area {
15
+ display: flex;
16
+ border: 1px solid transparent;
17
+ box-sizing: border-box;
18
+ border-radius: 8px;
19
+ position: relative;
20
+ }
21
+
22
+ .area-transition-in {
23
+ transition: all 0.3s ease-in-out, min-height 0.5s ease-in-out 0.2s, min-width 0.5s ease-in-out 0.2s;
24
+ }
25
+
26
+ .area-transition-out {
27
+ transition: all 0.3s ease-in-out 0.4s, min-height 0.5s ease-in-out 0.2s, min-width 0.5s ease-in-out 0.2s;
28
+ }
29
+
30
+ .item {
31
+ border: 1px solid transparent;
32
+ box-sizing: border-box;
33
+ margin: 6px;
34
+ border-radius: 6px;
35
+ }
36
+
37
+ /* Variable styles */
38
+
39
+ .vertical {
40
+ flex-direction: column;
41
+ }
42
+
43
+ .vertical-r {
44
+ flex-direction: column-reverse;
45
+ }
46
+
47
+ .horizontal {
48
+ flex-direction: row;
49
+ }
50
+
51
+ .horizontal-r {
52
+ flex-direction: row-reverse;
53
+ }
54
+
55
+ .stretch {
56
+ flex: auto;
57
+ }
58
+
59
+ .middle {
60
+ flex-grow: 0;
61
+ flex: auto;
62
+ }
63
+
64
+ .just-centered {
65
+ justify-content: center;
66
+ }
67
+
68
+ .just-end {
69
+ justify-content: flex-end;
70
+ }
71
+
72
+ .end {
73
+ align-items:flex-end;
74
+ }
75
+
76
+ .hide {
77
+ display: none;
78
+ }
@@ -0,0 +1,5 @@
1
+ export type DragItem = {
2
+ type: string;
3
+ index: number;
4
+ id: string;
5
+ };
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="24" height="24" rx="4" fill="black" fill-opacity="0.5"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M19 19L5 19L5 5L19 5L19 19ZM20 20L19 20L5 20L4 20L4 19L4 5L4 4L5 4L19 4L20 4L20 5L20 19L20 20ZM16 14C16 14.5523 15.5523 15 15 15C14.4477 15 14 14.5523 14 14L14 10C14 9.44772 14.4477 9 15 9C15.5523 9 16 9.44771 16 10L16 14ZM13 14C13 14.5523 12.5523 15 12 15C11.4477 15 11 14.5523 11 14L11 10C11 9.44771 11.4477 9 12 9C12.5523 9 13 9.44771 13 10L13 14ZM9 15C9.55228 15 10 14.5523 10 14L10 10C10 9.44771 9.55228 9 9 9C8.44771 9 8 9.44771 8 10L8 14C8 14.5523 8.44772 15 9 15Z" fill="currentColor"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect y="24" width="24" height="24" rx="4" transform="rotate(-90 0 24)" fill="black" fill-opacity="0.5"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M19 5L19 19L5 19L5 5L19 5ZM20 4L20 5L20 19L20 20L19 20L5 20L4 20L4 19L4 5L4 4L5 4L19 4L20 4ZM14 8C14.5523 8 15 8.44772 15 9C15 9.55228 14.5523 10 14 10L10 10C9.44772 10 9 9.55229 9 9C9 8.44772 9.44771 8 10 8L14 8ZM14 11C14.5523 11 15 11.4477 15 12C15 12.5523 14.5523 13 14 13L10 13C9.44772 13 9 12.5523 9 12C9 11.4477 9.44771 11 10 11L14 11ZM15 15C15 14.4477 14.5523 14 14 14L10 14C9.44772 14 9 14.4477 9 15C9 15.5523 9.44772 16 10 16L14 16C14.5523 16 15 15.5523 15 15Z" fill="currentColor"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="24" height="24" rx="4" fill="black" fill-opacity="0.5"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M19 19L5 19L5 5L19 5L19 19ZM20 20L19 20L5 20L4 20L4 19L4 5L4 4L5 4L19 4L20 4L20 5L20 19L20 20ZM18 14C18 14.5523 17.5523 15 17 15C16.4477 15 16 14.5523 16 14L16 10C16 9.44772 16.4477 9 17 9C17.5523 9 18 9.44771 18 10L18 14ZM15 14C15 14.5523 14.5523 15 14 15C13.4477 15 13 14.5523 13 14L13 10C13 9.44772 13.4477 9 14 9C14.5523 9 15 9.44772 15 10L15 14ZM11 15C11.5523 15 12 14.5523 12 14L12 10C12 9.44772 11.5523 9 11 9C10.4477 9 10 9.44772 10 10L10 14C10 14.5523 10.4477 15 11 15Z" fill="currentColor"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect y="24" width="24" height="24" rx="4" transform="rotate(-90 0 24)" fill="black" fill-opacity="0.5"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M5 19L5 5L19 5L19 19L5 19ZM4 20L4 19L4 5L4 4L5 4L19 4L20 4L20 5L20 19L20 20L19 20L5 20L4 20ZM10 18C9.44772 18 9 17.5523 9 17C9 16.4477 9.44772 16 10 16L14 16C14.5523 16 15 16.4477 15 17C15 17.5523 14.5523 18 14 18L10 18ZM10 15C9.44772 15 9 14.5523 9 14C9 13.4477 9.44771 13 10 13L14 13C14.5523 13 15 13.4477 15 14C15 14.5523 14.5523 15 14 15L10 15ZM9 11C9 11.5523 9.44771 12 10 12L14 12C14.5523 12 15 11.5523 15 11C15 10.4477 14.5523 10 14 10L10 10C9.44771 10 9 10.4477 9 11Z" fill="currentColor"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="24" height="24" rx="4" fill="black" fill-opacity="0.5"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M5 5H19V19H5V5ZM4 4H5H19H20V5V19V20H19H5H4V19V5V4ZM6 10C6 9.44772 6.44772 9 7 9C7.55228 9 8 9.44772 8 10V14C8 14.5523 7.55228 15 7 15C6.44772 15 6 14.5523 6 14V10ZM9 10C9 9.44772 9.44772 9 10 9C10.5523 9 11 9.44772 11 10V14C11 14.5523 10.5523 15 10 15C9.44772 15 9 14.5523 9 14V10ZM13 9C12.4477 9 12 9.44772 12 10V14C12 14.5523 12.4477 15 13 15C13.5523 15 14 14.5523 14 14V10C14 9.44772 13.5523 9 13 9Z" fill="currentColor"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect y="24" width="24" height="24" rx="4" transform="rotate(-90 0 24)" fill="black" fill-opacity="0.5"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M19 5L19 19L5 19L5 5L19 5ZM20 4L20 5L20 19L20 20L19 20L5 20L4 20L4 19L4 5L4 4L5 4L19 4L20 4ZM14 6C14.5523 6 15 6.44772 15 7C15 7.55229 14.5523 8 14 8L10 8C9.44772 8 9 7.55229 9 7C9 6.44772 9.44772 6 10 6L14 6ZM14 9C14.5523 9 15 9.44772 15 10C15 10.5523 14.5523 11 14 11L10 11C9.44772 11 9 10.5523 9 10C9 9.44772 9.44772 9 10 9L14 9ZM15 13C15 12.4477 14.5523 12 14 12L10 12C9.44772 12 9 12.4477 9 13C9 13.5523 9.44772 14 10 14L14 14C14.5523 14 15 13.5523 15 13Z" fill="currentColor"/>
4
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M0.999999 20.25L1 3.75" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ <path d="M23 20.25L23 3.75" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M12 12L20.5 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M17.5 9L20.5 12L17.5 15" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
6
+ <path d="M12 12L4 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
7
+ <path d="M7 15L4 12L7 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
8
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M1 12L6 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ <path d="M3 9L6 12L3 15" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M23 12L18 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M21 15L18 12L21 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
6
+ <rect x="8.75" y="2.75" width="6.5" height="18.5" rx="1.25" stroke="currentColor" stroke-width="1.5"/>
7
+ </svg>
@@ -0,0 +1,10 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M14.6514 19.0977L11.9998 21.7493L9.34814 19.0977" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ <path d="M12 15V21.75" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M9.34814 4.90163L11.9998 2.25L14.6514 4.90163" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M12 9V2.25" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
6
+ <path d="M4.90163 14.6509L2.25 11.9993L4.90163 9.34766" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
7
+ <path d="M9 12H2.25" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
8
+ <path d="M19.0981 9.34766L21.7498 11.9993L19.0981 14.6509" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
9
+ <path d="M15 12H21.75" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
10
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M3.75 0.999999L20.25 1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ <path d="M3.75 23L20.25 23" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M12 12L12 20.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M15 17.5L12 20.5L9 17.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
6
+ <path d="M12 12L12 4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
7
+ <path d="M9 7L12 4L15 7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
8
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M12 1L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ <path d="M15 3L12 6L9 3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M12 23L12 18" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M9 21L12 18L15 21" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
6
+ <rect x="21.25" y="8.75" width="6.5" height="18.5" rx="1.25" transform="rotate(90 21.25 8.75)" stroke="currentColor" stroke-width="1.5"/>
7
+ </svg>
@@ -0,0 +1,25 @@
1
+ import HorizontalExtend from './Icons/horizontalExtend.svg';
2
+ import HorizontalNormal from './Icons/horizontalNormal.svg';
3
+ import VerticalExtend from './Icons/verticalExtend.svg';
4
+ import VerticalNormal from './Icons/verticalNormal.svg';
5
+ import MoveArrows from './Icons/moveArrows.svg';
6
+ import AlignStart from './Icons/alignStart.svg';
7
+ import AlignCenter from './Icons/alignCenter.svg';
8
+ import AlignEnd from './Icons/alignEnd.svg';
9
+ import AlignStartV from './Icons/alignStartV.svg';
10
+ import AlignCenterV from './Icons/alignCenterV.svg';
11
+ import AlignEndV from './Icons/alignEndV.svg';
12
+
13
+ export default {
14
+ horizontalExtend: HorizontalExtend,
15
+ horizontalNormal: HorizontalNormal,
16
+ verticalExtend: VerticalExtend,
17
+ verticalNormal: VerticalNormal,
18
+ moveArrows: MoveArrows,
19
+ alignStart: AlignStart,
20
+ alignCenter: AlignCenter,
21
+ alignEnd: AlignEnd,
22
+ alignStartV: AlignStartV,
23
+ alignCenterV: AlignCenterV,
24
+ alignEndV: AlignEndV,
25
+ };
@@ -0,0 +1,45 @@
1
+ import React, { CSSProperties } from 'react';
2
+ import { css } from 'glamor';
3
+
4
+ import Icons from './icons';
5
+
6
+ export type Icons = keyof typeof Icons;
7
+
8
+ export type IconProps = {
9
+ className?: string;
10
+ name: string | Icons;
11
+ size?: number;
12
+ onClick?: () => void;
13
+ styles?: CSSProperties;
14
+ };
15
+
16
+ const IconStyles = (size?: number) =>
17
+ css({
18
+ cursor: 'pointer',
19
+ width: size || 24 + 'px',
20
+ height: size || 24 + 'px',
21
+ ' svg': {
22
+ height: size || 24 + 'px',
23
+ width: size || 24 + 'px',
24
+ },
25
+ });
26
+
27
+ const Icon: React.FC<IconProps> = ({
28
+ className,
29
+ name,
30
+ size,
31
+ onClick,
32
+ styles,
33
+ }) => {
34
+ const LocalIconComponent = Icons[name as Icons];
35
+ return (
36
+ <LocalIconComponent
37
+ className={className}
38
+ {...IconStyles(size)}
39
+ style={styles}
40
+ onClick={onClick}
41
+ />
42
+ );
43
+ };
44
+
45
+ export default Icon;
@@ -0,0 +1,6 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ export const EditorModeContext = createContext<{
4
+ enabled: boolean | undefined;
5
+ }>({ enabled: undefined });
6
+ export const useEditorMode = () => useContext(EditorModeContext);
package/src/index.tsx ADDED
@@ -0,0 +1,8 @@
1
+ export { default as GridWrapper } from "./Grid/GridWrapper";
2
+ export { default as GridSection } from "./Grid/GridSection";
3
+ export { default as GridArea } from "./Grid/GridArea";
4
+ export { default as GridItem } from "./Grid/GridItem";
5
+ export { default as Icon } from "./Icon";
6
+
7
+ // eslint-disable-next-line prettier/prettier
8
+ export type { Alignment } from "./Grid/GridArea";
@@ -0,0 +1,28 @@
1
+ import React, { ComponentProps } from 'react';
2
+ import { Story } from '@storybook/react';
3
+
4
+ import GridWrapper from '../Grid/GridWrapper';
5
+ import GridSection from '../Grid/GridSection';
6
+ import GridArea from '../Grid/GridArea';
7
+
8
+ export default {
9
+ title: 'Grid',
10
+ component: GridArea,
11
+ };
12
+
13
+ const BasicOneAreaOneItem: Story<ComponentProps<typeof GridArea>> = args => (
14
+ <div style={{ width: '500px', height: '600px' }}>
15
+ <GridWrapper>
16
+ <GridSection>
17
+ <GridArea {...args} />
18
+ </GridSection>
19
+ </GridWrapper>
20
+ </div>
21
+ );
22
+
23
+ export const Wrapper = BasicOneAreaOneItem.bind({});
24
+ Wrapper.args = {
25
+ styles: {
26
+ background: '#4770FF',
27
+ },
28
+ };