Skip to content

Commit 2cd3915

Browse files
committed
Release version 1.0.0
0 parents  commit 2cd3915

10 files changed

Lines changed: 3974 additions & 0 deletions

File tree

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
7+
# Logs
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
12+
# System files
13+
.DS_Store
14+
15+
# Demo build files
16+
demo/
17+
18+
# Presentation page
19+
index.html

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [1.0.0] - 2025-11-19
6+
7+
### Added
8+
- Initial release of **DepthText**.
9+
- High-performance 3D layered text rendering.
10+
- Interactive depth effects with pointer and scroll events.
11+
- Configurable depth, layers, direction, and rotation.
12+
- Automatic initialization via `data-depth` attributes.
13+
- TypeScript support with full type definitions.
14+
- ESM, CJS, and IIFE (Global) build artifacts.
15+
- Motion smoothing (lerp) for fluid pointer interaction.
16+
- Accessibility features (`aria-hidden` layers).

CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Contributing to DepthText
2+
3+
Thank you for your interest in contributing to DepthText! We welcome contributions from everyone.
4+
5+
## How to Contribute
6+
7+
1. **Fork the repository** on GitHub.
8+
2. **Clone your fork** locally.
9+
3. **Install dependencies**: `npm install`
10+
4. **Create a branch** for your feature or fix: `git checkout -b my-feature`
11+
5. **Make your changes**.
12+
6. **Run the build** to ensure everything works: `npm run build`
13+
7. **Test the demo**: Open `demo/index.html` in your browser.
14+
8. **Commit your changes** with a clear message.
15+
9. **Push to your fork** and submit a **Pull Request**.
16+
17+
## Development
18+
19+
- **Source Code**: The source is in `src/depthtext.ts`.
20+
- **Build**: We use `tsup` for bundling. Run `npm run dev` for watch mode.
21+
- **Style**: Please try to match the existing code style.
22+
23+
## Reporting Issues
24+
25+
If you find a bug or have a feature request, please open an issue on GitHub. Include as much detail as possible.
26+
27+
## License
28+
29+
By contributing, you agree that your contributions will be licensed under the MIT License.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 MobiWise.dev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
# DepthText
2+
3+
DepthText is a lightweight, dependency-free JavaScript library that creates smooth multi-layer 3D text with depth, parallax, and interactive rotation.
4+
Designed for high performance, accessibility, and modern UX motion guidelines.
5+
6+
It is the spiritual successor of ztext.js, but rewritten from scratch with a cleaner API, better performance, and a modern ES module architecture.
7+
8+
---
9+
10+
## ✨ Features
11+
12+
- 🌀 **True 3D layered depth** using CSS `transform-style: preserve-3d`
13+
- 🖱️ **Interactive rotation** (auto, pointer, scroll…)
14+
- 🎚️ **Configurable number of layers**
15+
- 🎨 Optional **fade effect** across layers
16+
-**GPU-optimized** and jank-free
17+
- 🦾 **Accessibility-friendly** (`aria-hidden`, reduced-motion support)
18+
- 🔥 **No dependencies**, only 4–6 KB minified
19+
- 📦 Works with bundlers, ES modules, and browsers
20+
21+
---
22+
23+
## 🛠 Installation
24+
25+
### NPM
26+
27+
```bash
28+
npm install depthtext
29+
```
30+
31+
### Import (ES module)
32+
33+
```js
34+
import { DepthTextify } from "depthtext";
35+
```
36+
37+
---
38+
39+
## 🚀 Quick Start
40+
41+
### HTML
42+
43+
```html
44+
<h1 class="depthtext" data-depth="4" data-depth-event="pointer">DepthText Rocks</h1>
45+
```
46+
47+
### JavaScript
48+
49+
```js
50+
import { DepthTextify } from "depthtext";
51+
52+
DepthTextify(); // Enhances all .depthtext elements
53+
```
54+
55+
---
56+
57+
## 🧩 Options
58+
59+
DepthText can be configured using either:
60+
61+
- **HTML data attributes**
62+
- or **JavaScript options**
63+
64+
---
65+
66+
### HTML Attributes
67+
68+
| Attribute | Type | Default | Description |
69+
| --------------------------- | ------- | ------- | ----------------------------------------------------- |
70+
| `data-depth` | number | `8` | Number of 3D layers |
71+
| `data-depth-depth` | number | `20` | Z distance between layers |
72+
| `data-depth-event` | string | `none` | Interaction type: `none`, `pointer`, `scroll`, `auto` |
73+
| `data-depth-direction` | number | `1` | Reverse or invert orientation |
74+
| `data-depth-fade` | boolean | `false` | Fade layers as depth increases |
75+
| `data-depth-eventdirection` | number | `1` | Invert pointer/scroll direction |
76+
| `data-depth-eventrotation` | number | `20` | Max rotation angle on interaction |
77+
78+
---
79+
80+
### JavaScript API
81+
82+
```js
83+
import { DepthTextInstance } from "depthtext";
84+
85+
const instance = new DepthTextInstance(element, {
86+
layers: 8,
87+
depth: 20,
88+
fade: false,
89+
event: "pointer",
90+
eventRotation: 20,
91+
});
92+
```
93+
94+
---
95+
96+
## 🌐 Automatic Initialization
97+
98+
If you want DepthText to automatically enhance all matching elements:
99+
100+
```js
101+
import { DepthTextify } from "depthtext";
102+
103+
DepthTextify({
104+
selector: ".depthtext",
105+
});
106+
```
107+
108+
---
109+
110+
## 🧼 Accessibility
111+
112+
DepthText is designed to remain invisible to assistive technologies:
113+
114+
- Wrappers are automatically marked with `aria-hidden="true"`
115+
- Motion reacts to `prefers-reduced-motion: reduce`
116+
- Original text remains intact and readable in source
117+
118+
---
119+
120+
## 🎛 Custom Styling
121+
122+
Each generated depth layer receives:
123+
124+
```html
125+
<span class="depthtext-layer"></span>
126+
```
127+
128+
You can style them globally:
129+
130+
```css
131+
.depthtext-layer {
132+
color: #d0d0d0;
133+
}
134+
.depthtext-layer:first-child {
135+
color: #000;
136+
}
137+
```
138+
139+
---
140+
141+
## 📦 Browser Usage (no bundler)
142+
143+
```html
144+
<script src="dist/depthtext.global.js"></script>
145+
<script>
146+
// DepthText is available globally
147+
DepthText.DepthTextify();
148+
</script>
149+
```
150+
151+
---
152+
153+
## ⚛️ Framework Integration
154+
155+
DepthText is framework-agnostic. You can use it with React, Vue, Angular, Svelte, etc., by instantiating `DepthTextInstance` on a mounted DOM element.
156+
157+
### React / Next.js
158+
159+
```jsx
160+
import { useEffect, useRef } from 'react';
161+
import { DepthTextInstance } from 'depthtext';
162+
163+
export default function DepthComponent() {
164+
const textRef = useRef(null);
165+
166+
useEffect(() => {
167+
if (!textRef.current) return;
168+
169+
const dt = new DepthTextInstance(textRef.current, {
170+
layers: 10,
171+
depth: "1rem",
172+
event: "pointer"
173+
});
174+
175+
// Cleanup on unmount
176+
return () => dt.destroy();
177+
}, []);
178+
179+
return <h1 ref={textRef}>DepthText in React</h1>;
180+
}
181+
```
182+
183+
### Vue 3
184+
185+
```html
186+
<script setup>
187+
import { onMounted, onUnmounted, ref } from 'vue';
188+
import { DepthTextInstance } from 'depthtext';
189+
190+
const textRef = ref(null);
191+
let dt = null;
192+
193+
onMounted(() => {
194+
if (textRef.value) {
195+
dt = new DepthTextInstance(textRef.value, {
196+
layers: 10,
197+
event: 'pointer'
198+
});
199+
}
200+
});
201+
202+
onUnmounted(() => {
203+
if (dt) dt.destroy();
204+
});
205+
</script>
206+
207+
<template>
208+
<h1 ref="textRef">DepthText in Vue</h1>
209+
</template>
210+
```
211+
212+
### Angular
213+
214+
```ts
215+
import { Component, ElementRef, ViewChild, AfterViewInit, OnDestroy } from '@angular/core';
216+
import { DepthTextInstance } from 'depthtext';
217+
218+
@Component({
219+
selector: 'app-depth-text',
220+
template: '<h1 #depthText>DepthText in Angular</h1>'
221+
})
222+
export class DepthTextComponent implements AfterViewInit, OnDestroy {
223+
@ViewChild('depthText') textRef!: ElementRef;
224+
private dt?: DepthTextInstance;
225+
226+
ngAfterViewInit() {
227+
this.dt = new DepthTextInstance(this.textRef.nativeElement, {
228+
layers: 10,
229+
event: 'pointer'
230+
});
231+
}
232+
233+
ngOnDestroy() {
234+
this.dt?.destroy();
235+
}
236+
}
237+
```
238+
239+
## 🐛 Known Issues & Notes
240+
241+
- DepthText uses CSS transforms; parent elements must not flatten 3D contexts.
242+
- Avoid nested DepthText unless you understand `transform-style: preserve-3d`.
243+
244+
---
245+
246+
## 🧑‍💻 Contributing
247+
248+
Pull requests are welcome!
249+
If you add a major feature, please include documentation updates.
250+
251+
---
252+
253+
## 📄 License
254+
255+
MIT License — free to use in commercial and open-source projects.
256+
257+
---
258+
259+
## 💬 Author
260+
261+
Created by **MobiWise**.
262+
A modern reimagining of the classic [ztext.js](https://github.com/bennettfeely/ztext).

0 commit comments

Comments
 (0)