hamzus-ui 0.0.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.
Files changed (73) hide show
  1. package/README.md +38 -0
  2. package/index.js +6 -0
  3. package/package.json +48 -0
  4. package/src/components/hamzus-ui/AdvancedTooltip/Content.svelte +22 -0
  5. package/src/components/hamzus-ui/AdvancedTooltip/Label.svelte +1 -0
  6. package/src/components/hamzus-ui/AdvancedTooltip/Root.svelte +336 -0
  7. package/src/components/hamzus-ui/AdvancedTooltip/Separator.svelte +12 -0
  8. package/src/components/hamzus-ui/AdvancedTooltip/Trigger.svelte +5 -0
  9. package/src/components/hamzus-ui/AdvancedTooltip/index.js +5 -0
  10. package/src/components/hamzus-ui/AlertCard/AlertCard.svelte +32 -0
  11. package/src/components/hamzus-ui/Avatar/Avatar.svelte +32 -0
  12. package/src/components/hamzus-ui/Button/Button.svelte +79 -0
  13. package/src/components/hamzus-ui/Button/Button_default.svelte +142 -0
  14. package/src/components/hamzus-ui/Button/Button_link.svelte +138 -0
  15. package/src/components/hamzus-ui/Checkboxes/Checkbox/Checkbox.svelte +41 -0
  16. package/src/components/hamzus-ui/Checkboxes/Checkbox/index.css +68 -0
  17. package/src/components/hamzus-ui/Checkboxes/CheckboxCard/CheckboxCard.svelte +27 -0
  18. package/src/components/hamzus-ui/Checkboxes/CheckboxCard/index.css +54 -0
  19. package/src/components/hamzus-ui/Code/Code.svelte +192 -0
  20. package/src/components/hamzus-ui/CopyCode/CopyCode.svelte +55 -0
  21. package/src/components/hamzus-ui/CopyLabel/CopyLabel.svelte +43 -0
  22. package/src/components/hamzus-ui/DataList/DataList.svelte +82 -0
  23. package/src/components/hamzus-ui/DatePicker/DatePicker.svelte +326 -0
  24. package/src/components/hamzus-ui/Dialog/Dialog.svelte +61 -0
  25. package/src/components/hamzus-ui/DropdownMenu/Button.svelte +46 -0
  26. package/src/components/hamzus-ui/DropdownMenu/Content.svelte +22 -0
  27. package/src/components/hamzus-ui/DropdownMenu/Label.svelte +1 -0
  28. package/src/components/hamzus-ui/DropdownMenu/Root.svelte +340 -0
  29. package/src/components/hamzus-ui/DropdownMenu/Separator.svelte +12 -0
  30. package/src/components/hamzus-ui/DropdownMenu/Trigger.svelte +1 -0
  31. package/src/components/hamzus-ui/DropdownMenu/index.js +6 -0
  32. package/src/components/hamzus-ui/IconButton/IconButton.svelte +80 -0
  33. package/src/components/hamzus-ui/IconButton/IconButton_default.svelte +140 -0
  34. package/src/components/hamzus-ui/IconButton/IconButton_link.svelte +141 -0
  35. package/src/components/hamzus-ui/InfoCard/InfoCard.svelte +32 -0
  36. package/src/components/hamzus-ui/Input/Input.svelte +304 -0
  37. package/src/components/hamzus-ui/KBD/KBD.svelte +24 -0
  38. package/src/components/hamzus-ui/Link/Link.svelte +36 -0
  39. package/src/components/hamzus-ui/List/List.svelte +30 -0
  40. package/src/components/hamzus-ui/LoaderCircle/Loader.svelte +25 -0
  41. package/src/components/hamzus-ui/LoaderCircle/index.js +1 -0
  42. package/src/components/hamzus-ui/Popover/Button.svelte +46 -0
  43. package/src/components/hamzus-ui/Popover/Content.svelte +21 -0
  44. package/src/components/hamzus-ui/Popover/Label.svelte +1 -0
  45. package/src/components/hamzus-ui/Popover/Root.svelte +374 -0
  46. package/src/components/hamzus-ui/Popover/Separator.svelte +12 -0
  47. package/src/components/hamzus-ui/Popover/Trigger.svelte +1 -0
  48. package/src/components/hamzus-ui/Popover/index.js +6 -0
  49. package/src/components/hamzus-ui/Portal/Portal.svelte +46 -0
  50. package/src/components/hamzus-ui/Portal/Wormhole.svelte +7 -0
  51. package/src/components/hamzus-ui/Radios/Radio/Radio.svelte +43 -0
  52. package/src/components/hamzus-ui/Radios/Radio/index.css +68 -0
  53. package/src/components/hamzus-ui/Radios/RadioCard/RadioCard.svelte +32 -0
  54. package/src/components/hamzus-ui/Radios/RadioCard/index.css +50 -0
  55. package/src/components/hamzus-ui/Radios/RadioGroup/RadioGroup.svelte +46 -0
  56. package/src/components/hamzus-ui/Radios/RadioGroup/index.css +8 -0
  57. package/src/components/hamzus-ui/ScrollArea/ScrollArea.svelte +360 -0
  58. package/src/components/hamzus-ui/Swicth/Swicth.svelte +84 -0
  59. package/src/components/hamzus-ui/Swicth/index.css +120 -0
  60. package/src/components/hamzus-ui/Table/ActionsBar.svelte +174 -0
  61. package/src/components/hamzus-ui/Table/Content.svelte +68 -0
  62. package/src/components/hamzus-ui/Table/Header.svelte +268 -0
  63. package/src/components/hamzus-ui/Table/NavigationBar.svelte +10 -0
  64. package/src/components/hamzus-ui/Table/Root.svelte +128 -0
  65. package/src/components/hamzus-ui/Table/index.js +5 -0
  66. package/src/components/hamzus-ui/Table/table.js +48 -0
  67. package/src/components/hamzus-ui/Tabs/Tabs.svelte +87 -0
  68. package/src/components/hamzus-ui/TabsLink/Tabs.svelte +80 -0
  69. package/src/components/hamzus-ui/Tag/Tag.svelte +43 -0
  70. package/src/components/hamzus-ui/TinyScrollArea/TinyScrollArea.svelte +350 -0
  71. package/src/styles/font.css +71 -0
  72. package/src/styles/global.css +37 -0
  73. package/src/styles/variables.css +81 -0
