You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update version to 1.0.4, enhance README with new UI visibility controls, and improve JSON viewer component with key editing and customizable UI options.
The component uses **component-scoped CSS custom properties** for theming, ensuring that theme changes only affect the JsonViewer component and do not interfere with your parent application's styling.
258
+
259
+
### Component-Only Theming
260
+
261
+
The theme is completely self-contained within the component:
262
+
263
+
**Dynamic Theme Icons**: The theme button automatically shows:
264
+
- 🌙 **Moon icon** when in light theme (click to switch to dark)
265
+
- ☀️ **Sun icon** when in dark theme (click to switch to light)
266
+
267
+
```vue
268
+
<template>
269
+
<JsonViewer
270
+
:theme="'dark'" <!-- Theme only affects this component -->
271
+
v-model:data="jsonData"
272
+
/>
273
+
</template>
274
+
```
275
+
276
+
### CSS Custom Properties
197
277
198
-
The component uses CSS custom properties for theming. You can customize the appearance by overriding these variables:
278
+
You can customize the appearance by overriding these CSS variables within the component scope:
199
279
200
280
```css
201
281
.json-viewer {
@@ -213,6 +293,49 @@ The component uses CSS custom properties for theming. You can customize the appe
213
293
}
214
294
```
215
295
296
+
### Using in Other Projects
297
+
298
+
When you use this component in other projects, the theme will **only affect the component itself**:
299
+
300
+
```vue
301
+
<template>
302
+
<div>
303
+
<!-- This header won't be affected by theme changes -->
304
+
<header class="my-app-header">
305
+
<h1>My Application</h1>
306
+
</header>
307
+
308
+
<!-- Only this component will change theme -->
309
+
<JsonViewer
310
+
:theme="componentTheme"
311
+
v-model:data="jsonData"
312
+
@theme-change="handleThemeChange"
313
+
/>
314
+
315
+
<!-- This footer also won't be affected -->
316
+
<footer class="my-app-footer">
317
+
<p>My Application Footer</p>
318
+
</footer>
319
+
</div>
320
+
</template>
321
+
322
+
<script setup>
323
+
const componentTheme = ref('light');
324
+
325
+
const handleThemeChange = (newTheme) => {
326
+
componentTheme.value = newTheme;
327
+
// Theme only affects the JsonViewer component
328
+
// Your app's global styling remains unchanged
329
+
};
330
+
</script>
331
+
```
332
+
333
+
**Benefits:**
334
+
- ✅ **No Global Side Effects** - Theme changes only affect the component
335
+
- ✅ **Better Encapsulation** - Component manages its own appearance
336
+
- ✅ **Easier Integration** - No conflicts with parent project's theme system
337
+
- ✅ **Reusable** - Can be used in any project without affecting global styles
338
+
216
339
## 🛠️ Development
217
340
218
341
### Setup
@@ -308,6 +431,28 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
308
431
- Font families: [Inter](https://rsms.me/inter/) and [Fira Code](https://github.com/tonsky/FiraCode)
309
432
- Built with [Vue 3](https://vuejs.org/) and [Vite](https://vitejs.dev/)
310
433
434
+
## 🔧 Troubleshooting
435
+
436
+
### Theme Not Working?
437
+
438
+
**Problem**: Theme changes not visible in your project
439
+
440
+
**Solution**: The component now uses component-only theming. Make sure you're passing the theme prop correctly:
**Problem**: Theme changes affecting your entire application
453
+
454
+
**Solution**: This shouldn't happen anymore! The component is now completely self-contained. If you're still experiencing issues, make sure you're using the latest version.
0 commit comments