implement theme-system
This commit is contained in:
parent
443ab0b804
commit
5bf9ac9fe6
4 changed files with 53 additions and 2 deletions
2
ui/dist/index.html
vendored
2
ui/dist/index.html
vendored
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<link href='https://fonts.googleapis.com/css?family=Raleway:600,300' rel='stylesheet' type='text/css'>
|
<link href='https://fonts.googleapis.com/css?family=Raleway:600,300' rel='stylesheet' type='text/css'>
|
||||||
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400italic,600italic,600' rel='stylesheet' type='text/css'>
|
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400italic,600italic,600' rel='stylesheet' type='text/css'>
|
||||||
<link href="./css/all.css" rel="stylesheet" type="text/css" media="screen,print" />
|
<link id="theme" href="./css/all.css" rel="stylesheet" type="text/css" media="screen,print" />
|
||||||
<link rel="icon" type="image/png" href="./img/fav/favicon-32x32.png" sizes="32x32">
|
<link rel="icon" type="image/png" href="./img/fav/favicon-32x32.png" sizes="32x32">
|
||||||
<link rel="icon" type="image/png" href="./img/fav/favicon-194x194.png" sizes="194x194">
|
<link rel="icon" type="image/png" href="./img/fav/favicon-194x194.png" sizes="194x194">
|
||||||
<link rel="icon" type="image/png" href="./img/fav/favicon-96x96.png" sizes="96x96">
|
<link rel="icon" type="image/png" href="./img/fav/favicon-96x96.png" sizes="96x96">
|
||||||
|
|
|
@ -19,6 +19,7 @@ let lbry = {
|
||||||
customLighthouseServers: [],
|
customLighthouseServers: [],
|
||||||
showDeveloperMenu: false,
|
showDeveloperMenu: false,
|
||||||
language: "en",
|
language: "en",
|
||||||
|
theme: "light",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,12 @@ import { FormField, FormRow } from "component/form.js";
|
||||||
import SubHeader from "component/subHeader";
|
import SubHeader from "component/subHeader";
|
||||||
import lbry from "lbry.js";
|
import lbry from "lbry.js";
|
||||||
import Link from "component/link";
|
import Link from "component/link";
|
||||||
|
import getThemes from "util/getThemes";
|
||||||
const { remote } = require("electron");
|
const { remote } = require("electron");
|
||||||
|
|
||||||
|
const themes = getThemes();
|
||||||
|
console.log(themes);
|
||||||
|
|
||||||
class SettingsPage extends React.PureComponent {
|
class SettingsPage extends React.PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -18,6 +21,7 @@ class SettingsPage extends React.PureComponent {
|
||||||
showUnavailable: lbry.getClientSetting("showUnavailable"),
|
showUnavailable: lbry.getClientSetting("showUnavailable"),
|
||||||
language: lbry.getClientSetting("language"),
|
language: lbry.getClientSetting("language"),
|
||||||
clearingCache: false,
|
clearingCache: false,
|
||||||
|
theme: lbry.getClientSetting("theme"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +85,13 @@ class SettingsPage extends React.PureComponent {
|
||||||
this.setDaemonSetting("disable_max_key_fee", isDisabled);
|
this.setDaemonSetting("disable_max_key_fee", isDisabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onThemeChange(event) {
|
||||||
|
const value = event.target.value;
|
||||||
|
const link = document.getElementById("theme");
|
||||||
|
link.href = `./themes/${value}.css`;
|
||||||
|
this.props.setClientSetting("theme", value);
|
||||||
|
}
|
||||||
|
|
||||||
// onMaxUploadPrefChange(isLimited) {
|
// onMaxUploadPrefChange(isLimited) {
|
||||||
// if (!isLimited) {
|
// if (!isLimited) {
|
||||||
// this.setDaemonSetting("max_upload", 0.0);
|
// this.setDaemonSetting("max_upload", 0.0);
|
||||||
|
@ -251,6 +262,25 @@ class SettingsPage extends React.PureComponent {
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section className="card">
|
||||||
|
<div className="card__content">
|
||||||
|
<h3>{__("Theme")}</h3>
|
||||||
|
</div>
|
||||||
|
<div className="card__content">
|
||||||
|
<FormField
|
||||||
|
type="select"
|
||||||
|
onChange={this.onThemeChange.bind(this)}
|
||||||
|
defaultValue={"Light"}
|
||||||
|
className="form-field__input--inline"
|
||||||
|
>
|
||||||
|
{themes.map((i, k) =>
|
||||||
|
<option key={k} value={i}>{__(`${i} theme`)}</option>
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section className="card">
|
<section className="card">
|
||||||
<div className="card__content">
|
<div className="card__content">
|
||||||
<h3>{__("Application Cache")}</h3>
|
<h3>{__("Application Cache")}</h3>
|
||||||
|
|
20
ui/js/util/getThemes.js
Normal file
20
ui/js/util/getThemes.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
const { readdirSync } = require("fs");
|
||||||
|
const { extname } = require("path");
|
||||||
|
const { remote } = require("electron");
|
||||||
|
|
||||||
|
function getThemes() {
|
||||||
|
// Themes path
|
||||||
|
const themesPath = `${remote.app.getAppPath()}/dist/themes`;
|
||||||
|
|
||||||
|
// Get all themes / only .css
|
||||||
|
const themes = readdirSync(themesPath).filter(function(file) {
|
||||||
|
return extname(file) === ".css";
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove file extension (css)
|
||||||
|
return themes.map(function(theme) {
|
||||||
|
return theme.replace(".css", "");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default getThemes;
|
Loading…
Reference in a new issue