@@ -0,0 +1,142 @@
1
+ <script>
2
+ // import
3
+ import Loader from '@hamzus-ui/LoaderCircle/Loader.svelte';
4
+ // props
5
+ export let loading = false;
6
+ export let desabled = false;
7
+ export let onClick = undefined;
8
+ export let label = '';
9
+ export let avoidRipple = false;
10
+ // local var
11
+ let button;
12
+ // functions
13
+ function handleClick(event) {
14
+ if (!desabled && !loading) {
15
+ if (onClick && typeof onClick === "function") {
16
+ onClick()
17
+ }
18
+ }
19
+ }
20
+ function createRipple(event) {
21
+ if (avoidRipple || desabled || loading) {
22
+ return;
23
+ }
24
+
25
+ console.log("ripple");
26
+
27
+ const ripple = document.createElement('span');
28
+
29
+ const rect = button.getBoundingClientRect();
30
+ const x = event.clientX - rect.left;
31
+ const y = event.clientY - rect.top;
32
+
33
+ ripple.style.left = `${x}px`;
34
+ ripple.style.top = `${y}px`;
35
+ ripple.classList.add('ripple');
36
+
37
+ button.appendChild(ripple);
38
+
39
+ setTimeout(() => {
40
+ ripple.remove();
41
+ }, 1000);
42
+ }
43
+ </script>
44
+
45
+ <button bind:this={button} on:click={handleClick} on:mousedown={createRipple} class="button h4" class:desabled class:loading {...$$restProps}>
46
+ {#if label}
47
+ <h4>{label}</h4>
48
+ {:else}
49
+ <slot />
50
+ {/if}
51
+ {#if loading}
52
+ <div class="loader">
53
+ <Loader size="16px" color="var(--button-default-color)"></Loader>
54
+ </div>
55
+ {/if}
56
+ </button>
57
+
58
+ <style>
59
+ .button {
60
+ display: flex;
61
+ align-items: center;
62
+ padding: var(--pad-xs) var(--pad-xl);
63
+ column-gap: var(--pad-m);
64
+ border-radius: var(--radius-m);
65
+ background-color: var(--button-default-bg);
66
+ color: var(--button-default-color);
67
+ transition-property: background-color, transform, color;
68
+ transition-duration: 0.2s;
69
+ transition-timing-function: ease-out;
70
+ cursor: pointer;
71
+ border: 1px solid var(--button-default-border);
72
+ width: max-content;
73
+ white-space: nowrap;
74
+ text-overflow: ellipsis;
75
+ overflow: hidden;
76
+ position: relative;
77
+ }
78
+ .button > :global(*) {
79
+ color: var(--button-default-color);
80
+ }
81
+ .button > :global(svg) {
82
+ height: 16px;
83
+ width: 16px;
84
+ flex-shrink: 0;
85
+ }
86
+ .button > :global(svg > path) {
87
+ fill: var(--button-default-color);
88
+ }
89
+ /* states */
90
+ .button:not(.desabled):not(.loading):hover {
91
+ background-color: var(--button-hover-bg);
92
+ border: 1px solid var(--button-hover-border);
93
+ color: var(--button-hover-color);
94
+ }
95
+ .button:not(.desabled):not(.loading):hover > :global(*) {
96
+ color: var(--button-hover-color);
97
+ }
98
+ .button:not(.desabled):not(.loading):hover > :global(svg > path) {
99
+ fill: var(--button-hover-color);
100
+ }
101
+ .button:active {
102
+ transform: scale(0.95);
103
+ }
104
+ .button.desabled,
105
+ .button.loading {
106
+ opacity: 0.8;
107
+ cursor: not-allowed;
108
+ transform: scale(0.9);
109
+ }
110
+
111
+ .button.loading :global(> *:not(.loader)) {
112
+ opacity: 0;
113
+ user-select: none;
114
+ pointer-events: none;
115
+ }
116
+ .loader {
117
+ position: absolute;
118
+ top: 50%;
119
+ left: 50%;
120
+ transform: translate(-50%, -50%);
121
+ }
122
+ /* ripple */
123
+ .button :global(.ripple) {
124
+ width: 0px;
125
+ aspect-ratio: 1/1;
126
+ background: var(--ripple-gradient);
127
+ position: absolute;
128
+ transform: translate(-50%, -50%);
129
+ border-radius: 100%;
130
+ animation: grow .7s ease-out;
131
+ }
132
+ @keyframes grow {
133
+ from {
134
+ width: 0px;
135
+ opacity: 1;
136
+ }
137
+ to {
138
+ width: 200%;
139
+ opacity: 0;
140
+ }
141
+ }
142
+ </style>
@@ -0,0 +1,138 @@
1
+ <script>
2
+ // import
3
+ import Loader from '@hamzus-ui/LoaderCircle/Loader.svelte';
4
+ // props
5
+ export let loading = false;
6
+ export let desabled = false;
7
+ export let href = '';
8
+ export let onClick = undefined;
9
+ export let label = '';
10
+ export let avoidRipple = false;
11
+ // local var
12
+ let button;
13
+ // functions
14
+ function handleClick(event) {
15
+ if (!desabled && !loading) {
16
+ if (onClick && typeof onClick === "function") {
17
+ onClick()
18
+ }
19
+ }
20
+ }
21
+ function createRipple(event) {
22
+ if (avoidRipple || desabled || loading) {
23
+ return;
24
+ }
25
+
26
+ const ripple = document.createElement('span');
27
+
28
+ const rect = button.getBoundingClientRect();
29
+ const x = event.clientX - rect.left;
30
+ const y = event.clientY - rect.top;
31
+
32
+ ripple.style.left = `${x}px`;
33
+ ripple.style.top = `${y}px`;
34
+ ripple.classList.add('ripple');
35
+
36
+ button.appendChild(ripple);
37
+
38
+ setTimeout(() => {
39
+ ripple.remove();
40
+ }, 1000);
41
+ }
42
+ </script>
43
+
44
+ <a on:click={handleClick} on:mousedown={createRipple} bind:this={button} class="button h4" class:desabled class:loading {href} {...$$restProps}>
45
+ {#if label}
46
+ <h4>{label}</h4>
47
+ {:else}
48
+ <slot />
49
+ {/if}
50
+ {#if loading}
51
+ <div class="loader">
52
+ <Loader size="16px" color="var(--button-default-color)"></Loader>
53
+ </div>
54
+ {/if}
55
+ </a>
56
+
57
+ <style>
58
+ .button {
59
+ display: flex;
60
+ align-items: center;
61
+ padding: var(--pad-xs) var(--pad-xl);
62
+ border-radius: var(--radius-m);
63
+ background-color: var(--button-default-bg);
64
+ color: var(--button-default-color);
65
+ transition-property: background-color, transform, color;
66
+ transition-duration: 0.2s;
67
+ transition-timing-function: ease-out;
68
+ cursor: pointer;
69
+ border: 1px solid var(--button-default-border);
70
+ width: max-content;
71
+ white-space: nowrap;
72
+ text-overflow: ellipsis;
73
+ overflow: hidden;
74
+ position: relative;
75
+ }
76
+ .button > :global(*) {
77
+ color: var(--button-default-color);
78
+ }
79
+ .button > :global(svg) {
80
+ height: 24px;
81
+ width: 24px;
82
+ flex-shrink: 0;
83
+ }
84
+ .button > :global(svg > path) {
85
+ fill: var(--button-default-color);
86
+ }
87
+ /* states */
88
+ .button:not(.desabled):not(.loading):hover {
89
+ background-color: var(--button-hover-bg);
90
+ border: 1px solid var(--button-hover-border);
91
+ color: var(--button-hover-color);
92
+ }
93
+ .button:not(.desabled):not(.loading):hover > :global(*) {
94
+ color: var(--button-hover-color);
95
+ }
96
+ .button:not(.desabled):not(.loading):hover > :global(svg > path) {
97
+ fill: var(--button-hover-color);
98
+ }
99
+ .button:active {
100
+ transform: scale(0.95);
101
+ }
102
+ .button.desabled {
103
+ opacity: 0.8;
104
+ cursor: not-allowed;
105
+ transform: scale(0.9);
106
+ }
107
+ .button.loading :global(> *:not(.loader)) {
108
+ opacity: 0;
109
+ user-select: none;
110
+ pointer-events: none;
111
+ }
112
+ .loader {
113
+ position: absolute;
114
+ top: 50%;
115
+ left: 50%;
116
+ transform: translate(-50%, -50%);
117
+ }
118
+ /* ripple */
119
+ .button :global(.ripple) {
120
+ width: 0px;
121
+ aspect-ratio: 1/1;
122
+ background: var(--ripple-gradient);
123
+ position: absolute;
124
+ transform: translate(-50%, -50%);
125
+ border-radius: 100%;
126
+ animation: grow 1s ease-out;
127
+ }
128
+ @keyframes grow {
129
+ from {
130
+ width: 0px;
131
+ opacity: 1;
132
+ }
133
+ to {
134
+ width: 500%;
135
+ opacity: 0;
136
+ }
137
+ }
138
+ </style>
@@ -0,0 +1,41 @@
1
+ <script>
2
+ export let size = "24px"
3
+ export let name = '';
4
+ export let label = '';
5
+ export let disabled = false;
6
+ export let fullWidth = false;
7
+ export let checked = false;
8
+ export let onChange = null;
9
+
10
+ import "./index.css"
11
+
12
+ function handleCheckboxChange() {
13
+ if (disabled) {
14
+ checked = checked
15
+ return
16
+ }
17
+
18
+ checked = !checked
19
+
20
+ if (onChange) {
21
+ onChange(checked)
22
+ }
23
+ }
24
+ </script>
25
+ <label class="checkbox-label {disabled ? "disabled" : ""} {fullWidth ? "full-width" : ""}" >
26
+ {#if label}
27
+ <h4>{label}</h4>
28
+ {/if}
29
+ <div class="checkbox-box" style="width:{size};height:{size};">
30
+ <input
31
+ {disabled}
32
+ type="checkbox"
33
+ {name}
34
+ {checked}
35
+ on:change={handleCheckboxChange}
36
+ style="display:none;" />
37
+ <svg width="20px" height="20px" viewBox="0 0 20 20">
38
+ <polyline points="4 11 8 15 16 6"></polyline>
39
+ </svg>
40
+ </div>
41
+ </label>
@@ -0,0 +1,68 @@
1
+ .checkbox-label{
2
+ display: flex;
3
+ align-items: center;
4
+ column-gap: 7px;
5
+ cursor: pointer;
6
+ user-select: none;
7
+ }
8
+ .checkbox-label.full-width{
9
+ width: 100%;
10
+ flex-direction: row-reverse;
11
+ justify-content: start;
12
+ }
13
+ .checkbox-box{
14
+ width: 22px;
15
+ height: 22px;
16
+ display: flex;
17
+ flex-shrink: 0;
18
+ border-radius: var(--radius-m);
19
+ border: 2px solid var(--stroke);
20
+ position: relative;
21
+ cursor: pointer;
22
+ transition: background-color .2s ease-out;
23
+ }
24
+ .checkbox-box:hover{
25
+ background-color: var(--bg-2);
26
+ }
27
+ .checkbox-box svg {
28
+ position: absolute;
29
+ width: 70%;
30
+ height: auto;
31
+ left: 50%;
32
+ top: 50%;
33
+ transform: translate(-50%, -50%) scale(.6);
34
+ user-select: none;
35
+ pointer-events: none;
36
+ transition-property: transform;
37
+ transition-duration: .2s;
38
+ transition-timing-function: ease-out;
39
+ }
40
+ .checkbox-box svg polyline{fill: none;
41
+ stroke: #FFF;
42
+ stroke-width: 2;
43
+ stroke-linecap: round;
44
+ stroke-linejoin: round;
45
+ stroke-dasharray: 50px;
46
+ stroke-dashoffset: 50px;
47
+ transition: stroke-dashoffset .2s ease-out;
48
+ }
49
+
50
+ .checkbox-box:has(input:checked){
51
+ background-color: var(--accent);
52
+ border: 2px solid var(--accent);
53
+ }
54
+ .checkbox-box:has(input:checked) svg{
55
+ user-select: initial;
56
+ pointer-events: initial;
57
+ transform: translate(-50%, -50%) scale(1);
58
+ }
59
+ .checkbox-box:has(input:checked) svg polyline{
60
+ stroke-dashoffset: 0;
61
+ }
62
+ .checkbox-label.disabled {
63
+ opacity: .9;
64
+ cursor: not-allowed;
65
+ }
66
+ .checkbox-label.disabled .checkbox-box {
67
+ cursor: not-allowed;
68
+ }
@@ -0,0 +1,27 @@
1
+ <script>
2
+ export let checkboxSize ="24px"
3
+ export let checked = false
4
+ export let title = "title"
5
+ export let text
6
+ export let disabled
7
+ export let style
8
+ export let icon = null
9
+
10
+ import Checkbox from "../Checkbox/Checkbox.svelte"
11
+ import "./index.css"
12
+ </script>
13
+
14
+ <label {style} class="checkbox-card {disabled ? "disabled" : ""}">
15
+ <div class="checkbox-left-content">
16
+ {#if icon}
17
+ {icon}
18
+ {/if}
19
+ <div class="text">
20
+ <h3>{title}</h3>
21
+ {#if text}
22
+ <p>{text}</p>
23
+ {/if}
24
+ </div>
25
+ </div>
26
+ <Checkbox {disabled} {checked} size={checkboxSize} name="test"/>
27
+ </label>
@@ -0,0 +1,54 @@
1
+
2
+ .checkbox-card{
3
+ display: flex;
4
+ align-items: center;
5
+ justify-content: space-between;
6
+ padding: 10px;
7
+ border-radius: 10px;
8
+ background-color: var(--bg-2);
9
+ border: 2px solid var(--bg-2);
10
+ column-gap: 24px;
11
+ transition-property: transform border;
12
+ transition-duration: .2s;
13
+ transition-timing-function: ease-out;
14
+ cursor: pointer;
15
+ user-select: none;
16
+ }
17
+ .checkbox-card:not(.disabled):active{
18
+ transform: scale(.95);
19
+ }
20
+ .checkbox-card:hover{
21
+ background-color: var(--bg-3);
22
+ }
23
+
24
+ .checkbox-card .checkbox-left-content{
25
+ display: flex;
26
+ column-gap: 7px;
27
+ }
28
+ .checkbox-card .checkbox-left-content .text{
29
+ row-gap: -10px;
30
+ display: flex;
31
+ flex-direction: column;
32
+ }
33
+ .checkbox-card .checkbox-left-content svg{
34
+ width: 30px;
35
+ height: 30px;
36
+ flex-shrink: 0;
37
+ }
38
+ .checkbox-card .checkbox-left-content svg path{
39
+ fill: var(--font-d);
40
+ }
41
+
42
+ .checkbox-card:has(input:checked){
43
+ border: 2px solid var(--accent);
44
+ }
45
+ .checkbox-card:has(input:checked) .checkbox-left-content svg path{
46
+ fill: var(--accent);
47
+ }
48
+
49
+ /* disabled */
50
+ .checkbox-card.disabled{
51
+ background-color: var(--bg-3);
52
+ opacity: .8;
53
+ cursor: not-allowed;
54
+ }
@@ -0,0 +1,192 @@
1
+ <script>
2
+ import Button from '@hamzus-ui/Button/Button.svelte';
3
+ import IconButton from '@hamzus-ui/IconButton/IconButton.svelte';
4
+ import ScrollArea from '@hamzus-ui/ScrollArea/ScrollArea.svelte';
5
+
6
+ export let text = '';
7
+ export let title = '';
8
+ export let src = '';
9
+ export let limit = 15;
10
+
11
+ let lines = [];
12
+ let isCoppied = false;
13
+
14
+ function lintCode(text) {
15
+ // text = text.replace(/ /g, '\t');
16
+ text = text.replace(/"([^"]*)":/g, '<span>"$1"</span> <span class="syntax">:</span>');
17
+ text = text.replace(/(,)\n/g, '<span class="syntax">$1</span>\n');
18
+
19
+ let tempText = text.split('\n');
20
+ lines = tempText;
21
+
22
+
23
+ }
24
+ $: lintCode(text);
25
+
26
+ let isExpanded = false;
27
+ function handleExpand() {
28
+ isExpanded = true;
29
+ }
30
+ function handleUnexpand() {
31
+ isExpanded = false;
32
+ }
33
+
34
+ async function handleCopy() {
35
+ await navigator.clipboard.writeText(text);
36
+ isCoppied = true;
37
+
38
+ setTimeout(() => {
39
+ isCoppied = false;
40
+ }, 800);
41
+ }
42
+ </script>
43
+
44
+ <div>
45
+ <div class="top-code">
46
+ <h3>{title}</h3>
47
+ <IconButton variant="ghost" onClick={handleCopy}>
48
+ {#if isCoppied}
49
+ <svg
50
+ width="25"
51
+ height="25"
52
+ viewBox="0 0 25 25"
53
+ fill="none"
54
+ xmlns="http://www.w3.org/2000/svg"
55
+ >
56
+ <path
57
+ d="M10.1178 18.3979C9.78728 18.3979 9.47333 18.2658 9.242 18.0344L4.56581 13.3582C4.08662 12.8791 4.08662 12.0859 4.56581 11.6067C5.045 11.1275 5.83813 11.1275 6.31732 11.6067L10.1178 15.4072L18.6109 6.91402C19.0901 6.43483 19.8832 6.43483 20.3624 6.91402C20.8416 7.3932 20.8416 8.18634 20.3624 8.66552L10.9935 18.0344C10.7622 18.2658 10.4482 18.3979 10.1178 18.3979Z"
58
+ fill="black"
59
+ />
60
+ </svg>
61
+ {:else}
62
+ <svg
63
+ width="24"
64
+ height="24"
65
+ viewBox="0 0 24 24"
66
+ fill="none"
67
+ xmlns="http://www.w3.org/2000/svg"
68
+ >
69
+ <path
70
+ d="M11.1 22.75H6.9C2.99 22.75 1.25 21.01 1.25 17.1V12.9C1.25 8.99 2.99 7.25 6.9 7.25H11.1C15.01 7.25 16.75 8.99 16.75 12.9V17.1C16.75 21.01 15.01 22.75 11.1 22.75ZM6.9 8.75C3.8 8.75 2.75 9.8 2.75 12.9V17.1C2.75 20.2 3.8 21.25 6.9 21.25H11.1C14.2 21.25 15.25 20.2 15.25 17.1V12.9C15.25 9.8 14.2 8.75 11.1 8.75H6.9Z"
71
+ fill="#292D32"
72
+ />
73
+ <path
74
+ d="M17.1 16.75H16C15.59 16.75 15.25 16.41 15.25 16V12.9C15.25 9.8 14.2 8.75 11.1 8.75H8C7.59 8.75 7.25 8.41 7.25 8V6.9C7.25 2.99 8.99 1.25 12.9 1.25H17.1C21.01 1.25 22.75 2.99 22.75 6.9V11.1C22.75 15.01 21.01 16.75 17.1 16.75ZM16.75 15.25H17.1C20.2 15.25 21.25 14.2 21.25 11.1V6.9C21.25 3.8 20.2 2.75 17.1 2.75H12.9C9.8 2.75 8.75 3.8 8.75 6.9V7.25H11.1C15.01 7.25 16.75 8.99 16.75 12.9V15.25Z"
75
+ fill="#292D32"
76
+ />
77
+ </svg>
78
+ {/if}
79
+ </IconButton>
80
+ </div>
81
+ <div class="code-block">
82
+ <ScrollArea style="height:fit-content;" proximity={3}>
83
+ <div class="code">
84
+ {#each lines as line, index}
85
+ {#if !isExpanded && index < limit}
86
+ <div class="line">
87
+ <span class="line-index h5">{index + 1}</span>
88
+ <p class="line-content">{line}</p>
89
+ </div>
90
+ {/if}
91
+ {#if isExpanded}
92
+ <div class="line">
93
+ <span class="line-index h5">{index + 1}</span>
94
+ <p class="line-content">{line}</p>
95
+ </div>
96
+ {/if}
97
+ {/each}
98
+ </div>
99
+ </ScrollArea>
100
+
101
+ {#if lines.length > limit && !isExpanded}
102
+ <div class="see-more" style="padding: 3px;">
103
+ <Button onClick={handleExpand} variant="ghost" style="width:100%" label="Afficher plus"></Button>
104
+ </div>
105
+ {/if}
106
+ {#if isExpanded && lines.length > limit - 1}
107
+ <div style="padding: 3px;border-top: 1px solid var(--stroke);">
108
+ <Button onClick={handleUnexpand} variant="ghost" style="width:100%" label="Afficher moins"></Button>
109
+ </div>
110
+ {/if}
111
+ </div>
112
+ </div>
113
+ {#if src}
114
+ <h5 class="src">{src}</h5>
115
+ {/if}
116
+
117
+ <style>
118
+ .top-code {
119
+ display: flex;
120
+ align-items: center;
121
+ justify-content: space-between;
122
+ border: 1px solid var(--stroke);
123
+ border-bottom: unset;
124
+ padding: var(--pad-xxl);
125
+ border-top-left-radius: 7px;
126
+ border-top-right-radius: 7px;
127
+ }
128
+ .code-block {
129
+ border: 1px solid var(--stroke);
130
+ border-bottom-left-radius: 7px;
131
+ border-bottom-right-radius: 7px;
132
+ overflow-y: hidden;
133
+ }
134
+ .code {
135
+ width: 100%;
136
+ min-width: fit-content;
137
+ display: flex;
138
+ flex-direction: column;
139
+ }
140
+ .line {
141
+ min-width: 100%;
142
+ width: 100%;
143
+ display: flex;
144
+ align-items: center;
145
+ }
146
+ .line:nth-child(even) {
147
+ background-color: var(--bg-2);
148
+ }
149
+ .line:hover {
150
+ background-color: var(--bg-3);
151
+ }
152
+
153
+ .line-index {
154
+ width: 50px;
155
+ background-color: rgba(133, 133, 133, 0.068);
156
+ color: var(--font-u);
157
+ padding: var(--pad-xs) var(--pad-m);
158
+ user-select: none;
159
+ }
160
+ .line-content {
161
+ width: calc(100% - 50px);
162
+ text-wrap: nowrap;
163
+ white-space: pre;
164
+ }
165
+ .line-content > :global(span) {
166
+ color: var(--blue);
167
+ }
168
+ .line-content > :global(.syntax) {
169
+ color: var(--orange);
170
+ }
171
+
172
+ .see-more {
173
+ position: relative;
174
+ border-top: 1px solid var(--stroke);
175
+ }
176
+ .see-more::after {
177
+ content: '';
178
+ position: absolute;
179
+ bottom: 100%;
180
+ left: 0;
181
+ width: 100%;
182
+ height: 60px;
183
+ background: linear-gradient(0deg, rgba(0, 0, 0, 0.466) 0%, rgba(255, 255, 255, 0) 100%);
184
+ user-select: none;
185
+ pointer-events: none;
186
+ }
187
+
188
+ .src{
189
+ width: 100%;
190
+ text-align: end;
191
+ }
192
+ </style>