@refrakt-md/lumina 0.4.0 → 0.5.1
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/base.css +18 -0
- package/contracts/structures.json +1360 -3
- package/dist/config.d.ts +2 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -229
- package/dist/config.js.map +1 -1
- package/dist/icons.d.ts +3 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +86 -0
- package/dist/icons.js.map +1 -0
- package/dist/transform.d.ts +2 -0
- package/dist/transform.d.ts.map +1 -1
- package/dist/transform.js +2 -0
- package/dist/transform.js.map +1 -1
- package/index.css +12 -0
- package/package.json +18 -11
- package/styles/elements/blockquote.css +8 -4
- package/styles/elements/code.css +40 -0
- package/styles/global.css +0 -7
- package/styles/layouts/blog.css +267 -0
- package/styles/layouts/default.css +26 -6
- package/styles/layouts/docs.css +84 -18
- package/styles/layouts/mobile.css +84 -0
- package/styles/runes/bento.css +2 -0
- package/styles/runes/codegroup.css +7 -2
- package/styles/runes/design-context.css +25 -0
- package/styles/runes/feature.css +30 -14
- package/styles/runes/form.css +1 -2
- package/styles/runes/grid.css +25 -7
- package/styles/runes/hero.css +15 -0
- package/styles/runes/map.css +113 -0
- package/styles/runes/palette.css +91 -0
- package/styles/runes/preview.css +188 -0
- package/styles/runes/sandbox.css +23 -0
- package/styles/runes/spacing.css +110 -0
- package/styles/runes/steps.css +21 -3
- package/styles/runes/swatch.css +28 -0
- package/styles/runes/symbol.css +164 -0
- package/styles/runes/tabs.css +6 -0
- package/styles/runes/testimonial.css +2 -3
- package/styles/runes/timeline.css +43 -24
- package/styles/runes/typography.css +104 -0
- package/svelte/elements.ts +1 -0
- package/{sveltekit → svelte}/index.ts +0 -8
- package/svelte/layouts/BlogLayout.svelte +173 -0
- package/svelte/layouts/DefaultLayout.svelte +67 -0
- package/svelte/layouts/DocsLayout.svelte +155 -0
- package/{sveltekit → svelte}/manifest.json +1 -1
- package/svelte/registry.ts +2 -0
- package/svelte/tokens.css +6 -0
- package/dist/lib/engine.d.ts +0 -13
- package/dist/lib/engine.d.ts.map +0 -1
- package/dist/lib/engine.js +0 -218
- package/dist/lib/engine.js.map +0 -1
- package/dist/lib/helpers.d.ts +0 -14
- package/dist/lib/helpers.d.ts.map +0 -1
- package/dist/lib/helpers.js +0 -26
- package/dist/lib/helpers.js.map +0 -1
- package/dist/lib/types.d.ts +0 -74
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js +0 -2
- package/dist/lib/types.js.map +0 -1
- package/sveltekit/components/Accordion.svelte +0 -26
- package/sveltekit/components/Bento.svelte +0 -50
- package/sveltekit/components/Chart.svelte +0 -121
- package/sveltekit/components/CodeGroup.svelte +0 -88
- package/sveltekit/components/Comparison.svelte +0 -209
- package/sveltekit/components/DataTable.svelte +0 -154
- package/sveltekit/components/Details.svelte +0 -23
- package/sveltekit/components/Diagram.svelte +0 -45
- package/sveltekit/components/Embed.svelte +0 -36
- package/sveltekit/components/Form.svelte +0 -194
- package/sveltekit/components/Grid.svelte +0 -42
- package/sveltekit/components/Nav.svelte +0 -62
- package/sveltekit/components/Pricing.svelte +0 -20
- package/sveltekit/components/Reveal.svelte +0 -62
- package/sveltekit/components/Storyboard.svelte +0 -41
- package/sveltekit/components/Tabs.svelte +0 -75
- package/sveltekit/components/Testimonial.svelte +0 -26
- package/sveltekit/elements/Blockquote.svelte +0 -37
- package/sveltekit/elements/Pre.svelte +0 -77
- package/sveltekit/elements/Table.svelte +0 -40
- package/sveltekit/elements.ts +0 -11
- package/sveltekit/layouts/BlogLayout.svelte +0 -382
- package/sveltekit/layouts/DefaultLayout.svelte +0 -70
- package/sveltekit/layouts/DocsLayout.svelte +0 -133
- package/sveltekit/registry.ts +0 -59
- package/sveltekit/tokens.css +0 -71
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { SerializedTag, RendererNode } from '@refrakt-md/svelte';
|
|
4
|
-
import { Renderer } from '@refrakt-md/svelte';
|
|
5
|
-
|
|
6
|
-
let { tag, children }: { tag: SerializedTag; children: Snippet } = $props();
|
|
7
|
-
|
|
8
|
-
function isTag(c: RendererNode): c is SerializedTag {
|
|
9
|
-
return typeof c === 'object' && c !== null && 'name' in c;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const isGroup = tag.attributes.typeof === 'Bento';
|
|
13
|
-
|
|
14
|
-
// For Bento container
|
|
15
|
-
const metas = isGroup ? tag.children.filter((c: any) => c?.name === 'meta') : [];
|
|
16
|
-
const gap = isGroup ? metas[0]?.attributes?.content || '1rem' : '1rem';
|
|
17
|
-
const columns = isGroup ? parseInt(metas[1]?.attributes?.content || '4', 10) : 4;
|
|
18
|
-
|
|
19
|
-
// Find the grid container in tag.children
|
|
20
|
-
const gridEl = isGroup
|
|
21
|
-
? tag.children.find((c): c is SerializedTag => isTag(c) && c.attributes?.['data-name'] === 'grid')
|
|
22
|
-
: undefined;
|
|
23
|
-
|
|
24
|
-
// For BentoCell
|
|
25
|
-
const cellName = !isGroup
|
|
26
|
-
? tag.children.find((c: any) => c?.name === 'span' && c?.attributes?.property === 'name')?.children?.[0] || ''
|
|
27
|
-
: '';
|
|
28
|
-
const cellSize = !isGroup
|
|
29
|
-
? tag.attributes['data-size'] || 'small'
|
|
30
|
-
: 'small';
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
{#if isGroup}
|
|
34
|
-
<section class="rf-bento">
|
|
35
|
-
<div class="rf-bento__grid" style:grid-template-columns="repeat({columns}, 1fr)" style:gap={gap}>
|
|
36
|
-
{#if gridEl}
|
|
37
|
-
<Renderer node={gridEl.children} />
|
|
38
|
-
{/if}
|
|
39
|
-
</div>
|
|
40
|
-
</section>
|
|
41
|
-
{:else}
|
|
42
|
-
<div class="rf-bento-cell rf-bento-cell--{cellSize}">
|
|
43
|
-
{#if cellName}
|
|
44
|
-
<h3 class="rf-bento-cell__title">{cellName}</h3>
|
|
45
|
-
{/if}
|
|
46
|
-
<div class="rf-bento-cell__body">
|
|
47
|
-
{@render children()}
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
{/if}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { SerializedTag } from '@refrakt-md/svelte';
|
|
4
|
-
|
|
5
|
-
let { tag, children }: { tag: SerializedTag; children: Snippet } = $props();
|
|
6
|
-
|
|
7
|
-
const chartType = tag.children.find((c: any) => c?.name === 'meta' && c?.attributes?.property === 'type')?.attributes?.content || 'bar';
|
|
8
|
-
const title = tag.children.find((c: any) => c?.name === 'meta' && c?.attributes?.property === 'title')?.attributes?.content || '';
|
|
9
|
-
const stacked = tag.children.find((c: any) => c?.name === 'meta' && c?.attributes?.property === 'stacked')?.attributes?.content === 'true';
|
|
10
|
-
|
|
11
|
-
const dataJson = tag.children.find((c: any) => c?.name === 'meta' && c?.attributes?.['data-name'] === 'data')?.attributes?.content || '{}';
|
|
12
|
-
let chartData: { headers: string[]; rows: string[][] } = { headers: [], rows: [] };
|
|
13
|
-
try {
|
|
14
|
-
chartData = JSON.parse(dataJson);
|
|
15
|
-
} catch {}
|
|
16
|
-
|
|
17
|
-
const colors = [
|
|
18
|
-
'var(--rf-color-info)',
|
|
19
|
-
'var(--rf-color-success)',
|
|
20
|
-
'var(--rf-color-warning)',
|
|
21
|
-
'var(--rf-color-danger)',
|
|
22
|
-
'#7c3aed',
|
|
23
|
-
'#0891b2',
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
const svgWidth = 600;
|
|
27
|
-
const svgHeight = 300;
|
|
28
|
-
const padding = { top: 30, right: 20, bottom: 40, left: 50 };
|
|
29
|
-
const chartWidth = svgWidth - padding.left - padding.right;
|
|
30
|
-
const chartHeight = svgHeight - padding.top - padding.bottom;
|
|
31
|
-
|
|
32
|
-
const labels = chartData.rows.map(r => r[0] || '');
|
|
33
|
-
const series = chartData.headers.slice(1);
|
|
34
|
-
const values = chartData.rows.map(r => r.slice(1).map(v => parseFloat(v) || 0));
|
|
35
|
-
|
|
36
|
-
const allValues = values.flat();
|
|
37
|
-
const maxValue = Math.max(...allValues, 1);
|
|
38
|
-
|
|
39
|
-
const barGroupWidth = chartWidth / Math.max(labels.length, 1);
|
|
40
|
-
const barWidth = barGroupWidth / Math.max(series.length + 1, 2);
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<figure class="rf-chart" typeof="Chart">
|
|
44
|
-
{#if title}
|
|
45
|
-
<figcaption class="rf-chart__title">{title}</figcaption>
|
|
46
|
-
{/if}
|
|
47
|
-
<div class="rf-chart__container">
|
|
48
|
-
<svg viewBox="0 0 {svgWidth} {svgHeight}" class="rf-chart__svg">
|
|
49
|
-
<line
|
|
50
|
-
x1={padding.left} y1={padding.top}
|
|
51
|
-
x2={padding.left} y2={svgHeight - padding.bottom}
|
|
52
|
-
stroke="var(--rf-color-border)" stroke-width="1"
|
|
53
|
-
/>
|
|
54
|
-
<line
|
|
55
|
-
x1={padding.left} y1={svgHeight - padding.bottom}
|
|
56
|
-
x2={svgWidth - padding.right} y2={svgHeight - padding.bottom}
|
|
57
|
-
stroke="var(--rf-color-border)" stroke-width="1"
|
|
58
|
-
/>
|
|
59
|
-
|
|
60
|
-
{#if chartType === 'bar'}
|
|
61
|
-
{#each labels as label, i}
|
|
62
|
-
{#each series as _, si}
|
|
63
|
-
<rect
|
|
64
|
-
x={padding.left + i * barGroupWidth + si * barWidth + barWidth * 0.25}
|
|
65
|
-
y={padding.top + chartHeight - (values[i][si] / maxValue) * chartHeight}
|
|
66
|
-
width={barWidth * 0.75}
|
|
67
|
-
height={(values[i][si] / maxValue) * chartHeight}
|
|
68
|
-
style="fill: {colors[si % colors.length]}"
|
|
69
|
-
rx="2"
|
|
70
|
-
/>
|
|
71
|
-
{/each}
|
|
72
|
-
<text
|
|
73
|
-
x={padding.left + i * barGroupWidth + barGroupWidth / 2}
|
|
74
|
-
y={svgHeight - padding.bottom + 20}
|
|
75
|
-
text-anchor="middle"
|
|
76
|
-
font-size="12"
|
|
77
|
-
fill="var(--rf-color-muted)"
|
|
78
|
-
>{label}</text>
|
|
79
|
-
{/each}
|
|
80
|
-
{:else if chartType === 'line'}
|
|
81
|
-
{#each series as _, si}
|
|
82
|
-
<polyline
|
|
83
|
-
points={labels.map((_, i) =>
|
|
84
|
-
`${padding.left + i * barGroupWidth + barGroupWidth / 2},${padding.top + chartHeight - (values[i][si] / maxValue) * chartHeight}`
|
|
85
|
-
).join(' ')}
|
|
86
|
-
fill="none"
|
|
87
|
-
style="stroke: {colors[si % colors.length]}"
|
|
88
|
-
stroke-width="2"
|
|
89
|
-
/>
|
|
90
|
-
{#each labels as _, i}
|
|
91
|
-
<circle
|
|
92
|
-
cx={padding.left + i * barGroupWidth + barGroupWidth / 2}
|
|
93
|
-
cy={padding.top + chartHeight - (values[i][si] / maxValue) * chartHeight}
|
|
94
|
-
r="4"
|
|
95
|
-
style="fill: {colors[si % colors.length]}"
|
|
96
|
-
/>
|
|
97
|
-
{/each}
|
|
98
|
-
{/each}
|
|
99
|
-
{#each labels as label, i}
|
|
100
|
-
<text
|
|
101
|
-
x={padding.left + i * barGroupWidth + barGroupWidth / 2}
|
|
102
|
-
y={svgHeight - padding.bottom + 20}
|
|
103
|
-
text-anchor="middle"
|
|
104
|
-
font-size="12"
|
|
105
|
-
fill="var(--rf-color-muted)"
|
|
106
|
-
>{label}</text>
|
|
107
|
-
{/each}
|
|
108
|
-
{/if}
|
|
109
|
-
</svg>
|
|
110
|
-
</div>
|
|
111
|
-
{#if series.length > 1}
|
|
112
|
-
<div class="rf-chart__legend">
|
|
113
|
-
{#each series as name, i}
|
|
114
|
-
<span class="rf-chart__legend-item">
|
|
115
|
-
<span class="rf-chart__legend-color" style="background: {colors[i % colors.length]};"></span>
|
|
116
|
-
{name}
|
|
117
|
-
</span>
|
|
118
|
-
{/each}
|
|
119
|
-
</div>
|
|
120
|
-
{/if}
|
|
121
|
-
</figure>
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { SerializedTag, RendererNode } from '@refrakt-md/svelte';
|
|
3
|
-
import { Renderer } from '@refrakt-md/svelte';
|
|
4
|
-
import type { Snippet } from 'svelte';
|
|
5
|
-
|
|
6
|
-
let { tag, children }: { tag: SerializedTag; children: Snippet } = $props();
|
|
7
|
-
|
|
8
|
-
function isTag(n: RendererNode): n is SerializedTag {
|
|
9
|
-
return n !== null && typeof n === 'object' && !Array.isArray(n) && (n as any).$$mdtype === 'Tag';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getTextContent(node: RendererNode): string {
|
|
13
|
-
if (typeof node === 'string') return node;
|
|
14
|
-
if (typeof node === 'number') return String(node);
|
|
15
|
-
if (isTag(node)) return node.children.map(getTextContent).join('');
|
|
16
|
-
if (Array.isArray(node)) return node.map(getTextContent).join('');
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const title = $derived.by(() => {
|
|
21
|
-
for (const child of tag.children) {
|
|
22
|
-
if (isTag(child) && child.attributes?.property === 'title') {
|
|
23
|
-
return getTextContent(child);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return '';
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const { tabs, panels } = $derived.by(() => {
|
|
30
|
-
const tabs: { name: string }[] = [];
|
|
31
|
-
const panels: { children: RendererNode[] }[] = [];
|
|
32
|
-
for (const child of tag.children) {
|
|
33
|
-
if (!isTag(child) || child.name !== 'ul') continue;
|
|
34
|
-
for (const item of child.children) {
|
|
35
|
-
if (!isTag(item)) continue;
|
|
36
|
-
if (item.attributes?.typeof === 'Tab') {
|
|
37
|
-
const nameNode = item.children.find(
|
|
38
|
-
(c): c is SerializedTag => isTag(c) && c.attributes?.property === 'name'
|
|
39
|
-
);
|
|
40
|
-
tabs.push({ name: (nameNode ? getTextContent(nameNode) : getTextContent(item)).trim() });
|
|
41
|
-
} else if (item.attributes?.typeof === 'TabPanel') {
|
|
42
|
-
panels.push({ children: item.children });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return { tabs, panels };
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
let activeIndex = $state(0);
|
|
50
|
-
</script>
|
|
51
|
-
|
|
52
|
-
{#if tabs.length > 0}
|
|
53
|
-
<div class="rf-codegroup">
|
|
54
|
-
<div class="rf-codegroup__topbar">
|
|
55
|
-
<span class="rf-codegroup__dot"></span>
|
|
56
|
-
<span class="rf-codegroup__dot"></span>
|
|
57
|
-
<span class="rf-codegroup__dot"></span>
|
|
58
|
-
{#if title}
|
|
59
|
-
<span class="rf-codegroup__title">{title}</span>
|
|
60
|
-
{/if}
|
|
61
|
-
</div>
|
|
62
|
-
{#if tabs.length > 1}
|
|
63
|
-
<div class="rf-codegroup__tabs" role="tablist">
|
|
64
|
-
{#each tabs as tab, i}
|
|
65
|
-
<button
|
|
66
|
-
class="rf-codegroup__tab {i === activeIndex ? 'rf-codegroup__tab--active' : ''}"
|
|
67
|
-
role="tab"
|
|
68
|
-
aria-selected={i === activeIndex}
|
|
69
|
-
onclick={() => activeIndex = i}
|
|
70
|
-
>
|
|
71
|
-
{tab.name}
|
|
72
|
-
</button>
|
|
73
|
-
{/each}
|
|
74
|
-
</div>
|
|
75
|
-
{/if}
|
|
76
|
-
<div class="rf-codegroup__content">
|
|
77
|
-
{#each panels as panel, i}
|
|
78
|
-
{#if i === activeIndex}
|
|
79
|
-
<div class="rf-codegroup__panel" role="tabpanel">
|
|
80
|
-
<Renderer node={panel.children} />
|
|
81
|
-
</div>
|
|
82
|
-
{/if}
|
|
83
|
-
{/each}
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
{:else}
|
|
87
|
-
{@render children()}
|
|
88
|
-
{/if}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { SerializedTag, RendererNode } from '@refrakt-md/svelte';
|
|
3
|
-
import { Renderer } from '@refrakt-md/svelte';
|
|
4
|
-
import type { Snippet } from 'svelte';
|
|
5
|
-
|
|
6
|
-
let { tag, children }: { tag: SerializedTag; children: Snippet } = $props();
|
|
7
|
-
|
|
8
|
-
const typeName = tag.attributes.typeof;
|
|
9
|
-
|
|
10
|
-
function isTag(n: RendererNode): n is SerializedTag {
|
|
11
|
-
return n !== null && typeof n === 'object' && !Array.isArray(n) && (n as any).$$mdtype === 'Tag';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function meta(node: SerializedTag, prop: string): string {
|
|
15
|
-
const child = node.children.find(
|
|
16
|
-
(c): c is SerializedTag => isTag(c) && c.name === 'meta' && c.attributes?.property === prop
|
|
17
|
-
);
|
|
18
|
-
return child?.attributes?.content ?? '';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function propText(node: SerializedTag, prop: string): string {
|
|
22
|
-
const child = node.children.find(
|
|
23
|
-
(c): c is SerializedTag => isTag(c) && c.attributes?.property === prop
|
|
24
|
-
);
|
|
25
|
-
if (!child) return '';
|
|
26
|
-
return child.children.filter((c): c is string => typeof c === 'string').join('');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function findByType(node: SerializedTag, type: string): SerializedTag[] {
|
|
30
|
-
const results: SerializedTag[] = [];
|
|
31
|
-
function walk(children: RendererNode[]) {
|
|
32
|
-
for (const c of children) {
|
|
33
|
-
if (isTag(c)) {
|
|
34
|
-
if (c.attributes?.typeof === type) {
|
|
35
|
-
results.push(c);
|
|
36
|
-
} else {
|
|
37
|
-
walk(c.children);
|
|
38
|
-
}
|
|
39
|
-
} else if (Array.isArray(c)) {
|
|
40
|
-
walk(c);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
walk(node.children);
|
|
45
|
-
return results;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function findRef(node: SerializedTag, name: string): SerializedTag | undefined {
|
|
49
|
-
for (const c of node.children) {
|
|
50
|
-
if (isTag(c) && c.attributes?.['data-name'] === name) return c;
|
|
51
|
-
}
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const isComparison = typeName === 'Comparison';
|
|
56
|
-
const layout = isComparison ? (meta(tag, 'layout') || 'table') : '';
|
|
57
|
-
const verdict = isComparison ? meta(tag, 'verdict') : '';
|
|
58
|
-
const highlightedName = isComparison ? meta(tag, 'highlighted') : '';
|
|
59
|
-
const labelsPosition = isComparison ? (meta(tag, 'labels') || 'left') : '';
|
|
60
|
-
const rowLabelsJson = isComparison ? meta(tag, 'rowLabels') : '[]';
|
|
61
|
-
const rowLabels: string[] = isComparison ? (() => { try { return JSON.parse(rowLabelsJson); } catch { return []; } })() : [];
|
|
62
|
-
const columns = isComparison ? findByType(tag, 'ComparisonColumn') : [];
|
|
63
|
-
|
|
64
|
-
const titleTag = isComparison ? tag.children.find(
|
|
65
|
-
(c): c is SerializedTag => isTag(c) && /^h[1-6]$/.test(c.name)
|
|
66
|
-
) : undefined;
|
|
67
|
-
const titleText = titleTag ? titleTag.children.filter((c): c is string => typeof c === 'string').join('') : '';
|
|
68
|
-
|
|
69
|
-
interface ColumnData {
|
|
70
|
-
name: string;
|
|
71
|
-
highlighted: boolean;
|
|
72
|
-
rows: SerializedTag[];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const columnData: ColumnData[] = isComparison ? columns.map(col => ({
|
|
76
|
-
name: propText(col, 'name'),
|
|
77
|
-
highlighted: meta(col, 'highlighted') === 'true',
|
|
78
|
-
rows: findByType(col, 'ComparisonRow'),
|
|
79
|
-
})) : [];
|
|
80
|
-
|
|
81
|
-
const isColumn = typeName === 'ComparisonColumn';
|
|
82
|
-
const colName = isColumn ? propText(tag, 'name') : '';
|
|
83
|
-
const colHighlighted = isColumn ? meta(tag, 'highlighted') === 'true' : false;
|
|
84
|
-
|
|
85
|
-
const isRow = typeName === 'ComparisonRow';
|
|
86
|
-
const rowLabel = isRow ? propText(tag, 'label') : '';
|
|
87
|
-
const rowType = isRow ? meta(tag, 'rowType') : '';
|
|
88
|
-
const rowBody = isRow ? findRef(tag, 'body') : undefined;
|
|
89
|
-
</script>
|
|
90
|
-
|
|
91
|
-
{#if isComparison}
|
|
92
|
-
<section class="rf-comparison rf-comparison--{layout}">
|
|
93
|
-
{#if titleText}
|
|
94
|
-
<h2 class="rf-comparison__title">{titleText}</h2>
|
|
95
|
-
{/if}
|
|
96
|
-
|
|
97
|
-
{#if layout === 'cards'}
|
|
98
|
-
<div class="rf-comparison__cards">
|
|
99
|
-
{#each columnData as col}
|
|
100
|
-
<div class="rf-comparison-card {col.highlighted ? 'rf-comparison-card--highlighted' : ''}">
|
|
101
|
-
{#if col.highlighted}
|
|
102
|
-
<div class="rf-comparison-card__badge">Recommended</div>
|
|
103
|
-
{/if}
|
|
104
|
-
<h3 class="rf-comparison-card__name">{col.name}</h3>
|
|
105
|
-
<ul class="rf-comparison-card__rows">
|
|
106
|
-
{#each col.rows as row}
|
|
107
|
-
{@const rType = meta(row, 'rowType')}
|
|
108
|
-
{@const rLabel = propText(row, 'label')}
|
|
109
|
-
{@const rBody = findRef(row, 'body')}
|
|
110
|
-
{#if rType !== 'empty'}
|
|
111
|
-
<li class="rf-comparison-card__row {rType === 'negative' ? 'rf-comparison-card__row--negative' : ''} {rType === 'callout' ? 'rf-comparison-card__row--callout' : ''}">
|
|
112
|
-
{#if rType === 'check'}
|
|
113
|
-
<span class="rf-comparison__row-icon rf-comparison__row-icon--check" aria-label="Supported">✓</span>
|
|
114
|
-
{#if rLabel}<strong>{rLabel}</strong>{/if}
|
|
115
|
-
{#if rBody}<Renderer node={rBody.children} />{/if}
|
|
116
|
-
{:else if rType === 'cross'}
|
|
117
|
-
<span class="rf-comparison__row-icon rf-comparison__row-icon--cross" aria-label="Not supported">✗</span>
|
|
118
|
-
{#if rLabel}<strong>{rLabel}</strong>{/if}
|
|
119
|
-
{#if rBody}<Renderer node={rBody.children} />{/if}
|
|
120
|
-
{:else if rType === 'negative'}
|
|
121
|
-
{#if rLabel}<strong>{rLabel}</strong>{/if}
|
|
122
|
-
{#if rBody}<span class="rf-comparison__negative"><Renderer node={rBody.children} /></span>{/if}
|
|
123
|
-
{:else if rType === 'callout'}
|
|
124
|
-
<div class="rf-comparison__callout-badge">
|
|
125
|
-
{#if rBody}<Renderer node={rBody.children} />{/if}
|
|
126
|
-
</div>
|
|
127
|
-
{:else}
|
|
128
|
-
{#if rLabel}<strong>{rLabel}</strong>{/if}
|
|
129
|
-
{#if rBody}<Renderer node={rBody.children} />{/if}
|
|
130
|
-
{/if}
|
|
131
|
-
</li>
|
|
132
|
-
{/if}
|
|
133
|
-
{/each}
|
|
134
|
-
</ul>
|
|
135
|
-
</div>
|
|
136
|
-
{/each}
|
|
137
|
-
</div>
|
|
138
|
-
{:else}
|
|
139
|
-
<div class="rf-comparison__table-wrapper">
|
|
140
|
-
<table class="rf-comparison__table">
|
|
141
|
-
<thead>
|
|
142
|
-
<tr>
|
|
143
|
-
{#if labelsPosition !== 'hidden'}
|
|
144
|
-
<th class="rf-comparison__label-col"></th>
|
|
145
|
-
{/if}
|
|
146
|
-
{#each columnData as col}
|
|
147
|
-
<th class="{col.highlighted ? 'rf-comparison__col-header--highlighted' : ''}">
|
|
148
|
-
{col.name}
|
|
149
|
-
{#if col.highlighted}
|
|
150
|
-
<span class="rf-comparison__recommended-badge">Recommended</span>
|
|
151
|
-
{/if}
|
|
152
|
-
</th>
|
|
153
|
-
{/each}
|
|
154
|
-
</tr>
|
|
155
|
-
</thead>
|
|
156
|
-
<tbody>
|
|
157
|
-
{#each rowLabels as label, i}
|
|
158
|
-
<tr>
|
|
159
|
-
{#if labelsPosition !== 'hidden'}
|
|
160
|
-
<th class="rf-comparison__row-label" scope="row">{label}</th>
|
|
161
|
-
{/if}
|
|
162
|
-
{#each columnData as col}
|
|
163
|
-
{@const row = col.rows[i]}
|
|
164
|
-
{@const rType = row ? meta(row, 'rowType') : 'empty'}
|
|
165
|
-
{@const rBody = row ? findRef(row, 'body') : undefined}
|
|
166
|
-
<td class="rf-comparison__cell {col.highlighted ? 'rf-comparison__cell--highlighted' : ''} {rType === 'empty' ? 'rf-comparison__cell--empty' : ''}">
|
|
167
|
-
{#if rType === 'check'}
|
|
168
|
-
<span class="rf-comparison__row-icon rf-comparison__row-icon--check" aria-label="Supported">✓</span>
|
|
169
|
-
{:else if rType === 'cross'}
|
|
170
|
-
<span class="rf-comparison__row-icon rf-comparison__row-icon--cross" aria-label="Not supported">✗</span>
|
|
171
|
-
{:else if rType === 'negative'}
|
|
172
|
-
{#if rBody}
|
|
173
|
-
<span class="rf-comparison__negative"><Renderer node={rBody.children} /></span>
|
|
174
|
-
{/if}
|
|
175
|
-
{:else if rType === 'empty'}
|
|
176
|
-
<span class="rf-comparison__cell--empty" aria-label="Not applicable">—</span>
|
|
177
|
-
{:else if rType === 'callout'}
|
|
178
|
-
{#if rBody}
|
|
179
|
-
<span class="rf-comparison__callout-badge"><Renderer node={rBody.children} /></span>
|
|
180
|
-
{/if}
|
|
181
|
-
{:else}
|
|
182
|
-
{#if rBody}
|
|
183
|
-
<Renderer node={rBody.children} />
|
|
184
|
-
{/if}
|
|
185
|
-
{/if}
|
|
186
|
-
</td>
|
|
187
|
-
{/each}
|
|
188
|
-
</tr>
|
|
189
|
-
{/each}
|
|
190
|
-
</tbody>
|
|
191
|
-
</table>
|
|
192
|
-
</div>
|
|
193
|
-
{/if}
|
|
194
|
-
|
|
195
|
-
{#if verdict}
|
|
196
|
-
<p class="rf-comparison__verdict">{verdict}</p>
|
|
197
|
-
{/if}
|
|
198
|
-
</section>
|
|
199
|
-
{:else if isColumn}
|
|
200
|
-
<div class="rf-comparison-column {colHighlighted ? 'rf-comparison-column--highlighted' : ''}">
|
|
201
|
-
<h3>{colName}</h3>
|
|
202
|
-
{@render children()}
|
|
203
|
-
</div>
|
|
204
|
-
{:else if isRow}
|
|
205
|
-
<div class="rf-comparison-row rf-comparison-row--{rowType}">
|
|
206
|
-
{#if rowLabel}<strong>{rowLabel}</strong>{/if}
|
|
207
|
-
{@render children()}
|
|
208
|
-
</div>
|
|
209
|
-
{/if}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { onMount } from 'svelte';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
|
-
import type { SerializedTag } from '@refrakt-md/svelte';
|
|
5
|
-
|
|
6
|
-
let { tag, children }: { tag: SerializedTag; children: Snippet } = $props();
|
|
7
|
-
|
|
8
|
-
const sortable = (tag.children.find((c: any) => c?.name === 'meta' && c?.attributes?.property === 'sortable')?.attributes?.content || '').split(',').map((s: string) => s.trim()).filter(Boolean);
|
|
9
|
-
const searchable = tag.children.find((c: any) => c?.name === 'meta' && c?.attributes?.property === 'searchable')?.attributes?.content === 'true';
|
|
10
|
-
const pageSize = parseInt(tag.children.find((c: any) => c?.name === 'meta' && c?.attributes?.property === 'pageSize')?.attributes?.content || '0', 10);
|
|
11
|
-
const defaultSort = tag.children.find((c: any) => c?.name === 'meta' && c?.attributes?.property === 'defaultSort')?.attributes?.content || '';
|
|
12
|
-
|
|
13
|
-
let searchQuery = $state('');
|
|
14
|
-
let sortColumn = $state(defaultSort);
|
|
15
|
-
let sortDirection = $state<'asc' | 'desc'>('asc');
|
|
16
|
-
let currentPage = $state(0);
|
|
17
|
-
|
|
18
|
-
let contentEl: HTMLDivElement;
|
|
19
|
-
let headers: string[] = [];
|
|
20
|
-
let allRows: { el: HTMLTableRowElement; cells: string[] }[] = [];
|
|
21
|
-
let totalFiltered = $state(0);
|
|
22
|
-
|
|
23
|
-
function toggleSort(column: string) {
|
|
24
|
-
if (!sortable.includes(column)) return;
|
|
25
|
-
if (sortColumn === column) {
|
|
26
|
-
sortDirection = sortDirection === 'asc' ? 'desc' : 'asc';
|
|
27
|
-
} else {
|
|
28
|
-
sortColumn = column;
|
|
29
|
-
sortDirection = 'asc';
|
|
30
|
-
}
|
|
31
|
-
currentPage = 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
onMount(() => {
|
|
35
|
-
const table = contentEl?.querySelector('table');
|
|
36
|
-
if (!table) return;
|
|
37
|
-
|
|
38
|
-
const thEls = table.querySelectorAll('th');
|
|
39
|
-
headers = Array.from(thEls).map(th => th.textContent?.trim() || '');
|
|
40
|
-
|
|
41
|
-
thEls.forEach((th) => {
|
|
42
|
-
const name = th.textContent?.trim() || '';
|
|
43
|
-
if (sortable.includes(name)) {
|
|
44
|
-
th.style.cursor = 'pointer';
|
|
45
|
-
th.style.userSelect = 'none';
|
|
46
|
-
th.addEventListener('click', () => toggleSort(name));
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const bodyRows = table.querySelectorAll('tbody tr');
|
|
51
|
-
const rows = bodyRows.length > 0 ? bodyRows : table.querySelectorAll('tr:not(:first-child)');
|
|
52
|
-
allRows = Array.from(rows).map(tr => ({
|
|
53
|
-
el: tr as HTMLTableRowElement,
|
|
54
|
-
cells: Array.from(tr.querySelectorAll('td')).map(td => td.textContent?.trim() || ''),
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
totalFiltered = allRows.length;
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
$effect(() => {
|
|
61
|
-
if (!allRows.length) return;
|
|
62
|
-
|
|
63
|
-
let filtered = [...allRows];
|
|
64
|
-
|
|
65
|
-
if (searchQuery) {
|
|
66
|
-
const q = searchQuery.toLowerCase();
|
|
67
|
-
filtered = filtered.filter(r => r.cells.some(c => c.toLowerCase().includes(q)));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (sortColumn) {
|
|
71
|
-
const idx = headers.indexOf(sortColumn);
|
|
72
|
-
if (idx >= 0) {
|
|
73
|
-
filtered.sort((a, b) => {
|
|
74
|
-
const cmp = a.cells[idx].localeCompare(b.cells[idx], undefined, { numeric: true });
|
|
75
|
-
return sortDirection === 'asc' ? cmp : -cmp;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
totalFiltered = filtered.length;
|
|
81
|
-
|
|
82
|
-
const visible = pageSize > 0
|
|
83
|
-
? filtered.slice(currentPage * pageSize, (currentPage + 1) * pageSize)
|
|
84
|
-
: filtered;
|
|
85
|
-
|
|
86
|
-
const tbody = contentEl?.querySelector('tbody') || contentEl?.querySelector('table');
|
|
87
|
-
if (!tbody) return;
|
|
88
|
-
|
|
89
|
-
allRows.forEach(r => r.el.style.display = 'none');
|
|
90
|
-
visible.forEach(r => {
|
|
91
|
-
r.el.style.display = '';
|
|
92
|
-
tbody.appendChild(r.el);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const thEls = contentEl?.querySelectorAll('th');
|
|
96
|
-
thEls?.forEach(th => {
|
|
97
|
-
const name = th.textContent?.replace(/[▲▼]/g, '').trim() || '';
|
|
98
|
-
const indicator = th.querySelector('.sort-indicator');
|
|
99
|
-
if (sortable.includes(name)) {
|
|
100
|
-
if (sortColumn === name) {
|
|
101
|
-
if (indicator) {
|
|
102
|
-
indicator.textContent = sortDirection === 'asc' ? ' ▲' : ' ▼';
|
|
103
|
-
} else {
|
|
104
|
-
const span = document.createElement('span');
|
|
105
|
-
span.className = 'sort-indicator';
|
|
106
|
-
span.textContent = sortDirection === 'asc' ? ' ▲' : ' ▼';
|
|
107
|
-
th.appendChild(span);
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
if (indicator) indicator.remove();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const totalPages = $derived(pageSize > 0 ? Math.ceil(totalFiltered / pageSize) : 1);
|
|
117
|
-
</script>
|
|
118
|
-
|
|
119
|
-
<div class="rf-datatable" typeof="DataTable">
|
|
120
|
-
{#if searchable}
|
|
121
|
-
<div class="rf-datatable__toolbar">
|
|
122
|
-
<input
|
|
123
|
-
type="search"
|
|
124
|
-
placeholder="Filter rows..."
|
|
125
|
-
bind:value={searchQuery}
|
|
126
|
-
class="rf-datatable__input"
|
|
127
|
-
/>
|
|
128
|
-
</div>
|
|
129
|
-
{/if}
|
|
130
|
-
<div class="rf-datatable__content" bind:this={contentEl}>
|
|
131
|
-
{@render children()}
|
|
132
|
-
</div>
|
|
133
|
-
{#if pageSize > 0 && totalPages > 1}
|
|
134
|
-
<div class="rf-datatable__pagination">
|
|
135
|
-
<button
|
|
136
|
-
class="rf-datatable__page-btn"
|
|
137
|
-
disabled={currentPage === 0}
|
|
138
|
-
onclick={() => currentPage--}
|
|
139
|
-
>
|
|
140
|
-
← Prev
|
|
141
|
-
</button>
|
|
142
|
-
<span class="rf-datatable__page-info">
|
|
143
|
-
{currentPage + 1} / {totalPages}
|
|
144
|
-
</span>
|
|
145
|
-
<button
|
|
146
|
-
class="rf-datatable__page-btn"
|
|
147
|
-
disabled={currentPage >= totalPages - 1}
|
|
148
|
-
onclick={() => currentPage++}
|
|
149
|
-
>
|
|
150
|
-
Next →
|
|
151
|
-
</button>
|
|
152
|
-
</div>
|
|
153
|
-
{/if}
|
|
154
|
-
</div>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { SerializedTag } from '@refrakt-md/svelte';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
|
-
|
|
5
|
-
let { tag, children }: { tag: SerializedTag; children: Snippet } = $props();
|
|
6
|
-
|
|
7
|
-
const summary = $derived(tag.children
|
|
8
|
-
.find((c: any) => c?.name === 'span' && c?.attributes?.property === 'summary')
|
|
9
|
-
?.children?.[0] ?? 'Details');
|
|
10
|
-
|
|
11
|
-
const isOpen = $derived(tag.children
|
|
12
|
-
.find((c: any) => c?.name === 'meta' && c?.attributes?.property === 'open')
|
|
13
|
-
?.attributes?.content ?? false);
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<details class="rf-details" open={isOpen || undefined}>
|
|
17
|
-
<summary class="rf-details__summary">
|
|
18
|
-
<span>{summary}</span>
|
|
19
|
-
</summary>
|
|
20
|
-
<div class="rf-details__body">
|
|
21
|
-
{@render children()}
|
|
22
|
-
</div>
|
|
23
|
-
</details>
|