-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6dddb7
commit 7e63132
Showing
15 changed files
with
261 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,99 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="icon" type="image/svg+xml" href="{{ path '/favicon/favicon.svg' }}"> | ||
<link rel="icon" type="image/png" href="{{ path '/favicon/favicon.png' }}"> | ||
<link rel="stylesheet" href="{{ path '/css/reactive-graph.css' }}"> | ||
<title>Preview</title> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="icon" type="image/svg+xml" href="{{ path '/favicon/favicon.svg' }}"> | ||
<link rel="icon" type="image/png" href="{{ path '/favicon/favicon.png' }}"> | ||
<link rel="stylesheet" href="{{ path '/css/reactive-graph.css' }}"> | ||
<title>Preview</title> | ||
<link rel="preload" href="{{ path '/reactive-graph-design_bg.wasm' }}" crossorigin="anonymous" as="fetch" | ||
type="application/wasm"> | ||
<link rel="modulepreload" href="{{ path '/reactive-graph-design.js' }}" crossorigin="anonymous"> | ||
</head> | ||
<body> | ||
<main> | ||
<main> | ||
<details open> | ||
<summary> | ||
<span class="font-black"><p> | ||
{{#if _target.context.renderAsCss}}CSS Styled{{/if}} | ||
{{#if _target.context.renderAsWebComponents}}Web Components{{/if}} | ||
</span> | ||
</summary> | ||
<p>This is a {{{ yield }}} token</p> | ||
</details> | ||
<details open> | ||
<summary> | ||
<span class="font-black"><h6> | ||
{{#if _target.context.renderAsCss}}CSS Styled{{/if}} | ||
{{#if _target.context.renderAsWebComponents}}Web Components{{/if}} | ||
</span> | ||
</summary> | ||
<h6>This is a {{{ yield }}} token</h6> | ||
</details> | ||
<details open> | ||
<summary> | ||
<span class="font-black"><h5> | ||
{{#if _target.context.renderAsCss}}CSS Styled{{/if}} | ||
{{#if _target.context.renderAsWebComponents}}Web Components{{/if}} | ||
</span> | ||
</summary> | ||
<h5>This is a {{{ yield }}} token</h5> | ||
</details> | ||
<details open> | ||
<summary> | ||
<span class="font-black"><h4> | ||
{{#if _target.context.renderAsCss}}CSS Styled{{/if}} | ||
{{#if _target.context.renderAsWebComponents}}Web Components{{/if}} | ||
</span> | ||
</summary> | ||
<h4>This is a {{{ yield }}} token</h4> | ||
</details> | ||
<details open> | ||
<summary> | ||
<span class="font-black"><h3> | ||
{{#if _target.context.renderAsCss}}CSS Styled{{/if}} | ||
{{#if _target.context.renderAsWebComponents}}Web Components{{/if}} | ||
</span> | ||
</summary> | ||
<h3>This is a {{{ yield }}} token</h3> | ||
</details> | ||
<details open> | ||
<summary> | ||
<span class="font-black"><h2> | ||
{{#if _target.context.renderAsCss}}CSS Styled{{/if}} | ||
{{#if _target.context.renderAsWebComponents}}Web Components{{/if}} | ||
</span> | ||
</summary> | ||
<h2>This is a {{{ yield }}} token</h2> | ||
</details> | ||
<details open> | ||
<summary> | ||
<span class="font-black"><h1> | ||
{{#if _target.context.renderAsCss}}CSS Styled{{/if}} | ||
{{#if _target.context.renderAsWebComponents}}Web Components{{/if}} | ||
</span> | ||
</summary> | ||
<h1>This is a {{{ yield }}} token</h1> | ||
</details> | ||
<details open> | ||
<summary> | ||
<span class="font-black"><blockquote> <p> | ||
{{#if _target.context.renderAsCss}}CSS Styled{{/if}} | ||
{{#if _target.context.renderAsWebComponents}}Web Components{{/if}} | ||
</span> | ||
</summary> | ||
<blockquote> | ||
<p>This is a {{{ yield }}} token</p> | ||
<h6>This is a {{{ yield }}} token</h6> | ||
<h5>This is a {{{ yield }}} token</h5> | ||
<h4>This is a {{{ yield }}} token</h4> | ||
<h3>This is a {{{ yield }}} token</h3> | ||
<h2>This is a {{{ yield }}} token</h2> | ||
<h1>This is a {{{ yield }}} token</h1> | ||
<blockquote><p>This is a {{{ yield }}} token</p></blockquote> | ||
</main> | ||
</blockquote> | ||
</details> | ||
</main> | ||
<script type="module"> | ||
import init, * as bindings from "{{ path '/reactive-graph-design.js' }}"; | ||
init("{{ path '/reactive-graph-design_bg.wasm' }}"); | ||
window.wasmBindings = bindings; | ||
</script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
<span class="token string">{{token}}</span> | ||
{{#if renderAsCss}} | ||
<span class="token rg-{{ty}}">{{text}}</span> | ||
{{/if}} | ||
{{#if renderAsWebComponents}} | ||
<rg-token ty="{{ty}}">{{text}}</rg-token> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
use crate::atoms::tag::RgTag; | ||
use crate::atoms::token::RgToken; | ||
use crate::base::CustomElementCreator; | ||
|
||
pub mod tag; | ||
pub mod token; | ||
|
||
pub(crate) fn define_elements() { | ||
RgTag::define_element(); | ||
RgToken::define_element(); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use rs_web_component::Component; | ||
use wasm_bindgen::prelude::*; | ||
use web_sys::HtmlElement; | ||
use web_sys::ShadowRoot; | ||
use web_sys::ShadowRootInit; | ||
use web_sys::ShadowRootMode; | ||
|
||
use crate::base::CustomElementCreator; | ||
use crate::base::RootVal; | ||
use crate::base::ThisVal; | ||
|
||
pub struct RgToken { | ||
root: RootVal, | ||
this: ThisVal, | ||
} | ||
|
||
impl CustomElementCreator for RgToken { | ||
fn tag_name() -> String { | ||
"rg-token".to_string() | ||
} | ||
|
||
fn create_component() -> Box<dyn Component> { | ||
Box::new(Self { | ||
root: RootVal::None, | ||
this: ThisVal::None, | ||
}) | ||
} | ||
} | ||
|
||
impl Component for RgToken { | ||
fn init(&mut self, this: HtmlElement) { | ||
self.this = ThisVal::Value(this); | ||
} | ||
|
||
fn observed_attributes(&self) -> Vec<String> { | ||
return vec!["ty".to_string()]; | ||
} | ||
|
||
fn attribute_changed_callback(&self, _name: String, _old_value: JsValue, _new_value: JsValue) {} | ||
|
||
fn connected_callback(&mut self) { | ||
self.root = RootVal::Value(self.get_this().attach_shadow(&ShadowRootInit::new(ShadowRootMode::Open)).unwrap()); | ||
self.rerender(); | ||
} | ||
|
||
fn disconnected_callback(&self) {} | ||
} | ||
|
||
impl RgToken { | ||
fn render(&self) -> String { | ||
let ty = self.get_this().get_attribute("ty").unwrap_or(String::new()); | ||
let text = self.get_this().inner_html(); | ||
format!("<link rel=\"stylesheet\" href=\"/css/reactive-graph.css\"><span class=\"token rg-{ty}\">{text}</span>",).to_string() | ||
} | ||
|
||
fn rerender(&self) { | ||
self.get_root().set_inner_html(self.render().as_str()); | ||
} | ||
|
||
fn get_root(&self) -> &ShadowRoot { | ||
return match &self.root { | ||
RootVal::Value(root) => &root, | ||
RootVal::None => panic!("not a root!"), | ||
}; | ||
} | ||
|
||
fn get_this(&self) -> &HtmlElement { | ||
match &self.this { | ||
ThisVal::Value(val) => val, | ||
ThisVal::None => panic!("not an HtmlElement"), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters