@muffled-ui/react 1.3.1 → 1.3.2
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 +131 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -6
- package/dist/index.mjs +8 -6
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="/public/logo-dark.svg#gh-dark-mode-only" height="128"/>
|
|
3
|
+
<img src="/public/logo-light.svg#gh-light-mode-only" height="128"/>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<div align="center">
|
|
7
|
+
|
|
8
|
+
[![License][license-image]][license-url]
|
|
9
|
+
|
|
10
|
+
[license-image]: https://img.shields.io/github/license/joshbatley/muffled-ui
|
|
11
|
+
[license-url]: https://github.com/joshbatley/muffled-ui/blob/main/LICENSE
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
# Muffled UI
|
|
16
|
+
|
|
17
|
+
Muffled UI is a React component library providing a set of accessible and customizable UI components for modern web applications.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- 🚀 **React Components**: A collection of reusable React components
|
|
22
|
+
- 📚 **Storybook Documentation**: Comprehensive documentation with Storybook
|
|
23
|
+
- 🧩 **Modular**: Use only the components you need
|
|
24
|
+
- 📱 **Responsive**: Designed to work on all device sizes
|
|
25
|
+
- ♿ **Accessible**: Built with accessibility in mind
|
|
26
|
+
|
|
27
|
+
## Project Structure
|
|
28
|
+
|
|
29
|
+
This project is organized as a monorepo using pnpm workspaces:
|
|
30
|
+
|
|
31
|
+
### Packages
|
|
32
|
+
|
|
33
|
+
- [React](/packages/react) - The main React UI component library
|
|
34
|
+
|
|
35
|
+
### Apps
|
|
36
|
+
|
|
37
|
+
- [Docs](/apps/docs) - Storybook documentation site for the components
|
|
38
|
+
- [Web](/apps/web) - Demo application showcasing the components
|
|
39
|
+
|
|
40
|
+
## Getting Started
|
|
41
|
+
|
|
42
|
+
### Prerequisites
|
|
43
|
+
|
|
44
|
+
- Node.js 18 or higher
|
|
45
|
+
- pnpm 9.1.4 or higher
|
|
46
|
+
|
|
47
|
+
### Installation
|
|
48
|
+
|
|
49
|
+
Install the Muffled UI package:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Using npm
|
|
53
|
+
npm install @muffled-ui/react
|
|
54
|
+
|
|
55
|
+
# Using yarn
|
|
56
|
+
yarn add @muffled-ui/react
|
|
57
|
+
|
|
58
|
+
# Using pnpm
|
|
59
|
+
pnpm add @muffled-ui/react
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Install the CSS:
|
|
63
|
+
|
|
64
|
+
Try out muffled-ui with no dependencies, only recommended for demo and prototyping:
|
|
65
|
+
```jsx
|
|
66
|
+
// main.tsx
|
|
67
|
+
import '@muffled-ui/react/styled.css';
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Using Tailwind CSS:
|
|
71
|
+
```css
|
|
72
|
+
/* index.css */
|
|
73
|
+
@import "tailwindcss";
|
|
74
|
+
@import '@muffled-ui/react/theme';
|
|
75
|
+
@source "../node_modules/@muffled-ui/react";
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Finally wrap the application with the Muffled UI provider:
|
|
79
|
+
```jsx
|
|
80
|
+
// main.tsx
|
|
81
|
+
import { StrictMode } from 'react';
|
|
82
|
+
import { createRoot } from 'react-dom/client';
|
|
83
|
+
import { MuffledUI } from '@muffled-ui/react';
|
|
84
|
+
import App from './App.tsx';
|
|
85
|
+
|
|
86
|
+
import './index.css';
|
|
87
|
+
// See CSS imports above
|
|
88
|
+
// import '@muffled-ui/react/styled.css'
|
|
89
|
+
|
|
90
|
+
createRoot(document.getElementById('root')!).render(
|
|
91
|
+
<StrictMode>
|
|
92
|
+
<MuffledUI theme="dark">
|
|
93
|
+
<App />
|
|
94
|
+
</MuffledUI>
|
|
95
|
+
</StrictMode>,
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Usage
|
|
100
|
+
|
|
101
|
+
```jsx
|
|
102
|
+
import { Button } from '@muffled-ui/react';
|
|
103
|
+
|
|
104
|
+
function App() {
|
|
105
|
+
return (
|
|
106
|
+
<Button variant="primary" onClick={() => console.log('Clicked!')}>
|
|
107
|
+
Click Me
|
|
108
|
+
</Button>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Development
|
|
114
|
+
|
|
115
|
+
To develop Muffled UI locally:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Clone the repository
|
|
119
|
+
git clone https://github.com/joshbatley/muffled-ui.git
|
|
120
|
+
cd muffled-ui
|
|
121
|
+
|
|
122
|
+
# Install dependencies
|
|
123
|
+
pnpm install
|
|
124
|
+
|
|
125
|
+
# Start the documentation site (Storybook)
|
|
126
|
+
pnpm dev
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
This project is MIT licensed.
|
package/dist/index.d.mts
CHANGED
|
@@ -500,7 +500,7 @@ declare function Textarea({ className, ...props }: React$1.ComponentProps<'texta
|
|
|
500
500
|
|
|
501
501
|
type ProvidedTheme = 'light' | 'dark' | 'system';
|
|
502
502
|
type ThemeProviderProps = {
|
|
503
|
-
|
|
503
|
+
defaultTheme?: ProvidedTheme;
|
|
504
504
|
children?: React$1.ReactNode;
|
|
505
505
|
};
|
|
506
506
|
type SettingsCtx = {
|
package/dist/index.d.ts
CHANGED
|
@@ -500,7 +500,7 @@ declare function Textarea({ className, ...props }: React$1.ComponentProps<'texta
|
|
|
500
500
|
|
|
501
501
|
type ProvidedTheme = 'light' | 'dark' | 'system';
|
|
502
502
|
type ThemeProviderProps = {
|
|
503
|
-
|
|
503
|
+
defaultTheme?: ProvidedTheme;
|
|
504
504
|
children?: React$1.ReactNode;
|
|
505
505
|
};
|
|
506
506
|
type SettingsCtx = {
|
package/dist/index.js
CHANGED
|
@@ -3796,28 +3796,30 @@ var useMuffledSettings = () => {
|
|
|
3796
3796
|
}
|
|
3797
3797
|
return context;
|
|
3798
3798
|
};
|
|
3799
|
-
var MuffledUI = ({ children }) => {
|
|
3799
|
+
var MuffledUI = ({ children, defaultTheme }) => {
|
|
3800
3800
|
const [theme, setThemeKey] = (0, import_react23.useState)(() => {
|
|
3801
3801
|
var _a;
|
|
3802
3802
|
if (localStorage.getItem(LocalStorageKey) !== null) {
|
|
3803
3803
|
return (_a = JSON.parse(localStorage.getItem(LocalStorageKey) || "")) == null ? void 0 : _a.theme;
|
|
3804
3804
|
}
|
|
3805
|
-
return "system";
|
|
3805
|
+
return defaultTheme ? defaultTheme : "system";
|
|
3806
3806
|
});
|
|
3807
|
+
const setTheme = (t) => {
|
|
3808
|
+
localStorage.setItem(LocalStorageKey, JSON.stringify({ theme: t }));
|
|
3809
|
+
setThemeKey(t);
|
|
3810
|
+
};
|
|
3807
3811
|
(0, import_react23.useEffect)(() => {
|
|
3808
3812
|
const root = window.document.documentElement;
|
|
3809
3813
|
root.classList.remove("light", "dark");
|
|
3810
3814
|
if (theme === "system") {
|
|
3811
3815
|
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
3812
3816
|
root.classList.add(systemTheme);
|
|
3817
|
+
setTheme(systemTheme);
|
|
3813
3818
|
return;
|
|
3814
3819
|
}
|
|
3820
|
+
setTheme(theme);
|
|
3815
3821
|
root.classList.add(theme);
|
|
3816
3822
|
}, [theme]);
|
|
3817
|
-
const setTheme = (t) => {
|
|
3818
|
-
localStorage.setItem(LocalStorageKey, JSON.stringify({ theme: t }));
|
|
3819
|
-
setThemeKey(t);
|
|
3820
|
-
};
|
|
3821
3823
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3822
3824
|
SettingsContext.Provider,
|
|
3823
3825
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -3594,28 +3594,30 @@ var useMuffledSettings = () => {
|
|
|
3594
3594
|
}
|
|
3595
3595
|
return context;
|
|
3596
3596
|
};
|
|
3597
|
-
var MuffledUI = ({ children }) => {
|
|
3597
|
+
var MuffledUI = ({ children, defaultTheme }) => {
|
|
3598
3598
|
const [theme, setThemeKey] = useState2(() => {
|
|
3599
3599
|
var _a;
|
|
3600
3600
|
if (localStorage.getItem(LocalStorageKey) !== null) {
|
|
3601
3601
|
return (_a = JSON.parse(localStorage.getItem(LocalStorageKey) || "")) == null ? void 0 : _a.theme;
|
|
3602
3602
|
}
|
|
3603
|
-
return "system";
|
|
3603
|
+
return defaultTheme ? defaultTheme : "system";
|
|
3604
3604
|
});
|
|
3605
|
+
const setTheme = (t) => {
|
|
3606
|
+
localStorage.setItem(LocalStorageKey, JSON.stringify({ theme: t }));
|
|
3607
|
+
setThemeKey(t);
|
|
3608
|
+
};
|
|
3605
3609
|
useEffect(() => {
|
|
3606
3610
|
const root = window.document.documentElement;
|
|
3607
3611
|
root.classList.remove("light", "dark");
|
|
3608
3612
|
if (theme === "system") {
|
|
3609
3613
|
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
3610
3614
|
root.classList.add(systemTheme);
|
|
3615
|
+
setTheme(systemTheme);
|
|
3611
3616
|
return;
|
|
3612
3617
|
}
|
|
3618
|
+
setTheme(theme);
|
|
3613
3619
|
root.classList.add(theme);
|
|
3614
3620
|
}, [theme]);
|
|
3615
|
-
const setTheme = (t) => {
|
|
3616
|
-
localStorage.setItem(LocalStorageKey, JSON.stringify({ theme: t }));
|
|
3617
|
-
setThemeKey(t);
|
|
3618
|
-
};
|
|
3619
3621
|
return /* @__PURE__ */ jsx36(
|
|
3620
3622
|
SettingsContext.Provider,
|
|
3621
3623
|
{
|