Skip to content

Commit 80c1a3d

Browse files
committed
final polish, check examples
1 parent 6b60c4a commit 80c1a3d

13 files changed

Lines changed: 178 additions & 75 deletions

File tree

code-editor/assets/dioxus-code-editor.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
min-height: 0;
88
overflow: auto;
99
tab-size: 4;
10+
transition: box-shadow 160ms ease;
1011
}
1112

1213
.dxc-editor *,

demo/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,27 @@ desktop = ["dioxus/desktop"]
2121
web = ["dioxus/web", "dioxus-primitives/web"]
2222
fullstack = ["dioxus/fullstack"]
2323
server = ["dioxus/server", "dioxus/fullstack"]
24+
25+
[[example]]
26+
name = "snippet-starter"
27+
path = "snippets/starter.rs"
28+
29+
[[example]]
30+
name = "snippet-demo"
31+
path = "snippets/demo.rs"
32+
33+
[[example]]
34+
name = "snippet-runtime"
35+
path = "snippets/runtime.rs"
36+
37+
[[example]]
38+
name = "snippet-static-macro"
39+
path = "snippets/static_macro.rs"
40+
41+
[[example]]
42+
name = "snippet-example"
43+
path = "snippets/example.rs"
44+
45+
[[example]]
46+
name = "snippet-palette"
47+
path = "snippets/palette.rs"

demo/assets/app.css

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,11 +3378,11 @@ a {
33783378

33793379
.playground-code-editor {
33803380
--dxc-editor-caret: var(--editor-fg);
3381-
--dxc-editor-focus-ring: inset 0 0 0 2px var(--accent);
3381+
--dxc-editor-focus-ring: inset 0 0 0 1px var(--accent);
33823382
--dxc-editor-gutter-line-padding: 0 14px 0 18px;
33833383
--dxc-editor-gutter-padding: 20px 0;
33843384
--dxc-editor-gutter-width: 4ch;
3385-
--dxc-editor-padding: 20px 22px 20px 0;
3385+
--dxc-editor-padding: 20px 22px 20px 18px;
33863386
--dxc-editor-selection: var(--editor-selection);
33873387
background: var(--editor-bg);
33883388
color: var(--editor-fg);
@@ -3513,11 +3513,6 @@ a {
35133513

35143514
/* ============ Footer ============ */
35153515

3516-
.site-footer {
3517-
padding-top: 48px;
3518-
padding-bottom: 48px;
3519-
}
3520-
35213516
.card-footer {
35223517
background: var(--feature-bg-footer);
35233518
border: 1px solid var(--feature-line);
@@ -3526,7 +3521,7 @@ a {
35263521
color: var(--feature-text);
35273522
margin: 0 auto;
35283523
max-width: var(--max-width);
3529-
padding: 32px 40px;
3524+
padding: 48px;
35303525
width: 100%;
35313526
display: flex;
35323527
flex-direction: column;
@@ -3545,11 +3540,6 @@ a {
35453540
gap: 12px;
35463541
}
35473542

3548-
.card-footer .brand-mark {
3549-
background: var(--feature-text);
3550-
color: var(--feature-bg-footer);
3551-
}
3552-
35533543
.footer-brand-name {
35543544
color: var(--feature-text);
35553545
font-family: Inter, sans-serif;
@@ -3590,6 +3580,13 @@ a {
35903580
color: var(--feature-text);
35913581
}
35923582

3583+
.external-icon {
3584+
display: inline-block;
3585+
margin-left: 0.35em;
3586+
vertical-align: -0.1em;
3587+
opacity: 0.7;
3588+
}
3589+
35933590
.footer-meta {
35943591
color: var(--feature-mute);
35953592
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;

demo/snippets/demo.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn main() {}
2+
3+
pub struct Report<'a> {
4+
pub title: &'a str,
5+
pub rows: usize,
6+
}
7+
8+
impl Report<'_> {
9+
pub fn is_empty(&self) -> bool {
10+
self.rows == 0
11+
}
12+
}

demo/snippets/example.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn main() {}
2+
3+
pub fn fib(n: u32) -> u64 {
4+
let mut a: u64 = 0;
5+
let mut b: u64 = 1;
6+
for _ in 0..n {
7+
let next = a + b;
8+
a = b;
9+
b = next;
10+
}
11+
a
12+
}

demo/snippets/install.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dioxus-code = { version = "0.1", features = ["runtime"] }

demo/snippets/palette.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
use dioxus::prelude::*;
22
use dioxus_code::{Code, Theme, code};
33

4+
fn main() {
5+
dioxus::launch(TokenPalette);
6+
}
7+
48
#[component]
59
pub fn TokenPalette() -> Element {
610
rsx! {

demo/snippets/runtime.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use dioxus::prelude::*;
2+
use dioxus_code::{Code, CodeTheme, SourceCode, Theme};
3+
4+
fn main() {
5+
dioxus::launch(App);
6+
}
7+
8+
#[component]
9+
fn App() -> Element {
10+
let source = use_signal(|| "fn main() {}".to_string());
11+
12+
rsx! {
13+
Code {
14+
src: SourceCode::new(source()).with_language("rust"),
15+
theme: CodeTheme::system(Theme::GITHUB_LIGHT, Theme::GITHUB_DARK),
16+
}
17+
}
18+
}

demo/snippets/starter.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use dioxus::prelude::*;
2+
use dioxus_code::{Code, Theme, code};
3+
4+
fn main() {
5+
dioxus::launch(App);
6+
}
7+
8+
#[component]
9+
fn App() -> Element {
10+
rsx! {
11+
div { class: "app",
12+
Code {
13+
src: code!("/snippets/demo.rs"),
14+
theme: Theme::GITHUB_DARK,
15+
}
16+
}
17+
}
18+
}

demo/snippets/static_macro.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use dioxus::prelude::*;
2+
use dioxus_code::{Code, Theme, code};
3+
4+
fn main() {
5+
dioxus::launch(App);
6+
}
7+
8+
#[component]
9+
fn App() -> Element {
10+
rsx! {
11+
Code {
12+
src: code!("/snippets/example.rs"),
13+
theme: Theme::GITHUB_DARK,
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)