@rokkit/stories 1.0.0-next.131 → 1.0.0-next.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/package.json +7 -2
- package/src/Code.svelte +0 -21
- package/src/CodeViewer.svelte +0 -16
- package/src/CopyToClipboard.svelte +0 -26
- package/src/Notes.svelte +0 -57
- package/src/Preview.svelte +0 -10
- package/src/lib/StoryViewer.svelte +0 -16
- package/tsconfig.build.json +0 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jerry Thomas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/stories",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.133",
|
|
4
4
|
"description": "Utilities for building tutorials.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,8 +22,13 @@
|
|
|
22
22
|
"import": "./src/index.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
+
"files": [
|
|
26
|
+
"src/**/*.js",
|
|
27
|
+
"dist/**/*.d.ts",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
25
30
|
"scripts": {
|
|
26
|
-
"prepublishOnly": "bun clean && bun tsc --project tsconfig.build.json",
|
|
31
|
+
"prepublishOnly": "cp ../../LICENSE . && bun clean && bun tsc --project tsconfig.build.json",
|
|
27
32
|
"clean": "rm -rf dist",
|
|
28
33
|
"build": "bun prepublishOnly"
|
|
29
34
|
},
|
package/src/Code.svelte
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { vibe } from '@rokkit/states'
|
|
3
|
-
import { highlightCode } from './shiki.js'
|
|
4
|
-
import CopyToClipboard from './CopyToClipboard.svelte'
|
|
5
|
-
|
|
6
|
-
let { content, language } = $props()
|
|
7
|
-
let theme = $derived(vibe.mode === 'dark' ? 'github-dark' : 'github-light')
|
|
8
|
-
let highlightedCode = $derived(highlightCode(content, { lang: language, theme }))
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<div data-code-root>
|
|
12
|
-
<CopyToClipboard {content} floating={true} />
|
|
13
|
-
{#await highlightedCode}
|
|
14
|
-
<div class="text-surface-z7 p-4">Highlighting code...</div>
|
|
15
|
-
{:then code}
|
|
16
|
-
<!-- eslint-disable svelte/no-at-html-tags -->
|
|
17
|
-
{@html code}
|
|
18
|
-
{:catch error}
|
|
19
|
-
<div class="p-4 text-red-500">Error highlighting code: {error.message}</div>
|
|
20
|
-
{/await}
|
|
21
|
-
</div>
|
package/src/CodeViewer.svelte
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { Tabs } from '@rokkit/ui'
|
|
3
|
-
import Code from './Code.svelte'
|
|
4
|
-
let { files = [] } = $props()
|
|
5
|
-
let current = $state(null)
|
|
6
|
-
$effect(() => {
|
|
7
|
-
if (files.length > 0 && current === null) {
|
|
8
|
-
current = files[0]
|
|
9
|
-
}
|
|
10
|
-
})
|
|
11
|
-
let fields = { text: 'name', icon: 'language' }
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<Tabs items={files} {fields} bind:value={current} class="no-padding">
|
|
15
|
-
<Code content={current?.content} language={current?.language} />
|
|
16
|
-
</Tabs>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { DEFAULT_STATE_ICONS } from '@rokkit/core'
|
|
3
|
-
import { Icon, Button } from '@rokkit/ui'
|
|
4
|
-
let { content, class: className = 'absolute right-2 top-2 z-10', title = 'Copy code' } = $props()
|
|
5
|
-
let copySuccess = $state(false)
|
|
6
|
-
|
|
7
|
-
async function copyToClipboard() {
|
|
8
|
-
try {
|
|
9
|
-
await navigator.clipboard.writeText(content || '')
|
|
10
|
-
copySuccess = true
|
|
11
|
-
setTimeout(() => {
|
|
12
|
-
copySuccess = false
|
|
13
|
-
}, 2000)
|
|
14
|
-
} catch (err) {
|
|
15
|
-
console.error('Failed to copy code:', err)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<Button onclick={copyToClipboard} class={className} {title}>
|
|
21
|
-
{#if copySuccess}
|
|
22
|
-
<Icon name={DEFAULT_STATE_ICONS.action.copysuccess} />
|
|
23
|
-
{:else}
|
|
24
|
-
<Icon name={DEFAULT_STATE_ICONS.action.copy} />
|
|
25
|
-
{/if}
|
|
26
|
-
</Button>
|
package/src/Notes.svelte
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { Icon, BreadCrumbs } from '@rokkit/ui'
|
|
3
|
-
import { getContext } from 'svelte'
|
|
4
|
-
import { goto } from '$app/navigation'
|
|
5
|
-
import { page } from '$app/state'
|
|
6
|
-
const site = getContext('site')()
|
|
7
|
-
|
|
8
|
-
let { content, crumbs, previous, next } = $props()
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {string} route
|
|
12
|
-
*/
|
|
13
|
-
async function gotoPage(route) {
|
|
14
|
-
if (route) {
|
|
15
|
-
const location = `/${ page.params.segment }/${ route}`
|
|
16
|
-
await goto(location)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function toggle() {
|
|
20
|
-
site.sidebar = !site.sidebar
|
|
21
|
-
}
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<aside class="border-r-surface-z0 flex h-full w-full flex-col border-r">
|
|
25
|
-
{#if content}
|
|
26
|
-
<nav class="border-b-surface-z0 box-border flex h-10 items-center gap-1 border-b px-2 text-sm">
|
|
27
|
-
{#if !site.sidebar}
|
|
28
|
-
<Icon
|
|
29
|
-
name="i-rokkit:menu"
|
|
30
|
-
class="border-r-surface-z2 border-r"
|
|
31
|
-
role="button"
|
|
32
|
-
onclick={toggle}
|
|
33
|
-
/>
|
|
34
|
-
{/if}
|
|
35
|
-
<Icon
|
|
36
|
-
name="i-rokkit:arrow-left"
|
|
37
|
-
role="button"
|
|
38
|
-
onclick={() => gotoPage(previous)}
|
|
39
|
-
class="square"
|
|
40
|
-
/>
|
|
41
|
-
<h1 class="w-full">
|
|
42
|
-
<BreadCrumbs items={crumbs} class="text-xs" />
|
|
43
|
-
</h1>
|
|
44
|
-
<Icon
|
|
45
|
-
name="i-rokkit:arrow-right"
|
|
46
|
-
role="button"
|
|
47
|
-
onclick={() => gotoPage(next)}
|
|
48
|
-
class="square"
|
|
49
|
-
/>
|
|
50
|
-
</nav>
|
|
51
|
-
|
|
52
|
-
{@const SvelteComponent = content}
|
|
53
|
-
<notes class="markdown-body h-full w-full overflow-scroll p-8 font-thin">
|
|
54
|
-
<SvelteComponent />
|
|
55
|
-
</notes>
|
|
56
|
-
{/if}
|
|
57
|
-
</aside>
|
package/src/Preview.svelte
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import CodeViewer from './CodeViewer.svelte'
|
|
3
|
-
|
|
4
|
-
let { App, files } = $props()
|
|
5
|
-
</script>
|
|
6
|
-
|
|
7
|
-
<div data-story-root>
|
|
8
|
-
<div data-story-preview>
|
|
9
|
-
{#if App}
|
|
10
|
-
<App />
|
|
11
|
-
{:else}
|
|
12
|
-
<div>No preview available</div>
|
|
13
|
-
{/if}
|
|
14
|
-
</div>
|
|
15
|
-
<CodeViewer {files} />
|
|
16
|
-
</div>
|
package/tsconfig.build.json
DELETED