Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chapter: #9 change book page path #17

Merged
merged 7 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ coverage
*.tsbuildinfo


book/.vitepress/cache
book/.vitepress/dist
packages/.vitepress/cache
packages/.vitepress/dist
49 changes: 0 additions & 49 deletions book/api-examples.md

This file was deleted.

85 changes: 0 additions & 85 deletions book/markdown-examples.md

This file was deleted.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"type-check": "vue-tsc --build --force",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"fmt": "prettier --write src/",
"docs:dev": "vitepress dev book",
"docs:build": "vitepress build book",
"docs:preview": "vitepress preview book"
"docs:dev": "vitepress dev packages",
"docs:build": "vitepress build packages",
"docs:preview": "vitepress preview packages"
},
"dependencies": {
"@vueuse/core": "^10.9.0",
Expand All @@ -22,6 +22,7 @@
"devDependencies": {
"@rushstack/eslint-patch": "^1.3.3",
"@tsconfig/node20": "^20.1.2",
"@types/fs-extra": "^11.0.4",
"@types/jsdom": "^21.1.6",
"@types/node": "^20.11.28",
"@vitejs/plugin-vue": "^5.0.4",
Expand All @@ -31,6 +32,7 @@
"@vue/tsconfig": "^0.5.1",
"eslint": "^8.49.0",
"eslint-plugin-vue": "^9.17.0",
"fs-extra": "^11.2.0",
"jsdom": "^24.0.0",
"npm-run-all2": "^6.1.2",
"prettier": "^3.0.3",
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { useManualRefHistory } from './useManualRefHistory';
export { useRefHistory } from './useRefHistory';
File renamed without changes.
45 changes: 45 additions & 0 deletions packages/core/useManualRefHistory/demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<script setup lang="ts">
import { ref } from 'vue';
// TODO: make formatDate
import { formatDate } from '@vueuse/core';

import { useManualRefHistory } from '../useManualRefHistory';

function format(ts: number) {
return formatDate(new Date(ts), 'YYYY-MM-DD HH:mm:ss');
}

const count = ref(0);
const inc = () => count.value++;
const dec = () => count.value--;
const { canUndo, canRedo, history, commit, undo, redo } = useManualRefHistory(count);
</script>

<template>
<div>Count: {{ count }}</div>
<button @click="inc()">
Increment
</button>
<button @click="dec()">
Decrement
</button>
<span class="ml-2">/</span>
<button @click="commit()">
Commit
</button>
<button :disabled="!canUndo" @click="undo()">
Undo
</button>
<button :disabled="!canRedo" @click="redo()">
Redo
</button>
<br>
<br>
<note>History (limited to 10 records for demo)</note>
<div class="code-block mt-4">
<div v-for="i in history" :key="i.timestamp">
<span class="opacity-50 mr-2 font-mono">{{ format(i.timestamp) }}</span>
<span class="font-mono">{ value: {{ i.snapshot }} }</span>
</div>
</div>
</template>
6 changes: 6 additions & 0 deletions packages/core/useManualRefHistory/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: State
related: useManualRefHistory
---

# useManualRefHistory
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// NOTE: 実際は 'vue-demi' からimportされてる
import { computed, markRaw, ref, type Ref } from 'vue';

import { timestamp } from '@/packages/shared/utils';
import { timestamp } from '@vueyous/shared';

export interface UseRefHistoryRecord<T> {
snapshot: T;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type Ref } from 'vue';
import { watchIgnorable } from '@/packages/shared';
import { watchIgnorable } from '@vueyous/shared';

import { useManualRefHistory, type UseManualRefHistoryReturn } from '../useManualRefHistory';

export interface UseRefHistoryReturn<Raw> extends UseManualRefHistoryReturn<Raw> {}
export interface UseRefHistoryReturn<Raw> extends UseManualRefHistoryReturn<Raw> { }

export function useRefHistory<Raw>(source: Ref<Raw>) {
const { ignoreUpdates } = watchIgnorable(source, commit);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed public/favicon.ico
Binary file not shown.
Loading