tinywidgets 1.0.14 → 1.0.16
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/README.md +60 -0
- package/package.json +15 -6
- package/src/components/Image/index.css.ts +4 -0
- package/src/components/Image/index.tsx +20 -4
- package/src/css/global.css.ts +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# TinyWidgets
|
|
2
|
+
|
|
3
|
+
A collection of tiny, reusable, UI components
|
|
4
|
+
— wrapped in a helpful app layout with header, side bar, dark mode, and more.
|
|
5
|
+
|
|
6
|
+
See the [website](https://tinywidgets.org/) for more details. Get started [here](https://tinywidgets.org/#installation).
|
|
7
|
+
|
|
8
|
+
<img width="1213" alt="image" src="https://github.com/user-attachments/assets/22b69545-52d5-424d-ab80-084bb87237f4">
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Dependencies
|
|
13
|
+
|
|
14
|
+
TinyWidgets uses [React](https://react.dev/) for DOM manipulation, [Vanilla-Extract](https://vanilla-extract.style/) at build-time for styling, [Lucide](https://lucide.dev/) for icons, and [TinyBase](https://tinybase.org/) for state management. Its philosophy is all about simplicity, decent defaults, a streamlined DOM, and concise styling.
|
|
15
|
+
|
|
16
|
+
But, just to be clear - that doesn't mean you need to use Vanilla-Extract, Lucide, or Tinybase in the apps you build with these widgets. You can set arbitrary class names (from Tailwind, for example!) on all components if you like.
|
|
17
|
+
|
|
18
|
+
## Help out!
|
|
19
|
+
|
|
20
|
+
This project was created because [I](https://github.com/jamesgpearce) want to be able to build lots of local-first apps quickly and without the overhead of all the app boilerplate each time.
|
|
21
|
+
|
|
22
|
+
Making it open source seemed like the right thing to do, so please try and it out and get involved. I'll always be interested in issues, more style variants, new components altogether, or even some professional-grade design assistance. I'm not a designer...
|
|
23
|
+
|
|
24
|
+
See you on [GitHub](https://github.com/tinyplex/tinywidgets)!
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
The easiest way to get started with TinyWidgets is to use its [Vite template](https://github.com/tinyplex/vite-tinywidgets/). This comes with the (simple) build configuration you need to work with TinyWidgets.
|
|
29
|
+
|
|
30
|
+
To create a new TinyWidgets application using this template, do the following:
|
|
31
|
+
|
|
32
|
+
1. Make a copy of this template into a new directory:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npx tiged tinyplex/vite-tinywidgets my-tinywidgets-app
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Go into the directory:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
cd my-tinywidgets-app
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
3. Install the dependencies:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm install
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
4. Run the application:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
npm run dev
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
5. The Vite server should start up. Go the URL shown and enjoy!
|
|
57
|
+
|
|
58
|
+
<img width="1160" alt="image" src="https://github.com/user-attachments/assets/073a26dc-4212-4ab0-b5a0-d968ac47342c">
|
|
59
|
+
|
|
60
|
+
Note that you can also create a production build with `npm run build`.
|
package/package.json
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinywidgets",
|
|
3
|
-
"
|
|
4
|
-
"version": "1.0.14",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"prePublishPackage": "eslint . && cspell --quiet . && tsc"
|
|
7
|
-
},
|
|
3
|
+
"version": "1.0.16",
|
|
8
4
|
"author": "jamesgpearce",
|
|
9
5
|
"repository": "github:tinyplex/tinywidgets",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://tinywidgets.org",
|
|
8
|
+
"description": "A collection of tiny, reusable, UI components - wrapped in a helpful app layout with header, side bar, dark mode, and more.",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"tiny",
|
|
11
|
+
"local-first",
|
|
12
|
+
"ui",
|
|
13
|
+
"components",
|
|
14
|
+
"styling",
|
|
15
|
+
"react"
|
|
16
|
+
],
|
|
10
17
|
"type": "module",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prePublishPackage": "eslint . && cspell --quiet . && tsc && cp ../README.md ./README.md"
|
|
20
|
+
},
|
|
11
21
|
"devDependencies": {
|
|
12
22
|
"@types/react": "^18.3.11",
|
|
13
23
|
"@types/react-dom": "^18.3.0",
|
|
@@ -26,7 +36,6 @@
|
|
|
26
36
|
".": "./src/index.ts",
|
|
27
37
|
"./css": "./src/index.css.ts"
|
|
28
38
|
},
|
|
29
|
-
"license": "MIT",
|
|
30
39
|
"dependencies": {
|
|
31
40
|
"@vanilla-extract/css": "^1.16.0",
|
|
32
41
|
"lucide-react": "^0.447.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import React, {useCallback} from 'react';
|
|
2
|
+
import {clickable, image, imageVariants} from './index.css.ts';
|
|
3
3
|
import {classNames} from '../../common/functions.tsx';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -46,6 +46,7 @@ export const Image = ({
|
|
|
46
46
|
src,
|
|
47
47
|
onClick,
|
|
48
48
|
variant = 'default',
|
|
49
|
+
href,
|
|
49
50
|
alt,
|
|
50
51
|
className,
|
|
51
52
|
}: {
|
|
@@ -65,6 +66,11 @@ export const Image = ({
|
|
|
65
66
|
* - `icon`
|
|
66
67
|
*/
|
|
67
68
|
readonly variant?: keyof typeof imageVariants;
|
|
69
|
+
/**
|
|
70
|
+
* A URL that can be used instead of an `onClick` to launch a new web
|
|
71
|
+
* page, much like a link.
|
|
72
|
+
*/
|
|
73
|
+
readonly href?: string;
|
|
68
74
|
/**
|
|
69
75
|
* Alternative text shown when the user hovers over the image.
|
|
70
76
|
*/
|
|
@@ -74,12 +80,22 @@ export const Image = ({
|
|
|
74
80
|
*/
|
|
75
81
|
readonly className?: string;
|
|
76
82
|
}) => {
|
|
83
|
+
const hrefClick = useCallback(
|
|
84
|
+
() => (href ? open(href, '_blank', 'noreferrer') : null),
|
|
85
|
+
[href],
|
|
86
|
+
);
|
|
87
|
+
|
|
77
88
|
return (
|
|
78
89
|
<img
|
|
79
90
|
src={src}
|
|
80
|
-
onClick={onClick}
|
|
91
|
+
onClick={onClick ?? hrefClick}
|
|
81
92
|
title={alt}
|
|
82
|
-
className={classNames(
|
|
93
|
+
className={classNames(
|
|
94
|
+
image,
|
|
95
|
+
imageVariants[variant],
|
|
96
|
+
(onClick || href) && clickable,
|
|
97
|
+
className,
|
|
98
|
+
)}
|
|
83
99
|
/>
|
|
84
100
|
);
|
|
85
101
|
};
|
package/src/css/global.css.ts
CHANGED