Skip to content

Commit f3d2a6f

Browse files
committed
feat: custom selection style support (#119)
1 parent 1ce9fbe commit f3d2a6f

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

_config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ yat:
124124
# Custom color as below:
125125
# brand_color: "#1a8e42"
126126

127+
# You can custom selection style
128+
# selection:
129+
# color: "#ff00ff"
130+
# background_color: "yellow"
131+
127132
# Night/Dark mode
128133
# Default mode is "auto", "auto" is for auto nightshift
129134
# (19:00 - 07:00), "manual" is for manual toggle, and

_sass/yat/_base.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,26 @@ table {
291291
overflow: hidden;
292292
}
293293

294+
/**
295+
* Text Selection
296+
*/
297+
::selection {
298+
color: $selection-color;
299+
background-color: $selection-background-color;
300+
}
301+
::-moz-selection { /* Code for Firefox */
302+
color: $selection-color;
303+
background-color: $selection-background-color;
304+
}
305+
::-ms-selection {
306+
color: $selection-color;
307+
background-color: $selection-background-color;
308+
}
309+
::-o-selection {
310+
color: $selection-color;
311+
background-color: $selection-background-color;
312+
}
313+
::-webkit-selection {
314+
color: $selection-color;
315+
background-color: $selection-background-color;
316+
}

assets/css/main.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,15 @@ $click-to-top-light-color: {{ site.click_to_top.light.color | default: "#454545"
4141
$click-to-top-dark-background-color: {{ site.click_to_top.dark.background_color | default: "#34323d" }};
4242
$click-to-top-dark-color: {{ site.click_to_top.dark.color | default: "#bbb" }};
4343

44+
// Selection styles
45+
$selection-color: unquote("{{ site.selection.color }}");
46+
$selection-background-color: unquote("{{ site.selection.background_color }}");
47+
48+
@if $selection-color == "" {
49+
$selection-color: inherit;
50+
}
51+
@if $selection-background-color == "" {
52+
$selection-background-color: rgba(invert($brand-color), 0.3);
53+
}
54+
4455
@import "yat";

0 commit comments

Comments
 (0)