Skip to content

Commit

Permalink
Rework colors variables to use primary/secondary and make them config…
Browse files Browse the repository at this point in the history
…urable
  • Loading branch information
alimtunc authored and xsyann committed Oct 17, 2022
1 parent 8bee421 commit 26db8ea
Show file tree
Hide file tree
Showing 22 changed files with 132 additions and 44 deletions.
4 changes: 3 additions & 1 deletion app/_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"gods": [],
"production": true,
"staging": false,
"enableLogClient": false
"enableLogClient": false,
"primaryColor": "#A5E6BA",
"secondaryColor": "#13C4A3"
},

"debug": false,
Expand Down
4 changes: 3 additions & 1 deletion app/settings-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"gods": [],
"production": false,
"staging": false,
"enableLogClient": false
"enableLogClient": false,
"primaryColor": "#A5E6BA",
"secondaryColor": "#13C4A3"
},

"debug": false,
Expand Down
33 changes: 28 additions & 5 deletions core/client/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
$primary-color: #E8C97A;
$secondary-color: #3B3A4F;
:root {
--edit-border-size: 1rem;
--edit-border-radius: 1rem;
--primary-color: #A5E6BA;
--secondary-color: #13C4A3;

// We split the HSL (Hue Saturarion Lightness) value to play with th lightness color
// #A5E6BA converted to hsl(139, 57%, 77%);
--primary-color-hs: 139, 57%;
--primary-color-l: 77%;
// #13C4A3 converted to hsl(169, 82%, 82%);
--secondary-color-hs: 169, 82%;
--secondary-color-l: 82%;

// And now if we want our color lighter, we increase the lightness value BUT our value shouldn't be more than 100% or it will be black.
--primary-color-lighten-20: hsl(var(--primary-color-hs), calc(var(--primary-color-l) + 20%));

// Or darker, we decrease the lightness value
--secondary-color-darken-5: hsl(var(--secondary-color-hs), calc(var(--secondary-color-l) - 5%));
--secondary-color-darken-10: hsl(var(--secondary-color-hs), calc(var(--secondary-color-l) - 10%));
--secondary-color-darken-15: hsl(var(--secondary-color-hs), calc(var(--secondary-color-l) - 15%));
--secondary-color-darken-20: hsl(var(--secondary-color-hs), calc(var(--secondary-color-l) - 20%));
}

$text-color: #D17851;
$lem-border: rgba(0, 38, 255, 0.08);
$primary-color-transparent-1: rgba(59, 58, 79, 0.4);
Expand All @@ -12,6 +34,7 @@ $lem-color-6: #3bbc84;
$lem-color-7: #d14e53;
$lem-color-8: #3c3c3c;
$lem-color-9: #1d1d1d;
$lem-color-10: #3B3A4F;

// Shade of grey
$gray100: #f0f7f8;
Expand All @@ -22,14 +45,12 @@ $gray500: #425a65;
$main-color: #201d2c;
$highlight-color: #b18800;
$light-red: #EB584E;
$light-green: #13C4A3;
$light-blue: #4381C1;
$light-yellow: #FFE19C;
$light-orange: #FFBB04;
$main-text-color: #eeebf1;
$radius: 0.5rem;

