anim-3d-obj 1.1.19 → 1.1.22

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 (90) hide show
  1. package/README.md +154 -154
  2. package/babel.config.json +18 -0
  3. package/dist/components/Card.tsx +56 -0
  4. package/dist/components/Cuboid.tsx +61 -0
  5. package/dist/components/Face/face.d.ts +39 -0
  6. package/dist/components/Face/index.tsx +85 -0
  7. package/dist/components/Ribbon.tsx +58 -0
  8. package/dist/components/styles/Anim.d.ts +16 -0
  9. package/dist/components/styles/AnimWrap.tsx +85 -0
  10. package/dist/{esm/components/styles/Anims.js → components/styles/Anims.ts} +77 -58
  11. package/dist/components/styles/Global.ts +7 -0
  12. package/dist/components/styles/Scene.tsx +37 -0
  13. package/dist/index.ts +6 -0
  14. package/img.png +0 -0
  15. package/package.json +61 -33
  16. package/public/favicon.ico +0 -0
  17. package/public/index.html +43 -0
  18. package/public/manifest.json +15 -0
  19. package/public/robots.txt +3 -0
  20. package/src/App.css +11 -0
  21. package/src/App.test.tsx +10 -0
  22. package/src/App.tsx +115 -0
  23. package/src/index.tsx +19 -0
  24. package/src/lib/components/Card.tsx +56 -0
  25. package/src/lib/components/Cuboid.tsx +61 -0
  26. package/src/lib/components/Face/face.d.ts +39 -0
  27. package/src/lib/components/Face/index.tsx +85 -0
  28. package/src/lib/components/Ribbon.tsx +58 -0
  29. package/src/lib/components/styles/Anim.d.ts +16 -0
  30. package/src/lib/components/styles/AnimWrap.tsx +85 -0
  31. package/{dist/cjs/components/styles/Anims.js → src/lib/components/styles/Anims.ts} +77 -62
  32. package/src/lib/components/styles/Global.ts +7 -0
  33. package/src/lib/components/styles/Scene.tsx +37 -0
  34. package/src/lib/index.ts +6 -0
  35. package/src/reportWebVitals.ts +15 -0
  36. package/src/setupTests.ts +5 -0
  37. package/tsconfig.json +26 -0
  38. package/LICENSE +0 -21
  39. package/dist/cjs/components/Card.d.ts +0 -2
  40. package/dist/cjs/components/Card.js +0 -20
  41. package/dist/cjs/components/Card.js.map +0 -1
  42. package/dist/cjs/components/Cuboid.d.ts +0 -2
  43. package/dist/cjs/components/Cuboid.js +0 -21
  44. package/dist/cjs/components/Cuboid.js.map +0 -1
  45. package/dist/cjs/components/Faces/Face.d.ts +0 -3
  46. package/dist/cjs/components/Faces/Face.js +0 -86
  47. package/dist/cjs/components/Faces/Face.js.map +0 -1
  48. package/dist/cjs/components/Ribbon.d.ts +0 -2
  49. package/dist/cjs/components/Ribbon.js +0 -20
  50. package/dist/cjs/components/Ribbon.js.map +0 -1
  51. package/dist/cjs/components/styles/AnimWrap.d.ts +0 -2
  52. package/dist/cjs/components/styles/AnimWrap.js +0 -94
  53. package/dist/cjs/components/styles/AnimWrap.js.map +0 -1
  54. package/dist/cjs/components/styles/Anims.d.ts +0 -30
  55. package/dist/cjs/components/styles/Anims.js.map +0 -1
  56. package/dist/cjs/components/styles/Global.d.ts +0 -1
  57. package/dist/cjs/components/styles/Global.js +0 -14
  58. package/dist/cjs/components/styles/Global.js.map +0 -1
  59. package/dist/cjs/components/styles/Scene.d.ts +0 -10
  60. package/dist/cjs/components/styles/Scene.js +0 -22
  61. package/dist/cjs/components/styles/Scene.js.map +0 -1
  62. package/dist/cjs/index.d.ts +0 -5
  63. package/dist/cjs/index.js +0 -17
  64. package/dist/cjs/index.js.map +0 -1
  65. package/dist/esm/components/Card.d.ts +0 -2
  66. package/dist/esm/components/Card.js +0 -13
  67. package/dist/esm/components/Card.js.map +0 -1
  68. package/dist/esm/components/Cuboid.d.ts +0 -2
  69. package/dist/esm/components/Cuboid.js +0 -14
  70. package/dist/esm/components/Cuboid.js.map +0 -1
  71. package/dist/esm/components/Faces/Face.d.ts +0 -3
  72. package/dist/esm/components/Faces/Face.js +0 -81
  73. package/dist/esm/components/Faces/Face.js.map +0 -1
  74. package/dist/esm/components/Ribbon.d.ts +0 -2
  75. package/dist/esm/components/Ribbon.js +0 -13
  76. package/dist/esm/components/Ribbon.js.map +0 -1
  77. package/dist/esm/components/styles/AnimWrap.d.ts +0 -2
  78. package/dist/esm/components/styles/AnimWrap.js +0 -87
  79. package/dist/esm/components/styles/AnimWrap.js.map +0 -1
  80. package/dist/esm/components/styles/Anims.d.ts +0 -30
  81. package/dist/esm/components/styles/Anims.js.map +0 -1
  82. package/dist/esm/components/styles/Global.d.ts +0 -1
  83. package/dist/esm/components/styles/Global.js +0 -8
  84. package/dist/esm/components/styles/Global.js.map +0 -1
  85. package/dist/esm/components/styles/Scene.d.ts +0 -10
  86. package/dist/esm/components/styles/Scene.js +0 -15
  87. package/dist/esm/components/styles/Scene.js.map +0 -1
  88. package/dist/esm/index.d.ts +0 -5
  89. package/dist/esm/index.js +0 -8
  90. package/dist/esm/index.js.map +0 -1
