@muffled-ui/react 1.3.0 → 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 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
- theme?: ProvidedTheme;
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
- theme?: ProvidedTheme;
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
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muffled-ui/react",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "private": false,
5
5
  "homepage": "https://ui.muffled.studio/",
6
6
  "bugs": {
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "files": [
32
32
  "dist",
33
+ "src/styles/theme.css",
33
34
  "package.json"
34
35
  ],
35
36
  "peerDependencies": {
@@ -0,0 +1,127 @@
1
+ @import "tw-animate-css";
2
+
3
+ @custom-variant dark (&:is(.dark *));
4
+
5
+ :root {
6
+ font-size: 14px;
7
+ --radius: 0.625rem;
8
+ --background: oklch(1 0 0);
9
+ --foreground: oklch(0.141 0.005 285.823);
10
+ --card: oklch(1 0 0);
11
+ --card-foreground: oklch(0.141 0.005 285.823);
12
+ --popover: oklch(1 0 0);
13
+ --popover-foreground: oklch(0.141 0.005 285.823);
14
+ --primary: oklch(0.23 0.010 260);
15
+ --primary-foreground: oklch(0.985 0 0);
16
+ --secondary: oklch(0.95 0.006 260);
17
+ --secondary-foreground: oklch(0.23 0.010 260);
18
+ --muted: oklch(0.95 0.004 260);
19
+ --muted-foreground: oklch(0.42 0.012 260);
20
+ --accent: oklch(0.95 0.006 260);
21
+ --accent-foreground: oklch(0.23 0.010 260);
22
+ --destructive: oklch(0.637 0.208 25.3);
23
+ --destructive-foreground: oklch(0.96 0 0);
24
+ --border: oklch(0.90 0.006 260);
25
+ --input: oklch(0.90 0.006 260);
26
+ --ring: oklch(0.705 0.015 286.067);
27
+ --chart-1: oklch(0.646 0.222 41.116);
28
+ --chart-2: oklch(0.6 0.118 184.704);
29
+ --chart-3: oklch(0.398 0.07 227.392);
30
+ --chart-4: oklch(0.828 0.189 84.429);
31
+ --chart-5: oklch(0.769 0.188 70.08);
32
+ --sidebar: oklch(0.985 0.002 260);
33
+ --sidebar-foreground: oklch(0.141 0.005 260);
34
+ --sidebar-primary: oklch(0.23 0.010 260);
35
+ --sidebar-primary-foreground: oklch(0.985 0 0);
36
+ --sidebar-accent: oklch(0.95 0.006 260);
37
+ --sidebar-accent-foreground: oklch(0.23 0.010 260);
38
+ --sidebar-border: oklch(0.90 0.006 260);
39
+ --sidebar-ring: oklch(0.705 0.015 286.067);
40
+ }
41
+
42
+ .dark {
43
+ --background: oklch(0.21 0.0109 264);
44
+ --foreground: oklch(0.96 0 0);
45
+ --card: oklch(0.22 0.008 260);
46
+ --card-foreground: oklch(0.96 0 0);
47
+ --popover: oklch(0.22 0.008 260);
48
+ --popover-foreground: oklch(0.96 0 0);
49
+ --primary: oklch(0.92 0.004 260);
50
+ --primary-foreground: oklch(0.21 0.0109 264);
51
+ --secondary: oklch(0.28 0.014 260);
52
+ --secondary-foreground: oklch(0.985 0 0);
53
+ --muted: oklch(0.25 0.010 260);
54
+ --muted-foreground: oklch(0.78 0.010 260);
55
+ --accent: oklch(0.25 0.010 260);
56
+ --accent-foreground: oklch(0.96 0 0);
57
+ --destructive: oklch(0.529 0.195 27.2);
58
+ --destructive-foreground: oklch(0.96 0 0);
59
+ --border: oklch(0.34 0.006 260 / 55%);
60
+ --input: oklch(0.36 0.006 260 / 65%);
61
+ --ring: oklch(0.552 0.016 285.938);
62
+ --chart-1: oklch(0.488 0.243 264.376);
63
+ --chart-2: oklch(0.696 0.17 162.48);
64
+ --chart-3: oklch(0.769 0.188 70.08);
65
+ --chart-4: oklch(0.627 0.265 303.9);
66
+ --chart-5: oklch(0.645 0.246 16.439);
67
+ --sidebar: oklch(0.24 0.010 260);
68
+ --sidebar-foreground: oklch(0.90 0.010 260);
69
+ --sidebar-primary: oklch(0.40 0.070 260);
70
+ --sidebar-primary-foreground: oklch(0.985 0 0);
71
+ --sidebar-accent: oklch(0.28 0.014 260);
72
+ --sidebar-accent-foreground: oklch(0.90 0.010 260);
73
+ --sidebar-border: oklch(0.21 0 0 / 18%);
74
+ --sidebar-ring: oklch(0.552 0.016 285.938);
75
+ }
76
+
77
+ @theme inline {
78
+ --font-sans: 'DM Sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
79
+ --color-background: var(--background);
80
+ --color-foreground: var(--foreground);
81
+ --color-card: var(--card);
82
+ --color-card-foreground: var(--card-foreground);
83
+ --color-popover: var(--popover);
84
+ --color-popover-foreground: var(--popover-foreground);
85
+ --color-primary: var(--primary);
86
+ --color-primary-foreground: var(--primary-foreground);
87
+ --color-secondary: var(--secondary);
88
+ --color-secondary-foreground: var(--secondary-foreground);
89
+ --color-muted: var(--muted);
90
+ --color-muted-foreground: var(--muted-foreground);
91
+ --color-accent: var(--accent);
92
+ --color-accent-foreground: var(--accent-foreground);
93
+ --color-destructive: var(--destructive);
94
+ --color-destructive-foreground: var(--destructive-foreground);
95
+ --color-border: var(--border);
96
+ --color-input: var(--input);
97
+ --color-ring: var(--ring);
98
+ --color-chart-1: var(--chart-1);
99
+ --color-chart-2: var(--chart-2);
100
+ --color-chart-3: var(--chart-3);
101
+ --color-chart-4: var(--chart-4);
102
+ --color-chart-5: var(--chart-5);
103
+ --radius-sm: calc(var(--radius) - 4px);
104
+ --radius-md: calc(var(--radius) - 2px);
105
+ --radius-lg: var(--radius);
106
+ --radius-xl: calc(var(--radius) + 4px);
107
+ --color-sidebar: var(--sidebar);
108
+ --color-sidebar-foreground: var(--sidebar-foreground);
109
+ --color-sidebar-primary: var(--sidebar-primary);
110
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
111
+ --color-sidebar-accent: var(--sidebar-accent);
112
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
113
+ --color-sidebar-border: var(--sidebar-border);
114
+ --color-sidebar-ring: var(--sidebar-ring);
115
+ --sidebar-width: 20rem;
116
+ --sidebar-width-mobile: 18rem;
117
+ }
118
+
119
+ @layer base {
120
+ * {
121
+ @apply border-border outline-ring/50 antialiased;
122
+ }
123
+ body {
124
+ @apply bg-background text-foreground;
125
+
126
+ }
127
+ }