Skip to content

Commit e461710

Browse files
committed
use code editor in demo site
1 parent 1d188f9 commit e461710

14 files changed

Lines changed: 1137 additions & 530 deletions

File tree

Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[workspace]
22
members = [
33
".",
4+
"code-editor",
45
"dioxus-code-macro",
56
"demo",
67
"examples/basic",
7-
"examples/content-editable",
88
"examples/dioxus-hello",
99
"examples/live-input",
1010
"examples/macro-only",
@@ -16,6 +16,10 @@ version = "0.1.0"
1616
edition = "2024"
1717
license = "MIT OR Apache-2.0"
1818

19+
[workspace.dependencies]
20+
dioxus-code = { path = "." }
21+
dioxus-code-editor = { path = "code-editor", default-features = false }
22+
1923
[package]
2024
name = "dioxus-code"
2125
version.workspace = true
@@ -27,6 +31,7 @@ default = ["macro"]
2731
macro = ["dep:dioxus-code-macro"]
2832
runtime = ["arborium/lang-rust"]
2933
lang-python = ["runtime", "arborium/lang-python"]
34+
lang-toml = ["runtime", "arborium/lang-toml"]
3035
all-languages = ["runtime", "arborium/all-languages"]
3136

3237
[dependencies]

code-editor/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "dioxus-code-editor"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
7+
[dependencies]
8+
dioxus = { version = "0.7.0", default-features = false, features = ["lib"] }
9+
dioxus-code = { workspace = true, features = ["runtime"] }
10+
11+
[features]
12+
default = ["desktop"]
13+
desktop = ["dioxus/desktop", "dioxus/launch"]
14+
web = ["dioxus/web", "dioxus/launch"]

code-editor/assets/demo.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
html,
2+
body,
3+
#main {
4+
margin: 0;
5+
min-height: 100%;
6+
}
7+
8+
body {
9+
background: #10131a;
10+
color: #d9e1ee;
11+
font-family: Avenir Next, Gill Sans, Trebuchet MS, sans-serif;
12+
}
13+
14+
.shell {
15+
box-sizing: border-box;
16+
display: grid;
17+
gap: 16px;
18+
grid-template-rows: auto minmax(0, 1fr);
19+
min-height: 100vh;
20+
padding: 24px;
21+
}
22+
23+
.toolbar {
24+
align-items: end;
25+
display: flex;
26+
justify-content: space-between;
27+
}
28+
29+
h1 {
30+
font-size: 22px;
31+
letter-spacing: 0;
32+
margin: 0;
33+
}
34+
35+
.toolbar span {
36+
border: 1px solid rgba(217, 225, 238, 0.28);
37+
color: #94a3b8;
38+
font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace;
39+
padding: 5px 8px;
40+
text-transform: uppercase;
41+
}
42+
43+
.dxc-editor {
44+
--dxc-editor-caret: #e8eef7;
45+
--dxc-editor-focus-ring: 0 0 0 3px rgba(122, 162, 247, 0.22);
46+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
.dxc-editor {
2+
border-radius: 8px;
3+
box-sizing: border-box;
4+
display: grid;
5+
font: 15px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
6+
grid-template-columns: max-content minmax(0, 1fr);
7+
min-height: 0;
8+
overflow: auto;
9+
tab-size: 4;
10+
}
11+
12+
.dxc-editor *,
13+
.dxc-editor *::before,
14+
.dxc-editor *::after {
15+
box-sizing: border-box;
16+
}
17+
18+
.dxc-editor-viewport {
19+
min-height: 100%;
20+
min-width: 0;
21+
position: relative;
22+
}
23+
24+
.dxc-editor-gutter,
25+
.dxc-editor-highlight,
26+
.dxc-editor-input {
27+
min-height: 100%;
28+
}
29+
30+
.dxc-editor-highlight,
31+
.dxc-editor-input {
32+
padding: var(--dxc-editor-padding, 14px 18px 14px 0);
33+
white-space: pre;
34+
}
35+
36+
.dxc-editor-gutter {
37+
color: var(--muted, currentColor);
38+
padding: var(--dxc-editor-gutter-padding, 14px 0);
39+
pointer-events: none;
40+
user-select: none;
41+
}
42+
43+
.dxc-editor-highlight {
44+
pointer-events: none;
45+
}
46+
47+
.dxc-editor-highlight span {
48+
font-style: normal !important;
49+
font-weight: inherit !important;
50+
}
51+
52+
.dxc-editor-input {
53+
caret-color: var(--dxc-editor-caret, currentColor);
54+
color: transparent;
55+
inset: 0;
56+
outline: none;
57+
overflow-wrap: normal;
58+
position: absolute;
59+
z-index: 1;
60+
}
61+
62+
.dxc-editor-input::selection {
63+
background: var(--dxc-editor-selection, rgba(122, 162, 247, 0.34));
64+
color: transparent;
65+
}
66+
67+
.dxc-editor-input:empty::before {
68+
color: var(--muted, currentColor);
69+
content: attr(data-placeholder);
70+
opacity: 0.72;
71+
}
72+
73+
.dxc-editor:focus-within {
74+
box-shadow: var(--dxc-editor-focus-ring, 0 0 0 3px rgba(122, 162, 247, 0.22));
75+
}
76+
77+
.dxc-editor-line,
78+
.dxc-editor-gutter-line {
79+
min-height: 1.55em;
80+
}
81+
82+
.dxc-editor-gutter-line {
83+
min-width: var(--dxc-editor-gutter-width, 4ch);
84+
padding: var(--dxc-editor-gutter-line-padding, 0 14px);
85+
text-align: right;
86+
}
87+
88+
.dxc-editor-no-gutter {
89+
grid-template-columns: minmax(0, 1fr);
90+
}
91+
92+
.dxc-editor-no-gutter .dxc-editor-highlight,
93+
.dxc-editor-no-gutter .dxc-editor-input {
94+
padding-left: var(--dxc-editor-padding-left, 18px);
95+
}

0 commit comments

Comments
 (0)