Moving to new theme

This commit is contained in:
Fabian 2019-06-18 22:55:04 +02:00
parent 560828f4a2
commit 0b56f9b1a8
21 changed files with 268 additions and 462 deletions

367
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@hibas123/secure-file-wrapper": "^2.5.0", "@hibas123/secure-file-wrapper": "^2.5.0",
"@hibas123/theme": "^1.0.0",
"@hibas123/utils": "^2.1.0", "@hibas123/utils": "^2.1.0",
"aes-js": "^3.1.2", "aes-js": "^3.1.2",
"feather-icons": "^4.21.0", "feather-icons": "^4.21.0",
@ -41,6 +42,7 @@
"node-sass": "^4.12.0", "node-sass": "^4.12.0",
"preact": "^8.3.1", "preact": "^8.3.1",
"preact-svg-loader": "^0.2.1", "preact-svg-loader": "^0.2.1",
"raw-loader": "^3.0.0",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"style-loader": "^0.23.1", "style-loader": "^0.23.1",
"ts-loader": "^6.0.2", "ts-loader": "^6.0.2",

View File

@ -3,8 +3,8 @@ import "./add_button.scss";
import Plus from "feather-icons/dist/icons/plus.svg"; import Plus from "feather-icons/dist/icons/plus.svg";
export default function AddButton({ onClick }: { onClick: () => void }) { export default function AddButton({ onClick }: { onClick: () => void }) {
return <button return <button
title={"add button"} title="add button"
class="add-button-button uk-button-primary uk-border-circle def-shadow" class="fab btn-primary"
onClick={() => onClick()} onClick={() => onClick()}
> >
<Plus width={undefined} height={undefined} /> <Plus width={undefined} height={undefined} />

View File

@ -56,7 +56,7 @@ export class Footer extends Component<{}, { synced: boolean, syncing: boolean }>
text = "not synced"; text = "not synced";
} }
} }
return <footer class="uk-background-default def-shadow"> return <footer class="elv-8">
<span> <span>
<span class={extrac} ><a onClick={() => this.onSyncClick()} ><Refresh style="height: 1em; width: 1em;"></Refresh></a></span> <span class={extrac} ><a onClick={() => this.onSyncClick()} ><Refresh style="height: 1em; width: 1em;"></Refresh></a></span>
<span style={"margin-left: 8px; color:" + color}>{text}</span> <span style={"margin-left: 8px; color:" + color}>{text}</span>

View File