package/README.md CHANGED
@@ -1,154 +1,154 @@
1
- # React Typescript Cuboid Builder
2
-
3
- This project allows a user to create Cuboids of any size simply by entering a set of parameters.
4
- The program does the leg work with regard to calculating translationZ depth and config on the fly.
5
-
6
- - [GIT HOME](https://github.com/mdnelles/anim-3d-objs-launcher)
7
- - [NPM HOME](https://www.npmjs.com/package/anim-3d-obj) npm i anim-3d-obj
8
-
9
- ## Examples
10
-
11
- - [6 sided Cuboid - animate X360 Y360](https://codesandbox.io/s/anim-3d-obj-all-sides-simple-bf67yg)
12
- - [3 sided Object - animate y-axis](https://codesandbox.io/s/anim-3d-obj-3-sides-wobble-y-axis-wglkms)
13
- - [Double box spin](https://codesandbox.io/s/react-anim-3d-double-box-spin-vbdhg2)
14
- - [2 sided object with animation wobble](https://codesandbox.io/s/anim-3d-obj-wobblex-mmidkg)
15
- - [Parallel divs animated x and y axis in tandem](https://codesandbox.io/s/anim-3d-obj-2-sides-simple-4057y7)
16
- - [Spinning Slab](https://codesandbox.io/s/react-anim-3d-pulse-kc8g0f)
17
-
18
- ## Config
19
-
20
- Animations are optional. Either or both of `anim1Specs` or `anim2Specs` can be applied to the object.
21
-
22
- ```typescript
23
- const anim1Specs: object = {
24
- border: '', // while testing reveal the animation wrapper
25
- degreesHi: -45, // degrees if spin
26
- degreesLow: 45, // degrees if spin
27
- delay: 0, // start delay in seconds
28
- direction: 'normal', //normal alternating reverse
29
- duration: 8, // seconds
30
- fillMode: 'forward', // node forward backward both
31
- iterationCount: 'infinite', // number or infinte
32
- name: 'Y360', // ** ANIMATIONS
33
- timing: 'ease-in-out' // linear ease ease-in-out
34
- };
35
- ```
36
-
37
- `** ANIMATIONS`
38
-
39
- - X360: rotate 360 degrees on the x-axis
40
- - Y360: rotate 360 degrees on the y-axis
41
- - fadeInkf: fade object in from 0 to 1 Opacity
42
- - wobY: wobble on y-axis (degreesHi <-> degreesLow)
43
- - wobX: wobble on x-axis (degreesHi <-> degreesLow)
44
- - fwdx018: spin object on x-axis from 0 degrees to 180 degrees
45
- - fwdx1836: spin object on x-axis from 180 degrees to 360 degrees
46
- - fwdx09: spin object on x-axis from 0 degrees to 90 degrees
47
- - fwdx918: spin object on x-axis from 90 degrees to 180 degrees
48
- - fwdx1827: spin object on x-axis from 180 degrees to 270 degrees
49
- - fwdx2736: spin object on x-axis from 270 degrees to 360 degrees
50
- - fwdy018: spin object on y-axis from 0 degrees to 180 degrees
51
- - fwdy1836: spin object on y-axis from 180 degrees to 360 degrees
52
- - fwdy09: spin object on y-axis from 0 degrees to 90 degrees
53
- - fwdy918: spin object on y-axis from 90 degrees to 180 degrees
54
- - fwdy1827: spin object on y-axis from 180 degrees to 270 degrees
55
- - fwdy2736: spin object on y-axis from 270 degrees to 360 degrees
56
- - floatX: float object so is not stationary
57
- - floatShadow: float object + add shadow
58
- - pulseSM: pulse object Small
59
- - pulseMD: pulse object Medium
60
- - pulseLG: pulse object Large
61
- - noAnim: no animation place holder
62
-
63
- <>
64
-
65
- GLOBAL CONFIG
66
-
67
- ```typescript
68
- // EXAMPLE GLOBAL FACE CONFIG
69
- // This will be applied to all Faces that do not have their own custom config
70
- const global: object = {
71
- // // face individual styles (over rides global)
72
- css: `
73
- border: 1px solid #fff;
74
- background: rgb(2,0,36);
75
- background: linear-gradient(180deg, rgba(255,255,255,.1) 0%, rgba(141,191,249,.7) 100%);
76
- color:white;
77
- text-align:center;
78
- line-height:10;
79
- backface-visibility: visible;
80
- font-family: Arial, Helvetica, sans-serif;
81
- border-radius:5px;
82
- `,
83
- body: ' '
84
- };
85
- ```
86
-
87
- <>
88
-
89
- CUSTOM CONFIG FOR INDIVIDUAL FACES
90
-
91
- ```typescript
92
- const custom: object = {
93
- // // face individual styles (over rides global)
94
- front: {
95
- css: ``,
96
- body: <Login />,
97
- },
98
- left: {
99
- css: `
100
- border: 1px solid #fff;
101
- background: rgb(2,0,36);
102
- color:white;
103
- text-align: center;
104
- line-height:8;`
105
- body: " ",
106
- },
107
- right: {
108
- css: ``,
109
- body: " ",
110
- },
111
- back: {
112
- css: ``,
113
- body: <Logout />,
114
- },
115
- bottom: {
116
- css: `
117
- background-color:rgba(141,191,249,1);
118
- -webkit-box-shadow: 0px 0px 23px 18px #858585;
119
- box-shadow: 0px 0px 23px 18px #858585;
120
- `,
121
- },
122
- ```
123
-
124
- ## Render
125
-
126
- and
127
-
128
- ```typescript
129
- <Cuboid
130
- width={250}
131
- height={300}
132
- depth={250}
133
- perspective={800}
134
- perspectiveOrigin="50% 50%"
135
- zIndex={10}
136
- anim1Specs={anim1Specs}
137
- anim2Specs={anim2Specs}
138
- custom={custom}
139
- faces={faceprops}
140
- global={global}
141
- />
142
- ```
143
-
144
- will produce the following
145
-
146
- ![Logo](https://raw.githubusercontent.com/mdnelles/objs-local/main/img.png?token=GHSAT0AAAAAABQVNJ4VATWQM4SI3LXSTDZWYVDOL7Q)
147
-
148
- ## Authors
149
-
150
- - [@mdnelles](https://github.com/mdnelles)
151
-
152
- ## License
153
-
154
- [MIT](https://choosealicense.com/licenses/mit/)
1
+ # React Typescript Cuboid Builder
2
+
3
+ This project allows a user to create Cuboids of any size simply by entering a set of parameters.
4
+ The program does the leg work with regard to calculating translationZ depth and config on the fly.
5
+
6
+ - [GIT HOME](https://github.com/mdnelles/anim-3d-objs-launcher)
7
+ - [NPM HOME](https://www.npmjs.com/package/anim-3d-obj) npm i anim-3d-obj
8
+
9
+ ## Examples
10
+
11
+ - [6 sided Cuboid - animate X360 Y360](https://codesandbox.io/s/anim-3d-obj-all-sides-simple-bf67yg)
12
+ - [3 sided Object - animate y-axis](https://codesandbox.io/s/anim-3d-obj-3-sides-wobble-y-axis-wglkms)
13
+ - [Double box spin](https://codesandbox.io/s/react-anim-3d-double-box-spin-vbdhg2)
14
+ - [2 sided object with animation wobble](https://codesandbox.io/s/anim-3d-obj-wobblex-mmidkg)
15
+ - [Parallel divs animated x and y axis in tandem](https://codesandbox.io/s/anim-3d-obj-2-sides-simple-4057y7)
16
+ - [Spinning Slab](https://codesandbox.io/s/react-anim-3d-pulse-kc8g0f)
17
+
18
+ ## Config
19
+
20
+ Animations are optional. Either or both of `anim1Specs` or `anim2Specs` can be applied to the object.
21
+
22
+ ```typescript
23
+ const anim1Specs: object = {
24
+ border: "", // while testing reveal the animation wrapper
25
+ degreesHi: -45, // degrees if spin
26
+ degreesLow: 45, // degrees if spin
27
+ delay: 0, // start delay in seconds
28
+ direction: "normal", //normal alternating reverse
29
+ duration: 8, // seconds
30
+ fillMode: "forward", // node forward backward both
31
+ iterationCount: "infinite", // number or infinte
32
+ name: "Y360", // ** ANIMATIONS
33
+ timing: "ease-in-out", // linear ease ease-in-out
34
+ };
35
+ ```
36
+
37
+ `** ANIMATIONS`
38
+
39
+ - X360: rotate 360 degrees on the x-axis
40
+ - Y360: rotate 360 degrees on the y-axis
41
+ - fadeInkf: fade object in from 0 to 1 Opacity
42
+ - wobY: wobble on y-axis (degreesHi <-> degreesLow)
43
+ - wobX: wobble on x-axis (degreesHi <-> degreesLow)
44
+ - fwdx018: spin object on x-axis from 0 degrees to 180 degrees
45
+ - fwdx1836: spin object on x-axis from 180 degrees to 360 degrees
46
+ - fwdx09: spin object on x-axis from 0 degrees to 90 degrees
47
+ - fwdx918: spin object on x-axis from 90 degrees to 180 degrees
48
+ - fwdx1827: spin object on x-axis from 180 degrees to 270 degrees
49
+ - fwdx2736: spin object on x-axis from 270 degrees to 360 degrees
50
+ - fwdy018: spin object on y-axis from 0 degrees to 180 degrees
51
+ - fwdy1836: spin object on y-axis from 180 degrees to 360 degrees
52
+ - fwdy09: spin object on y-axis from 0 degrees to 90 degrees
53
+ - fwdy918: spin object on y-axis from 90 degrees to 180 degrees
54
+ - fwdy1827: spin object on y-axis from 180 degrees to 270 degrees
55
+ - fwdy2736: spin object on y-axis from 270 degrees to 360 degrees
56
+ - floatX: float object so is not stationary
57
+ - floatShadow: float object + add shadow
58
+ - pulseSM: pulse object Small
59
+ - pulseMD: pulse object Medium
60
+ - pulseLG: pulse object Large
61
+ - noAnim: no animation place holder
62
+
63
+ <>
64
+
65
+ GLOBAL CONFIG
66
+
67
+ ```typescript
68
+ // EXAMPLE GLOBAL FACE CONFIG
69
+ // This will be applied to all Faces that do not have their own custom config
70
+ const global: object = {
71
+ // // face individual styles (over rides global)
72
+ css: `
73
+ border: 1px solid #fff;
74
+ background: rgb(2,0,36);
75
+ background: linear-gradient(180deg, rgba(255,255,255,.1) 0%, rgba(141,191,249,.7) 100%);
76
+ color:white;
77
+ text-align:center;
78
+ line-height:10;
79
+ backface-visibility: visible;
80
+ font-family: Arial, Helvetica, sans-serif;
81
+ border-radius:5px;
82
+ `,
83
+ body: " ",
84
+ };
85
+ ```
86
+
87
+ <>
88
+
89
+ CUSTOM CONFIG FOR INDIVIDUAL FACES
90
+
91
+ ```typescript
92
+ const custom: object = {
93
+ // // face individual styles (over rides global)
94
+ front: {
95
+ css: ``,
96
+ body: <Login />,
97
+ },
98
+ left: {
99
+ css: `
100
+ border: 1px solid #fff;
101
+ background: rgb(2,0,36);
102
+ color:white;
103
+ text-align: center;
104
+ line-height:8;`
105
+ body: " ",
106
+ },
107
+ right: {
108
+ css: ``,
109
+ body: " ",
110
+ },
111
+ back: {
112
+ css: ``,
113
+ body: <Logout />,
114
+ },
115
+ bottom: {
116
+ css: `
117
+ background-color:rgba(141,191,249,1);
118
+ -webkit-box-shadow: 0px 0px 23px 18px #858585;
119
+ box-shadow: 0px 0px 23px 18px #858585;
120
+ `,
121
+ },
122
+ ```
123
+
124
+ ## Render
125
+
126
+ and
127
+
128
+ ```typescript
129
+ <Cuboid
130
+ width={250}
131
+ height={300}
132
+ depth={250}
133
+ perspective={800}
134
+ perspectiveOrigin='50% 50%'
135
+ zIndex={10}
136
+ anim1Specs={anim1Specs}
137
+ anim2Specs={anim2Specs}
138
+ custom={custom}
139
+ faces={faceprops}
140
+ global={global}
141
+ />
142
+ ```
143
+
144
+ will produce the following
145
+
146
+ ![Logo](https://raw.githubusercontent.com/mdnelles/objs-local/main/img.png?token=GHSAT0AAAAAABQVNJ4VATWQM4SI3LXSTDZWYVDOL7Q)
147
+
148
+ ## Authors
149
+
150
+ - [@mdnelles](https://github.com/mdnelles)
151
+
152
+ ## License
153
+
154
+ [MIT](https://choosealicense.com/licenses/mit/)
@@ -0,0 +1,18 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/env",
5
+ {
6
+ "targets": {
7
+ "edge": "17",
8
+ "firefox": "60",
9
+ "chrome": "67",
10
+ "safari": "11.1"
11
+ },
12
+ "useBuiltIns": "usage",
13
+ "corejs": "3.6.5"
14
+ }
15
+ ],
16
+ "@babel/preset-react"
17
+ ]
18
+ }
@@ -0,0 +1,56 @@
1
+ import React from "react";
2
+ import { AnimWrap } from "./styles/AnimWrap";
3
+ import { SceneStyle } from "./styles/Scene";
4
+ import { ObjProps } from "./Face/face";
5
+ import Face from "./Face";
6
+ import { ObjWrapper } from "./styles/Global";
7
+
8
+ export const Card = (props: ObjProps): any => {
9
+ let {
10
+ anim1Specs,
11
+ anim2Specs,
12
+ width = 5,
13
+ height = 5,
14
+ faces,
15
+ global = {},
16
+ custom = {},
17
+ tranz = (+height / 2) | 0,
18
+ perspective,
19
+ perspectiveOrigin,
20
+ zIndex,
21
+ } = props;
22
+
23
+ const buildFace = (faceType: any): any => {
24
+ return (
25
+ <Face
26
+ width={width}
27
+ height={height}
28
+ depth={0.1}
29
+ faceType={faceType}
30
+ id={faceType}
31
+ tranz={tranz}
32
+ global={global}
33
+ custom={custom}
34
+ />
35
+ );
36
+ };
37
+
38
+ return (
39
+ <SceneStyle
40
+ width={width}
41
+ height={height}
42
+ perspective={perspective}
43
+ perspectiveOrigin={perspectiveOrigin}
44
+ zIndex={zIndex}
45
+ >
46
+ <AnimWrap animSpecs={anim1Specs}>
47
+ <AnimWrap animSpecs={anim2Specs}>
48
+ <ObjWrapper>
49
+ {!!faces && !!faces.front ? buildFace("front") : null}
50
+ {!!faces && !!faces.back ? buildFace("back") : null}
51
+ </ObjWrapper>
52
+ </AnimWrap>
53
+ </AnimWrap>
54
+ </SceneStyle>
55
+ );
56
+ };
@@ -0,0 +1,61 @@
1
+ import React from "react";
2
+ import { AnimWrap } from "./styles/AnimWrap";
3
+ import { SceneStyle } from "./styles/Scene";
4
+ import { ObjProps } from "./Face/face";
5
+ import Face from "./Face";
6
+ import { ObjWrapper } from "./styles/Global";
7
+
8
+ export const Cuboid = (props: ObjProps): any => {
9
+ let {
10
+ anim1Specs,
11
+ anim2Specs,
12
+ width = 5,
13
+ height = 5,
14
+ depth = 5,
15
+ faces,
16
+ global = {},
17
+ custom = {},
18
+ tranz = (+height / 2) | 0,
19
+ perspective,
20
+ perspectiveOrigin,
21
+ zIndex,
22
+ } = props;
23
+
24
+ const buildFace = (faceType: any): any => {
25
+ return (
26
+ <Face
27
+ width={width}
28
+ height={height}
29
+ depth={depth}
30
+ faceType={faceType}
31
+ id={faceType}
32
+ tranz={tranz}
33
+ global={global}
34
+ custom={custom}
35
+ />
36
+ );
37
+ };
38
+
39
+ return (
40
+ <SceneStyle
41
+ width={width}
42
+ height={height}
43
+ perspective={perspective}
44
+ perspectiveOrigin={perspectiveOrigin}
45
+ zIndex={zIndex}
46
+ >
47
+ <AnimWrap animSpecs={anim1Specs}>
48
+ <AnimWrap animSpecs={anim2Specs}>
49
+ <ObjWrapper>
50
+ {!!faces && !!faces.front ? buildFace("front") : null}
51
+ {!!faces && !!faces.right ? buildFace("right") : null}
52
+ {!!faces && !!faces.back ? buildFace("back") : null}
53
+ {!!faces && !!faces.left ? buildFace("left") : null}
54
+ {!!faces && !!faces.top ? buildFace("top") : null}
55
+ {!!faces && !!faces.bottom ? buildFace("bottom") : null}
56
+ </ObjWrapper>
57
+ </AnimWrap>
58
+ </AnimWrap>
59
+ </SceneStyle>
60
+ );
61
+ };
@@ -0,0 +1,39 @@
1
+ export interface FaceProps {
2
+ children?: any;
3
+ depth?: number | any;
4
+ faceType?: any;
5
+ custom?: any;
6
+ global?: any;
7
+ height?: number | string;
8
+ id?: string | number | boolean;
9
+ styles?: object | any;
10
+ tranz: any;
11
+ width?: number | string;
12
+ }
13
+
14
+ export interface ObjProps {
15
+ anim1Specs?: object | undefined;
16
+ anim2Specs?: object | undefined;
17
+ children: any;
18
+ depth?: number;
19
+ global?: { border?: string; bgc?: string; opac?: number | string } | any;
20
+ faces?:
21
+ | {
22
+ front: boolean;
23
+ back: boolean;
24
+ left: boolean;
25
+ right: boolean;
26
+ top: boolean;
27
+ bottom: boolean;
28
+ }
29
+ | undefined;
30
+
31
+ height?: number | string;
32
+ custom?: object | string | undefined;
33
+ perspective?: string | number | undefined;
34
+ perspectiveOrigin?: string | undefined;
35
+ tranz?: number | undefined;
36
+ txt?: string | any;
37
+ width?: number;
38
+ zIndex?: number | undefined;
39
+ }
@@ -0,0 +1,85 @@
1
+ import styled from "styled-components";
2
+ import React from "react";
3
+ import { FaceProps } from "./face";
4
+
5
+ const Face = (props: FaceProps): JSX.Element => {
6
+ let {
7
+ depth = 10,
8
+ faceType,
9
+ global = {},
10
+ height = 10,
11
+ custom = false,
12
+ tranz = 80,
13
+ width = 100,
14
+ } = props;
15
+
16
+ let transform;
17
+ let styles =
18
+ !!custom[faceType] && !!custom[faceType].css
19
+ ? custom[faceType].css
20
+ : global.css;
21
+ const body =
22
+ !!custom[faceType] && !!custom[faceType].body
23
+ ? custom[faceType].body
24
+ : global.body;
25
+ if (faceType === "bottom") {
26
+ tranz = +height - +depth / 2;
27
+ height = +depth;
28
+ transform = `transform: rotateX(-90deg) translateZ(${tranz}px);`;
29
+ //styles = !!custom["top"] ? custom : global;
30
+ } else if (faceType === "top") {
31
+ height = +depth;
32
+ if (!!depth) tranz = +depth / 2;
33
+ transform = `transform: rotateX(90deg) translateZ(${tranz}px);`;
34
+ } else if (faceType === "front") {
35
+ if (!!depth) tranz = +depth / 2;
36
+ transform = `transform: rotateY(0deg) translateZ(${tranz}px);`;
37
+ } else if (faceType === "back") {
38
+ if (!!depth) tranz = +depth / 2;
39
+ transform = `transform: rotateY(180deg) translateZ(${tranz}px);`;
40
+ } else if (faceType === "right") {
41
+ if (height > width && !depth) {
42
+ tranz = -(+height / 2 - +width);
43
+ width = +height;
44
+ } else if (width > height && !depth) {
45
+ tranz = +height / 2;
46
+ height = +width;
47
+ } else {
48
+ tranz = +width - +depth / 2;
49
+ width = +depth;
50
+ }
51
+ transform = `transform: rotateY(90deg) translateZ(${tranz}px);`;
52
+ // topr is to of Ribbon which points back
53
+ } else if (faceType === "topr") {
54
+ height = +depth;
55
+ if (!!depth) tranz = +depth / 2;
56
+ let offset = depth / 2;
57
+ transform = `transform: rotateX(90deg) translateZ(${tranz}px ); `;
58
+ } else {
59
+ if (height > width && !depth) {
60
+ tranz = -(+height / 2 - +width);
61
+ width = +height;
62
+ } else if (width > height && !depth) {
63
+ tranz = +height / 2;
64
+ height = +width;
65
+ } else {
66
+ tranz = +depth / 2;
67
+ width = +depth;
68
+ }
69
+ transform = `transform: rotateY(-90deg) translateZ(${tranz}px);`;
70
+ }
71
+
72
+ const BackFlip: any = styled.section``;
73
+
74
+ const Specs: any = styled.section`
75
+ ${styles}
76
+ width: ${width}px;
77
+ position: absolute;
78
+ height: ${height}px;
79
+ ${transform};
80
+ `;
81
+
82
+ return <Specs>{body}</Specs>;
83
+ };
84
+
85
+ export default Face;
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import { AnimWrap } from "./styles/AnimWrap";
3
+ import { SceneStyle } from "./styles/Scene";
4
+ import { ObjProps } from "./Face/face";
5
+ import Face from "./Face";
6
+ import { ObjWrapper } from "./styles/Global";
7
+
8
+ export const Ribbon = (props: ObjProps): any => {
9
+ let {
10
+ anim1Specs,
11
+ anim2Specs,
12
+ width = 5,
13
+ height = 5,
14
+ depth = 5,
15
+ faces,
16
+ global = {},
17
+ custom = {},
18
+ tranz = (+height / 2) | 0,
19
+ perspective,
20
+ perspectiveOrigin,
21
+ zIndex,
22
+ } = props;
23
+
24
+ const buildFace = (faceType: any): any => {
25
+ return (
26
+ <Face
27
+ width={width}
28
+ height={height}
29
+ depth={depth}
30
+ faceType={faceType}
31
+ id={faceType}
32
+ tranz={tranz}
33
+ global={global}
34
+ custom={custom}
35
+ />
36
+ );
37
+ };
38
+
39
+ return (
40
+ <SceneStyle
41
+ width={width}
42
+ height={height}
43
+ perspective={perspective}
44
+ perspectiveOrigin={perspectiveOrigin}
45
+ zIndex={zIndex}
46
+ >
47
+ <AnimWrap animSpecs={anim1Specs}>
48
+ <AnimWrap animSpecs={anim2Specs}>
49
+ <ObjWrapper>
50
+ {!!faces && !!faces.bottom ? buildFace("bottom") : null}
51
+ {!!faces && !!faces.back ? buildFace("back") : null}
52
+ {!!faces && !!faces.top ? buildFace("topr") : null}
53
+ </ObjWrapper>
54
+ </AnimWrap>
55
+ </AnimWrap>
56
+ </SceneStyle>
57
+ );
58
+ };
@@ -0,0 +1,16 @@
1
+ export interface AnimStylesProps {
2
+ children?: any;
3
+ animSpecs?: any;
4
+ }
5
+ export interface AnimSpecsProps {
6
+ border?: string | undefined;
7
+ degreesHi?: number | undefined;
8
+ degreesLow?: number | undefined;
9
+ delay: any;
10
+ direction?: string | undefined;
11
+ duration?: number | string | undefined;
12
+ fillMode?: string | undefined;
13
+ iterationCount?: number | string | undefined;
14
+ name?: string | undefined;
15
+ timing?: string | undefined;
16
+ }