diff --git a/README.md b/README.md index f12c148..a021ddc 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,15 @@ A premium, customizable, and interactive 3D-style Bitcoin logo component for Vue 3. +**Live Demo:** [https://bitcoin-logo.7u.pl/](https://bitcoin-logo.7u.pl/) + ## 🚀 Features -- **Interactive 3D Rotation**: Tilt and rotate the logo with mouse or touch. -- **Inertia & Momentum**: Smooth rotation that continues after release. -- **Customizable**: Control size, colors, and animation speed via props. -- **Premium Aesthetics**: Clean SVG-based design with subtle gradients and shadows. +- **3 Rotation Modes**: Auto-rotate, Interactive (drag & throw), and Controlled. +- **Physics-based Inertia**: Smooth deceleration in interactive mode. +- **Fully Customizable**: Adjust size, colors, stroke, animation speed, and more. +- **Lightweight**: Built with Vue 3 and SVG, no heavy 3D libraries. +- **Responsive**: Centers perfectly in any container. ## 📦 Installation @@ -20,30 +23,114 @@ npm install @gkucmierz/bitcoin-logo ## 🛠 Usage +Import the component and its styles. + ```vue ``` +## 📖 API + ### Props | Prop | Type | Default | Description | | --- | --- | --- | --- | -| `size` | `Number` | `256` | The width and height of the logo in pixels. | -| `symbolColor` | `String` | `'#f7931a'` | The color of the Bitcoin symbol. | -| `autoRotate` | `Boolean` | `true` | Whether the logo should rotate automatically. | -| `rotationDuration` | `Number` | `10` | Duration of one full rotation in seconds. | -| `inertia` | `Boolean` | `true` | Enable inertia during manual interaction. | +| `mode` | `String` | `'interactive'` | Operation mode: `'auto'`, `'interactive'`, or `'controlled'`. | +| `size` | `Number` | `200` | Size of the logo in pixels. | +| `symbolColor` | `String` | `'#fff'` | Color of the Bitcoin symbol (B) and stroke. | +| `strokeWidth` | `Number` | `5` | Thickness of the outer stroke. | +| `duration` | `Number` | `4` | **(Auto mode)** Duration of one full rotation in seconds. | +| `easing` | `String` | `'linear'` | **(Auto mode)** CSS easing function (e.g. `'ease-in-out'`). | +| `friction` | `Number` | `0.98` | **(Interactive mode)** Inertia friction factor (0.0 - 1.0). | +| `rotation` | `Number` | `0` | **(Controlled mode)** The rotation angle in degrees. Can be used with `v-model:rotation`. | + +### Modes + +#### 1. `interactive` (Default) +The user can drag the logo to rotate it. Releasing it with velocity triggers inertia. +- Emits `update:rotation` event with the current angle. +- `friction` prop controls how fast it stops spinning. + +#### 2. `auto` +The logo rotates continuously using CSS animations. +- `duration` controls speed. +- `easing` controls animation curve. +- **Note:** Does not emit rotation events. +- **Easing Options:** `linear`, `ease`, `ease-in`, `ease-out`, `ease-in-out`. + + +#### 3. `controlled` +The rotation is strictly determined by the `rotation` prop. +- Use this to link rotation to scroll position, mouse movement elsewhere, or other external state. + +### Events + +| Event | Payload | Description | +| --- | --- | --- | +| `update:rotation` | `Number` | Emitted when rotation changes in `'interactive'` mode. | + +## 💡 Examples + +### Interactive Mode (with v-model) + +```vue + + + +``` + +### Auto Mode + +```vue + +``` + +### Controlled Mode + +```vue + + + +``` --- diff --git a/index.html b/index.html index 2bbcb43..89615e0 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,20 @@ ₿ Bitcoin 3D - Premium SVG Animation + + + + + + + + + + + diff --git a/public/preview.png b/public/preview.png new file mode 100644 index 0000000..eac1e68 Binary files /dev/null and b/public/preview.png differ diff --git a/src/components/BitcoinLogo.vue b/src/components/BitcoinLogo.vue index 4310884..33d9d9a 100644 --- a/src/components/BitcoinLogo.vue +++ b/src/components/BitcoinLogo.vue @@ -151,12 +151,10 @@ const symbolShape = 'M72.0434988 42.8770472c0.9951968,-6.6540344 -4.0707264,-10. font-size: v-bind("props.size + 'px'"); width: 1em; height: 1em; - margin: auto; position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); /* background: rgba(255, 0, 0, 0.2); Bounding rect debug */ display: flex; justify-content: center; diff --git a/src/style.css b/src/style.css index 57eff8c..7c78fca 100644 --- a/src/style.css +++ b/src/style.css @@ -62,4 +62,18 @@ p { padding: 3rem; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); display: inline-block; -} \ No newline at end of file + box-sizing: border-box; + max-width: 100%; +} + +@media (max-width: 640px) { + #app { + padding: 1rem; + } + + .glass-card { + padding: 1.5rem; + width: 100%; + border-radius: 16px; + } +}