Skip to content

Commit 13202b3

Browse files
committed
better icon-settings-expand
1 parent 002345f commit 13202b3

File tree

5 files changed

+62
-77
lines changed

5 files changed

+62
-77
lines changed

src-theme/src/routes/clickgui/Module.svelte

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@
133133
</div>
134134

135135
<style lang="scss">
136-
@use "../../colors.scss" as *;
136+
@use "../../colors" as *;
137+
@use "./icon-settings-expand" as *;
137138
138139
.module {
139140
position: relative;
@@ -178,21 +179,8 @@
178179
179180
&.has-settings {
180181
.name::after {
181-
content: "";
182-
display: block;
183-
position: absolute;
184-
height: 10px;
185-
width: 10px;
186-
right: 15px;
187-
top: 50%;
188-
background-image: url("/img/clickgui/icon-settings-expand.svg");
189-
background-position: center;
190-
background-repeat: no-repeat;
182+
@include icon-settings-expand($right: 15px);
191183
opacity: 0.5;
192-
transform-origin: 50% 50%;
193-
transform: translateY(-50%) rotate(-90deg);
194-
transition: ease opacity 0.2s,
195-
ease transform 0.4s;
196184
}
197185
198186
&.expanded .name::after {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*!
2+
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3+
*
4+
* Copyright (c) 2015 - 2025 CCBlueX
5+
*
6+
* LiquidBounce is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* LiquidBounce is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
@mixin icon-settings-expand(
21+
$size: 10px,
22+
$right: 10px,
23+
$rotate: -90deg,
24+
) {
25+
content: "";
26+
display: block;
27+
position: absolute;
28+
height: $size;
29+
width: $size;
30+
right: $right;
31+
top: 50%;
32+
background-image: url("/img/clickgui/icon-settings-expand.svg");
33+
background-position: center;
34+
background-repeat: no-repeat;
35+
transform-origin: 50% 50%;
36+
transform: translateY(-50%) rotate($rotate);
37+
transition: ease opacity 0.2s, ease transform 0.4s;
38+
}

src-theme/src/routes/clickgui/setting/bind/SwitchBindAction.svelte

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
}
3939
</script>
4040

41-
<button on:click|stopPropagation={switchAction}>
41+
<!-- svelte-ignore a11y_consider_explicit_label -->
42+
<button style="--direction: {direction}" on:click|stopPropagation={switchAction}>
4243
<span class="chosen-holder">
4344
{#key chosen}
4445
<span
@@ -49,30 +50,30 @@
4950
{/key}
5051
</span>
5152

52-
<span class="arrow-wrapper" class:jiggle bind:this={arrowWrapper}>
53-
<ExpandArrow
54-
expanded={false}
55-
expandable={false}
56-
compact={true}
57-
dimmed={true}
58-
/>
53+
<span class="arrow arrow-right" class:jiggle bind:this={arrowWrapper}>
5954
</span>
6055
</button>
6156

6257
<style lang="scss">
6358
@use "../../../../colors" as *;
59+
@use "../../icon-settings-expand" as *;
6460
65-
@keyframes jiggle-right {
61+
@keyframes jiggle {
6662
0% { transform: translateX(0); }
67-
50% { transform: translateX(2px); }
63+
50% { transform: translateX(calc(var(--direction) * 2px)); }
6864
100% { transform: translateX(0); }
6965
}
7066
71-
.arrow-wrapper {
72-
display: flex;
67+
.arrow {
68+
width: 10px;
69+
70+
&.arrow-right::after {
71+
@include icon-settings-expand($size: 10px, $right: auto);
72+
color: $clickgui-text-dimmed-color;
73+
}
7374
7475
&.jiggle {
75-
animation: jiggle-right 200ms ease;
76+
animation: jiggle 200ms ease;
7677
}
7778
}
7879

src-theme/src/routes/clickgui/setting/common/Dropdown.svelte

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
<style lang="scss">
5555
@use "../../../../colors.scss" as *;
56+
@use "../../icon-settings-expand" as *;
5657
5758
.dropdown {
5859
position: relative;
@@ -90,20 +91,7 @@
9091
}
9192
9293
.text::after {
93-
content: "";
94-
display: block;
95-
position: absolute;
96-
height: 10px;
97-
width: 10px;
98-
right: 10px;
99-
top: 50%;
100-
background-image: url("/img/clickgui/icon-settings-expand.svg");
101-
background-position: center;
102-
background-repeat: no-repeat;
103-
transform-origin: 50% 50%;
104-
transform: translateY(-50%) rotate(-90deg);
105-
transition: ease opacity 0.2s,
106-
ease transform 0.4s;
94+
@include icon-settings-expand();
10795
}
10896
}
10997

src-theme/src/routes/clickgui/setting/common/ExpandArrow.svelte

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,21 @@
22
import {createEventDispatcher} from "svelte";
33
44
export let expanded: boolean;
5-
export let expandable: boolean = true;
6-
export let compact = false;
7-
export let dimmed = false;
85
96
const dispatch = createEventDispatcher();
107
118
function handleClick() {
12-
if (expandable) {
13-
expanded = !expanded;
14-
dispatch("click");
15-
}
9+
expanded = !expanded;
10+
dispatch("click");
1611
}
1712
</script>
1813

1914
<!-- svelte-ignore a11y_consider_explicit_label -->
20-
<button class="arrow" class:expanded class:compact class:dimmed on:click={handleClick}
15+
<button class="arrow" class:expanded on:click={handleClick}
2116
></button>
2217

2318
<style lang="scss">
24-
@use "../../../../colors" as *;
19+
@use "../../icon-settings-expand" as *;
2520
2621
.arrow {
2722
width: 20px;
@@ -30,33 +25,8 @@
3025
background-color: transparent;
3126
border: none;
3227
33-
&.compact {
34-
width: 10px;
35-
}
36-
37-
&.dimmed {
38-
color: $clickgui-text-dimmed-color;
39-
}
40-
4128
&::after {
42-
content: "";
43-
display: block;
44-
position: absolute;
45-
height: 10px;
46-
width: 10px;
47-
right: 0;
48-
top: 50%;
49-
background-image: url("/img/clickgui/icon-settings-expand.svg");
50-
background-position: center;
51-
background-repeat: no-repeat;
52-
transform-origin: 50% 50%;
53-
transform: translateY(-50%) rotate(-90deg);
54-
transition: ease opacity 0.2s,
55-
ease transform 0.4s;
56-
}
57-
58-
&::after.compact {
59-
right: auto;
29+
@include icon-settings-expand($right: 0);
6030
}
6131
6232
&.expanded::after {

0 commit comments

Comments
 (0)