Skip to content

Commit

Permalink
Finished theming screen : background selection (with randomization op…
Browse files Browse the repository at this point in the history
…tion), fixes, and dependencies update
  • Loading branch information
Litarvan committed Nov 16, 2019
1 parent 454d000 commit e92bab1
Show file tree
Hide file tree
Showing 15 changed files with 2,188 additions and 1,774 deletions.
5 changes: 1 addition & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
module.exports = {
presets: [
'@vue/app'
],
plugins: [
'@babel/plugin-proposal-do-expressions'
]
};
};
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

echo Building LightDM Webkit theme Litarvan v$(cat version)...
echo
Expand Down
3,683 changes: 1,970 additions & 1,713 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
"build": "vue-cli-service build"
},
"dependencies": {
"@babel/plugin-proposal-do-expressions": "^7.2.0",
"vue": "^2.6.10",
"vue-router": "^3.0.6"
"vue-router": "^3.1.3"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.5",
"@vue/cli-service": "^3.0.5",
"node-sass": "^4.12.0",
"sass-loader": "^7.1.0",
"@vue/cli-plugin-babel": "^4.0.5",
"@vue/cli-service": "^4.0.5",
"node-sass": "^4.13.0",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.10"
},
"postcss": {
Expand Down
5 changes: 1 addition & 4 deletions src/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
* Nearly all theme colors
*/

$background-image: url(../assets/images/background.png);

$secondary-color: white;
$primary-color: #249cea;
$error-color: #de3c2d;
$password-field-background: rgba(255, 255, 255, 0.2);
$password-field-caret: rgba($password-field-background, 0.6);
$password-field-background-setup: rgba($password-field-background, 0.3); // Background on setup screen

$outer-background: black;
$outer-foreground: white; // Text color mostly
$outer-foreground: white; // Text color mostly
7 changes: 0 additions & 7 deletions src/components/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
</script>

<style lang="scss">
@import '../theme';
.checkbox {
border: solid 2px;
border-radius: 2px;
Expand All @@ -53,9 +51,4 @@
.checkbox:hover {
cursor: pointer;
}
.checkbox.checked {
border-color: $primary-color;
background: $primary-color;
}
</style>
6 changes: 0 additions & 6 deletions src/components/PowerButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
methods: {
apply() {
if (this.type === 'back') {
this.$router.push(settings.disableSplash || !settings.first ? '/base/login' : '/base/splash');
if (settings.first) {
settings.first = false;
}
return;
}
Expand Down
14 changes: 13 additions & 1 deletion src/lightdm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ const DEBUG_PASSWORD = 'test';
window.lightdm_debug = window.lightdm === undefined;

if (window.lightdm_debug) {
window.theme_utils = {
dirlist(_) {
return [];
}
};

window.greeter_config = {
branding: {
background_images: 'no where this is live test'
}
};

window.lightdm = {
is_authenticated: false,
authentication_user: undefined,
Expand Down Expand Up @@ -125,4 +137,4 @@ window.authentication_complete = () => {

window.show_message = (text, type) => {
errorCB(text);
};
};
13 changes: 4 additions & 9 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (local === 'undefined') {
local = null;
}

let settings = (local ? JSON.parse(local) : null) || {
export let settings = (local ? JSON.parse(local) : null) || {
first: true,

mode: 'classic',
Expand All @@ -17,6 +17,7 @@ let settings = (local ? JSON.parse(local) : null) || {
disableAvatar: false,
disableZoom: false,
clock12: false,
randomizeBG: false,

user: lightdm.users[0],
desktop: lightdm.sessions[0]
Expand All @@ -28,11 +29,11 @@ lightdm.sessions.forEach(s => settings.desktop.username === s.key && (settings.d

save();

function save(s) {
export function save(s) {
localStorage.setItem('settings', JSON.stringify(s ? settings = s : settings));
}

function avatar(avatar) {
export function avatar(avatar) {
if (!avatar || avatar === '') {
return require('./assets/images/default_user.png');
}
Expand All @@ -43,9 +44,3 @@ function avatar(avatar) {

return avatar;
}

export {
settings,
avatar,
save
}
48 changes: 45 additions & 3 deletions src/themer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export const DEFAULT = '#249cea';
export let color = localStorage.getItem('color') || DEFAULT;
import { settings } from './settings';

export const DEFAULT_COLOR = '#249cea';
const DEFAULT_BG = require('./assets/images/background.png');

export let color = localStorage.getItem('color') || DEFAULT_COLOR;
export let background = getBackground();

export function hook(element, rules) {
const style = element.style;
Expand All @@ -9,7 +14,44 @@ export function hook(element, rules) {
}
}

export function update(hex) {
export function updateColor(hex) {
color = hex;
localStorage.setItem('color', color);
}

export function updateBG(bg) {
background = bg;
localStorage.setItem('background', bg);
}

export function backgrounds() {
let result = [];

const recDirlist = dir => {
let result = [];
for (const file of theme_utils.dirlist(dir)) {
if (!file.includes('.')) { // I didn't find any good ways to do it
result = [...result, ...recDirlist(file)];
} else {
result.push(file);
}
}

return result;
};

for (const bg of recDirlist(greeter_config.branding.background_images)) {
result.push('file://' + bg);
}

return [DEFAULT_BG, ...result];
}

function getBackground() {
if(settings.randomizeBG) {
const bgs = backgrounds();
return bgs[Math.floor(Math.random() * bgs.length)];
}

return localStorage.getItem('background') || DEFAULT_BG;
}
17 changes: 14 additions & 3 deletions src/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const translations = {
restart: 'Rebooting...',

setup: 'Setup',
theming: 'Theming',
disableSplash: 'Disable splash ("Press Enter" screen)',
disableSplashText: 'Disable splash text (clock only)',
disableIntro: 'Disable intro (OS logo)',
Expand All @@ -19,7 +20,9 @@ const translations = {
clock12: '12-hours clock format',
capsLock: 'Caps lock is enabled',

primaryColor: 'Primary color'
primaryColor: 'Primary color',
randomizeBG: 'Select a random one each time',
bgAdd: 'Backgrounds can be added in:'
},

// French
Expand All @@ -31,6 +34,7 @@ const translations = {
restart: 'Redémarrage...',

setup: 'Réglages',
theming: 'Personnalisation',
disableSplash: 'Désactiver le splash (écran "Appuyez sur entrer")',
disableSplashText: 'Désactiver le texte du splash (seulement l\'horloge)',
disableIntro: 'Désactiver l\'introduction (logo de l\'OS)',
Expand All @@ -41,7 +45,9 @@ const translations = {
clock12: 'Format 12 heures de l\'horloge',
capsLock: 'Verrouillage des majuscules activé',

primaryColor: 'Couleur principale'
primaryColor: 'Couleur principale',
randomizeBG: 'En choisir un au hasard à chaque fois',
bgAdd: 'Des fonds peuvent être ajoutés dans :'
},

// Dutch (TODO)
Expand Down Expand Up @@ -111,7 +117,12 @@ function getLocale()

function trans(key)
{
const result = translations[getLocale().substring(0, 2)][key];
let lang = translations[getLocale().substring(0, 2)];
if (!lang) {
lang = translations['en'];
}

const result = lang[key];

if (!result) {
return translations.en[key];
Expand Down
12 changes: 10 additions & 2 deletions src/views/Base.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="base">
<div class="bg" :class="{ blured: isBlured() }">
<div class="bg" :class="{ blured: isBlured() }" :style="{ 'background-image': 'url(' + background + ')' }">
</div>

<transition name="fade">
Expand All @@ -10,9 +10,16 @@
</template>

<script>
import { background } from '../themer';
export default {
name: 'l-base',
data() {
return {
background
};
},
methods: {
isBlured() {
let name = this.$router.currentRoute.name;
Expand All @@ -26,7 +33,6 @@
@import '../theme';
.bg {
background-image: $background-image;
background-size: cover;
position: fixed;
left: 0;
Expand All @@ -37,6 +43,8 @@
height: 100vh;
z-index: -1;
filter: blur(0px);
transition: filter 500ms ease-in-out;
color: $secondary-color;
Expand Down
6 changes: 6 additions & 0 deletions src/views/Setup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
name: 'setup',
components: { PowerButton, Login, Checkbox },
mounted() {
if (settings.first) {
settings.first = false;
save();
}
},
data() {
return {
settings: settings,
Expand Down
Loading

0 comments on commit e92bab1

Please sign in to comment.