Skip to content

Commit

Permalink
Add prettier-plugin-svelte and format everything
Browse files Browse the repository at this point in the history
  • Loading branch information
dar5hak committed Nov 22, 2024
1 parent a22732e commit a3f586a
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and publish to GitHub Pages

on:
push:
branches: [ main ]
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
15 changes: 9 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel='preconnect' href='https://fonts.gstatic.com'>
<link rel='preload' href='/icons/remixicon.woff2?t=1607859683539'>
<link rel='stylesheet' href='/global.css'>
<link rel='stylesheet' href='/icons/remixicon.css'>
<link href='https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap' rel='stylesheet'>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="preload" href="/icons/remixicon.woff2?t=1607859683539" />
<link rel="stylesheet" href="/global.css" />
<link rel="stylesheet" href="/icons/remixicon.css" />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap"
rel="stylesheet"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Obliviate</title>
</head>
Expand Down
4 changes: 4 additions & 0 deletions src/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
144 changes: 77 additions & 67 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@
cipher,
site.toLowerCase(),
10000,
16
16,
);
const indices = new Uint8Array(derivedBuffer).map(
(byte) => byte % allowedCharacters.length
(byte) => byte % allowedCharacters.length,
);
derivedPassword = Array.from(indices)
Expand All @@ -133,63 +133,20 @@
}
function handleCopyWithoutSymbols() {
copy(derivedPassword.replaceAll(/[^0-9a-z]/ig, ""));
copy(derivedPassword.replaceAll(/[^0-9a-z]/gi, ""));
copyWithoutSymbolsText = "Copied!";
setTimeout(() => {
copyWithoutSymbolsText = "Copy without symbols";
}, 1000);
}
</script>

<style>
main {
display: grid;
grid-template-columns:
minmax(1.2rem, 1fr)
minmax(auto, 24rem)
minmax(1.2rem, 1fr);
grid-template-rows: auto 1fr auto;
}
article {
grid-column: 2;
display: grid;
grid-template-columns: 5rem auto 2rem;
column-gap: 0.5rem;
align-items: center;
}
label {
grid-column: 1;
justify-self: end;
text-align: right;
}
input,
button:not(.toggle):not(.info) {
grid-column: 2;
}
button.toggle,
button.info {
grid-column: 3;
}
.derived {
background: transparent;
border: none;
color: var(--fg-color);
margin: 0;
padding-left: 0;
font-weight: bold;
}
</style>

<main>
<Header
on:info={() => {
showInfoModal = true;
}} />
}}
/>

<article>
<label for="site">Site:</label>
Expand All @@ -199,64 +156,72 @@
id="site"
placeholder="GitHub"
bind:value={site}
oninput={handleDerive} />
oninput={handleDerive}
/>

<button class="info" tabindex="-1">
<i
class="ri-information-line"
title="Site is not case-sensitive. “GitHub” equals “github”."
aria-label="Site is not case-sensitive. “GitHub” equals “github”."></i>
aria-label="Site is not case-sensitive. “GitHub” equals “github”."
></i>
</button>

<label for="cipher">Cipher key:</label>

<!-- Svelte won't allow bind:value when type is dynamic. -->
<input
type={showCipher ? 'text' : 'password'}
type={showCipher ? "text" : "password"}
id="cipher"
placeholder="correct horse battery staple"
value={cipher}
oninput={(e) => {
cipher = e.target.value;
handleDerive();
}} />
}}
/>

<button
class="toggle"
disabled={!cipher}
onclick={() => (showCipher = !showCipher)}>
onclick={() => (showCipher = !showCipher)}
>
<i
class={showCipher ? 'ri-eye-line' : 'ri-eye-off-line'}
class={showCipher ? "ri-eye-line" : "ri-eye-off-line"}
title="Show/hide cipher key"
aria-label="Show/hide cipher key"></i>
aria-label="Show/hide cipher key"
></i>
</button>

<label for="derived-password">Password:</label>

