Better focus outlines & small improvements

This commit is contained in:
Filip Znachor 2024-06-21 22:51:23 +02:00
parent c3aa6857c2
commit 15d990a67c
8 changed files with 25 additions and 21 deletions

View file

@ -16,7 +16,6 @@
border-radius: var(--synergy-border-radius); border-radius: var(--synergy-border-radius);
transition: .2s background-color; transition: .2s background-color;
cursor: pointer; cursor: pointer;
outline: none;
transition: box-shadow .2s; transition: box-shadow .2s;
text-decoration: none; text-decoration: none;
} }
@ -41,9 +40,10 @@
} }
.btn:focus-visible { .btn:focus-visible {
box-shadow: 0 0 0 5px var(--synergy-focus-highlight); outline: 5px solid var(--synergy-btn-focus-highlight);
background-color: var(--synergy-btn-bg-hover);
} }
.btn.btn-primary:focus-visible { .btn.btn-primary:focus-visible {
box-shadow: 0 0 0 5px var(--synergy-focus-highlight); outline: 5px solid var(--synergy-focus-highlight);
} }

View file

@ -42,7 +42,7 @@ label.cbox > input:checked + *::before {
} }
label.cbox > input:focus-visible + *::before { label.cbox > input:focus-visible + *::before {
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .1), 0 0 0 8px var(--synergy-focus-highlight); outline: 5px solid var(--synergy-focus-highlight);
} }
label.cbox > input[type=checkbox] + *::before { label.cbox > input[type=checkbox] + *::before {

View file

@ -26,7 +26,7 @@
width: 60%; width: 60%;
height: var(--synergy-tab-bar-height); height: var(--synergy-tab-bar-height);
background-color: var(--synergy-border-active); background-color: var(--synergy-border-active);
bottom: 0; bottom: 0;
left: 20%; left: 20%;
transition: all .2s; transition: all .2s;
opacity: 0; opacity: 0;

View file

@ -30,7 +30,7 @@
} }
.toggle .indicator::after { .toggle .indicator::after {
transition: all .2s; transition: background-color .2s;
margin-left: auto; margin-left: auto;
display: inline-block; display: inline-block;
height: 100%; height: 100%;
@ -48,8 +48,8 @@
background: var(--synergy-border-active); background: var(--synergy-border-active);
} }
.toggle input:focus-visible + .indicator::after { .toggle input:focus-visible + .indicator:after {
box-shadow: 0 0 10px 0 var(--synergy-bg), 0 0 0 10px var(--synergy-focus-highlight); outline: 10px solid var(--synergy-focus-highlight);
} }

View file

