Skip to content

Commit

Permalink
Link helix editor playground
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgroenwoldt committed Jun 1, 2023
1 parent 3ba8489 commit 5fd4f80
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
11 changes: 10 additions & 1 deletion index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ body {
a {
font-size: 1.5vh;
display: flex;
margin: 2% auto;
margin: 2% auto 0 auto;
padding: 2%;
border: 0.01vh solid #7f849c;
transition: all 0.1s ease-in-out, font-size 0s;
Expand All @@ -265,6 +265,15 @@ body {
transition: all 0.1s ease-in-out, font-size 0s;
color: #bac2de;
}
.playground-new {
animation: shake 0.5s;
animation-iteration-count: infinite;
border-color: #cba6f7;
color: #bac2de;
}
.playground-new:hover {
animation: none;
}
}

.reset {
Expand Down
25 changes: 24 additions & 1 deletion src/help.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use yew::{html, Component};
use gloo_storage::{LocalStorage, Storage};
use yew::{html, Callback, Component};

use crate::constants::COMMANDS;

Expand All @@ -23,6 +24,22 @@ impl Component for Help {

fn view(&self, _ctx: &yew::Context<Self>) -> yew::Html {
let commands = &self.commands;

let playground_new = match LocalStorage::get("playground_new") {
Ok(value) => value,
Err(_) => {
LocalStorage::set::<bool>("playground_new", true).unwrap();
true
}
};
let onclick = Callback::from(move |_| {
LocalStorage::set::<bool>("playground_new", false).unwrap();
});
let playground_class = if playground_new {
"playground-new"
} else {
"playground"
};
// Handle the last command separately.
html! {
<div class="sidebox">
Expand All @@ -44,6 +61,12 @@ impl Component for Help {
target="_blank">
{"View source"}
</a>
<a class={playground_class}
href="https://tomgroenwoldt.github.io/helix-editor-playground/"
{onclick}
target="_blank">
{"Check out the playground"}
</a>
</div>
}
}
Expand Down

0 comments on commit 5fd4f80

Please sign in to comment.