<input
disabled
type={showDerivedPassword ? 'text' : 'password'}
type={showDerivedPassword ? "text" : "password"}
id="derived-password"
value={derivedPassword}
class="derived" />
class="derived"
/>

<button
class="toggle"
disabled={!derivedPassword}
onclick={() => (showDerivedPassword = !showDerivedPassword)}>
onclick={() => (showDerivedPassword = !showDerivedPassword)}
>
<i
class={showDerivedPassword ? 'ri-eye-line' : 'ri-eye-off-line'}
class={showDerivedPassword ? "ri-eye-line" : "ri-eye-off-line"}
title="Show/hide password"
aria-label="Show/hide password"></i>
aria-label="Show/hide password"
></i>
</button>

<button
disabled={!derivedPassword}
onclick={handleCopy}>{copyButtonText}</button>
<button disabled={!derivedPassword} onclick={handleCopy}
>{copyButtonText}</button
>

<button
disabled={!derivedPassword}
onclick={handleCopyWithoutSymbols}>{copyWithoutSymbolsText}</button>
<button disabled={!derivedPassword} onclick={handleCopyWithoutSymbols}
>{copyWithoutSymbolsText}</button
>
</article>

<Footer />
Expand All @@ -266,4 +231,49 @@
isOpen={showInfoModal}
on:close={() => {
showInfoModal = false;
}} />
}}
/>

<style>
main {
display: grid;
grid-template-columns:
minmax(1.2rem, 1fr)
minmax(auto, 24rem)
minmax(1.2rem, 1fr);
grid-template-rows: auto 1fr auto;
}
article {
grid-column: 2;
display: grid;
grid-template-columns: 5rem auto 2rem;
column-gap: 0.5rem;
align-items: center;
}
label {
grid-column: 1;
justify-self: end;
text-align: right;
}
input,
button:not(.toggle):not(.info) {
grid-column: 2;
}
button.toggle,
button.info {
grid-column: 3;
}
.derived {
background: transparent;
border: none;
color: var(--fg-color);
margin: 0;
padding-left: 0;
font-weight: bold;
}
</style>
30 changes: 16 additions & 14 deletions src/Footer.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<footer>
<p>
<a
href="https://appcenter.elementary.io/com.github.elfenware.obliviate/"
target="_blank"
rel="noopener noreferrer">Linux app</a
>
&middot;
<a
href="https://github.com/elfenware/obliviate-web"
target="_blank"
rel="noopener noreferrer">Source code</a
>
</p>
</footer>

<style>
footer {
grid-column: 2;
Expand All @@ -12,17 +28,3 @@
grid-column: 2;
}
</style>

<footer>
<p>
<a
href="https://appcenter.elementary.io/com.github.elfenware.obliviate/"
target="_blank"
rel="noopener noreferrer">Linux app</a>
&middot;
<a
href="https://github.com/elfenware/obliviate-web"
target="_blank"
rel="noopener noreferrer">Source code</a>
</p>
</footer>
27 changes: 14 additions & 13 deletions src/Header.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
<script>
import { preventDefault } from 'svelte/legacy';
import { preventDefault } from "svelte/legacy";
import { createEventDispatcher } from "svelte";
const dispatch = createEventDispatcher();
</script>

<header>
<h1>Obliviate</h1>
<p class="subtitle">
A password manager that forgets your passwords (<a
href="#info"
onclick={preventDefault(() => {
dispatch("info");
})}>Wut?</a
>)
</p>
<img src="logo.svg" alt="Obliviate logo" width="48" height="48" />
</header>

<style>
header {
grid-column: 2;
Expand Down Expand Up @@ -34,15 +47,3 @@
justify-self: end;
}
</style>

<header>
<h1>Obliviate</h1>
<p class="subtitle">
A password manager that forgets your passwords (<a
href="#info"
onclick={preventDefault(() => {
dispatch('info');
})}>Wut?</a>)
</p>
<img src="logo.svg" alt="Obliviate logo" width="48" height="48" />
</header>
Loading

0 comments on commit a3f586a

Please sign in to comment.