@ -38,9 +38,7 @@ function applyPreset(preset: Preset) {
{{ v.name }} {{ v.name }}
</label> </label>
<div v-if="v.type == 'color'"> <div v-if="v.type == 'color'">
<div class="inp inp-small color"> <div class="colori" :style="{ background: variableValues[v.name] }" />
<input v-model="variableValues[v.name]" type="color" :id="v.name" @change="update">
</div>
<div class="inp inp-small"> <div class="inp inp-small">
<input v-model="variableValues[v.name]" type="string" :id="v.name" @change="update"> <input v-model="variableValues[v.name]" type="string" :id="v.name" @change="update">
</div> </div>

View file

@ -42,14 +42,12 @@ header h1 .color {background-clip: text; -webkit-background-clip: text; backgrou
.form {display: flex; flex-direction: column; gap: 15px; max-width: 450px;} .form {display: flex; flex-direction: column; gap: 15px; max-width: 450px;}
.form > * {margin: 0;} .form > * {margin: 0;}
.colori {aspect-ratio: 1 / 1; height: 34px; border-radius: var(--synergy-border-radius);}
/* Synergy expansions */ /* Synergy expansions */
.inp.inp-small input {padding: 5px 9px; font-size: .9em;} .inp.inp-small input {padding: 5px 9px; font-size: .9em;}
.inp.color {width: 40px;}
.inp input[type=color] {padding: 0; border: 0;}
::-webkit-color-swatch, ::-moz-color-swatch {border: 0;}
a {color: var(--synergy-btn-primary-bg);} a {color: var(--synergy-btn-primary-bg);}
a:hover {color: var(--synergy-btn-primary-bg-hover);} a:hover {color: var(--synergy-btn-primary-bg-hover);}

View file

@ -38,27 +38,34 @@ export class Preset {
return { return {
"border": this.cMix(cMain, cBg, 0.4), "border": this.cMix(cMain, cBg, 0.4),
"border-active": cMain.hexFormat(), "border-active": cMain.hexFormat(),
"focus-highlight": this.cMix(cMain, cBg, 0.25), "focus-highlight": this.cAlpha(cMain, 0.25),
"tab-highlight": this.cMix(cMain, cBg, 0.1), "tab-highlight": this.cMix(cMain, cBg, 0.1),
"label": this.cMix(cMain, cBg, 0.8), "label": this.cMix(cMain, cBg, 0.8),
"label-active": this.cMix(cMain, cBg), "label-active": this.cMix(cMain, cBg),
"btn-primary-bg": this.cMix(cMain, cBg, 0.8), "btn-primary-bg": this.cMix(cMain, cBg, 0.8),
"btn-primary-bg-active": this.cMix(cMain, cBg, 0.5), "btn-primary-bg-active": this.cMix(cMain, cBg, 0.5),
"btn-primary-bg-hover": this.cMix(cMain, cBg), "btn-primary-bg-hover": this.cMix(cMain, cBg, 0.9),
"btn-bg": this.cMix(cBg.mix(cGray, 0.8).mix(cMain, 0.1), cBg, 0.3), "btn-focus-highlight": this.cAlpha(cBg.mix(cGray, 0.6).mix(cMain, 0.1), 0.25),
"btn-bg-active": this.cMix(cBg.mix(cGray, 0.8).mix(cMain, 0.1), cBg, 0.6), "btn-bg": this.cMix(cBg.mix(cGray, 0.6).mix(cMain, 0.1), cBg, 0.3),
"btn-bg-hover": this.cMix(cBg.mix(cGray, 0.8).mix(cMain, 0.1), cBg, 0.4), "btn-bg-active": this.cMix(cBg.mix(cGray, 0.6).mix(cMain, 0.1), cBg, 0.6),
"btn-bg-hover": this.cMix(cBg.mix(cGray, 0.6).mix(cMain, 0.1), cBg, 0.45),
"text-color": cText.hexFormat(), "text-color": cText.hexFormat(),
"bg": cBg.hexFormat(), "bg": cBg.hexFormat(),
"site-bg": cSiteBg.hexFormat() "site-bg": cSiteBg.hexFormat()
}; };
} }
public cMix(color: Color, color2: Color, ratio: number = 1) { public cMix(color: Color, color2: Color, ratio: number = 1) {
let c = color2.mix(color, ratio); let c = color2.mix(color, ratio);
return c.hexFormat(); return c.hexFormat();
} }
public cAlpha(color: Color, alpha: number = 1) {
let c = color.clone();
c.a = alpha;
return c.hexFormat();
}
public static convertColors(input: Colors<Color | string>) { public static convertColors(input: Colors<Color | string>) {
return Object.entries(input).reduce<Partial<Colors<Color>>>((acc, [key, value]) => { return Object.entries(input).reduce<Partial<Colors<Color>>>((acc, [key, value]) => {
acc[key as ColorType] = value instanceof Color ? value : Color.fromHex(value); acc[key as ColorType] = value instanceof Color ? value : Color.fromHex(value);

View file

@ -13,6 +13,7 @@ export const variables: Variable[] = [
{name: "btn-primary-bg", type: "color", requiredBy: ["button"]}, {name: "btn-primary-bg", type: "color", requiredBy: ["button"]},
{name: "btn-primary-bg-hover", type: "color", requiredBy: ["button"]}, {name: "btn-primary-bg-hover", type: "color", requiredBy: ["button"]},
{name: "btn-primary-bg-active", type: "color", requiredBy: ["button"]}, {name: "btn-primary-bg-active", type: "color", requiredBy: ["button"]},
{name: "btn-focus-highlight", type: "color", requiredBy: ["button"]},
{name: "btn-bg", type: "color", requiredBy: ["button"]}, {name: "btn-bg", type: "color", requiredBy: ["button"]},
{name: "btn-bg-hover", type: "color", requiredBy: ["button"]}, {name: "btn-bg-hover", type: "color", requiredBy: ["button"]},
{name: "btn-bg-active", type: "color", requiredBy: ["button"]}, {name: "btn-bg-active", type: "color", requiredBy: ["button"]},