Skip to content

Commit 92e8386

Browse files
authored
feat: add code editor (#222)
1 parent 0257a87 commit 92e8386

File tree

14 files changed

+712
-27
lines changed

14 files changed

+712
-27
lines changed

Diff for: apps/documentation/docs/.vitepress/config.mts

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ export default defineConfig({
9191
text: 'Details',
9292
link: '/design/components/details',
9393
},
94+
{
95+
text: 'Code',
96+
link: '/design/components/code',
97+
},
9498
],
9599
},
96100
],

Diff for: apps/documentation/docs/design/components/code.md

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Collection Component <Badge type="warning" text="beta" />
2+
3+
<div class="component-name">&lt;ecc-utils-design-code&gt;</div>
4+
Simple code editor to handle Yaml, JSON and multiline text input.
5+
<ClientOnly>
6+
<div :class="isDark ? 'component-dark component' : 'component-light component'">
7+
<ecc-utils-design-code :v-if="renderComponent" :items="primaryItems" :filters="primaryFilters" totalItems="50"></ecc-utils-design-code>
8+
9+
::: details Code Blocks
10+
::: code-group
11+
12+
```js [HTML]
13+
import "@elixir-cloud/design/dist/components/code/index.js";
14+
```
15+
16+
<!-- ```jsx [React]
17+
``` -->
18+
19+
:::
20+
21+
</div>
22+
</ClientOnly>
23+
24+
## Importing
25+
26+
```js [HTML]
27+
import "@elixir-cloud/design/dist/components/code/index.js";
28+
```
29+
30+
## Properties
31+
32+
| Property | Required | Default | Type | Description |
33+
| ------------- | -------- | ------- | --------- | ---------------------------------------------------------------------- |
34+
| `code` | `false` | | `String` | Specifies the code to be rendered in the editor during initialization. |
35+
| `label` | `Code` | | `String` | Label for code editor input field. |
36+
| `language` | `false` | | `String` | Specifies the language interpreter for syntax highlighting. |
37+
| `indentation` | `false` | `2` | `Number` | Specifies number of spaces that should be considered for 1 Tab space. |
38+
| `blurDelay` | `false` | `150` | `Number` | Time in ms between 2 Tab key presses that should move the focus. |
39+
| `required` | `false` | `true` | `Boolean` | Makes the code area a required field. |
40+
| `disabled` | `false` | `false` | `Boolean` | Disables the code area. |
41+
42+
## Events
43+
44+
| Event Name | Description |
45+
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
46+
| `ecc-utils-change` | This event is triggered when there is a change in the code within the editor. The event details include the language set by the package author, the code as value, and an error attribute indicating whether the entered code is valid based on the specified language. |
47+
48+
## Methods
49+
50+
| Method Name | Arguments | Description |
51+
| ----------- | --------- | ------------------ |
52+
| `getCode()` | | Returns the input. |
53+
54+
## Slots
55+
56+
## Parts
57+
58+
## Examples
59+
60+
### JSON
61+
62+
<ClientOnly>
63+
<div :class="isDark ? 'component-dark component' : 'component-light component'">
64+
<ecc-utils-design-code :v-if="renderComponent" :items="primaryItems" :filters="primaryFilters" totalItems="50" language="JSON"></ecc-utils-design-code>
65+
66+
::: details Code Blocks
67+
::: code-group
68+
69+
```js [HTML]
70+
import "@elixir-cloud/design/dist/components/code/index.js";
71+
```
72+
73+
<!-- ```jsx [React]
74+
``` -->
75+
76+
:::
77+
78+
</div>
79+
</ClientOnly>
80+
81+
### Indentation
82+
83+
<ClientOnly>
84+
<div :class="isDark ? 'component-dark component' : 'component-light component'">
85+
<ecc-utils-design-code :v-if="renderComponent" indentation="4"></ecc-utils-design-code>
86+
87+
::: details Code Blocks
88+
::: code-group
89+
90+
```js [HTML]
91+
import "@elixir-cloud/design/dist/components/code/index.js";
92+
93+
<ecc-utils-design-code indentation=12></ecc-utils-design-code>;
94+
```
95+
96+
<!-- ```jsx [React]
97+
``` -->
98+
99+
:::
100+
101+
</div>
102+
</ClientOnly>
103+
104+
<script setup>
105+
import { onMounted, ref } from "vue";
106+
import { useData } from "vitepress";
107+
const { isDark } = useData();
108+
const renderComponent = ref(false);
109+
110+
onMounted(() => {
111+
import("@elixir-cloud/design/dist/components/code/index.js").then((module) => {
112+
});
113+
});
114+
</script>
115+
116+
<style>
117+
</style>

0 commit comments

Comments
 (0)