diff --git a/.gitignore b/.gitignore index daa834e..347b2fa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dist dist-ssr *.local tags +yarn-error.log diff --git a/package.json b/package.json index dc1278a..b48540e 100644 --- a/package.json +++ b/package.json @@ -2,23 +2,8 @@ "name": "schlechtenburg", "version": "0.0.0", "license": "GPL-3.0-or-later", - "scripts": { - "dev": "concurrently 'vuedx-typecheck --no-pretty --watch ./src' 'vite'", - "build": "vuedx-typecheck --no-pretty ./src && vite build" - }, - "dependencies": { - "lodash-es": "^4.17.21", - "vue": "^3.0.7" - }, + "scripts": {}, "devDependencies": { - "@vitejs/plugin-vue-jsx": "^1.1.2", - "@vue/compiler-sfc": "^3.0.7", - "@vuedx/typecheck": "^0.6.3", - "@vuedx/typescript-plugin-vue": "^0.6.3", - "concurrently": "^6.0.0", - "lerna": "^3.22.1", - "sass": "^1.32.8", - "typescript": "^4.2.3", - "vite": "^2.0.5" + "lerna": "^3.22.1" } } diff --git a/packages/core/lib/components/Block.tsx b/packages/core/lib/components/Block.tsx index 06cc6e6..58da740 100644 --- a/packages/core/lib/components/Block.tsx +++ b/packages/core/lib/components/Block.tsx @@ -8,15 +8,11 @@ import { } from 'vue'; import { BlockData } from '../types'; import { SbMode } from '../mode'; -import { useResizeObserver, SymBlockDimensions } from '../use-resize-observer'; -import { useActivation } from '../use-activation'; import { useBlockTree } from '../use-block-tree'; import { useDynamicBlocks } from '../use-dynamic-blocks'; import SbMissingBlock from './MissingBlock'; -import './Block.scss'; - export const SbBlock = defineComponent({ name: 'sb-block', @@ -40,17 +36,7 @@ export const SbBlock = defineComponent({ setup(props, context) { const el: Ref = ref(null); const { mode, getBlock } = useDynamicBlocks(); - const { - isActive, - activate, - } = useActivation(props.block.id); - const classes = computed(() => ({ - 'sb-block': true, - 'sb-block_active': isActive.value, - })); - - const { triggerSizeCalculation } = useResizeObserver(el, SymBlockDimensions); - watch(() => props.block.data, triggerSizeCalculation); + const classes = computed(() => ({ 'sb-block': true })); const { register } = useBlockTree(); register(props.block); @@ -88,8 +74,6 @@ export const SbBlock = defineComponent({ ref={el} class={classes.value} > -
- {context.slots['context-toolbar'] ? context.slots['context-toolbar']() : null} { $event.stopPropagation(); - activate(); }, ...context.attrs, }} diff --git a/packages/core/lib/components/Main.tsx b/packages/core/lib/components/Main.tsx index 49cc465..d877c2f 100644 --- a/packages/core/lib/components/Main.tsx +++ b/packages/core/lib/components/Main.tsx @@ -21,14 +21,9 @@ import { SymBlockTreeUnregister, } from '../use-block-tree'; import { SymEditorDimensions, useResizeObserver } from '../use-resize-observer'; -import { SymActiveBlock } from '../use-activation'; -import { SbMainMenu } from './MainMenu'; -import { SbBlockToolbar } from './BlockToolbar'; import { SbBlock } from './Block'; -import './Main.scss'; - export const SbMain = defineComponent({ name: 'sb-main', @@ -60,9 +55,6 @@ export const SbMain = defineComponent({ const mode = ref(props.mode); provide(Mode, mode); - const activeBlock = ref(null); - provide(SymActiveBlock, activeBlock); - const blockTree: Ref = ref(null); provide(SymBlockTree, blockTree); provide(SymBlockTreeRegister, (block: TreeNode) => { blockTree.value = block; }); @@ -82,14 +74,6 @@ export const SbMain = defineComponent({ class="sb-main" ref={el} > - { - mode.value === SbMode.Edit - ? <> - - - - : null - } TODO: description + +## Usage + +``` +const docs = require('@schlechtenburg/docs'); + +// TODO: DEMONSTRATE API +``` diff --git a/packages/docs/__tests__/docs.test.js b/packages/docs/__tests__/docs.test.js new file mode 100644 index 0000000..19e2a9b --- /dev/null +++ b/packages/docs/__tests__/docs.test.js @@ -0,0 +1,7 @@ +'use strict'; + +const docs = require('..'); + +describe('@schlechtenburg/docs', () => { + it('needs tests'); +}); diff --git a/index.html b/packages/docs/index.html similarity index 83% rename from index.html rename to packages/docs/index.html index a508f20..ac0d357 100644 --- a/index.html +++ b/packages/docs/index.html @@ -8,6 +8,6 @@
- + diff --git a/src/App.scss b/packages/docs/lib/App.scss similarity index 100% rename from src/App.scss rename to packages/docs/lib/App.scss diff --git a/packages/docs/lib/App.tsx b/packages/docs/lib/App.tsx new file mode 100644 index 0000000..d7928d5 --- /dev/null +++ b/packages/docs/lib/App.tsx @@ -0,0 +1,41 @@ +import { + onBeforeMount, + defineComponent, + reactive, +} from 'vue'; + +import { SbMain, BlockData, SbMode } from '@schlechtenburg/core'; + +export default defineComponent({ + name: 'App', + + setup() { + const block: BlockData = reactive({ + name: 'none', + id: '0', + data: null, + }); + + onBeforeMount(async () => { + const res = await fetch('./initial-data.json'); + const data = await res.json(); + block.name = data.name; + block.id = data.id; + block.data = data.data; + }); + + return () => { + return
+ ) => { + block.data = newBlock.data; + }} + customBlocks={[ ]} + key="edit" + mode={SbMode.Edit} + /> +
; + }; + }, +}); diff --git a/packages/docs/lib/docs.js b/packages/docs/lib/docs.js new file mode 100644 index 0000000..502c6d6 --- /dev/null +++ b/packages/docs/lib/docs.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = docs; + +function docs() { + // TODO +} diff --git a/src/main.scss b/packages/docs/lib/main.scss similarity index 100% rename from src/main.scss rename to packages/docs/lib/main.scss diff --git a/src/main.ts b/packages/docs/lib/main.ts similarity index 100% rename from src/main.ts rename to packages/docs/lib/main.ts diff --git a/packages/docs/package.json b/packages/docs/package.json new file mode 100644 index 0000000..83c031d --- /dev/null +++ b/packages/docs/package.json @@ -0,0 +1,46 @@ +{ + "name": "@schlechtenburg/docs", + "version": "0.0.0", + "description": "> TODO: description", + "author": "Benjamin Bädorf ", + "homepage": "", + "license": "GPL-3.0-or-later", + "main": "lib/index.ts", + "directories": { + "lib": "lib", + "test": "__tests__" + }, + "files": [ + "lib" + ], + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git@git.b12f.io:b12f/schlechtenburg.git" + }, + "scripts": { + "dev": "concurrently 'vuedx-typecheck --no-pretty --watch ./lib' 'vite'", + "build": "vuedx-typecheck --no-pretty ./lib && vite build" + }, + "dependencies": { + "@schlechtenburg/core": "^0.0.0", + "@schlechtenburg/heading": "^0.0.0", + "@schlechtenburg/image": "^0.0.0", + "@schlechtenburg/layout": "^0.0.0", + "@schlechtenburg/paragraph": "^0.0.0", + "lodash-es": "^4.17.21", + "vue": "^3.0.7" + }, + "devDependencies": { + "@vitejs/plugin-vue-jsx": "^1.1.2", + "@vue/compiler-sfc": "^3.0.7", + "@vuedx/typecheck": "^0.6.3", + "@vuedx/typescript-plugin-vue": "^0.6.3", + "concurrently": "^6.0.0", + "sass": "^1.32.8", + "typescript": "^4.2.3", + "vite": "^2.0.5" + } +} diff --git a/public/favicon.ico b/packages/docs/public/favicon.ico similarity index 100% rename from public/favicon.ico rename to packages/docs/public/favicon.ico diff --git a/public/initial-data.json b/packages/docs/public/initial-data.json similarity index 100% rename from public/initial-data.json rename to packages/docs/public/initial-data.json diff --git a/packages/docs/vite.config.js b/packages/docs/vite.config.js new file mode 100644 index 0000000..00996cb --- /dev/null +++ b/packages/docs/vite.config.js @@ -0,0 +1,26 @@ +import vueJsx from '@vitejs/plugin-vue-jsx'; + +export default { + base: './', + resolve: { + alias: { + '@schlechtenburg/core': '../core/lib/index.ts', + '@schlechtenburg/paragraph': '../paragraph/lib/index.ts', + '@schlechtenburg/heading': '../heading/lib/index.ts', + '@schlechtenburg/image': '../image/lib/index.ts', + '@schlechtenburg/layout': '../layout/lib/index.ts', + }, + }, + plugins: [ + vueJsx({}), + ], + esbuild: { + jsxFactory: 'h', + jsxFragment: 'Fragment', + }, + build: { + minify: false, + sourcemap: true, + outDir: 'dist', + }, +}; diff --git a/src/App.tsx b/src/App.tsx deleted file mode 100644 index ee3019d..0000000 --- a/src/App.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import { - onBeforeMount, - computed, - defineComponent, - reactive, - ref, -} from 'vue'; - -import { SbMain, BlockData, SbMode } from '../packages/core/lib'; - -import SbLayout from '../packages/layout/lib'; -import SbHeading from '../packages/heading/lib'; -import SbParagraph from '../packages/paragraph/lib'; -import SbImage from '../packages/image/lib'; - -import './App.scss'; - -export default defineComponent({ - name: 'App', - - setup() { - const activeTab = ref('edit'); - const block: BlockData = reactive({ - name: 'none', - id: '0', - data: null, - }); - - onBeforeMount(async () => { - const res = await fetch('./initial-data.json'); - const data = await res.json(); - block.name = data.name; - block.id = data.id; - block.data = data.data; - }); - - const displayedElement = computed(() => { - switch (activeTab.value) { - case SbMode.Edit: - return ) => { - block.data = newBlock.data; - }} - customBlocks={[ - SbLayout, - SbHeading, - SbImage, - SbParagraph, - ]} - key="edit" - mode={SbMode.Edit} - />; - case SbMode.Display: - return ; - case 'data': - return
{ JSON.stringify(block, null, 2) }
; - } - }); - - return () => { - return
- - {displayedElement.value} -
; - }; - }, -}); diff --git a/vite.config.js b/vite.config.js deleted file mode 100644 index e9f9939..0000000 --- a/vite.config.js +++ /dev/null @@ -1,17 +0,0 @@ -import vueJsx from '@vitejs/plugin-vue-jsx'; - -export default { - base: './', - plugins: [ - vueJsx({}), - ], - esbuild: { - jsxFactory: 'h', - jsxFragment: 'Fragment', - }, - build: { - minify: false, - sourcemap: true, - outDir: 'dist', - }, -};