@hyvor/design 1.1.2 → 1.1.4

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.
@@ -16,6 +16,17 @@
16
16
  end?: import('svelte').Snippet;
17
17
  action?: import('svelte').Snippet;
18
18
  [key: string]: any;
19
+
20
+ onkeyup?: (event: KeyboardEvent) => void;
21
+ onkeydown?: (event: KeyboardEvent) => void;
22
+ onkeypress?: (event: KeyboardEvent) => void;
23
+ onfocus?: (event: FocusEvent) => void;
24
+ onblur?: (event: FocusEvent) => void;
25
+ onclick?: (event: MouseEvent) => void;
26
+ onmouseover?: (event: MouseEvent) => void;
27
+ onmouseenter?: (event: MouseEvent) => void;
28
+ onmouseleave?: (event: MouseEvent) => void;
29
+ onchange?: (event: Event) => void;
19
30
  }
20
31
 
21
32
  let {
@@ -30,6 +41,18 @@
30
41
  children,
31
42
  end,
32
43
  action,
44
+
45
+ onkeyup,
46
+ onkeydown,
47
+ onkeypress,
48
+ onfocus,
49
+ onblur,
50
+ onclick,
51
+ onmouseover,
52
+ onmouseenter,
53
+ onmouseleave,
54
+ onchange,
55
+
33
56
  ...rest
34
57
  }: Props = $props();
35
58
  </script>
@@ -38,16 +61,18 @@
38
61
  this={as}
39
62
  class="button {size} {color} {variant} {align}"
40
63
  class:block
41
- onkeyup={bubble('keyup')}
42
- onkeydown={bubble('keydown')}
43
- onkeypress={bubble('keypress')}
44
- onfocus={bubble('focus')}
45
- onblur={bubble('blur')}
46
- onclick={bubble('click')}
47
- onmouseover={bubble('mouseover')}
48
- onmouseenter={bubble('mouseenter')}
49
- onmouseleave={bubble('mouseleave')}
50
- onchange={bubble('change')}
64
+
65
+ onkeyup={(e: KeyboardEvent) => { bubble('keyup'); onkeyup?.(e); }}
66
+ onkeydown={(e: KeyboardEvent) => { bubble('keydown'); onkeydown?.(e); }}
67
+ onkeypress={(e: KeyboardEvent) => { bubble('keypress'); onkeypress?.(e); }}
68
+ onfocus={(e: FocusEvent) => { bubble('focus'); onfocus?.(e); }}
69
+ onblur={(e: FocusEvent) => { bubble('blur'); onblur?.(e); }}
70
+ onclick={(e: MouseEvent) => { bubble('click'); onclick?.(e); }}
71
+ onmouseover={(e: MouseEvent) => { bubble('mouseover'); onmouseover?.(e); }}
72
+ onmouseenter={(e: MouseEvent) => { bubble('mouseenter'); onmouseenter?.(e); }}
73
+ onmouseleave={(e: MouseEvent) => { bubble('mouseleave'); onmouseleave?.(e); }}
74
+ onchange={(e: Event) => { bubble('change'); onchange?.(e); }}
75
+
51
76
  role="button"
52
77
  tabindex="0"
53
78
  bind:this={button}
@@ -11,6 +11,16 @@ interface Props {
11
11
  end?: import('svelte').Snippet;
12
12
  action?: import('svelte').Snippet;
13
13
  [key: string]: any;
14
+ onkeyup?: (event: KeyboardEvent) => void;
15
+ onkeydown?: (event: KeyboardEvent) => void;
16
+ onkeypress?: (event: KeyboardEvent) => void;
17
+ onfocus?: (event: FocusEvent) => void;
18
+ onblur?: (event: FocusEvent) => void;
19
+ onclick?: (event: MouseEvent) => void;
20
+ onmouseover?: (event: MouseEvent) => void;
21
+ onmouseenter?: (event: MouseEvent) => void;
22
+ onmouseleave?: (event: MouseEvent) => void;
23
+ onchange?: (event: Event) => void;
14
24
  }
15
25
  declare const Button: import("svelte").Component<Props, {}, "button">;
16
26
  type Button = ReturnType<typeof Button>;
