anim-3d-obj 1.1.13 → 1.1.15
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.
- package/.eslintignore +2 -0
- package/.eslintrc +32 -0
- package/.prettierrc.json +10 -0
- package/README.md +9 -10
- package/jestconfig.json +8 -0
- package/package.json +63 -47
- package/src/components/Card.tsx +55 -0
- package/src/components/Cuboid.tsx +58 -109
- package/src/components/Faces/Face.tsx +66 -99
- package/src/components/Faces/FaceInter.d.ts +34 -65
- package/src/components/Ribbon.tsx +57 -0
- package/src/components/styles/Anim.d.ts +14 -9
- package/src/components/styles/AnimWrap.tsx +83 -70
- package/src/components/styles/Anims.ts +164 -79
- package/src/components/styles/Global.ts +7 -0
- package/src/components/styles/Scene.tsx +24 -27
- package/src/index.ts +9 -0
- package/tests/common.test.tsx +29 -0
- package/tsconfig.json +27 -24
- package/img.png +0 -0
- package/src/App.css +0 -810
- package/src/App.test.tsx +0 -10
- package/src/App.tsx +0 -83
- package/src/components/index.ts +0 -2
- package/src/index.tsx +0 -19
- package/src/reportWebVitals.ts +0 -15
- package/src/setupTests.ts +0 -5
package/.eslintignore
ADDED
package/.eslintrc
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"extends": [
|
|
4
|
+
"prettier",
|
|
5
|
+
"plugin:prettier/recommended",
|
|
6
|
+
"eslint:recommended",
|
|
7
|
+
"plugin:react/recommended",
|
|
8
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
9
|
+
"plugin:@typescript-eslint/recommended"
|
|
10
|
+
],
|
|
11
|
+
"parser": "@typescript-eslint/parser",
|
|
12
|
+
"plugins": ["@typescript-eslint", "prettier", "react", "react-hooks"],
|
|
13
|
+
"rules": {
|
|
14
|
+
"react-hooks/rules-of-hooks": "error",
|
|
15
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
16
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
17
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
18
|
+
"@typescript-eslint/no-explicit-any": "off"
|
|
19
|
+
},
|
|
20
|
+
"settings": {
|
|
21
|
+
"react": {
|
|
22
|
+
"version": "detect"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"env": {
|
|
26
|
+
"browser": true,
|
|
27
|
+
"node": true
|
|
28
|
+
},
|
|
29
|
+
"globals": {
|
|
30
|
+
"JSX": true
|
|
31
|
+
}
|
|
32
|
+
}
|
package/.prettierrc.json
ADDED
package/README.md
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
1
|
# React Typescript Cuboid Builder
|
|
3
2
|
|
|
4
3
|
This project allows a user to create Cuboids of any size simply by entering a set of parameters.
|
|
5
4
|
The program does the leg work with regard to calculating translationZ depth and config on the fly.
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
6
|
## Deployment
|
|
10
7
|
|
|
11
8
|
Install sequence
|
|
@@ -17,6 +14,7 @@ npm run start
|
|
|
17
14
|
```
|
|
18
15
|
|
|
19
16
|
## Examples
|
|
17
|
+
|
|
20
18
|
All sided simple https://codesandbox.io/s/anim-3d-obj-all-sides-simple-sdy1q0
|
|
21
19
|
|
|
22
20
|
Two sided simple https://codesandbox.io/s/anim-3d-obj-2-sides-simple-9wognm
|
|
@@ -27,8 +25,7 @@ speed wobble(y) 3 sides https://codesandbox.io/s/anim-3d-obj-3-sides-wobble-y-ax
|
|
|
27
25
|
|
|
28
26
|
## Authors
|
|
29
27
|
|
|
30
|
-
-
|
|
31
|
-
|
|
28
|
+
- [@mdnelles](https://github.com/mdnelles)
|
|
32
29
|
|
|
33
30
|
## Demo
|
|
34
31
|
|
|
@@ -65,7 +62,8 @@ const indivStyles: object = {
|
|
|
65
62
|
};
|
|
66
63
|
```
|
|
67
64
|
|
|
68
|
-
and
|
|
65
|
+
and
|
|
66
|
+
|
|
69
67
|
```
|
|
70
68
|
<Cuboid
|
|
71
69
|
width={260}
|
|
@@ -88,9 +86,10 @@ will produce the following
|
|
|
88
86
|
|
|
89
87
|
##Face Format
|
|
90
88
|
for things like `background-image: url("myImg.png");` they can be done in `moreStyles` argument.
|
|
89
|
+
|
|
91
90
|
```
|
|
92
91
|
const Specs: any = styled.div`
|
|
93
|
-
opacity: ${
|
|
92
|
+
opacity: ${opac ? opac : globalStyles.opac};
|
|
94
93
|
position: ${position};
|
|
95
94
|
left: ${left};
|
|
96
95
|
margin: ${margin};
|
|
@@ -98,9 +97,9 @@ for things like `background-image: url("myImg.png");` they can be done in `moreS
|
|
|
98
97
|
width: ${width}px;
|
|
99
98
|
font-family: ${fontFamily};
|
|
100
99
|
height: ${height}px;
|
|
101
|
-
background-color: ${
|
|
102
|
-
border: ${
|
|
103
|
-
backface-visibility: ${
|
|
100
|
+
background-color: ${bgc ? bgc : globalStyles.bgc};
|
|
101
|
+
border: ${border ? border : globalStyles.border};
|
|
102
|
+
backface-visibility: ${bfv ? bfv : globalStyles.bfv};
|
|
104
103
|
${transform}
|
|
105
104
|
top: ${top};
|
|
106
105
|
${moreStyles}
|
package/jestconfig.json
ADDED
package/package.json
CHANGED
|
@@ -1,49 +1,65 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
"name": "anim-3d-obj",
|
|
3
|
+
"version": "1.1.15",
|
|
4
|
+
"private": false,
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@reduxjs/toolkit": "^1.8.4",
|
|
7
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
8
|
+
"@testing-library/user-event": "^14.4.3",
|
|
9
|
+
"@types/node": "^18.7.3",
|
|
10
|
+
"@types/react": "^18.0.17",
|
|
11
|
+
"@types/react-dom": "^18.0.6",
|
|
12
|
+
"react": "^18.2.0",
|
|
13
|
+
"react-dom": "^18.2.0",
|
|
14
|
+
"react-redux": "^8.0.2",
|
|
15
|
+
"react-scripts": "5.0.1",
|
|
16
|
+
"styled-components": "^5.3.5",
|
|
17
|
+
"typescript": "^4.7.4",
|
|
18
|
+
"web-vitals": "^2.1.4"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"buildOLD": "react-scripts build",
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"build4jest": "npm build:esm && npm build:cjs",
|
|
24
|
+
"build:esm": "tsc",
|
|
25
|
+
"build:cjs": "tsc --module commonjs --outDir dist/cjs",
|
|
26
|
+
"lint": "eslint \"{**/*,*}.{js,ts,jsx,tsx}\"",
|
|
27
|
+
"prettier": "prettier --write \"{src,tests,example/src}/**/*.{js,ts,jsx,tsx}\"",
|
|
28
|
+
"test": "jest --config jestconfig.json"
|
|
29
|
+
},
|
|
30
|
+
"eslintConfig": {
|
|
31
|
+
"extends": [
|
|
32
|
+
"react-app",
|
|
33
|
+
"react-app/jest"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"browserslist": {
|
|
37
|
+
"production": [
|
|
38
|
+
">0.2%",
|
|
39
|
+
"not dead",
|
|
40
|
+
"not op_mini all"
|
|
41
|
+
],
|
|
42
|
+
"development": [
|
|
43
|
+
"last 1 chrome version",
|
|
44
|
+
"last 1 firefox version",
|
|
45
|
+
"last 1 safari version"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@testing-library/react": "^13.3.0",
|
|
50
|
+
"@types/jest": "^28.1.6",
|
|
51
|
+
"@types/styled-components": "^5.1.26",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
53
|
+
"@typescript-eslint/parser": "^5.33.0",
|
|
54
|
+
"eslint": "^8.22.0",
|
|
55
|
+
"eslint-config-prettier": "^8.5.0",
|
|
56
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
57
|
+
"eslint-plugin-react": "^7.30.1",
|
|
58
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
59
|
+
"jest": "^28.1.3",
|
|
60
|
+
"jest-canvas-mock": "^2.4.0",
|
|
61
|
+
"jest-environment-jsdom": "^28.1.3",
|
|
62
|
+
"prettier": "^2.7.1",
|
|
63
|
+
"ts-jest": "^28.0.7"
|
|
64
|
+
}
|
|
49
65
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { AnimWrap } from './styles/AnimWrap'
|
|
2
|
+
import { SceneStyle } from './styles/Scene'
|
|
3
|
+
import { ObjProps } from './Faces/FaceInter'
|
|
4
|
+
import Face from './Faces/Face'
|
|
5
|
+
import { ObjWrapper } from './styles/Global'
|
|
6
|
+
|
|
7
|
+
export const Card = (props: ObjProps): any => {
|
|
8
|
+
const {
|
|
9
|
+
anim1Specs,
|
|
10
|
+
anim2Specs,
|
|
11
|
+
width = 5,
|
|
12
|
+
height = 5,
|
|
13
|
+
faces,
|
|
14
|
+
global = {},
|
|
15
|
+
custom = {},
|
|
16
|
+
tranz = (+height / 2) | 0,
|
|
17
|
+
perspective,
|
|
18
|
+
perspectiveOrigin,
|
|
19
|
+
zIndex,
|
|
20
|
+
} = props
|
|
21
|
+
|
|
22
|
+
const buildFace = (faceType: any): any => {
|
|
23
|
+
return (
|
|
24
|
+
<Face
|
|
25
|
+
width={width}
|
|
26
|
+
height={height}
|
|
27
|
+
depth={0.1}
|
|
28
|
+
faceType={faceType}
|
|
29
|
+
id={faceType}
|
|
30
|
+
tranz={tranz}
|
|
31
|
+
global={global}
|
|
32
|
+
custom={custom}
|
|
33
|
+
/>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<SceneStyle
|
|
39
|
+
width={width}
|
|
40
|
+
height={height}
|
|
41
|
+
perspective={perspective}
|
|
42
|
+
perspectiveOrigin={perspectiveOrigin}
|
|
43
|
+
zIndex={zIndex}
|
|
44
|
+
>
|
|
45
|
+
<AnimWrap animSpecs={anim1Specs}>
|
|
46
|
+
<AnimWrap animSpecs={anim2Specs}>
|
|
47
|
+
<ObjWrapper>
|
|
48
|
+
{faces && faces.front ? buildFace('front') : null}
|
|
49
|
+
{faces && faces.back ? buildFace('back') : null}
|
|
50
|
+
</ObjWrapper>
|
|
51
|
+
</AnimWrap>
|
|
52
|
+
</AnimWrap>
|
|
53
|
+
</SceneStyle>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -1,112 +1,61 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
//import React from 'react'
|
|
2
|
+
import { AnimWrap } from './styles/AnimWrap'
|
|
3
|
+
import { SceneStyle } from './styles/Scene'
|
|
4
|
+
import { ObjProps } from './Faces/FaceInter'
|
|
5
|
+
import Face from './Faces/Face'
|
|
6
|
+
import { ObjWrapper } from './styles/Global'
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export const Cuboid = (props: ObjProps): any => {
|
|
9
|
+
const {
|
|
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
|
|
14
23
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
}
|
|
23
38
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
width
|
|
27
|
-
height
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
tranz={tranz}
|
|
48
|
-
// if specified opac / bgc / border will over-ride globalStyles
|
|
49
|
-
globalStyles={globalStyles}
|
|
50
|
-
indivStyles={indivStyles}
|
|
51
|
-
>
|
|
52
|
-
<div
|
|
53
|
-
style={{
|
|
54
|
-
color,
|
|
55
|
-
fontWeight,
|
|
56
|
-
textShadow,
|
|
57
|
-
lineHeight,
|
|
58
|
-
fontSize,
|
|
59
|
-
fontFamily,
|
|
60
|
-
textAlign,
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
{child}
|
|
64
|
-
</div>
|
|
65
|
-
</Face>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<SceneStyle
|
|
71
|
-
width={width}
|
|
72
|
-
height={height}
|
|
73
|
-
perspectiveOrigin={perspectiveOrigin}
|
|
74
|
-
zIndex={zIndex}
|
|
75
|
-
>
|
|
76
|
-
<AnimWrap
|
|
77
|
-
duration={animSpecs.anim1duration}
|
|
78
|
-
iterationCount={animSpecs.anim1count}
|
|
79
|
-
animName={animSpecs.anim1}
|
|
80
|
-
animLow={animSpecs.anim1low}
|
|
81
|
-
animHi={animSpecs.anim1hi}
|
|
82
|
-
animDirection={animSpecs.anim1direction}
|
|
83
|
-
>
|
|
84
|
-
<AnimWrap
|
|
85
|
-
duration={animSpecs.anim2duration}
|
|
86
|
-
iterationCount={animSpecs.anim2count}
|
|
87
|
-
animName={animSpecs.anim2}
|
|
88
|
-
animLow={animSpecs.anim2low}
|
|
89
|
-
animHi={animSpecs.anim2hi}
|
|
90
|
-
animDirection={animSpecs.anim2direction}
|
|
91
|
-
>
|
|
92
|
-
<CuboidWrapper>
|
|
93
|
-
{!!faces && !!faces.front
|
|
94
|
-
? buildFace("front", "FRONT")
|
|
95
|
-
: null}
|
|
96
|
-
{!!faces && !!faces.right
|
|
97
|
-
? buildFace("right", "RIGHT")
|
|
98
|
-
: null}
|
|
99
|
-
{!!faces && !!faces.back ? buildFace("back", "BACK") : null}
|
|
100
|
-
{!!faces && !!faces.left ? buildFace("left", "LEFT") : null}
|
|
101
|
-
{!!faces && !!faces.top ? buildFace("top", "TOP") : null}
|
|
102
|
-
{!!faces && !!faces.bottom
|
|
103
|
-
? buildFace("bottom", "BOTTOM")
|
|
104
|
-
: null}
|
|
105
|
-
</CuboidWrapper>
|
|
106
|
-
</AnimWrap>
|
|
107
|
-
</AnimWrap>
|
|
108
|
-
</SceneStyle>
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export default Cuboid;
|
|
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
|
+
}
|
|
@@ -1,105 +1,72 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
import
|
|
3
|
-
import { FaceProps, VarsProps } from "./FaceInter";
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import { FaceProps } from './FaceInter'
|
|
4
3
|
|
|
5
|
-
const Face = (props: FaceProps):
|
|
6
|
-
|
|
7
|
-
bfv = false,
|
|
8
|
-
bgc = false,
|
|
9
|
-
border = false,
|
|
10
|
-
children,
|
|
11
|
-
depth = 10,
|
|
12
|
-
faceType,
|
|
13
|
-
globalStyles = {},
|
|
14
|
-
fontFamily,
|
|
15
|
-
height = 10,
|
|
16
|
-
indivStyles = false,
|
|
17
|
-
left = 0,
|
|
18
|
-
margin = 0,
|
|
19
|
-
opac = false,
|
|
20
|
-
padding = 20,
|
|
21
|
-
position = "absolute",
|
|
22
|
-
top = 0,
|
|
23
|
-
tranz = 80,
|
|
24
|
-
width = 100,
|
|
25
|
-
} = props;
|
|
4
|
+
const Face = (props: FaceProps): JSX.Element => {
|
|
5
|
+
let { height = 10, tranz = 80, width = 100 } = props
|
|
26
6
|
|
|
27
|
-
|
|
7
|
+
const { depth = 10, faceType, global = {}, custom = false } = props
|
|
28
8
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
let transform
|
|
10
|
+
const styles = custom[faceType] && custom[faceType].css ? custom[faceType].css : global.css
|
|
11
|
+
const body = custom[faceType] && custom[faceType].body ? custom[faceType].body : global.body
|
|
12
|
+
if (faceType === 'bottom') {
|
|
13
|
+
tranz = +height - +depth / 2
|
|
14
|
+
height = +depth
|
|
15
|
+
transform = `transform: rotateX(-90deg) translateZ(${tranz}px);`
|
|
16
|
+
//styles = custom["top"] ? custom : global;
|
|
17
|
+
} else if (faceType === 'top') {
|
|
18
|
+
height = +depth
|
|
19
|
+
if (depth) tranz = +depth / 2
|
|
20
|
+
transform = `transform: rotateX(90deg) translateZ(${tranz}px);`
|
|
21
|
+
} else if (faceType === 'front') {
|
|
22
|
+
if (depth) tranz = +depth / 2
|
|
23
|
+
transform = `transform: rotateY(0deg) translateZ(${tranz}px);`
|
|
24
|
+
} else if (faceType === 'back') {
|
|
25
|
+
if (depth) tranz = +depth / 2
|
|
26
|
+
transform = `transform: rotateY(180deg) translateZ(${tranz}px);`
|
|
27
|
+
} else if (faceType === 'right') {
|
|
28
|
+
if (height > width && !depth) {
|
|
29
|
+
tranz = -(+height / 2 - +width)
|
|
30
|
+
width = +height
|
|
31
|
+
} else if (width > height && !depth) {
|
|
32
|
+
tranz = +height / 2
|
|
33
|
+
height = +width
|
|
34
|
+
} else {
|
|
35
|
+
tranz = +width - +depth / 2
|
|
36
|
+
width = +depth
|
|
37
|
+
}
|
|
38
|
+
transform = `transform: rotateY(90deg) translateZ(${tranz}px);`
|
|
39
|
+
// topr is to of Ribbon which points back
|
|
40
|
+
} else if (faceType === 'topr') {
|
|
41
|
+
height = +depth
|
|
42
|
+
if (depth) tranz = +depth / 2
|
|
43
|
+
//let offset = depth / 2;
|
|
44
|
+
transform = `transform: rotateX(90deg) translateZ(${tranz}px ); `
|
|
45
|
+
} else {
|
|
46
|
+
if (height > width && !depth) {
|
|
47
|
+
tranz = -(+height / 2 - +width)
|
|
48
|
+
width = +height
|
|
49
|
+
} else if (width > height && !depth) {
|
|
50
|
+
tranz = +height / 2
|
|
51
|
+
height = +width
|
|
52
|
+
} else {
|
|
53
|
+
tranz = +depth / 2
|
|
54
|
+
width = +depth
|
|
55
|
+
}
|
|
56
|
+
transform = `transform: rotateY(-90deg) translateZ(${tranz}px);`
|
|
57
|
+
}
|
|
38
58
|
|
|
39
|
-
|
|
40
|
-
tranz = +height - +depth / 2;
|
|
41
|
-
height = +depth;
|
|
42
|
-
transform = `transform: rotateX(-90deg) translateZ(${tranz}px);`;
|
|
43
|
-
setCustomVars(indivStyles["bottom"], props);
|
|
44
|
-
} else if (faceType === "top") {
|
|
45
|
-
height = +depth;
|
|
46
|
-
if (!!depth) tranz = +depth / 2;
|
|
47
|
-
transform = `transform: rotateX(90deg) translateZ(${tranz}px);`;
|
|
48
|
-
setCustomVars(indivStyles["top"], props);
|
|
49
|
-
} else if (faceType === "front") {
|
|
50
|
-
if (!!depth) tranz = +depth / 2;
|
|
51
|
-
transform = `transform: rotateY(0deg) translateZ(${tranz}px);`;
|
|
52
|
-
setCustomVars(indivStyles["front"], props);
|
|
53
|
-
} else if (faceType === "back") {
|
|
54
|
-
if (!!depth) tranz = +depth / 2;
|
|
55
|
-
transform = `transform: rotateY(180deg) translateZ(${tranz}px);`;
|
|
56
|
-
setCustomVars(indivStyles["back"], props);
|
|
57
|
-
} else if (faceType === "right") {
|
|
58
|
-
if (height > width && !depth) {
|
|
59
|
-
tranz = -(+height / 2 - +width);
|
|
60
|
-
width = +height;
|
|
61
|
-
} else if (width > height && !depth) {
|
|
62
|
-
tranz = +height / 2;
|
|
63
|
-
height = +width;
|
|
64
|
-
} else {
|
|
65
|
-
tranz = +width - +depth / 2;
|
|
66
|
-
width = +depth;
|
|
67
|
-
}
|
|
68
|
-
transform = `transform: rotateY(90deg) translateZ(${tranz}px);`;
|
|
69
|
-
setCustomVars(indivStyles["right"], props);
|
|
70
|
-
} else {
|
|
71
|
-
if (height > width && !depth) {
|
|
72
|
-
console.log(1);
|
|
73
|
-
tranz = -(+height / 2 - +width);
|
|
74
|
-
width = +height;
|
|
75
|
-
} else if (width > height && !depth) {
|
|
76
|
-
console.log(2);
|
|
77
|
-
tranz = +height / 2;
|
|
78
|
-
height = +width;
|
|
79
|
-
} else {
|
|
80
|
-
tranz = +depth / 2;
|
|
81
|
-
width = +depth;
|
|
82
|
-
}
|
|
83
|
-
transform = `transform: rotateY(-90deg) translateZ(${tranz}px);`;
|
|
84
|
-
setCustomVars(indivStyles["left"], props);
|
|
85
|
-
}
|
|
59
|
+
//const BackFlip: any = styled.section``;
|
|
86
60
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
font-family: ${fontFamily};
|
|
95
|
-
height: ${height}px;
|
|
96
|
-
background-color: ${!!bgc ? bgc : globalStyles.bgc};
|
|
97
|
-
border: ${!!border ? border : globalStyles.border};
|
|
98
|
-
backface-visibility: ${!!bfv ? bfv : globalStyles.bfv};
|
|
99
|
-
${transform}
|
|
100
|
-
top: ${top};
|
|
101
|
-
`;
|
|
102
|
-
return <Specs>{children}</Specs>;
|
|
103
|
-
};
|
|
61
|
+
const Specs: any = styled.section`
|
|
62
|
+
${styles}
|
|
63
|
+
width: ${width}px;
|
|
64
|
+
position: absolute;
|
|
65
|
+
height: ${height}px;
|
|
66
|
+
${transform};
|
|
67
|
+
`
|
|
104
68
|
|
|
105
|
-
|
|
69
|
+
return <Specs>{body}</Specs>
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default Face
|