@bunnix/components 0.9.0 → 0.9.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/@types/index.d.ts CHANGED
@@ -67,6 +67,13 @@ export interface InputFieldProps extends BaseProps {
67
67
  keydown?: (event?: any) => void;
68
68
  }
69
69
 
70
+ export interface CodeBlockProps extends BaseProps {
71
+ html?: string;
72
+ language?: string;
73
+ overflowX?: "auto" | "scroll" | "hidden" | string;
74
+ wrap?: boolean;
75
+ }
76
+
70
77
  export interface ComboBoxOption {
71
78
  value: string;
72
79
  label?: string;
@@ -227,6 +234,7 @@ export const AccordionGroup: Component<BaseProps>;
227
234
  export const Badge: Component<BadgeProps>;
228
235
  export const Button: Component<ButtonProps>;
229
236
  export const Checkbox: Component<CheckboxProps>;
237
+ export const CodeBlock: Component<CodeBlockProps>;
230
238
  export const ComboBox: Component<ComboBoxProps>;
231
239
  export const Container: Component<ContainerProps>;
232
240
  export const DatePicker: Component<DatePickerProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnix/components",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Bunnix components: a set of bunnix ready components for modern web apps.",
5
5
  "keywords": [
6
6
  "bunnix",
@@ -0,0 +1,31 @@
1
+ import Bunnix from "@bunnix/core";
2
+
3
+ const { div, pre, code } = Bunnix;
4
+
5
+ export default function CodeBlock({
6
+ html,
7
+ language,
8
+ overflowX = "auto",
9
+ wrap = false,
10
+ class: className = "",
11
+ ...rest
12
+ } = {}, children) {
13
+ const languageClass = language ? `language-${language}` : "";
14
+ const wrapClass = wrap ? "codeblock-wrap" : "";
15
+ const codeChildren = html ? null : children;
16
+ const codeProps = {
17
+ class: `codeblock-code ${languageClass}`.trim()
18
+ };
19
+ if (html !== null && html !== undefined) {
20
+ codeProps.innerHTML = html;
21
+ }
22
+
23
+ return div({ class: `codeblock ${className}`.trim(), ...rest }, [
24
+ pre({
25
+ class: `codeblock-pre ${wrapClass}`.trim(),
26
+ style: { overflowX, overflowY: "auto" }
27
+ }, [
28
+ code(codeProps, codeChildren)
29
+ ])
30
+ ]);
31
+ }
package/src/index.mjs CHANGED
@@ -2,6 +2,7 @@ export { default as AccordionGroup } from "./components/AccordionGroup.mjs";
2
2
  export { default as Badge } from "./components/Badge.mjs";
3
3
  export { default as Button } from "./components/Button.mjs";
4
4
  export { default as Checkbox } from "./components/Checkbox.mjs";
5
+ export { default as CodeBlock } from "./components/CodeBlock.mjs";
5
6
  export { default as ComboBox } from "./components/ComboBox.mjs";
6
7
  export { default as Container } from "./components/Container.mjs";
7
8
  export { default as DatePicker } from "./components/DatePicker.mjs";
@@ -299,6 +299,31 @@ kbd {
299
299
  font-size: var(--font-size-xs) !important;
300
300
  }
301
301
 
302
+ /* Code Block */
303
+ .codeblock {
304
+ width: 100%;
305
+ }
306
+
307
+ .codeblock-pre {
308
+ margin: 0;
309
+ padding: var(--base-padding);
310
+ border-radius: var(--min-control-radius);
311
+ border: 1px solid var(--border-color);
312
+ background-color: var(--alternate-background-color);
313
+ }
314
+
315
+ .codeblock-pre code {
316
+ display: block;
317
+ font-family: monospace;
318
+ font-size: var(--font-size-sm);
319
+ line-height: 1.6;
320
+ white-space: pre;
321
+ }
322
+
323
+ .codeblock-pre.codeblock-wrap code {
324
+ white-space: pre-wrap;
325
+ }
326
+
302
327
  /* Control Sizes */
303
328
  .input-lg {
304
329
  padding: calc(var(--base-padding) * 0.75) calc(var(--base-padding) * 1.25) !important;