@usequeek/theme-kit 0.5.13 → 0.5.15
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/package.json +1 -1
- package/shared-blocks/core-blocks.css +12 -0
- package/shared-blocks/faq.tsx +16 -1
package/package.json
CHANGED
|
@@ -1222,6 +1222,18 @@
|
|
|
1222
1222
|
line-height: 1.6;
|
|
1223
1223
|
}
|
|
1224
1224
|
|
|
1225
|
+
/* A formatted answer (markdown): paragraphs and lists sit flush with the answer box, one clear gap between them. Scoped under
|
|
1226
|
+
* `.core-block-faq` (specificity 0,2,2) so the gap outranks a theme's prose resets — `.theme-x p { margin: 0 }` (0,1,1) and
|
|
1227
|
+
* `html :where(.theme-x) .content-stack :is(p, ul, ol) { margin: 0 }` (0,1,2), which loads later and won a 0,1,2 tie. */
|
|
1228
|
+
.core-block-faq .core-block-faq__answer > :is(p, ul, ol) {
|
|
1229
|
+
margin-top: 0;
|
|
1230
|
+
margin-bottom: 0;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
.core-block-faq .core-block-faq__answer > :is(p, ul, ol) + :is(p, ul, ol) {
|
|
1234
|
+
margin-top: 1em;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1225
1237
|
/* ── Policies listing (core fallback for /policies) ──────────────
|
|
1226
1238
|
* Themeable via `.theme-<slug> .core-policies__*` overrides. Pure CSS
|
|
1227
1239
|
* variables — tint follows the active theme automatically.
|
package/shared-blocks/faq.tsx
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
import type { JSX } from 'react';
|
|
4
4
|
import type { FaqBlockData } from '../types/block';
|
|
5
|
+
import { renderMarkdown } from '../utils/markdown';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* An answer carrying formatting (a line break, **bold**, _italic_, a [link](/x) or `code`) renders as markdown: paragraphs and inline
|
|
9
|
+
* emphasis, never raw HTML. A plain answer keeps rendering as the bare text it always did, so no existing store's FAQ markup moves.
|
|
10
|
+
*/
|
|
11
|
+
const FORMATTED_ANSWER = /\n|\*|_|\[|`/;
|
|
12
|
+
|
|
13
|
+
function FaqAnswer({ answer }: { answer: unknown }): JSX.Element {
|
|
14
|
+
const text = typeof answer === 'string' ? answer : '';
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className="core-block-faq__answer">{FORMATTED_ANSWER.test(text) ? renderMarkdown(text) : text}</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
5
20
|
|
|
6
21
|
/**
|
|
7
22
|
* Framework-owned FAQ block. Renders an accessible, SSR-friendly accordion
|
|
@@ -36,7 +51,7 @@ export function CoreFaqBlock({ heading, items }: FaqBlockData): JSX.Element | nu
|
|
|
36
51
|
<polyline points="6 9 12 15 18 9" />
|
|
37
52
|
</svg>
|
|
38
53
|
</summary>
|
|
39
|
-
<
|
|
54
|
+
<FaqAnswer answer={item.answer} />
|
|
40
55
|
</details>
|
|
41
56
|
))}
|
|
42
57
|
</div>
|