Skip to content

Commit

Permalink
feat: accent color based on folder color, closes #762
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Apr 30, 2024
1 parent 33bbc0e commit 058fc2f
Show file tree
Hide file tree
Showing 17 changed files with 204 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/renderer/components/BaseMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ onMounted(() => {
display: flex;
justify-content: center;
align-items: center;
background: $primary-color;
background: var(--primary-color);
border-radius: 50%;
box-shadow: 0 0 5px 1px darken($body-font-color-dark, 40%);
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/ModalAllConnections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ onBeforeUnmount(() => {
outline: none;
&:focus {
box-shadow: 0 0 3px 0.1rem rgba($primary-color, 80%);
box-shadow: 0 0 3px 0.1rem rgba(var(--primary-color), 80%);
}
&:hover {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/ModalConnectionAppearance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ onBeforeUnmount(() => {
cursor: pointer;
&.selected {
outline: 2px solid $primary-color;
outline: 2px solid var(--primary-color);
border-radius: 8px;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/ModalHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ onBeforeUnmount(() => {
max-width: 100%;
display: inline-block;
font-size: 100%;
// color: $primary-color;
// color: var(--primary-color);
opacity: 0.8;
font-weight: 600;
}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/ModalSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ onBeforeUnmount(() => {
&.selected {
img {
box-shadow: 0 0 0 3px $primary-color;
box-shadow: 0 0 0 3px var(--primary-color);
}
}
Expand Down Expand Up @@ -731,7 +731,7 @@ onBeforeUnmount(() => {
.badge-update::after {
bottom: initial;
background: $primary-color;
background: var(--primary-color);
}
.form-label {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/QueryEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ defineExpose({ editor });
position: absolute;
left: 3px;
top: 2px;
color: $primary-color;
color: var(--primary-color);
display: inline-block;
font: normal normal normal 24px/1 "Material Design Icons", sans-serif;
font-size: inherit;
Expand Down
14 changes: 12 additions & 2 deletions src/renderer/components/TheFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@
<script setup lang="ts">
import { shell } from 'electron';
import { storeToRefs } from 'pinia';
import { computed, ComputedRef } from 'vue';
import { computed, ComputedRef, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import BaseIcon from '@/components/BaseIcon.vue';
import { hexToRGBA } from '@/libs/hexToRgba';
import { useApplicationStore } from '@/stores/application';
import { useConnectionsStore } from '@/stores/connections';
import { useConsoleStore } from '@/stores/console';
Expand Down Expand Up @@ -117,7 +118,11 @@ const { getWorkspace } = workspacesStore;
const { getConnectionFolder, getConnectionByUid } = connectionsStore;
const workspace = computed(() => getWorkspace(workspaceUid.value));
const footerColor = computed(() => getConnectionFolder(workspaceUid.value)?.color || '#E36929');
const footerColor = computed(() => {
if (getConnectionFolder(workspaceUid.value)?.color)
return getConnectionFolder(workspaceUid.value).color;
return '#E36929';
});
const connectionInfos = computed(() => getConnectionByUid(workspaceUid.value));
const version: ComputedRef<DatabaseInfos> = computed(() => {
return getWorkspace(workspaceUid.value) ? workspace.value.version : null;
Expand All @@ -129,6 +134,11 @@ const versionString = computed(() => {
return '';
});
watch(footerColor, () => {
document.querySelector<HTMLBodyElement>(':root').style.setProperty('--primary-color', footerColor.value);
document.querySelector<HTMLBodyElement>(':root').style.setProperty('--primary-color-shadow', hexToRGBA(footerColor.value, 0.2));
});
const openOutside = (link: string) => shell.openExternal(link);
</script>
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/TheSettingBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ if (!connectionsArr.value.length)
border-radius: 0;
padding: 0;
position: relative;
border: none;
&:hover {
opacity: 1;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/WorkspaceExploreBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ const toggleSearchMethod = () => {
transition: background 0.2s;
&:hover {
background: rgba($primary-color, 50%);
background: rgba(var(--primary-color), 50%);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/WorkspaceQueryConsole.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ onMounted(() => {
transition: background 0.2s;
&:hover {
background: rgba($primary-color, 50%);
background: rgba(var(--primary-color), 50%);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/WorkspaceTabQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ onBeforeUnmount(() => {
transition: background 0.2s;
&:hover {
background: rgba($primary-color, 50%);
background: rgba(var(--primary-color), 50%);
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/renderer/libs/colorShade.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const colorShade = (color: string, amount: number) => {
color = color.replaceAll('#', '');
if (color.length === 3) color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
let [r, g, b] = color.match(/.{2}/g) as any;
([r, g, b] = [parseInt(r, 16) + amount, parseInt(g, 16) + amount, parseInt(b, 16) + amount]);

r = Math.max(Math.min(255, r), 0).toString(16);
g = Math.max(Math.min(255, g), 0).toString(16);
b = Math.max(Math.min(255, b), 0).toString(16);

const rr = (r.length < 2 ? '0' : '') + r;
const gg = (g.length < 2 ? '0' : '') + g;
const bb = (b.length < 2 ? '0' : '') + b;

return `#${rr}${gg}${bb}`;
};
16 changes: 16 additions & 0 deletions src/renderer/libs/hexToRgba.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const hexToRGBA = (hexCode: string, opacity = 1) => {
let hex = hexCode.replace('#', '');

if (hex.length === 3)
hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;

const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);

/* Backward compatibility for whole number based opacity values. */
if (opacity > 1 && opacity <= 100)
opacity = opacity / 100;

return `rgba(${r},${g},${b},${opacity})`;
};
2 changes: 1 addition & 1 deletion src/renderer/scss/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Colors */
$body-bg: #fdfdfd;
$body-bg: #f3f3f3;
$body-bg-dark: #1d1d1d;
$body-font-color-dark: #fff;
$bg-color-dark: #1d1d1d;
Expand Down
81 changes: 68 additions & 13 deletions src/renderer/scss/main.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/* stylelint-disable */
:root {
--primary-color: #e36929;
--primary-color-dark: color-mix(in srgb, var(--primary-color), #000 30%);
--primary-color-shadow: 0 0 0 0.1rem rgba(227, 105, 41, 0.2);
}

@import "~spectre.css/src/variables";
@import "variables";
@import "transitions";
Expand All @@ -16,12 +22,16 @@ body {
user-select: none;
}

a {
color: var(--primary-color);
}

::selection,
option:hover,
option:focus,
option:active,
option:checked {
background-color: $primary-color;
background-color: var(--primary-color);
color: $light-color;
}

Expand Down Expand Up @@ -248,7 +258,7 @@ option:checked {
height: 2px;
width: 0;
transition: width 0.2s;
background-color: $primary-color;
background-color: var(--primary-color);
position: absolute;
bottom: 0;
}
Expand Down Expand Up @@ -300,9 +310,23 @@ option:checked {
height: auto;
}

.form-checkbox input:checked + .form-icon, .form-radio input:checked + .form-icon, .form-switch input:checked + .form-icon {
background: var(--primary-color);
border-color: var(--primary-color);
}

.form-checkbox input:focus + .form-icon, .form-radio input:focus + .form-icon, .form-switch input:focus + .form-icon {
box-shadow: 0 0 0 0.1rem var(--primary-color-shadow);
border-color: var(--primary-color);
}

.form-select {
cursor: pointer;

&:focus {
box-shadow: 0 0 0 0.1rem var(--primary-color-shadow);
}

&.small-select {
height: 21px;
font-size: 0.7rem;
Expand All @@ -311,7 +335,8 @@ option:checked {

&.select {
&.select--open {
border-color: $primary-color !important;
border-color: var(--primary-color) !important;
box-shadow: 0 0 0 0.1rem var(--primary-color-shadow) !important;

@include control-shadow();
}
Expand All @@ -336,19 +361,28 @@ option:checked {
z-index: 401 !important;
border: 1px solid transparent;
border-radius: $border-radius;
box-shadow: 0 8px 17px 0 rgb(0 0 0 / 20%), 0 6px 20px 0 rgb(0 0 0 / 19%);
box-shadow:
0 8px 17px 0 rgb(0 0 0 / 20%),
0 6px 20px 0 rgb(0 0 0 / 19%);
}

.select__option--selected {
background: rgba($primary-color, 0.25);
background: rgba(var(--primary-color), 0.25);
}

.select__option--highlight {
background: $primary-color;
background: var(--primary-color);
text-shadow: 0 0 15px #000;
}

.form-input[type="file"] {
overflow: hidden;
.form-input {
&[type="file"] {
overflow: hidden;
}
&:focus {
border-color: var(--primary-color);
box-shadow: 0 0 0 0.1rem var(--primary-color-shadow);
}
}

.input-group .input-group-addon {
Expand All @@ -370,13 +404,34 @@ option:checked {
}

.btn {
color: var(--primary-color);
border-color: var(--primary-color);

&:not(.btn-link) {
text-shadow: 0 0 15px #000;
}

&:hover {
border-color: var(--primary-color-dark);
}

&:focus {
box-shadow: 0 0 3px 1px rgba($primary-color, 90%);
box-shadow: 0 0 3px 1px rgba(var(--primary-color), 90%);
}

&.btn-success:focus {
border-color: $primary-color;
box-shadow: 0 0 3px 1px rgba($primary-color, 90%);
border-color: var(--primary-color);
box-shadow: 0 0 3px 1px rgba(var(--primary-color), 90%);
}

&.btn-primary {
background: var(--primary-color);
border-color: var(--primary-color-dark);

&:hover {
background: var(--primary-color-dark);
border-color: var(--primary-color-dark);
}
}
}

Expand Down Expand Up @@ -435,7 +490,7 @@ code.sql {
}

.sql-hl-keyword {
color: $primary-color;
color: var(--primary-color);
}

.sql-hl-function {
Expand All @@ -456,4 +511,4 @@ code.sql {

.sql-hl-bracket {
color: darkorchid;
}
}

0 comments on commit 058fc2f

Please sign in to comment.