All Projects → trbrc → Svelte Inspect

trbrc / Svelte Inspect

Licence: mit
console.log()-like interactive inspector for Svelte 3

Projects that are alternatives of or similar to Svelte Inspect

Wg Ui
WireGuard Web UI for self-serve client configurations, with optional auth.
Stars: ✭ 690 (+1990.91%)
Mutual labels:  svelte
Svelte Tailwind Extension Boilerplate
A Chrome extension boilerplate built with Svelte, TailwindCSS, Jest, and Rollup.
Stars: ✭ 26 (-21.21%)
Mutual labels:  svelte
Svelte Redux Shopping Cart
Example Shopping Cart App using Svelte, Redux, and Webpack
Stars: ✭ 13 (-60.61%)
Mutual labels:  svelte
Selecto
Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.
Stars: ✭ 822 (+2390.91%)
Mutual labels:  svelte
Revelt
Analysis of a project using React and Svelte technologies
Stars: ✭ 20 (-39.39%)
Mutual labels:  svelte
Skeleton Elements
Skeleton elements - UI for improved perceived performance
Stars: ✭ 27 (-18.18%)
Mutual labels:  svelte
Bytemd
A hackable Markdown editor component built with Svelte
Stars: ✭ 656 (+1887.88%)
Mutual labels:  svelte
Sapper Template Firebase
Starter Rollup template for Sapper apps with Firebase functions based on https://github.com/nhristov/sapper-template-rollup.
Stars: ✭ 29 (-12.12%)
Mutual labels:  svelte
Realworld
Svelte/Sapper implementation of the RealWorld app
Stars: ✭ 923 (+2696.97%)
Mutual labels:  svelte
Wombat
Cross platform gRPC client
Stars: ✭ 868 (+2530.3%)
Mutual labels:  svelte
Svelte Quickstart
Svelte un nuevo framework de JavaScript para construir interfaces de usuario.
Stars: ✭ 16 (-51.52%)
Mutual labels:  svelte
Telegram Standup Bot
Very simple telegram bot for submitting daily standups
Stars: ✭ 20 (-39.39%)
Mutual labels:  svelte
Post Communicating With Interactive Articles
Stars: ✭ 27 (-18.18%)
Mutual labels:  svelte
Egjs Infinitegrid
A module used to arrange card elements including content infinitely on a grid layout.
Stars: ✭ 751 (+2175.76%)
Mutual labels:  svelte
Svelte Flat
Flat UI components built with Svelte.
Stars: ✭ 13 (-60.61%)
Mutual labels:  svelte
Carbon Components Svelte
Svelte implementation of the Carbon Design System
Stars: ✭ 685 (+1975.76%)
Mutual labels:  svelte
Sveltejs Tippy
Tippy.js for Svelte
Stars: ✭ 26 (-21.21%)
Mutual labels:  svelte
Why Svelte
Why Svelte is our choice for a large web project in 2020
Stars: ✭ 953 (+2787.88%)
Mutual labels:  svelte
Smelte
UI framework with material components built with Svelte and Tailwind CSS
Stars: ✭ 871 (+2539.39%)
Mutual labels:  svelte
Librelingo
🐢 🌎 📚 a community-owned language-learning platform
Stars: ✭ 844 (+2457.58%)
Mutual labels:  svelte

Svelte Inspect

Live & interactive object inspector for Svelte, inspired by DevTools.

npm install --save svelte-inspect

Try the example in the svelte.dev REPL. Use mouse and keyboard to inspect the todos.

<script>
  import Todos from './Todos.svelte';

  // You have some data you want to inspect
  let todos = [
    {done: false, text: 'Import svelte-inspect'},
    {done: false, text: 'Pass any number of values to it'},
    {done: false, text: 'See them update live'}
  ];

  // Simply import svelte-inspect…
  import Inspect from 'svelte-inspect';
</script>

<!-- …and add an inspector anywhere on your page -->
<Inspect {todos} />

<Todos bind:todos={todos} />

Types

See REPL demo of most of the types. These types have special formatting:

  • Arrays (including TypedArrays)
  • Objects
  • Functions (including async functions)
  • Classes
  • Map and Set
  • RegExps
  • Dates
  • Booleans
  • undefined and null
  • Numbers (including BigInt)
  • Strings
  • Symbols
  • Errors
  • HTML elements

There's support for enumerable and non-enumerable properties, symbol keys, __proto__, and getters (click to evaluate). It does not yet have any special support for e.g. iterators, promises.

Keyboard navigation

You can use your keyboard to move around in the object hierarchy.

Keys Action
AZ 09 Type anything Jump using fuzzy matching
Tab Focus next
Shift + Tab Focus previous
Left Close or step out
Right Open or step in
Up Focus previous
Down Focus next
      Space Toggle
Enter Open & step in
esc Escape Step out

API

Inspect

Create one inspector for every value passed in as a prop, with default colors.

<script>
  import Inspect from 'svelte-inspect';
</script>

<Inspect value={'foo'} {value2} {...etc} />

Inspect.Value

Inspect a single value, without showing the name of the prop. Also takes an optional depth directly as a prop.

<script>
  import Inspect from 'svelte-inspect';

  /* Or as a named import:
  import {Value} from 'svelte-inspect';
  */
</script>

<Inspect.Value value={'foo'} depth={2} />

Inspect.Inverted

Inspector with color palette suitable for dark backgrounds.

<script>
  import Inspect from 'svelte-inspect';

  /* Or as a named import:
  import {Inverted} from 'svelte-inspect';
  */
</script>

<Inspect.Inverted value={'foo'} {value2} {...etc} />

Inspect[0-10]

Inspectors pre-configured with {depth: 0-10}.

<script>
  import Inspect from 'svelte-inspect';
</script>

<Inspect[2] {document} />

Inspect.configure(configuration)

Create an inspect component with custom configuration.

<script context="module">
  import Inspect from 'svelte-inspect';
  const CustomInspect = Inspect.configure({/* configuration */});

  /* Or as a named import:
  import {configure} from 'svelte-inspect';
  const CustomInspect = configure({/* configuration */});
  */
</script>

<CustomInspect value={'foo'} />

Note the use of context="module", which is required for the Svelte compiler to understand that CustomInspector can be used in the template.

The config is WIP. There are currently two options:

{depth: number}

Set how many levels of the object hierarchy should start in the open state. Defaults to 1.

<script context="module">
  import Inspect from 'svelte-inspect';
  const CustomInspect = Inspect.configure({depth: 2});
  const object = {
    foo: {
      array: [1, 2, 3]
    }
  };
</script>

<!-- 2 levels deep – will show `foo` and `array` but not `[1, 2, 3]` -->
<CustomInspect {object} />

Non-enumerable properties will not be opened.

{palette: {...colors}}

Create a component with a customized color palette. Values are any valid CSS color, keys are red, blue, green, purple, orange, yellow, brown, pink, gray, black, white and selection (note that not all of these colors are currently used).

(work in progress; expect to change)

<script context="module">
  import Inspect from 'svelte-inspect';
  const CustomInspect = Inspect.configure({
    palette: {
      selection: 'hotpink',
      blue: 'dodgerblue'
    }
  });
</script>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].