@pyreon/document-primitives 0.11.4 → 0.11.6
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/lib/index.d.ts +1 -1
- package/lib/index.js +11 -11
- package/package.json +34 -33
- package/src/DocumentPreview.ts +24 -24
- package/src/__tests__/primitives-attrs.test.ts +238 -300
- package/src/__tests__/primitives.test.ts +61 -61
- package/src/__tests__/useDocumentExport.test.ts +28 -28
- package/src/index.ts +25 -25
- package/src/primitives/DocButton.ts +17 -17
- package/src/primitives/DocCode.ts +8 -8
- package/src/primitives/DocColumn.ts +5 -5
- package/src/primitives/DocDivider.ts +6 -6
- package/src/primitives/DocDocument.ts +5 -5
- package/src/primitives/DocHeading.ts +9 -9
- package/src/primitives/DocImage.ts +6 -6
- package/src/primitives/DocLink.ts +8 -8
- package/src/primitives/DocList.ts +5 -5
- package/src/primitives/DocListItem.ts +5 -5
- package/src/primitives/DocPage.ts +7 -7
- package/src/primitives/DocPageBreak.ts +5 -5
- package/src/primitives/DocQuote.ts +9 -9
- package/src/primitives/DocRow.ts +6 -6
- package/src/primitives/DocSection.ts +8 -8
- package/src/primitives/DocSpacer.ts +5 -5
- package/src/primitives/DocTable.ts +7 -7
- package/src/primitives/DocText.ts +12 -12
- package/src/theme.ts +11 -11
- package/src/useDocumentExport.ts +3 -3
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { describe, expect, it } from
|
|
2
|
-
import DocButton from
|
|
3
|
-
import DocCode from
|
|
4
|
-
import DocColumn from
|
|
5
|
-
import DocDivider from
|
|
6
|
-
import DocDocument from
|
|
7
|
-
import DocHeading from
|
|
8
|
-
import DocImage from
|
|
9
|
-
import DocLink from
|
|
10
|
-
import DocList from
|
|
11
|
-
import DocListItem from
|
|
12
|
-
import DocPage from
|
|
13
|
-
import DocPageBreak from
|
|
14
|
-
import DocQuote from
|
|
15
|
-
import DocRow from
|
|
16
|
-
import DocSection from
|
|
17
|
-
import DocSpacer from
|
|
18
|
-
import DocTable from
|
|
19
|
-
import DocText from
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import DocButton from '../primitives/DocButton'
|
|
3
|
+
import DocCode from '../primitives/DocCode'
|
|
4
|
+
import DocColumn from '../primitives/DocColumn'
|
|
5
|
+
import DocDivider from '../primitives/DocDivider'
|
|
6
|
+
import DocDocument from '../primitives/DocDocument'
|
|
7
|
+
import DocHeading from '../primitives/DocHeading'
|
|
8
|
+
import DocImage from '../primitives/DocImage'
|
|
9
|
+
import DocLink from '../primitives/DocLink'
|
|
10
|
+
import DocList from '../primitives/DocList'
|
|
11
|
+
import DocListItem from '../primitives/DocListItem'
|
|
12
|
+
import DocPage from '../primitives/DocPage'
|
|
13
|
+
import DocPageBreak from '../primitives/DocPageBreak'
|
|
14
|
+
import DocQuote from '../primitives/DocQuote'
|
|
15
|
+
import DocRow from '../primitives/DocRow'
|
|
16
|
+
import DocSection from '../primitives/DocSection'
|
|
17
|
+
import DocSpacer from '../primitives/DocSpacer'
|
|
18
|
+
import DocTable from '../primitives/DocTable'
|
|
19
|
+
import DocText from '../primitives/DocText'
|
|
20
20
|
|
|
21
|
-
describe(
|
|
21
|
+
describe('document primitives _documentType markers', () => {
|
|
22
22
|
const components = [
|
|
23
|
-
{ name:
|
|
24
|
-
{ name:
|
|
25
|
-
{ name:
|
|
26
|
-
{ name:
|
|
27
|
-
{ name:
|
|
28
|
-
{ name:
|
|
29
|
-
{ name:
|
|
30
|
-
{ name:
|
|
31
|
-
{ name:
|
|
32
|
-
{ name:
|
|
33
|
-
{ name:
|
|
34
|
-
{ name:
|
|
35
|
-
{ name:
|
|
36
|
-
{ name:
|
|
37
|
-
{ name:
|
|
38
|
-
{ name:
|
|
39
|
-
{ name:
|
|
40
|
-
{ name:
|
|
23
|
+
{ name: 'DocDocument', component: DocDocument, type: 'document' },
|
|
24
|
+
{ name: 'DocPage', component: DocPage, type: 'page' },
|
|
25
|
+
{ name: 'DocSection', component: DocSection, type: 'section' },
|
|
26
|
+
{ name: 'DocRow', component: DocRow, type: 'row' },
|
|
27
|
+
{ name: 'DocColumn', component: DocColumn, type: 'column' },
|
|
28
|
+
{ name: 'DocHeading', component: DocHeading, type: 'heading' },
|
|
29
|
+
{ name: 'DocText', component: DocText, type: 'text' },
|
|
30
|
+
{ name: 'DocLink', component: DocLink, type: 'link' },
|
|
31
|
+
{ name: 'DocImage', component: DocImage, type: 'image' },
|
|
32
|
+
{ name: 'DocTable', component: DocTable, type: 'table' },
|
|
33
|
+
{ name: 'DocList', component: DocList, type: 'list' },
|
|
34
|
+
{ name: 'DocListItem', component: DocListItem, type: 'list-item' },
|
|
35
|
+
{ name: 'DocCode', component: DocCode, type: 'code' },
|
|
36
|
+
{ name: 'DocDivider', component: DocDivider, type: 'divider' },
|
|
37
|
+
{ name: 'DocSpacer', component: DocSpacer, type: 'spacer' },
|
|
38
|
+
{ name: 'DocButton', component: DocButton, type: 'button' },
|
|
39
|
+
{ name: 'DocQuote', component: DocQuote, type: 'quote' },
|
|
40
|
+
{ name: 'DocPageBreak', component: DocPageBreak, type: 'page-break' },
|
|
41
41
|
]
|
|
42
42
|
|
|
43
43
|
for (const { name, component, type } of components) {
|
|
@@ -46,59 +46,59 @@ describe("document primitives _documentType markers", () => {
|
|
|
46
46
|
})
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
it(
|
|
49
|
+
it('all 18 node types are covered', () => {
|
|
50
50
|
expect(components).toHaveLength(18)
|
|
51
51
|
const types = new Set(components.map((c) => c.type))
|
|
52
52
|
expect(types.size).toBe(18)
|
|
53
53
|
})
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
describe(
|
|
57
|
-
it(
|
|
58
|
-
expect(DocHeading.displayName).toBe(
|
|
56
|
+
describe('document primitives have displayName', () => {
|
|
57
|
+
it('DocHeading', () => {
|
|
58
|
+
expect(DocHeading.displayName).toBe('DocHeading')
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
-
it(
|
|
62
|
-
expect(DocText.displayName).toBe(
|
|
61
|
+
it('DocText', () => {
|
|
62
|
+
expect(DocText.displayName).toBe('DocText')
|
|
63
63
|
})
|
|
64
64
|
|
|
65
|
-
it(
|
|
66
|
-
expect(DocSection.displayName).toBe(
|
|
65
|
+
it('DocSection', () => {
|
|
66
|
+
expect(DocSection.displayName).toBe('DocSection')
|
|
67
67
|
})
|
|
68
68
|
|
|
69
|
-
it(
|
|
70
|
-
expect(DocTable.displayName).toBe(
|
|
69
|
+
it('DocTable', () => {
|
|
70
|
+
expect(DocTable.displayName).toBe('DocTable')
|
|
71
71
|
})
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
describe(
|
|
75
|
-
it(
|
|
76
|
-
expect(typeof DocHeading).toBe(
|
|
74
|
+
describe('document primitives are callable', () => {
|
|
75
|
+
it('DocHeading is a function', () => {
|
|
76
|
+
expect(typeof DocHeading).toBe('function')
|
|
77
77
|
})
|
|
78
78
|
|
|
79
|
-
it(
|
|
80
|
-
expect(typeof DocText).toBe(
|
|
79
|
+
it('DocText is a function', () => {
|
|
80
|
+
expect(typeof DocText).toBe('function')
|
|
81
81
|
})
|
|
82
82
|
|
|
83
|
-
it(
|
|
84
|
-
expect(typeof DocTable).toBe(
|
|
83
|
+
it('DocTable is a function', () => {
|
|
84
|
+
expect(typeof DocTable).toBe('function')
|
|
85
85
|
})
|
|
86
86
|
|
|
87
|
-
it(
|
|
88
|
-
expect(typeof DocDocument).toBe(
|
|
87
|
+
it('DocDocument is a function', () => {
|
|
88
|
+
expect(typeof DocDocument).toBe('function')
|
|
89
89
|
})
|
|
90
90
|
})
|
|
91
91
|
|
|
92
|
-
describe(
|
|
93
|
-
it(
|
|
92
|
+
describe('document primitives IS_ROCKETSTYLE', () => {
|
|
93
|
+
it('DocHeading is a rocketstyle component', () => {
|
|
94
94
|
expect((DocHeading as any).IS_ROCKETSTYLE).toBe(true)
|
|
95
95
|
})
|
|
96
96
|
|
|
97
|
-
it(
|
|
97
|
+
it('DocText is a rocketstyle component', () => {
|
|
98
98
|
expect((DocText as any).IS_ROCKETSTYLE).toBe(true)
|
|
99
99
|
})
|
|
100
100
|
|
|
101
|
-
it(
|
|
101
|
+
it('DocSection is a rocketstyle component', () => {
|
|
102
102
|
expect((DocSection as any).IS_ROCKETSTYLE).toBe(true)
|
|
103
103
|
})
|
|
104
104
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { DocumentMarker } from
|
|
2
|
-
import { describe, expect, it } from
|
|
3
|
-
import { createDocumentExport } from
|
|
1
|
+
import type { DocumentMarker } from '@pyreon/connector-document'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { createDocumentExport } from '../useDocumentExport'
|
|
4
4
|
|
|
5
5
|
// Mock VNode
|
|
6
6
|
const vnode = (
|
|
@@ -11,70 +11,70 @@ const vnode = (
|
|
|
11
11
|
|
|
12
12
|
// Mock document-marked component
|
|
13
13
|
const docComponent = (docType: string) => {
|
|
14
|
-
const fn = (props: any) => vnode(
|
|
14
|
+
const fn = (props: any) => vnode('div', props, props.children ? [props.children] : [])
|
|
15
15
|
;(fn as any)._documentType = docType
|
|
16
16
|
return fn as ((...args: any[]) => any) & DocumentMarker
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const DocDocument = docComponent(
|
|
20
|
-
const DocHeading = docComponent(
|
|
21
|
-
const DocText = docComponent(
|
|
19
|
+
const DocDocument = docComponent('document')
|
|
20
|
+
const DocHeading = docComponent('heading')
|
|
21
|
+
const DocText = docComponent('text')
|
|
22
22
|
|
|
23
|
-
describe(
|
|
24
|
-
it(
|
|
23
|
+
describe('createDocumentExport', () => {
|
|
24
|
+
it('extracts a document tree from template function', () => {
|
|
25
25
|
const doc = createDocumentExport(() =>
|
|
26
|
-
vnode(DocDocument, { _documentProps: { title:
|
|
26
|
+
vnode(DocDocument, { _documentProps: { title: 'Test' } }, [
|
|
27
27
|
vnode(
|
|
28
28
|
DocHeading,
|
|
29
29
|
{
|
|
30
|
-
$rocketstyle: { fontSize: 24, fontWeight:
|
|
30
|
+
$rocketstyle: { fontSize: 24, fontWeight: 'bold' },
|
|
31
31
|
_documentProps: { level: 1 },
|
|
32
32
|
},
|
|
33
|
-
[
|
|
33
|
+
['Hello'],
|
|
34
34
|
),
|
|
35
35
|
vnode(
|
|
36
36
|
DocText,
|
|
37
37
|
{
|
|
38
|
-
$rocketstyle: { fontSize: 14, color:
|
|
38
|
+
$rocketstyle: { fontSize: 14, color: '#333' },
|
|
39
39
|
},
|
|
40
|
-
[
|
|
40
|
+
['World'],
|
|
41
41
|
),
|
|
42
42
|
]),
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
const tree = doc.getDocNode()
|
|
46
46
|
|
|
47
|
-
expect(tree.type).toBe(
|
|
48
|
-
expect(tree.props.title).toBe(
|
|
47
|
+
expect(tree.type).toBe('document')
|
|
48
|
+
expect(tree.props.title).toBe('Test')
|
|
49
49
|
expect(tree.children).toHaveLength(2)
|
|
50
50
|
|
|
51
51
|
const heading = tree.children[0] as any
|
|
52
|
-
expect(heading.type).toBe(
|
|
52
|
+
expect(heading.type).toBe('heading')
|
|
53
53
|
expect(heading.props.level).toBe(1)
|
|
54
54
|
expect(heading.styles?.fontSize).toBe(24)
|
|
55
|
-
expect(heading.children).toEqual([
|
|
55
|
+
expect(heading.children).toEqual(['Hello'])
|
|
56
56
|
|
|
57
57
|
const text = tree.children[1] as any
|
|
58
|
-
expect(text.type).toBe(
|
|
58
|
+
expect(text.type).toBe('text')
|
|
59
59
|
expect(text.styles?.fontSize).toBe(14)
|
|
60
|
-
expect(text.styles?.color).toBe(
|
|
60
|
+
expect(text.styles?.color).toBe('#333')
|
|
61
61
|
})
|
|
62
62
|
|
|
63
|
-
it(
|
|
63
|
+
it('can be called multiple times', () => {
|
|
64
64
|
const doc = createDocumentExport(() =>
|
|
65
|
-
vnode(DocText, { $rocketstyle: { fontSize: 14 } }, [
|
|
65
|
+
vnode(DocText, { $rocketstyle: { fontSize: 14 } }, ['Static']),
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
const tree1 = doc.getDocNode()
|
|
69
69
|
const tree2 = doc.getDocNode()
|
|
70
70
|
|
|
71
|
-
expect(tree1.type).toBe(
|
|
72
|
-
expect(tree2.type).toBe(
|
|
71
|
+
expect(tree1.type).toBe('text')
|
|
72
|
+
expect(tree2.type).toBe('text')
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
it(
|
|
75
|
+
it('respects includeStyles option', () => {
|
|
76
76
|
const doc = createDocumentExport(
|
|
77
|
-
() => vnode(DocHeading, { $rocketstyle: { fontSize: 24 } }, [
|
|
77
|
+
() => vnode(DocHeading, { $rocketstyle: { fontSize: 24 } }, ['Hello']),
|
|
78
78
|
{ includeStyles: false },
|
|
79
79
|
)
|
|
80
80
|
|
|
@@ -82,11 +82,11 @@ describe("createDocumentExport", () => {
|
|
|
82
82
|
expect(tree.styles).toBeUndefined()
|
|
83
83
|
})
|
|
84
84
|
|
|
85
|
-
it(
|
|
85
|
+
it('handles empty template', () => {
|
|
86
86
|
const doc = createDocumentExport(() => null)
|
|
87
87
|
|
|
88
88
|
const tree = doc.getDocNode()
|
|
89
|
-
expect(tree.type).toBe(
|
|
89
|
+
expect(tree.type).toBe('document')
|
|
90
90
|
expect(tree.children).toEqual([])
|
|
91
91
|
})
|
|
92
92
|
})
|
package/src/index.ts
CHANGED
|
@@ -6,32 +6,32 @@ export type {
|
|
|
6
6
|
ExtractOptions,
|
|
7
7
|
NodeType,
|
|
8
8
|
ResolvedStyles,
|
|
9
|
-
} from
|
|
10
|
-
export { extractDocumentTree, resolveStyles } from
|
|
9
|
+
} from '@pyreon/connector-document'
|
|
10
|
+
export { extractDocumentTree, resolveStyles } from '@pyreon/connector-document'
|
|
11
11
|
// Preview
|
|
12
|
-
export { default as DocumentPreview } from
|
|
12
|
+
export { default as DocumentPreview } from './DocumentPreview'
|
|
13
13
|
// Primitives
|
|
14
|
-
export { default as DocButton } from
|
|
15
|
-
export { default as DocCode } from
|
|
16
|
-
export { default as DocColumn } from
|
|
17
|
-
export { default as DocDivider } from
|
|
18
|
-
export { default as DocDocument } from
|
|
19
|
-
export { default as DocHeading } from
|
|
20
|
-
export { default as DocImage } from
|
|
21
|
-
export { default as DocLink } from
|
|
22
|
-
export { default as DocList } from
|
|
23
|
-
export { default as DocListItem } from
|
|
24
|
-
export { default as DocPage } from
|
|
25
|
-
export { default as DocPageBreak } from
|
|
26
|
-
export { default as DocQuote } from
|
|
27
|
-
export { default as DocRow } from
|
|
28
|
-
export { default as DocSection } from
|
|
29
|
-
export { default as DocSpacer } from
|
|
30
|
-
export { default as DocTable } from
|
|
31
|
-
export { default as DocText } from
|
|
14
|
+
export { default as DocButton } from './primitives/DocButton'
|
|
15
|
+
export { default as DocCode } from './primitives/DocCode'
|
|
16
|
+
export { default as DocColumn } from './primitives/DocColumn'
|
|
17
|
+
export { default as DocDivider } from './primitives/DocDivider'
|
|
18
|
+
export { default as DocDocument } from './primitives/DocDocument'
|
|
19
|
+
export { default as DocHeading } from './primitives/DocHeading'
|
|
20
|
+
export { default as DocImage } from './primitives/DocImage'
|
|
21
|
+
export { default as DocLink } from './primitives/DocLink'
|
|
22
|
+
export { default as DocList } from './primitives/DocList'
|
|
23
|
+
export { default as DocListItem } from './primitives/DocListItem'
|
|
24
|
+
export { default as DocPage } from './primitives/DocPage'
|
|
25
|
+
export { default as DocPageBreak } from './primitives/DocPageBreak'
|
|
26
|
+
export { default as DocQuote } from './primitives/DocQuote'
|
|
27
|
+
export { default as DocRow } from './primitives/DocRow'
|
|
28
|
+
export { default as DocSection } from './primitives/DocSection'
|
|
29
|
+
export { default as DocSpacer } from './primitives/DocSpacer'
|
|
30
|
+
export { default as DocTable } from './primitives/DocTable'
|
|
31
|
+
export { default as DocText } from './primitives/DocText'
|
|
32
32
|
// Theme
|
|
33
|
-
export type { DocumentTheme } from
|
|
34
|
-
export { documentTheme } from
|
|
33
|
+
export type { DocumentTheme } from './theme'
|
|
34
|
+
export { documentTheme } from './theme'
|
|
35
35
|
// Export helper
|
|
36
|
-
export type { DocumentExport, DocumentExportOptions } from
|
|
37
|
-
export { createDocumentExport } from
|
|
36
|
+
export type { DocumentExport, DocumentExportOptions } from './useDocumentExport'
|
|
37
|
+
export { createDocumentExport } from './useDocumentExport'
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { Text } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Text } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
4
|
const DocButton = rocketstyle({
|
|
5
5
|
dimensions: {
|
|
6
|
-
variants:
|
|
6
|
+
variants: 'variant',
|
|
7
7
|
},
|
|
8
8
|
useBooleans: true,
|
|
9
|
-
})({ name:
|
|
9
|
+
})({ name: 'DocButton', component: Text })
|
|
10
10
|
.theme({
|
|
11
11
|
fontSize: 14,
|
|
12
|
-
fontWeight:
|
|
13
|
-
padding:
|
|
12
|
+
fontWeight: 'bold',
|
|
13
|
+
padding: '10px 24px',
|
|
14
14
|
borderRadius: 4,
|
|
15
|
-
textAlign:
|
|
16
|
-
textDecoration:
|
|
15
|
+
textAlign: 'center',
|
|
16
|
+
textDecoration: 'none',
|
|
17
17
|
})
|
|
18
18
|
.variants({
|
|
19
19
|
primary: {
|
|
20
|
-
backgroundColor:
|
|
21
|
-
color:
|
|
20
|
+
backgroundColor: '#4f46e5',
|
|
21
|
+
color: '#ffffff',
|
|
22
22
|
},
|
|
23
23
|
secondary: {
|
|
24
|
-
backgroundColor:
|
|
25
|
-
color:
|
|
24
|
+
backgroundColor: '#ffffff',
|
|
25
|
+
color: '#4f46e5',
|
|
26
26
|
borderWidth: 1,
|
|
27
|
-
borderColor:
|
|
28
|
-
borderStyle:
|
|
27
|
+
borderColor: '#4f46e5',
|
|
28
|
+
borderStyle: 'solid',
|
|
29
29
|
},
|
|
30
30
|
})
|
|
31
|
-
.statics({ _documentType:
|
|
31
|
+
.statics({ _documentType: 'button' as const })
|
|
32
32
|
.attrs<{ href?: string; tag: string; _documentProps: { href: string } }>((props) => ({
|
|
33
|
-
tag:
|
|
34
|
-
_documentProps: { href: props.href ??
|
|
33
|
+
tag: 'a',
|
|
34
|
+
_documentProps: { href: props.href ?? '#' },
|
|
35
35
|
}))
|
|
36
36
|
|
|
37
37
|
export default DocButton
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Text } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Text } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocCode = rocketstyle()({ name:
|
|
4
|
+
const DocCode = rocketstyle()({ name: 'DocCode', component: Text })
|
|
5
5
|
.theme({
|
|
6
|
-
fontFamily:
|
|
6
|
+
fontFamily: 'ui-monospace, monospace',
|
|
7
7
|
fontSize: 13,
|
|
8
|
-
backgroundColor:
|
|
9
|
-
padding:
|
|
8
|
+
backgroundColor: '#f5f5f5',
|
|
9
|
+
padding: '8px 12px',
|
|
10
10
|
borderRadius: 4,
|
|
11
11
|
})
|
|
12
|
-
.statics({ _documentType:
|
|
12
|
+
.statics({ _documentType: 'code' as const })
|
|
13
13
|
.attrs<{ language?: string; tag: string; _documentProps: Record<string, unknown> }>((props) => ({
|
|
14
|
-
tag:
|
|
14
|
+
tag: 'pre',
|
|
15
15
|
_documentProps: props.language ? { language: props.language } : {},
|
|
16
16
|
}))
|
|
17
17
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocColumn = rocketstyle()({ name:
|
|
5
|
-
.statics({ _documentType:
|
|
4
|
+
const DocColumn = rocketstyle()({ name: 'DocColumn', component: Element })
|
|
5
|
+
.statics({ _documentType: 'column' as const })
|
|
6
6
|
.attrs<{ width?: number | string; tag: string; _documentProps: Record<string, unknown> }>(
|
|
7
7
|
(props) => ({
|
|
8
|
-
tag:
|
|
8
|
+
tag: 'div',
|
|
9
9
|
_documentProps: props.width != null ? { width: props.width } : {},
|
|
10
10
|
}),
|
|
11
11
|
)
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocDivider = rocketstyle()({ name:
|
|
4
|
+
const DocDivider = rocketstyle()({ name: 'DocDivider', component: Element })
|
|
5
5
|
.theme({
|
|
6
|
-
borderColor:
|
|
6
|
+
borderColor: '#dddddd',
|
|
7
7
|
borderWidth: 1,
|
|
8
8
|
})
|
|
9
|
-
.statics({ _documentType:
|
|
9
|
+
.statics({ _documentType: 'divider' as const })
|
|
10
10
|
.attrs<{
|
|
11
11
|
color?: string
|
|
12
12
|
thickness?: number
|
|
13
13
|
tag: string
|
|
14
14
|
_documentProps: Record<string, unknown>
|
|
15
15
|
}>((props) => ({
|
|
16
|
-
tag:
|
|
16
|
+
tag: 'hr',
|
|
17
17
|
_documentProps: {
|
|
18
18
|
...(props.color ? { color: props.color } : {}),
|
|
19
19
|
...(props.thickness ? { thickness: props.thickness } : {}),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocDocument = rocketstyle()({ name:
|
|
5
|
-
.statics({ _documentType:
|
|
4
|
+
const DocDocument = rocketstyle()({ name: 'DocDocument', component: Element })
|
|
5
|
+
.statics({ _documentType: 'document' as const })
|
|
6
6
|
.attrs<{
|
|
7
7
|
title?: string
|
|
8
8
|
author?: string
|
|
@@ -10,7 +10,7 @@ const DocDocument = rocketstyle()({ name: "DocDocument", component: Element })
|
|
|
10
10
|
tag: string
|
|
11
11
|
_documentProps: Record<string, unknown>
|
|
12
12
|
}>((props) => ({
|
|
13
|
-
tag:
|
|
13
|
+
tag: 'div',
|
|
14
14
|
_documentProps: {
|
|
15
15
|
...(props.title ? { title: props.title } : {}),
|
|
16
16
|
...(props.author ? { author: props.author } : {}),
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Text } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Text } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
4
|
const DocHeading = rocketstyle({
|
|
5
5
|
dimensions: {
|
|
6
|
-
levels:
|
|
6
|
+
levels: 'level',
|
|
7
7
|
},
|
|
8
8
|
useBooleans: true,
|
|
9
|
-
})({ name:
|
|
9
|
+
})({ name: 'DocHeading', component: Text })
|
|
10
10
|
.theme({
|
|
11
|
-
fontWeight:
|
|
12
|
-
color:
|
|
11
|
+
fontWeight: 'bold',
|
|
12
|
+
color: '#1a1a2e',
|
|
13
13
|
marginBottom: 12,
|
|
14
14
|
})
|
|
15
15
|
.levels({
|
|
@@ -20,10 +20,10 @@ const DocHeading = rocketstyle({
|
|
|
20
20
|
h5: { fontSize: 16, lineHeight: 1.5 },
|
|
21
21
|
h6: { fontSize: 14, lineHeight: 1.5 },
|
|
22
22
|
})
|
|
23
|
-
.statics({ _documentType:
|
|
23
|
+
.statics({ _documentType: 'heading' as const })
|
|
24
24
|
.attrs<{ level?: string; tag: string; _documentProps: { level: number } }>((props) => {
|
|
25
|
-
const lvl = props.level ??
|
|
26
|
-
const num = Number.parseInt(String(lvl).replace(
|
|
25
|
+
const lvl = props.level ?? 'h1'
|
|
26
|
+
const num = Number.parseInt(String(lvl).replace('h', ''), 10) || 1
|
|
27
27
|
return {
|
|
28
28
|
tag: lvl,
|
|
29
29
|
_documentProps: { level: num },
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocImage = rocketstyle()({ name:
|
|
5
|
-
.statics({ _documentType:
|
|
4
|
+
const DocImage = rocketstyle()({ name: 'DocImage', component: Element })
|
|
5
|
+
.statics({ _documentType: 'image' as const })
|
|
6
6
|
.attrs<{
|
|
7
7
|
src?: string
|
|
8
8
|
alt?: string
|
|
@@ -12,9 +12,9 @@ const DocImage = rocketstyle()({ name: "DocImage", component: Element })
|
|
|
12
12
|
tag: string
|
|
13
13
|
_documentProps: Record<string, unknown>
|
|
14
14
|
}>((props) => ({
|
|
15
|
-
tag:
|
|
15
|
+
tag: 'img',
|
|
16
16
|
_documentProps: {
|
|
17
|
-
src: props.src ??
|
|
17
|
+
src: props.src ?? '',
|
|
18
18
|
...(props.alt ? { alt: props.alt } : {}),
|
|
19
19
|
...(props.width ? { width: props.width } : {}),
|
|
20
20
|
...(props.height ? { height: props.height } : {}),
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Text } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Text } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocLink = rocketstyle()({ name:
|
|
4
|
+
const DocLink = rocketstyle()({ name: 'DocLink', component: Text })
|
|
5
5
|
.theme({
|
|
6
|
-
color:
|
|
7
|
-
textDecoration:
|
|
6
|
+
color: '#4f46e5',
|
|
7
|
+
textDecoration: 'underline',
|
|
8
8
|
})
|
|
9
|
-
.statics({ _documentType:
|
|
9
|
+
.statics({ _documentType: 'link' as const })
|
|
10
10
|
.attrs<{ href?: string; tag: string; _documentProps: { href: string } }>((props) => ({
|
|
11
|
-
tag:
|
|
12
|
-
_documentProps: { href: props.href ??
|
|
11
|
+
tag: 'a',
|
|
12
|
+
_documentProps: { href: props.href ?? '#' },
|
|
13
13
|
}))
|
|
14
14
|
|
|
15
15
|
export default DocLink
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Element } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocList = rocketstyle()({ name:
|
|
4
|
+
const DocList = rocketstyle()({ name: 'DocList', component: Element })
|
|
5
5
|
.theme({
|
|
6
6
|
marginBottom: 8,
|
|
7
7
|
paddingLeft: 20,
|
|
8
8
|
})
|
|
9
|
-
.statics({ _documentType:
|
|
9
|
+
.statics({ _documentType: 'list' as const })
|
|
10
10
|
.attrs<{ ordered?: boolean; tag: string; _documentProps: Record<string, unknown> }>((props) => ({
|
|
11
|
-
tag: props.ordered ?
|
|
11
|
+
tag: props.ordered ? 'ol' : 'ul',
|
|
12
12
|
_documentProps: props.ordered ? { ordered: props.ordered } : {},
|
|
13
13
|
}))
|
|
14
14
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Text } from
|
|
2
|
-
import rocketstyle from
|
|
1
|
+
import { Text } from '@pyreon/elements'
|
|
2
|
+
import rocketstyle from '@pyreon/rocketstyle'
|
|
3
3
|
|
|
4
|
-
const DocListItem = rocketstyle()({ name:
|
|
4
|
+
const DocListItem = rocketstyle()({ name: 'DocListItem', component: Text })
|
|
5
5
|
.theme({
|
|
6
6
|
fontSize: 14,
|
|
7
7
|
lineHeight: 1.5,
|
|
8
8
|
})
|
|
9
|
-
.statics({ _documentType:
|
|
9
|
+
.statics({ _documentType: 'list-item' as const })
|
|
10
10
|
.attrs<{ tag: string; _documentProps: Record<string, unknown> }>((_props) => ({
|
|
11
|
-
tag:
|
|
11
|
+
tag: 'li',
|
|
12
12
|
_documentProps: {},
|
|
13
13
|
}))
|
|
14
14
|
|