10.0.2 • Published 2 months ago

@eki-group/svelvet v10.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

banner

MIT License NPM Downloads GitHub Stars GitHub Forks NPM Version

Infinitely Customizable Node-Based User Interfaces with Svelvet!

Svelvet is a lightweight Svelte component library for building interactive node-based user interfaces and diagrams.

⚡ Website | 📚 Documentation | ⌨️ Blog | 💬 Twitter | 💼 LinkedIn

Version Updates

Shout out to our contributors! Here's what's new:

Changelog

  • Features:

    • Accessibility Enhancement: Now users can navigate the canvas using the keyboard.
      • Press 'l' to turn on light/dark mode.
      • Press 'd' to show drawer component, and 'D' to open/close drawer component.
      • Press Option + Tab || Ctrl + Tab for Node selection.
      • Press 'm' to toggle the minimap component.
      • Press 'c' to toggle control component.
      • Press 'e' to bring up editor component.
    • Persistent Canvas State: Added the ability to save the state persistently to local storage.
    • High Contrast Mode: Introduced a new high contrast accessibility component tailored for the visually impaired.
  • Refactoring:

    • Improved Keyboard Accessibility: Enhanced the keyboard accessibility of the drawer component through refactoring.
  • Documentation:

    • Updated Guidance: Documentation now includes instructions on utilizing keyboard accessibility features.
  • Miscellaneous:

    • Test Enhancements: Added comprehensive testing for drawer components.
    • Maintenance: Updated Playwright tests and configuration for improved stability.

Key Features

  • Easy to use: To get started with Svelvet, all you need is data for nodes and edges. Visit our documentation website for streamlined, user-friendly tutorials and examples on how to get the most out of your Svelvet interfaces!
  • Interactive: Elegant and smooth interface when selecting a node to drag it across the graph.
  • Customizable: Fully customizable Edges, Nodes, Backgrounds and components
  • Reliable: Svelvet is written in TypeScript and tested with Vitest, Playwright and Svelte Testing Library. Svelvet is maintained by motivated engineers seeking to contribute to the larger Svelte developer community and library ecosystem.
  • Room to Grow: There is so much we can do to improve, add features and make Svelvet the best version of itself - we welcome feedback and contributions! Scroll below for suggestions on how to contribute.

Installation

Svelvet is available as both an npm and a yarn package. You can install it by running one of the two commands:

npm install svelvet
yarn add svelvet

Quick Start

Start by importing the Svelvet and Node components into your application:

import { Svelvet, Node, Anchor, Edge, Controls } from 'svelvet';

A Svelvet canvas primarily consists of Nodes. You can pass any number of Nodes as children to the Svelvet wrapper. You can use all the standard conditional rendering syntax to populate nodes within the Svelvet component. Basic parameters like color, input and output count, label and more can be specified and feature two-way data binding with passed props. For greater customization, wrap your own custom components in our Node component and pass the whole thing to Svelvet.

Nodes, Edges and Anchors all feature click events, properties and functions to allow developers to fully customize the state of their graphs.

When creating custom Nodes, you can position any number of our Anchor components to enable dynamic connections. You can also wrap Nodes in a Group component to limit their boundaries and move them as one. These groups can be created dynamically by Shift + Click and dragging.

Finally, you can render our Controls, Minimap, Background and Theme Toggle components via props or named slots. In the latter use case, you can pass props to further customize them. The Controls component can wrap your own set of buttons as we expose the zoom/reset/lock actions using a let directive.

Svelvet is focused on dynamic edge connections, but if you'd like to specify edges ahead of time, you can pass an array of connections to any Anchor component. You can also pass a custom Edge component!

For more detailed use cases and examples, please visit our website.

<Svelvet width={500} height={500} theme="dark" initialZoom={0.6} minimap>
	<Node />
	<Node label="Demo Node" TD />
	<Node id="node-id" inputs={2} />
	<Node bgColor="red" inputs={10} outputs={5} height={200} position={{ x: 100, y: 100 }} />
	<Controls slot="controls" horizontal />
</Svelvet>

Testing

Testing is done with Playwright, Vitest, and the Svelte Testing Library. You can find tests in the /tests folder. We dramatically expanded test coverage, but there are still opportunities to improve it. In order to run the tests use the command:

For End-to-End testing

npx playwright test

For unit testing

npm run test:unit [filename]

The Svelvet Team

How to Contribute

Please refer to the roadmap for the full list of ideas for iteration. Some ideas inspired by v10.0.0 include:

  • Example Showcase: we've added a new section to the documentation which will contain example sandboxes of features and potential usecases of Svelvet. If you would like to contribute to the showcase with an example of how you’re using Svelvet, reach out to the team with your project via Github discussion.

  • Importing/Exporting canvas as JSON: we had planned to look into this as a way to maintain state through a page refresh.

  • Additional Data Input Components: we plan on creating additional input/parameter components that integrate with our data flow system and can be used when composing custom Nodes.

  • Extensive Test Converage: We expect to have full E2E and unit test coverage relatively soon. Especially the newly added features in contrast themes.

  • Accessibility Linter: We aim to ensure our components are accessible and compliant with accessibility standards. Implementation of an accessibility linter would streamline the process of identifying and rectifying accessibility issues within our components.

  • Persistent Canvas State saveStore.ts and reloadStore.ts lay the foundation for the save feature. They work together to get the state object of the canvas by turning it into a JSON string for storage and then parsing it into a JSON object for reconstruction. But they need further development as they only save the camera position and theme. Specifically, the traverse function in saveStore.ts needs to properly detect and expand each element inside the canvas (graph) state object. A good place to start on this would be addressing the anchors and edges property of the graph's state object. Use the "nodes" property on this object for reference on how this data should be unraveled and stored. Additionally, the createGraph function is used in reloadStore.ts to render a graph onMount of the Svelvet component according to the state object that was saved last in local storage on the user's browser. This implementation is simplified, however, so it only recreates the graph from partially saved data.

