Skip to content

Commit cf4eeef

Browse files
committed
cryptonote wip
1 parent ab6c142 commit cf4eeef

File tree

7 files changed

+98
-109
lines changed

7 files changed

+98
-109
lines changed

rust/cryptonote/assets/bare.min.css

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

rust/cryptonote/assets/matcha.css

Lines changed: 0 additions & 6 deletions
This file was deleted.

rust/cryptonote/src/i18n.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ impl Language {
4343

4444
#[derive(Clone)]
4545
pub struct Translations {
46-
pub app_title: &'static str,
47-
pub app_subtitle: &'static str,
48-
pub your_note: &'static str,
4946
pub note_placeholder: &'static str,
5047
pub encryption_options: &'static str,
5148
pub no_encryption: &'static str,
5249
pub password_encryption: &'static str,
5350
pub cipher: &'static str,
51+
pub password: &'static str,
5452
pub password_placeholder: &'static str,
5553
pub generate_button: &'static str,
5654
pub share_title: &'static str,
@@ -76,14 +74,12 @@ pub struct Translations {
7674
pub fn get_translations(lang: Language) -> Translations {
7775
match lang {
7876
Language::English => Translations {
79-
app_title: "Cryptonote",
80-
app_subtitle: "Create encrypted notes that live in URLs",
81-
your_note: "Your Note",
8277
note_placeholder: "Enter your note here...",
8378
encryption_options: "Encryption Options",
8479
no_encryption: "No encryption (plaintext)",
8580
password_encryption: "Password encryption",
8681
cipher: "Cipher",
82+
password: "Password",
8783
password_placeholder: "Enter password",
8884
generate_button: "Generate Shareable Link",
8985
share_title: "Share Your Note",
@@ -106,14 +102,12 @@ pub fn get_translations(lang: Language) -> Translations {
106102
invalid_utf8: "Decrypted data is not valid UTF-8",
107103
},
108104
Language::Spanish => Translations {
109-
app_title: "Cryptonote",
110-
app_subtitle: "Crea notas cifradas que viven en URLs",
111-
your_note: "Tu Nota",
112105
note_placeholder: "Escribe tu nota aquí...",
113106
encryption_options: "Opciones de Cifrado",
114107
no_encryption: "Sin cifrado (texto plano)",
115108
password_encryption: "Cifrado con contraseña",
116109
cipher: "Cifrado",
110+
password: "Contraseña",
117111
password_placeholder: "Ingresa contraseña",
118112
generate_button: "Generar Enlace Compartible",
119113
share_title: "Comparte Tu Nota",
@@ -136,14 +130,12 @@ pub fn get_translations(lang: Language) -> Translations {
136130
invalid_utf8: "Los datos descifrados no son UTF-8 válidos",
137131
},
138132
Language::Russian => Translations {
139-
app_title: "Cryptonote",
140-
app_subtitle: "Создавайте зашифрованные заметки в URL",
141-
your_note: "Ваша Заметка",
142133
note_placeholder: "Введите вашу заметку здесь...",
143134
encryption_options: "Параметры Шифрования",
144135
no_encryption: "Без шифрования (открытый текст)",
145136
password_encryption: "Шифрование паролем",
146137
cipher: "Шифр",
138+
password: "Пароль",
147139
password_placeholder: "Введите пароль",
148140
generate_button: "Создать Ссылку для Обмена",
149141
share_title: "Поделиться Заметкой",

rust/cryptonote/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn App() -> Element {
4747
// In addition to element and text (which we will see later), rsx can contain other components. In this case,
4848
// we are using the `document::Link` component to add a link to our favicon and main CSS file into the head of our app.
4949
document::Link { rel: "icon", href: FAVICON }
50-
document::Link { rel: "stylesheet", href: asset!("/assets/matcha.css") }
50+
document::Link { rel: "stylesheet", href: asset!("/assets/bare.min.css") }
5151

5252
// The router component renders the route enum we defined above. It will handle synchronization of the URL and render
5353
// the layouts and components for the active route.

rust/cryptonote/src/views/home.rs

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -106,92 +106,94 @@ pub fn Home() -> Element {
106106
};
107107

108108
rsx! {
109-
div {
110-
h1 { "{t.app_title}" }
111-
p { "{t.app_subtitle}" }
109+
section {
110+
fieldset {
112111

113-
div {
114-
h2 { "{t.your_note}" }
112+
label { "{t.password}" }
115113
textarea {
116114
placeholder: "{t.note_placeholder}",
117115
rows: "8",
118116
value: "{note_text}",
119117
oninput: move |evt| note_text.set(evt.value()),
120118
}
121119

122-
h3 { "{t.encryption_options}" }
123-
div {
124-
label {
125-
input {
126-
r#type: "radio",
127-
name: "encryption",
128-
value: "none",
129-
checked: encryption_mode() == "none",
130-
onchange: move |_| encryption_mode.set("none".to_string()),
131-
}
132-
" {t.no_encryption}"
133-
}
134-
label {
135-
input {
136-
r#type: "radio",
137-
name: "encryption",
138-
value: "symmetric",
139-
checked: encryption_mode() == "symmetric",
140-
onchange: move |_| encryption_mode.set("symmetric".to_string()),
141-
}
142-
" {t.password_encryption}"
143-
}
120+
input {
121+
r#type: "radio",
122+
id: "enc_none",
123+
name: "encryption",
124+
value: "none",
125+
checked: encryption_mode() == "none",
126+
onchange: move |_| encryption_mode.set("none".to_string()),
144127
}
128+
label { r#for: "enc_none", "{t.no_encryption}" }
129+
130+
br {}
131+
132+
input {
133+
r#type: "radio",
134+
id: "enc_symmetric",
135+
name: "encryption",
136+
value: "symmetric",
137+
checked: encryption_mode() == "symmetric",
138+
onchange: move |_| encryption_mode.set("symmetric".to_string()),
139+
}
140+
label { r#for: "enc_symmetric", "{t.password_encryption}" }
145141

146142
if encryption_mode() == "symmetric" {
147-
div {
148-
h4 { "{t.cipher}" }
149-
select {
150-
value: "{cipher_type}",
151-
onchange: move |evt| cipher_type.set(evt.value()),
152-
option { value: "chacha20", "ChaCha20-Poly1305" }
153-
option { value: "aes", "AES-256-GCM" }
154-
}
155-
156-
input {
157-
r#type: "password",
158-
placeholder: "{t.password_placeholder}",
159-
value: "{password}",
160-
oninput: move |evt| password.set(evt.value()),
161-
}
143+
144+
label { "{t.cipher}" }
145+
select {
146+
value: "{cipher_type}",
147+
onchange: move |evt| cipher_type.set(evt.value()),
148+
option { value: "chacha20", "ChaCha20-Poly1305" }
149+
option { value: "aes", "AES-256-GCM" }
150+
}
151+
152+
label { "{t.password}" }
153+
input {
154+
r#type: "password",
155+
placeholder: "{t.password_placeholder}",
156+
value: "{password}",
157+
oninput: move |evt| password.set(evt.value()),
162158
}
163159
}
164160

165-
button { onclick: generate_note, "{t.generate_button}" }
161+
br {}
162+
br {}
166163

167-
if let Some(err) = error_message() {
168-
div { "{err}" }
164+
p {
165+
button { onclick: generate_note, "{t.generate_button}" }
166+
167+
if let Some(err) = error_message() {
168+
div { "{err}" }
169+
}
169170
}
170171
}
172+
}
173+
171174

172-
if let Some(url) = generated_url() {
175+
if let Some(url) = generated_url() {
176+
section {
177+
h2 { "{t.share_title}" }
173178
div {
174-
h2 { "{t.share_title}" }
175-
div {
176-
input {
177-
r#type: "text",
178-
readonly: true,
179-
value: "{url}",
180-
onclick: move |_| {
181-
if let Some(window) = web_sys::window() {
182-
let clipboard = window.navigator().clipboard();
183-
let _ = clipboard.write_text(&url);
184-
}
185-
},
186-
}
187-
p { "{t.click_to_copy}" }
179+
input {
180+
r#type: "text",
181+
readonly: true,
182+
value: "{url}",
183+
onclick: move |_| {
184+
if let Some(window) = web_sys::window() {
185+
let clipboard = window.navigator().clipboard();
186+
let _ = clipboard.write_text(&url);
187+
}
188+
},
188189
}
190+
p { "{t.click_to_copy}" }
191+
}
189192

190-
if let Some(svg) = qr_code_svg() {
191-
div {
192-
h3 { "{t.qr_code}" }
193-
div { dangerous_inner_html: "{svg}" }
194-
}
193+
if let Some(svg) = qr_code_svg() {
194+
figure {
195+
h3 { "{t.qr_code}" }
196+
div { dangerous_inner_html: "{svg}" }
195197
}
196198
}
197199
}

rust/cryptonote/src/views/navbar.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ pub fn Navbar() -> Element {
99

1010
rsx! {
1111
nav {
12-
Link { to: Route::Home {}, "🔐 {t.app_title}" }
13-
select {
14-
value: "{language().code()}",
15-
onchange: move |evt| {
16-
language
17-
.set(
18-
match evt.value().as_str() {
19-
"es" => Language::Spanish,
20-
"ru" => Language::Russian,
21-
_ => Language::English,
22-
},
23-
);
24-
},
25-
option { value: "en", "English" }
26-
option { value: "es", "Español" }
27-
option { value: "ru", "Русский" }
12+
label {
13+
input { r#type: "checkbox" }
14+
header {
15+
Link { to: Route::Home {}, "🔐 Cryptonote" }
16+
}
17+
ul {
18+
li { class: if language() == Language::English { "selected" },
19+
a { onclick: move |_| language.set(Language::English), "English" }
20+
}
21+
li { class: if language() == Language::Spanish { "selected" },
22+
a { onclick: move |_| language.set(Language::Spanish), "Español" }
23+
}
24+
li { class: if language() == Language::Russian { "selected" },
25+
a { onclick: move |_| language.set(Language::Russian), "Русский" }
26+
}
27+
}
2828
}
2929
}
3030

rust/cryptonote/src/views/view.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,9 @@ pub fn View() -> Element {
8585
};
8686

8787
rsx! {
88-
div {
89-
h1 { "Cryptonote" }
90-
91-
if is_encrypted() {
92-
div {
88+
main {
89+
if is_encrypted() {
90+
section {
9391
h2 { "{t.encrypted_note}" }
9492
p { "{t.encrypted_note_desc}" }
9593

@@ -145,24 +143,25 @@ pub fn View() -> Element {
145143
}
146144
}
147145
} else if let Some(content) = note_content() {
148-
div {
146+
article {
149147
h2 { "{t.your_note_title}" }
150148
div {
151149
pre { "{content}" }
152150
}
153151
a { href: "/", "Create a new note" }
154152
}
155153
} else if let Some(err) = error_message() {
156-
div {
154+
section {
157155
h2 { "{t.error_title}" }
158156
p { "{err}" }
159157
a { href: "/", "Create a new note" }
160158
}
161159
} else {
162-
div {
160+
section {
163161
p { "{t.loading}" }
164162
}
165163
}
166-
}
164+
}
165+
167166
}
168167
}

0 commit comments

Comments
 (0)