@@ -0,0 +1,78 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ import Button from "../Button/Button.svelte";
4
+
5
+ interface Props {
6
+ children: Snippet;
7
+ tabs: string[];
8
+ }
9
+
10
+ let { children, tabs }: Props = $props();
11
+ let activeTab = $state(tabs[0]);
12
+
13
+ function activateTab(tab: string) {
14
+ activeTab = tab;
15
+
16
+ const pres = blocksEl.querySelectorAll("pre");
17
+ const tabIndex = tabs.indexOf(tab);
18
+
19
+ pres.forEach((pre, index) => {
20
+ if (index === tabIndex) {
21
+ pre.style.display = "block";
22
+ } else {
23
+ pre.style.display = "none";
24
+ }
25
+ });
26
+ }
27
+
28
+ let blocksEl: HTMLDivElement;
29
+ </script>
30
+
31
+ <div class="tabbed">
32
+
33
+ <div class="selectors">
34
+ {#each tabs as tab}
35
+ <Button
36
+ size="x-small"
37
+ color={activeTab === tab ? 'accent' : 'input'}
38
+ onclick={() => activateTab(tab)}
39
+ >{tab}</Button>
40
+ {/each}
41
+ </div>
42
+
43
+ <div class="blocks" bind:this={blocksEl}>
44
+ {@render children()}
45
+ </div>
46
+
47
+ </div>
48
+
49
+ <style>
50
+
51
+ .tabbed {
52
+ margin: 1.5rem 0 1rem 0;
53
+ position: relative
54
+ }
55
+
56
+ .selectors {
57
+ display: inline-flex;
58
+ position: absolute;
59
+ top: 0;
60
+ left: 20px;
61
+ z-index: 1;
62
+ transform: translateY(-50%);
63
+ gap: 3px;
64
+ }
65
+
66
+ .selectors > :global(button) {
67
+ border: 1px solid var(--border);
68
+ }
69
+
70
+ .blocks > :global(pre:not(:first-child)) {
71
+ display: none;
72
+ }
73
+
74
+ .blocks > :global(pre) {
75
+ margin: 0
76
+ }
77
+
78
+ </style>
@@ -0,0 +1,8 @@
1
+ import type { Snippet } from "svelte";
2
+ interface Props {
3
+ children: Snippet;
4
+ tabs: string[];
5
+ }
6
+ declare const TabbedCodeBlock: import("svelte").Component<Props, {}, "">;
7
+ type TabbedCodeBlock = ReturnType<typeof TabbedCodeBlock>;
8
+ export default TabbedCodeBlock;
@@ -26,10 +26,18 @@
26
26
 
27
27
  let hasComponentParams = false;
28
28
 
29
- function getElementFunc(el: string) {
29
+ function getElementFunc(el: string, props: Record<string, any> = {}) {
30
30
  return (chunks: string | string[]) => {
31
31
  const children = typeof chunks === 'string' ? chunks : chunks.join('');
32
- return `<${el}>${children}</${el}>`;
32
+ let propsStr = '';
33
+ for (let [propKey, propValue] of Object.entries(props)) {
34
+ if (typeof propValue === 'string' || typeof propValue === 'number') {
35
+ propsStr += ` ${propKey}="${propValue}"`;
36
+ } else if (typeof propValue === 'boolean' && propValue) {
37
+ propsStr += ` ${propKey}`;
38
+ }
39
+ }
40
+ return `<${el}${propsStr}>${children}</${el}>`;
33
41
  };
34
42
  }
35
43
 
@@ -52,7 +60,10 @@
52
60
  };
53
61
  hasComponentParams = true;
54
62
  } else if (value.hasOwnProperty('element')) {
55
- newValue = getElementFunc((value as any).element as string);
63
+ newValue = getElementFunc(
64
+ (value as any).element as string,
65
+ (value as any).props || {}
66
+ );
56
67
  }
57
68
  } else {
58
69
  newValue = value as PrimitiveType;
@@ -98,7 +109,7 @@
98
109
  return '<span id="' + id + '">' + children + '</span>';
99
110
  };
100
111
  } else if (value.hasOwnProperty('element')) {
101
- newValue = getElementFunc((value as any).element as string);
112
+ newValue = getElementFunc((value as any).element as string, (value as any).props || {});
102
113
  }
103
114
  } else {
104
115
  newValue = value as PrimitiveType;
@@ -11,6 +11,7 @@ export { default as BoxShadowPicker } from './BoxShadowPicker/BoxShadowPicker.sv
11
11
  export { default as Callout } from './Callout/Callout.svelte';
12
12
  export { default as Checkbox } from './Checkbox/Checkbox.svelte';
13
13
  export { default as CodeBlock } from './CodeBlock/CodeBlock.svelte';
14
+ export { default as TabbedCodeBlock } from './CodeBlock/TabbedCodeBlock.svelte';
14
15
  export { default as ColorPicker } from './ColorPicker/ColorPicker.svelte';
15
16
  export { default as DarkProvider } from './Dark/DarkProvider.svelte';
16
17
  export { default as DarkToggle } from './Dark/DarkToggle.svelte';
@@ -11,6 +11,7 @@ export { default as BoxShadowPicker } from './BoxShadowPicker/BoxShadowPicker.sv
11
11
  export { default as Callout } from './Callout/Callout.svelte';
12
12
  export { default as Checkbox } from './Checkbox/Checkbox.svelte';
13
13
  export { default as CodeBlock } from './CodeBlock/CodeBlock.svelte';
14
+ export { default as TabbedCodeBlock } from './CodeBlock/TabbedCodeBlock.svelte';
14
15
  export { default as ColorPicker } from './ColorPicker/ColorPicker.svelte';
15
16
  export { default as DarkProvider } from './Dark/DarkProvider.svelte';
16
17
  export { default as DarkToggle } from './Dark/DarkToggle.svelte';
package/dist/index.css CHANGED
@@ -49,3 +49,8 @@ a {
49
49
  padding: 0 15px;
50
50
  margin: auto;
51
51
  }
52
+
53
+ .hds-link {
54
+ color: var(--link);
55
+ text-decoration: underline;
56
+ }
package/package.json CHANGED
@@ -59,5 +59,5 @@
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  },
62
- "version": "1.1.2"
62
+ "version": "1.1.4"
63
63
  }