Skip to content

Commit dbe9207

Browse files
authored
fix: migrated Cube component to TailwindCSS
1 parent eeae7a9 commit dbe9207

2 files changed

Lines changed: 22 additions & 56 deletions

File tree

src/components/Cube/Cube.jsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
import PropTypes from "prop-types";
33
import { Component } from "react";
44

5-
// Load Styling
6-
import "./Cube.scss";
7-
85
export default class Cube extends Component {
96
static propTypes = {
107
hover: PropTypes.bool,
@@ -44,14 +41,15 @@ export default class Cube extends Component {
4441
>
4542
<span
4643
ref={(ref) => (this.container = ref)}
47-
className={`cube cube--${theme}`}
44+
className={`cube cube--${theme} relative block [transform-style:preserve-3d]`}
4845
style={{
4946
width: `${depth}px`,
5047
paddingBottom: `${depth * 0.5}px`,
48+
transform: "rotateX(-35.5deg) rotateY(45deg)",
5149
}}
5250
>
5351
<figure
54-
className="cube__outer"
52+
className="cube__outer inline-block [transform-style:preserve-3d] transition-transform duration-1000"
5553
style={{
5654
width: `${depth}px`,
5755
height: `${depth}px`,
@@ -65,7 +63,7 @@ export default class Cube extends Component {
6563
{this._getFaces("outer")}
6664
</figure>
6765
<figure
68-
className="cube__inner"
66+
className="cube__inner absolute -top-[2px] left-0 inline-block [transform-style:preserve-3d] transition-transform duration-1000"
6967
style={{
7068
width: `${depth}px`,
7169
height: `${depth}px`,
@@ -172,6 +170,15 @@ export default class Cube extends Component {
172170
},
173171
};
174172

173+
// Base classes applied to all faces
174+
const baseFaceClasses = "absolute w-full h-full border-white";
175+
176+
// Distinguish styles for inner vs outer faces natively via Tailwind
177+
const isOuter = type === "outer";
178+
const variantClasses = isOuter
179+
? "border bg-blue-200/50 transition-[border-width] duration-200 delay-200"
180+
: "border-2 bg-blue-400";
181+
175182
return [
176183
"rotateX(0deg)",
177184
"rotateX(-90deg)",
@@ -180,20 +187,19 @@ export default class Cube extends Component {
180187
"rotateY(90deg)",
181188
"rotateY(180deg)",
182189
].map((rotation, i) => {
183-
const borderStyles =
184-
type === "outer"
185-
? {
186-
borderTopWidth: borderWidthMap[i].top[iteration],
187-
borderRightWidth: borderWidthMap[i].right[iteration],
188-
borderBottomWidth: borderWidthMap[i].bottom[iteration],
189-
borderLeftWidth: borderWidthMap[i].left[iteration],
190-
}
191-
: {};
190+
const borderStyles = isOuter
191+
? {
192+
borderTopWidth: borderWidthMap[i].top[iteration],
193+
borderRightWidth: borderWidthMap[i].right[iteration],
194+
borderBottomWidth: borderWidthMap[i].bottom[iteration],
195+
borderLeftWidth: borderWidthMap[i].left[iteration],
196+
}
197+
: {};
192198

193199
return (
194200
<section
195201
key={i}
196-
className="cube__face"
202+
className={`cube__face ${baseFaceClasses} ${variantClasses}`}
197203
style={{
198204
transform: `${rotation} translateZ(${this.props.depth / 2}px)`,
199205
...borderStyles,

src/components/Cube/Cube.scss

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)