@ -26,7 +26,7 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
render() { render() {
let overlay; let overlay;
if (this.state.next) { if (this.state.next) {
overlay = <div class="transition_container transition_slidein uk-background-default" key={this.state.next.key} ref={(elm: HTMLDivElement) => { overlay = <div class="transition_container transition_slidein background-default" key={this.state.next.key} ref={(elm: HTMLDivElement) => {
let lst = () => { let lst = () => {
if (this.state.next) if (this.state.next)
this.setState({ current: this.state.next, next: undefined }, () => { this.setState({ current: this.state.next, next: undefined }, () => {
@ -43,7 +43,7 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
</div> </div>
} }
return <div style="position: relative; overflow-x: hidden; width: 100vw; height: calc(100vh - 2rem);"> return <div style="position: relative; overflow-x: hidden; width: 100vw; height: calc(100vh - 2rem);">
<div class="transition_container uk-background-default" key={this.state.current.key} ref={elm => this.mounted = elm}> <div class="transition_container background-default" key={this.state.current.key} ref={elm => this.mounted = elm}>
{this.state.current} {this.state.current}
</div> </div>
{overlay} {overlay}

View File

@ -27,27 +27,24 @@ export class InputModal extends Modal<string> {
render() { render() {
return <Modal.BaseModal modal={this.props.modal}> return <Modal.BaseModal modal={this.props.modal}>
<div class="uk-form-horizontal uk-margin-large"> <div>
<div class="uk-margin"> <div class="input-group">
<label class="uk-form-label" for={this.rand}>{this.props.modal.fieldname}</label> <label for={this.rand}>{this.props.modal.fieldname}</label>
<div class="uk-form-controls"> <input
<input id={this.rand}
class="uk-input" type={this.props.modal.type}
id={this.rand} placeholder={this.props.modal.fieldname}
type={this.props.modal.type} autofocus
placeholder={this.props.modal.fieldname} ref={elm => { this.input = elm; }}
autofocus onKeyDown={evt => {
ref={elm => { this.input = elm; }} if (evt.keyCode === 13) {
onKeyDown={evt => { this.props.modal.result(this.input.value)
if (evt.keyCode === 13) { }
this.props.modal.result(this.input.value) }}
} />
}}
/>
</div>
</div> </div>
<div class="uk-margin" style="text-align: right;"> <div class="modal-action">
<button class="uk-button uk-button-primary" style="display: inline-block;" onClick={() => { <button class="btn btn-primary" onClick={() => {
this.props.modal.result(this.input.value); this.props.modal.result(this.input.value);
}}>Enter</button> }}>Enter</button>
</div> </div>

View File

@ -12,7 +12,7 @@ export default class LoadingModal extends Modal<undefined> {
getComponent() { getComponent() {
return <Modal.BaseModal modal={this}> return <Modal.BaseModal modal={this}>
<div style="display: flex; justify-content: center;"> <div style="display: flex; justify-content: center;">
<div style="margin: 3rem;" class="uk-spinner uk-icon"> <div style="margin: 3rem;" class="">
<svg width="90" height="90" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg" data-svg="spinner"><circle fill="none" stroke="#000" cx="15" cy="15" r="14" style="stroke-width: 0.333333px;"></circle></svg> <svg width="90" height="90" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg" data-svg="spinner"><circle fill="none" stroke="#000" cx="15" cy="15" r="14" style="stroke-width: 0.333333px;"></circle></svg>
</div> </div>
</div> </div>

View File

@ -65,8 +65,8 @@ export default abstract class Modal<T> {
this.props.modal.result(null) this.props.modal.result(null)
} }
}}> }}>
<div id="ModalContent" class="uk-card uk-card-body uk-card-body modal-body" > <div id="ModalContent" class="modal" >
<div class="modal-title uk-card-title" style=""> <div class="modal-title" style="">
<h3>{this.props.modal.title}</h3> <h3>{this.props.modal.title}</h3>
{/* <div> */} {/* <div> */}
{!this.props.modal.noClose ? {!this.props.modal.noClose ?

View File

@ -28,15 +28,13 @@ export class YesNoModal extends Modal<boolean> {
render() { render() {
return <Modal.BaseModal modal={this.props.modal}> return <Modal.BaseModal modal={this.props.modal}>
<div class="uk-margin-large"> <div class="modal-action">
<div style="text-align: right;"> <button class="btn-primary" onClick={() => {
<button class="uk-button uk-button-primary uk-margin-right" style="display: inline-block;" onClick={() => { this.props.modal.result(false);
this.props.modal.result(false); }}><span style="text-decoration: underline;">N</span>o</button>
}}><span style="text-decoration: underline;">N</span>o</button> <button class="btn-primary" onClick={() => {
<button class="uk-button uk-button-primary" style="display: inline-block;" onClick={() => { this.props.modal.result(true);
this.props.modal.result(true); }}><span style="text-decoration: underline;">Y</span>es</button>
}}><span style="text-decoration: underline;">Y</span>es</button>
</div>
</div> </div>
</Modal.BaseModal> </Modal.BaseModal>
} }

View File

@ -19,17 +19,6 @@
} }
} }
.modal-container>.uk-card {
position: absolute;
left: 0;
right: 0;
top: 10%;
width: 80%;
max-width: 800px;
margin: auto;
background: white;
}
.modal-title { .modal-title {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -37,18 +26,4 @@
>svg { >svg {
height: 1em; height: 1em;
} }
}
.modal-body {
animation: growModalBox .2s linear;
}
@keyframes growModalBox {
from {
transform: scale(0);
}
to {
transform: scale(1);
}
} }

View File

@ -0,0 +1,24 @@
import { h } from "preact";
import { Page } from "../../../page";
import Theme from "../../../theme";
import Navigation from "../../../navigation";
import ArrowLeft from "feather-icons/dist/icons/arrow-left.svg";
export default class SettingsPage extends Page<{ state: any }, { vault: string }> {
componentWillMount() {
}
render() {
return <div>
<header class="header">
<a class="header-icon-button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a>
<h3 style="display:inline" class="header-title" onClick={() => Navigation.setPage("/")}>Settings</h3>
<span></span>
</header>
<div class="container">
<button class="btn" onClick={() => Theme.toggle()}>Toggle Dark Mode</button>
</div>
</div >;
}
}

View File

@ -165,17 +165,17 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
console.log("Rerender") console.log("Rerender")
return <div> return <div>
<header class="uk-background-primary"> <header class="header">
<a class="header-icon-button" onClick={() => this.exitHandler()}><X height={undefined} width={undefined} /></a> <a class="header-icon-button" onClick={() => this.exitHandler()}><X height={undefined} width={undefined} /></a>
{this.state.changed ? <a class="header-icon-button" style="margin-left: 0.5em;" onClick={() => save_handler()}><Save height={undefined} width={undefined} /></a> : undefined} {this.state.changed ? <a class="header-icon-button" style="margin-left: 0.5em;" onClick={() => save_handler()}><Save height={undefined} width={undefined} /></a> : undefined}
<h3 style="display:inline" class="button header-title">{this.state.title}</h3> <h3 style="display:inline" class="button header-title">{this.state.title}</h3>
<a class="header-icon-button" onClick={() => delete_handler()}><Trash height={undefined} width={undefined} /></a> <a class="header-icon-button" onClick={() => delete_handler()}><Trash height={undefined} width={undefined} /></a>
</header> </header>
<div class="uk-container"> <div class="container">
<textarea <textarea
value={this.text} value={this.text}
rows={this.rows} rows={this.rows}
class="doc uk-textarea" class="inp"
style="width:100%;" style="width:100%;"
onInput={this.textAreaChange} onInput={this.textAreaChange}
onKeyDown={this.textAreaKeyPress} onKeyDown={this.textAreaKeyPress}

View File

@ -107,15 +107,15 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
let share; let share;
if ((window.navigator as any).share) { if ((window.navigator as any).share) {
share = <button class="uk-button" onClick={shareNote}> share = <button class="btn" onClick={shareNote}>
share share
</button> </button>
} }
let context = <ContextMenu event={evt} > let context = <ContextMenu event={evt} >
{share} {share}
<button class="uk-button" onClick={deleteNote}>delete</button> <button class="btn" onClick={deleteNote}>delete</button>
<button class="uk-button" onClick={copyNote}>copy</button> <button class="btn" onClick={copyNote}>copy</button>
</ContextMenu> </ContextMenu>
this.setState({ context }); this.setState({ context });
@ -265,28 +265,28 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
return <div> return <div>
{this.state.context} {this.state.context}
<header class="uk-background-primary"> <header class="header">
<a class="header-icon-button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a> <a class="header-icon-button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a>
<h3 style="display:inline" class="header-title" onClick={() => Navigation.setPage("/")}>{this.vault ? this.vault.name : ""}</h3> <h3 style="display:inline" class="header-title" onClick={() => Navigation.setPage("/")}>{this.vault ? this.vault.name : ""}</h3>
<span></span> <span></span>
{/* <a class="button header_icon_button"><MoreVertival height={undefined} width={undefined} /></a> */} {/* <a class="button header_icon_button"><MoreVertival height={undefined} width={undefined} /></a> */}
</header> </header>
<AddButton onClick={() => open_entry(null)} /> <AddButton onClick={() => open_entry(null)} />
<div class="uk-container"> <div class="container">
<div style="display:flex;"> <div style="display:flex;">
<input class="uk-input" type="text" onKeyUp={this.searchChanged} ref={elm => this.searchInput = elm} /> <input class="inp" type="text" style="width: 100%; height: 40px;" onKeyUp={this.searchChanged} ref={elm => this.searchInput = elm} />
<button class="uk-button uk-button-primary" style="padding: 0 10px;"> <button class="btn btn-primary" style="padding: 5px 10px; margin: 0; height: 40px; width: 40px;">
<Search /> <Search />
</button> </button>
</div> </div>
<div class="uk-child-width-1-3@m uk-grid-small uk-grid-match" style="margin-top: 1rem;" uk-grid> <div class="vault-list" style="margin-top: 1rem;">
{this.state.notes.map(note => { {this.state.notes.map(note => {
let [first, second] = note.preview.split("\n", 2); let [first, second] = note.preview.split("\n", 2);
return <div class="" onContextMenu={evt => this.onContext(evt, note)} onClick={() => { return <div class="" onContextMenu={evt => this.onContext(evt, note)} onClick={() => {
open_entry(note._id) open_entry(note._id)
}}> }}>
<div class="uk-card uk-card-default uk-card-body vault-vault" style="box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3)"> <div class="card vault-vault">
<div>{first}</div> <div>{first}</div>
<div>{second}</div> <div>{second}</div>
</div> </div>

View File

@ -1,13 +1,22 @@
.uk-container> :last-child { .container> :last-child {
margin-bottom: 15px !important; margin-bottom: 15px !important;
} }
.vault-list {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 1rem;
grid-auto-rows: auto;
}
// TODO Media Query for small screens
.vault-vault { .vault-vault {
width: 100%; width: 100%;
>div { >div {
width: 100%; width: 100%;
font-size: 1rem; font-size: 1.1rem;
margin-left: 1rem; margin-left: 1rem;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
@ -25,22 +34,4 @@
white-space: pre; white-space: pre;
} }
} }
} }
// .vault_vault {
// padding: 0.5rem;
// border-bottom: solid 1px var(--card-border-color);
// }
// .vault_vault:hover {
// background: var(--nav-hover-back-color);
// }
// .vault_vault>svg {
// height: 2rem;
// margin-right: 1rem;
// }
// .vault_vault:last-child {
// border-bottom: none;
// }

View File

@ -4,6 +4,7 @@ import Notes, { VaultList } from "../../../notes";
import "./vaults.scss" import "./vaults.scss"
import Lock from "feather-icons/dist/icons/lock.svg"; import Lock from "feather-icons/dist/icons/lock.svg";
import Unlock from "feather-icons/dist/icons/unlock.svg"; import Unlock from "feather-icons/dist/icons/unlock.svg";
import Settings from "feather-icons/dist/icons/settings.svg"
import Navigation from "../../../navigation"; import Navigation from "../../../navigation";
import { InputModal } from "../../modals/InputModal"; import { InputModal } from "../../modals/InputModal";
import { YesNoModal } from "../../modals/YesNoModal"; import { YesNoModal } from "../../modals/YesNoModal";
@ -135,7 +136,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
} }
document.documentElement.addEventListener("click", close); document.documentElement.addEventListener("click", close);
let deleteb = <button class="uk-button" onClick={async () => { let deleteb = <button class="btn" onClick={async () => {
let delete_modal = new YesNoModal("Delete Vault? Cannot be undone!"); let delete_modal = new YesNoModal("Delete Vault? Cannot be undone!");
let result = await delete_modal.getResult(); let result = await delete_modal.getResult();
if (result) { if (result) {
@ -152,7 +153,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
let delete_key; let delete_key;
if (Notes.getVaultKey(vault.id)) { if (Notes.getVaultKey(vault.id)) {
delete_key = <button class="uk-button" onClick={() => { delete_key = <button class="btn" onClick={() => {
Notes.forgetVaultKey(vault.id); Notes.forgetVaultKey(vault.id);
Notifications.sendSuccess("Forgot password!") Notifications.sendSuccess("Forgot password!")
}}> }}>
@ -160,7 +161,7 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
</button>; </button>;
} }
let exportb = <button class="uk-button" onClick={async () => { let exportb = <button class="btn" onClick={async () => {
let key: Uint8Array; let key: Uint8Array;
if (vault.encrypted) { if (vault.encrypted) {
await this.getKey(vault, false) await this.getKey(vault, false)
@ -217,14 +218,14 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
return <div style={{ marginTop: "-12px", paddingTop: "12px" }} > return <div style={{ marginTop: "-12px", paddingTop: "12px" }} >
{/* {this.state.modal} */} {/* {this.state.modal} */}
{this.state.context} {this.state.context}
<header class="uk-background-primary"> <header class="header">
<span></span> <span></span>
<h3 style="display:inline" onClick={() => Navigation.setPage("/")}>{this.props.selectVault ? "Select Vault for share" : "Your vaults:"}</h3> <h3 style="display:inline" onClick={() => Navigation.setPage("/")}>{this.props.selectVault ? "Select Vault for share" : "Your vaults:"}</h3>
<span></span> <a class="header-icon-button" onClick={() => Navigation.setPage("/settings")}><Settings height={undefined} width={undefined} /></a>
</header> </header>
<AddButton onClick={() => this.addButtonClick()} /> <AddButton onClick={() => this.addButtonClick()} />
<div class="uk-container"> <div class="container">
<ul class="uk-list uk-list-divider"> <ul class="list list-divider list-clickable">
{elms} {elms}
</ul> </ul>
</div> </div>

View File

@ -1,23 +1,19 @@
@import "../../../vars.scss";
.vaults_vault { .vaults_vault {
display: flex;
padding: 0.5rem; padding: 0.5rem;
margin-top: 0 !important; margin-top: 0 !important;
align-items: flex-end;
justify-content: end;
// >span { >span {
// font-size: 2rem !important; font-size: 1.5rem;
// } line-height: 1.5rem;
}
// &:not(:last-child) {
// border-bottom: 1px $border_color solid;
// }
>svg { >svg {
height: 2rem; display: inline-block;
height: 1.5em;
width: 1.5em;
margin-right: 1rem; margin-right: 1rem;
} }
&:hover {
background: $hover-background;
}
} }

View File

@ -1,65 +1,53 @@
@import "./vars.scss"; @import "./vars.scss";
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body { // html {
font-family: 'Roboto', sans-serif; // font-family: Verdana, Geneva, sans-serif; // min-height: 100%;
font-size: 18px; // display: flex;
width: 100%; // }
height: 100%;
}
html { // $header-margin: .5em;
min-height: 100%; // $header-icon-size: calc(1.5rem * 1);
display: flex;
}
$header-margin: .5em;
$header-icon-size: calc(1.5rem * 1);
// $header-icon-size: 100%; // $header-icon-size: 100%;
header { // header {
display: flex; // display: flex;
justify-content: space-between; // justify-content: space-between;
margin-bottom: $header-margin; // margin-bottom: $header-margin;
align-content: center; // align-content: center;
padding: 0.75em; // padding: 0.75em;
border-bottom: solid var(--border-color) 1px; // border-bottom: solid var(--border-color) 1px;
background-color: var(--primary); // background-color: var(--primary);
>* { // >* {
margin: 0; // margin: 0;
color: white; // color: white;
background: var(--primary); // background: var(--primary);
} // }
>.header-title { // >.header-title {
overflow: hidden; // overflow: hidden;
text-overflow: ellipsis; // text-overflow: ellipsis;
text-overflow: ellipsis; // text-overflow: ellipsis;
white-space: nowrap; // white-space: nowrap;
overflow: hidden; // overflow: hidden;
flex-grow: 1; // flex-grow: 1;
margin: 0 1em; // margin: 0 1em;
} // }
.header-icon-button { // .header-icon-button {
display: block; // display: block;
margin-top: auto; // margin-top: auto;
margin-bottom: auto; // margin-bottom: auto;
min-width: $header-icon-size; // min-width: $header-icon-size;
>svg { // >svg {
height: $header-icon-size; // height: $header-icon-size;
width: $header-icon-size; // width: $header-icon-size;
} // }
} // }
} // }
.def-shadow { .def-shadow {
box-shadow: 0px 5px 8px 2px rgba(66, 66, 66, 0.53); box-shadow: 0px 5px 8px 2px rgba(66, 66, 66, 0.53);

View File

@ -64,8 +64,11 @@ import { h, render } from 'preact';
import App from './components/App'; import App from './components/App';
import "uikit"; // import "uikit";
import "uikit/dist/css/uikit.css" // import "uikit/dist/css/uikit.css"
import "@hibas123/theme/out/base.css"
// import "@hibas123/theme/out/light.css"
// import "@hibas123/theme/out/dark.css"
import "./index.scss"; import "./index.scss";
import Navigation from './navigation'; import Navigation from './navigation';
@ -78,8 +81,14 @@ import VaultPage from './components/routes/vault/Vault';
import SharePage from './components/routes/share/Share'; import SharePage from './components/routes/share/Share';
import Notifications from './notifications'; import Notifications from './notifications';
import Error404Page from './components/routes/404'; import Error404Page from './components/routes/404';
import SettingsPage from './components/routes/settings/Settings';
window.debug.notes = Notes; window.debug.notes = Notes;
import Theme from "./theme";
console.log("Dark mode:", Theme.active);
(async () => { (async () => {
// Initialize notes provider // Initialize notes provider
if (Notes.loginRequired()) { if (Notes.loginRequired()) {
@ -105,6 +114,7 @@ window.debug.notes = Notes;
Navigation.addPage("/vault", VaultPage as typeof Page) Navigation.addPage("/vault", VaultPage as typeof Page)
Navigation.addPage("/demo", DemoPage as typeof Page) Navigation.addPage("/demo", DemoPage as typeof Page)
Navigation.addPage("/share", SharePage as typeof Page) Navigation.addPage("/share", SharePage as typeof Page)
Navigation.addPage("/settings", SettingsPage as typeof Page)
Navigation.addPage("/404", Error404Page); Navigation.addPage("/404", Error404Page);
const trad = window.location.pathname; const trad = window.location.pathname;
if (trad && trad !== "/" && trad !== "") { if (trad && trad !== "/" && trad !== "") {

27
src/theme.ts Normal file
View File

@ -0,0 +1,27 @@
const light = require("!!raw-loader!@hibas123/theme/out/light.css").default;
const dark = require("!!raw-loader!@hibas123/theme/out/dark.css").default;
let isDark = localStorage.getItem("theme") === "dark";
let styleElm: HTMLStyleElement;
function apply() {
if (styleElm) styleElm.remove();
styleElm = document.createElement("style");
document.head.appendChild(styleElm);
styleElm.innerHTML = isDark ? dark : light;
}
apply();
function toggle() {
isDark = !isDark;
localStorage.setItem("theme", isDark ? "dark" : "light");
apply();
}
export default {
active: () => isDark,
toggle: () => toggle()
}

View File

@ -1,21 +1,9 @@
:root { :root {
--primary: #1E88E5; --primary: #1E88E5;
--on-primary: white;
// --mdc-theme-primary: var(--primary); // --mdc-theme-primary: var(--primary);
// --mdc-theme-primary-bg: var(--mdc-theme--primary); // --mdc-theme-primary-bg: var(--mdc-theme--primary);
// --mdc-theme-on-primary: white; // --mdc-theme-on-primary: white;
--error: #ff2f00; --error: #ff2f00;
--border-color: #ababab; --border-color: #ababab;
--default-font-size: 1.05rem; }
}
.uk-button-primary {
background: var(--primary) !important;
color: white;
}
.uk-background-primary {
background: var(--primary) !important;
color: white;
}
$hover-background: #DDDDDD;