GET CREATIVE!! Svelvet is an amazing project that has so much room to grow.

Credits

Inspired by React Flow, Svelvet expands the tools available to Svelte developers and makes Svelte more inviting to both new and seasoned software engineers.

License

Svelvet is developed under the MIT license.

ababacornacorn-jsxacorn-walkagent-baseajvansi-regexansi-stylesanymatchargparsearia-queryarray-buffer-byte-lengtharray-unionassertion-errorasynckitavailable-typed-arraysaxe-coreaxe-html-reporteraxobject-querybalanced-matchbinary-extensionsblueimp-md5brace-expansionbracesbuffer-crc32caccall-bindcallsiteschaichalkcheck-errorchokidarcode-redcolor-convertcolor-namecombined-streamconcat-mapconcordancecookiecross-spawncss-treecssesccssstyledata-urlsdate-formatdate-timedebugdecimal.jsdedent-jsdeep-eqldeep-equaldeep-isdeepmergedefine-data-propertydefine-propertiesdelayed-streamdequaldetect-indentdevaluedir-globdoctrinedom-accessibility-apidomexceptionentitieses-define-propertyes-errorses-get-iteratores6-promiseesbuildescape-string-regexpeslint-compat-utilseslint-scopeeslint-visitor-keysesm-envespreeesqueryesrecurseestraverseestree-walkeresutilsfast-deep-equalfast-difffast-globfast-json-stable-stringifyfast-levenshteinfastqfile-entry-cachefill-rangefind-upflat-cacheflattedfor-eachform-datafs.realpathfseventsfunction-bindfunctions-have-namesget-func-nameget-intrinsicglobglob-parentglobalsglobalyzerglobbyglobrexgopdgraceful-fsgraphemerhas-bigintshas-flaghas-property-descriptorshas-protohas-symbolshas-tostringtaghasownhtml-encoding-snifferhttp-proxy-agenthttps-proxy-agenticonv-liteignoreignore-walkimport-freshimport-meta-resolveimurmurhashinflightinheritsinternal-slotis-argumentsis-array-bufferis-bigintis-binary-pathis-boolean-objectis-callableis-date-objectis-extglobis-globis-mapis-numberis-number-objectis-path-insideis-potential-custom-element-nameis-referenceis-regexis-setis-shared-array-bufferis-stringis-symbolis-weakmapis-weaksetisarrayisexejs-string-escapejs-tokensjs-yamljson-bufferjson-schema-traversejson-stable-stringify-without-jsonifyjsonc-parserjunit-report-builderkeyvkleurknown-css-propertieslevnlilconfiglocal-pkglocate-characterlocate-pathlodashlodash.mergeloupelower-caselru-cachelz-stringmagic-stringmake-dirmd5-hexmdn-datamerge2micromatchmime-dbmime-typesmin-indentminimatchminimistmkdirpmllymrimrmimemsmustachenanoidnatural-comparenatural-compare-liteno-casenormalize-pathnpm-bundlednpm-normalize-package-binnpm-packlistnwsapiobject-inspectobject-isobject-keysobject.assignonceoptionatorp-limitp-locateparent-moduleparse5pascal-casepath-existspath-is-absolutepath-keypath-typepathepathvalperiscopicpicocolorspicomatchpkg-typesplaywrightplaywright-corepossible-typed-array-namespostcsspostcss-load-configpostcss-safe-parserpostcss-scsspostcss-selector-parserprelude-lspretty-formatpslpunycodequerystringifyqueue-microtaskreact-isreaddirpregenerator-runtimeregexp.prototype.flagsrequires-portresolve-fromreusifyrimrafrolluprrweb-cssomrun-parallelsadesafer-buffersandersaxessemverset-cookie-parserset-function-lengthset-function-nameshebang-commandshebang-regexside-channelsiginfosirvslashsorcerysource-map-jsstackbackstd-envstop-iteration-iteratorstrip-ansistrip-indentstrip-json-commentsstrip-literalsupports-colorsveltesvelte-eslint-parsersvelte-hmrsvelte-preprocesssvelte2tsxsymbol-treetext-tabletime-zonetiny-globtinybenchtinypooltinyspyto-regex-rangetotalisttough-cookietr46tsutilstype-checktype-detecttype-festufoundiciundici-typesuniversalifyuri-jsurl-parseutil-deprecatevite-nodevitefuw3c-xmlserializerwebidl-conversionswell-known-symbolswhatwg-encodingwhatwg-mimetypewhatwg-urlwhichwhich-boxed-primitivewhich-collectionwhich-typed-arraywhy-is-node-runningwrappywsxml-name-validatorxmlbuilderxmlcharsyallistyamlyocto-queue
10.0.2

2 months ago