All Projects → MacFJA → svelte-undoable

MacFJA / svelte-undoable

Licence: MIT license
Memento design pattern in Svelte

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
Svelte
593 projects
HTML
75241 projects

Projects that are alternatives of or similar to svelte-undoable

sdk-for-svelte
Appwrite SDK for Svelte 🧡 ⚠️ Warning - this SDK was designed to support Appwrite 0.9 and is not compatible with the latest Appwrite versions. We are planing to refactor it as part of the SDK Generator for better support and maintenance.
Stars: ✭ 69 (+76.92%)
Mutual labels:  svelte, sveltejs
ModalFileManager
A file manager built using Svelte and Wails. It has hotkeys that are modal just like Vim and NeoVim.
Stars: ✭ 21 (-46.15%)
Mutual labels:  svelte, sveltejs
ctx-core
A composable monorepo web-service/front-end toolkit
Stars: ✭ 25 (-35.9%)
Mutual labels:  svelte, sveltejs
sveltekit-blog
Sveltekit blog starter project created with sveltekit, typescript, tailwindcss, postcss, husky, and storybook. The project has the structure set up for the scaleable web application.
Stars: ✭ 100 (+156.41%)
Mutual labels:  svelte, sveltejs
s-date-range-picker
📅 A date range picker built with Svelte
Stars: ✭ 13 (-66.67%)
Mutual labels:  svelte, sveltejs
svelte-color-picker
A color picker component for svelte
Stars: ✭ 96 (+146.15%)
Mutual labels:  svelte, sveltejs
svelte-multiselect
Keyboard-friendly, accessible and highly customizable multi-select component
Stars: ✭ 91 (+133.33%)
Mutual labels:  svelte, svelte-component
svelte-inview
A Svelte action that monitors an element enters or leaves the viewport.🔥
Stars: ✭ 358 (+817.95%)
Mutual labels:  svelte, svelte-component
svelte-typewriter
A simple and reusable typewriter effect for your Svelte applications
Stars: ✭ 204 (+423.08%)
Mutual labels:  svelte, sveltejs
aqua-fanpage
⚓ 湊あくあ Fanpage created with Svelte and Sveltestrap.
Stars: ✭ 30 (-23.08%)
Mutual labels:  svelte, sveltejs
svelte-portal
Svelte component for rendering outside the DOM of parent component
Stars: ✭ 261 (+569.23%)
Mutual labels:  svelte, sveltejs
vite-plugin-webfont-dl
⚡ Webfont Download Vite Plugin - Make your Vite site load faster
Stars: ✭ 69 (+76.92%)
Mutual labels:  svelte, sveltejs
svelte-datagrid
Svelte data grid spreadsheet best best features and performance from excel
Stars: ✭ 48 (+23.08%)
Mutual labels:  svelte, sveltejs
hagura-sveltekit
A minimal markdown blog template built using SvelteKit
Stars: ✭ 51 (+30.77%)
Mutual labels:  svelte, sveltejs
fastify-vite
This plugin lets you load a Vite client application and set it up for Server-Side Rendering (SSR) with Fastify.
Stars: ✭ 497 (+1174.36%)
Mutual labels:  svelte, sveltejs
kahi-ui
Straight-forward Svelte UI for the Web
Stars: ✭ 169 (+333.33%)
Mutual labels:  svelte, sveltejs
fa-svelte
Font Awesome 5 for svelte.js
Stars: ✭ 72 (+84.62%)
Mutual labels:  svelte, sveltejs
SvelteTetris
Basic Tetris game created with Svelte
Stars: ✭ 21 (-46.15%)
Mutual labels:  svelte, sveltejs
d3-fdg-svelte
d3 Force Directed Graph example (d3-force) implemented in sveltejs. REPL:
Stars: ✭ 31 (-20.51%)
Mutual labels:  svelte, sveltejs
svelte-marquee-text
[CSS GPU Animation] Marquee Text for Svelte
Stars: ✭ 47 (+20.51%)
Mutual labels:  svelte, svelte-component

Svelte Undoable store

Memento design pattern in Svelte

Installation

npm install @macfja/svelte-undoable

Usage

import { undoable } from "@macfja/svelte-undoable"

let name = undoable("John")

$name = "Jeanne"
$name = "Doe"

name.undo()
// Now the value of $name is "Jeanne"

name.undo()
// Now $name is "John"

name.redo()
// Now $name is "Jeanne" again

Example

<script>
import { undoable, undo, redo, reset, canUndo, canRedo } from "@macfja/svelte-undoable"
import { derived } from "svelte/store"

let name = undoable("John")
let canUndoName = derived([name], () => canUndo(name))
let canRedoName = derived([name], () => canRedo(name))

let counter = undoable(0, 10, value => value%2 === 0)
let canUndoCounter = derived([counter], () => counter.canUndo())
let canRedoCounter = derived([counter], () => counter.canRedo())
</script>

<h1>Hello {$name}</h1>

<input bind:value={$name} />
<button disabled={!$canUndoName} on:click={() => undo(name)}>Undo</button>
<button disabled={!$canRedoName} on:click={() => redo(name)}>Redo</button>
<button disabled={!$canUndoName} on:click={() => reset(name)}>Reset</button>

<hr />
Only even number as saved in the store history. The maximum number of remembered value is 10.
(If you go to <code>20</code>, you can only go back to <code>2</code>)

<button on:click={() => $counter++}>
  Clicked {$counter} {$counter === 1 ? 'time' : 'times'}
</button>
<button disabled={!$canUndoCounter} on:click={() => undo(counter)}>Undo</button>
<button disabled={!$canRedoCounter} on:click={() => redo(counter)}>Redo</button>

(REPL)

Contributing

Contributions are welcome. Please open up an issue or create PR if you would like to help out.

Read more in the Contributing file

License

The MIT License (MIT). Please see License File for more information.

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].