$new-green: #A5E6BA;
$new-yellow: #E7DFC6;
$new-red: #C73E1D;
$new-dark-primary: #201d2c;
Expand All @@ -46,6 +67,8 @@ $breakpoints: (

@mixin media-max($_key) {
@media screen and (max-width: map-get($breakpoints, $_key)) {
& { @content; }
& {
@content;
}
}
}
48 changes: 45 additions & 3 deletions core/client/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,19 +303,61 @@ const vectorToTextDirection = vector => {
return undefined;
};

const getHslFromHex = H => {
// Convert hex to RGB first
let r = 0; let g = 0; let b = 0;

if (H.length === 4) {
r = `0x${H[1]}${H[1]}`;
g = `0x${H[2]}${H[2]}`;
b = `0x${H[3]}${H[3]}`;
} else if (H.length === 7) {
r = `0x${H[1]}${H[2]}`;
g = `0x${H[3]}${H[4]}`;
b = `0x${H[5]}${H[6]}`;
}
// Then to HSL
r /= 255;
g /= 255;
b /= 255;
const cmin = Math.min(r, g, b);
const cmax = Math.max(r, g, b);
const delta = cmax - cmin;
let h = 0;
let s = 0;
let l = 0;

if (delta === 0) h = 0;
else if (cmax === r) h = ((g - b) / delta) % 6;
else if (cmax === g) h = (b - r) / delta + 2;
else h = (r - g) / delta + 4;

h = Math.round(h * 60);

if (h < 0) h += 360;

l = (cmax + cmin) / 2;
s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
s = +(s * 100).toFixed(1);
l = +(l * 100).toFixed(1);

return { h, s, l };
};

export {
allowPhaserMouseInputs,
canAnswerCall,
clamp,
guestSkin,
formatURLs,
formatURL,
formatURLs,
generateEntityThumbnail,
getHslFromHex,
guestSkin,
meteorCallWithPromise,
nearestDuration,
replaceTextVars,
setReaction,
toggleUIInputs,
textDirectionToVector,
toggleUIInputs,
vectorToTextDirection,
};
21 changes: 20 additions & 1 deletion core/client/lemverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import hotkeys from 'hotkeys-js';
import Phaser from 'phaser';
import audioManager from './audio-manager';
import meetingRoom from './meeting-room';
import { setReaction } from './helpers';
import { setReaction, getHslFromHex } from './helpers';
import { guestAllowed, permissionTypes } from '../lib/misc';
import initSentryClient from './sentry';

Expand Down Expand Up @@ -60,6 +60,23 @@ const extractLevelIdFromURL = () => {
return `lvl_${levelId}`;
};

const initAppColor = () => {
const { primaryColor } = Meteor.settings.public.lp;
const { secondaryColor } = Meteor.settings.public.lp;
const rootStyle = document.querySelector(':root').style;

rootStyle.setProperty('--primary-color', primaryColor);
rootStyle.setProperty('--secondary-color', secondaryColor);

const primaryHSL = getHslFromHex(primaryColor);
const secondaryHSL = getHslFromHex(secondaryColor);

rootStyle.setProperty('--primary-color-hs', `${primaryHSL.h}, ${primaryHSL.s}%`);
rootStyle.setProperty('--primary-color-l', `${primaryHSL.l}%`);
rootStyle.setProperty('--secondary-color-hs', `${secondaryHSL.h}, ${secondaryHSL.s}%`);
rootStyle.setProperty('--secondary-color-l', `${secondaryHSL.l}%`);
};

Template.lemverse.onCreated(function () {
Session.set('editor', 0);
Session.set('sceneWorldReady', false);
Expand All @@ -75,6 +92,8 @@ Template.lemverse.onCreated(function () {
peer.destroy();
});

initAppColor();

const extractedLevelId = extractLevelIdFromURL();
if (extractedLevelId) Meteor.call('teleportUserInLevel', extractedLevelId);

Expand Down
6 changes: 3 additions & 3 deletions core/client/ui/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
}

&.green {
background-color: darken($light-green, 15%);
background-color: var(--secondary-color-darken-15);

&:hover {
background-color: darken($light-green, 5%);
background-color: var(--secondary-color-darken-5);
color: #fff;
}
}
Expand Down Expand Up @@ -85,7 +85,7 @@
outline: none;

&:focus {
border: 1px solid $new-green;
border: 1px solid var(--primary-color);
}

&[type="range"] {
Expand Down
2 changes: 1 addition & 1 deletion core/client/ui/avatar-viewer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $frame-height: 85px;
}

&.online::before {
background-color: $light-green;
background-color: var(--secondary-color);
}

.character-body-part-container {
Expand Down
2 changes: 1 addition & 1 deletion core/client/ui/editor-characters.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
cursor: pointer;

&.selected {
background-color: $light-green;
background-color: var(--secondary-color);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/client/ui/radial-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ $z-index: 4;

&.on {
button {
background-color: $light-green;
background-color: var(--secondary-color);

&:hover {
background-color: darken($light-green, 5%);
background-color: var(--secondary-color-darken-5);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/client/ui/remote-stream.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}

&.talking {
border: 2px solid $light-green;
border: 2px solid var(--secondary-color);
}

&::before {
Expand Down
6 changes: 3 additions & 3 deletions core/client/ui/settings-character.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@
height: 45px;
cursor: pointer;
border-radius: 10px;
border: 1px solid rgba($new-green, 0.5);
border: 1px solid rgba(var(--primary-color), 0.5);

svg {
margin: 0.3rem;
height: 30px;
width: 30px;
fill: $new-green;
fill: var(--primary-color);
}

&:hover,
&.selected {
background-color: $new-green;
background-color: var(--primary-color);

svg {
fill: $new-dark-secondary;
Expand Down
4 changes: 2 additions & 2 deletions core/client/ui/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ div.settings {

&.selected {
button {
background-color: #A5E6BA;
background-color: var(--primary-color);
color: #211d2c;
}

&:hover {
button {
background-color: $new-green;
background-color: var(--primary-color);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/client/ui/team-settings-members.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

.js-selectable {
&.selected {
background-color: rgba($light-green, 0.35);
background-color: rgba(var(--secondary-color), 0.35);

&:hover {
background-color: rgba($light-green, 0.5);
background-color: rgba(var(--secondary-color), 0.5);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/client/ui/toolboxes/edit-toolbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
bottom: 0;
width: 350px;
height: 100%;
background-color: rgba($secondary-color, 0.95);
background-color: rgba($lem-color-10, 0.95);
z-index: 100;
display: flex;
flex-direction: column;
Expand Down
6 changes: 3 additions & 3 deletions core/client/ui/toolboxes/entity-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
transition: margin-left .5s ease;
width: calc(200% - 20px);
height: 20px;
background: linear-gradient(0deg, darken($light-green, 15%) 0%, darken($light-green, 15%) 50%, darken($light-red, 15%) 50%, darken($light-red, 15%) 100%);
background: -webkit-linear-gradient(0deg, darken($light-green, 15%) 0%, darken($light-green, 15%) 50%, darken($light-red, 15%) 50%, darken($light-red, 15%) 100%);
background: -moz-linear-gradient(0deg, darken($light-green, 15%) 0%, darken($light-green, 15%) 50%, darken($light-red, 15%) 50%, #f00 100%);
background: linear-gradient(0deg, var(--secondary-color-darken-15) 0%, var(--secondary-color-darken-15) 50%, darken($light-red, 15%) 50%, darken($light-red, 15%) 100%);
background: -webkit-linear-gradient(0deg, var(--secondary-color-darken-15) 0%, var(--secondary-color-darken-15) 50%, darken($light-red, 15%) 50%, darken($light-red, 15%) 100%);
background: -moz-linear-gradient(0deg, var(--secondary-color-darken-15) 0%, var(--secondary-color-darken-15) 50%, darken($light-red, 15%) 50%, #f00 100%);
border-radius: 10px;

&.off {
Expand Down
4 changes: 2 additions & 2 deletions core/client/ui/user-list-selection.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
}

&.selected {
background-color: rgba($light-green, 0.35);
background-color: rgba(var(--secondary-color), 0.35);

&:hover {
background-color: rgba($light-green, 0.5);
background-color: rgba(var(--secondary-color), 0.5);
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/client/ui/user-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@
}

&.active {
background-color: $new-green;
background-color: var(--primary-color);
}

@media (hover: hover) {
&:hover {
background-color: lighten($new-green, 20%);
background-color: var(--primary-color-lighten-20);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/modules/console/client/console.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ $button-text-color: white;
}

&.has-content {
background-color: darken($light-green, 10%);
background-color: var(--secondary-color-darken-10);
}
}

Expand Down
8 changes: 4 additions & 4 deletions core/modules/messages/client/messages-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
font-weight: bold;

&.js-channel-subscribe {
background-color: $light-green;
background-color: var(--secondary-color);

&:hover {
background-color: darken($light-green, 10%);
background-color: var(--secondary-color-darken-10);
}
}

Expand All @@ -67,10 +67,10 @@
}

&.js-channel-mute {
background-color: $light-green;
background-color: var(--secondary-color);

&:hover {
background-color: darken($light-green, 10%);
background-color: var(--secondary-color-darken-10)
}
}

Expand Down

0 comments on commit 26db8ea

Please sign in to comment.