@shopify/klint 0.3.0 → 0.3.1

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 (2) hide show
  1. package/README.md +86 -62
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,89 +1,113 @@
1
- # Klint
1
+ # 🎨 Klint
2
2
 
3
- A modern creative coding library for React applications that provides an intuitive interface to HTML Canvas 2D rendering. Klint simplifies the process of creating interactive graphics, animations, and visualizations.
3
+ Klint is a modern 2D canvas library for React, inspired by p5.js and Processing. It makes creative coding in React intuitive and powerful, perfect for generative art, data visualization, interactive graphics, and creative web experiences.
4
4
 
5
- ## Features
5
+ ## Features
6
6
 
7
- - React integration with hooks and components
8
- - Intuitive drawing API inspired by Processing and P5.js
9
- - Responsive canvas that automatically resizes
10
- - Support for animations, static renderings, and interactive content
11
- - Built-in utilities for managing state, input, and resources
7
+ - 🎯 **React-first**: Built specifically for React with hooks and component patterns
8
+ - 🎨 **Creative coding**: p5.js-like API with modern JavaScript/TypeScript
9
+ - 🚀 **Performance**: Direct canvas access with minimal overhead
10
+ - 🛠️ **Developer friendly**: Full TypeScript support and great tooling
11
+ - 🔧 **Extensible**: Plugin system and easy customization
12
12
 
13
- ## Example
13
+ ## 🚀 Quick Start
14
+
15
+ ### Install Klint
16
+
17
+ ```bash
18
+ npm install @shopify/klint
19
+ ```
20
+
21
+ ### Basic Usage
14
22
 
15
23
  ```jsx
16
- import { Klint, useKlint, type KlintContext } from "klint";
24
+ import { useKlint, Klint } from '@shopify/klint';
17
25
 
18
- function AnimatedCircle() {
26
+ function MySketch() {
19
27
  const { context } = useKlint();
20
-
21
- const draw = (K: KlintContext) => {
22
- K.background("#222");
23
- K.fillColor("red");
24
-
25
- // Draw a pulsing circle at the center of the canvas
26
- const size = 50 + Math.sin(K.frame * 0.05) * 25;
27
- K.circle(K.width/2, K.height/2, size);
28
+
29
+ const draw = (K) => {
30
+ K.background('#000');
31
+ K.fillColor('#ff6b6b');
32
+ K.circle(K.width/2, K.height/2, 50);
28
33
  };
29
34
 
30
35
  return <Klint context={context} draw={draw} />;
31
36
  }
32
37
  ```
33
38
 
34
- ## Release Process
39
+ ## 🎮 Try the Editor
35
40
 
36
- This package uses GitHub Actions for automated releases. Here's how to create a new release:
41
+ Want to experiment with Klint interactively? Create a live editor environment:
37
42
 
38
- ## Development and tests
43
+ ```bash
44
+ npx @shopify/klint klint-create-editor my-klint-project
45
+ cd my-klint-project
46
+ npm install
47
+ npm run dev
48
+ ```
39
49
 
40
- > **Important:** The Klint library isn't public yet, so you'll need to link it manually if you want to edit it.
50
+ This creates a Monaco-based editor with live preview - perfect for learning and prototyping!
41
51
 
42
- 1. Clone the repository
43
- ```bash
44
- git clone https://github.com/Shopify/klint.git
45
- cd klint
46
- ```
52
+ ## 📚 Documentation
47
53
 
48
- 2. Go to the lib folder and link it locally
49
- ```bash
50
- cd lib
51
- npm link
52
- ```
54
+ - **[Getting Started Guide](https://shopify.github.io/Klint/)** - Learn the basics
55
+ - **[API Reference](https://shopify.github.io/Klint/docs/Functions/introduction)** - Complete function reference
56
+ - **[Examples](https://shopify.github.io/Klint/experiments)** - See Klint in action
57
+ - **[Lifecycle](https://shopify.github.io/Klint/docs/klint-introduction)** - Understand how Klint works with React
53
58
 
54
- 3. In your working directory, link to the local Klint
55
- ```bash
56
- cd your-project
57
- npm link klint
58
- ```
59
+ ## 🌟 Examples
59
60
 
60
- 4. Run the dev server:
61
- ```bash
62
- npm run dev
63
- ```
61
+ ### Animated Circle
62
+ ```jsx
63
+ function AnimatedCircle() {
64
+ const { context } = useKlint();
65
+
66
+ const draw = (K) => {
67
+ K.background('rgba(0, 0, 0, 0.1)');
68
+ K.fillColor('#4ecdc4');
69
+ const x = K.width/2 + Math.cos(K.frame * 0.02) * 100;
70
+ const y = K.height/2 + Math.sin(K.frame * 0.02) * 100;
71
+ K.circle(x, y, 20);
72
+ };
73
+
74
+ return <Klint context={context} draw={draw} />;
75
+ }
76
+ ```
64
77
 
65
- 5. When finished, unlink both in your project and the local repo
66
- ```bash
67
- # In your project
68
- npm unlink klint
69
-
70
- # In the Klint lib folder
71
- npm unlink
72
- ```
78
+ ### Interactive Drawing
79
+ ```jsx
80
+ function InteractiveDrawing() {
81
+ const { context, KlintMouse } = useKlint();
82
+ const { mouse } = KlintMouse();
83
+
84
+ const draw = (K) => {
85
+ if (mouse.pressed) {
86
+ K.fillColor('red');
87
+ K.circle(mouse.x, mouse.y, 10);
88
+ }
89
+ };
90
+
91
+ return <Klint context={context} draw={draw} />;
92
+ }
93
+ ```
73
94
 
74
- 6. If you change anything in the library, you will need to rebuild
75
- ```bash
76
- # In the Klint lib folder
77
- npm build
78
- npm link
79
- ```
95
+ ## 🛠️ Development
96
+
97
+ **For contributors** who want to work on Klint itself:
98
+
99
+ ```bash
100
+ git clone https://github.com/Shopify/klint.git
101
+ cd klint
102
+ npm install
103
+ npm run build
104
+ ```
105
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines.
80
106
 
81
- 7. I use Vitest for testing
82
- ```bash
83
- npm test
84
- ```
107
+ ## 📄 License
108
+ MIT
85
109
 
86
- 8. Push your commit
110
+ ---
87
111
 
112
+ **Ready to create?** Start with `npx @shopify/klint klint-create-editor my-project` 🎨
88
113
 
89
- Made with love at Shopify, 2025
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@shopify/klint",
3
3
  "author": "arthurcloche",
4
4
  "license": "MIT",
5
- "version": "0.3.0",
5
+ "version": "0.3.1",
6
6
  "description": "A modern creative coding library",
7
7
  "type": "module",
8
8
  "main": "dist/index.cjs",