Skip to content

Commit aac60fe

Browse files
committed
impr: add share buttons to desktop and mobile test config
1 parent 6bd5240 commit aac60fe

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

frontend/src/html/pages/test.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@
9292
<button class="textButton">change</button>
9393
</div>
9494
</div>
95+
<button class="shareButton textButton">
96+
<i class="fas fa-fw fa-share"></i>
97+
</button>
9598
</div>
99+
96100
<div id="mobileTestConfigButton">
97101
<button>
98102
<i class="fas fa-fw fa-cog"></i>

frontend/src/html/popups.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@
296296
<div class="group customGroup hidden">
297297
<button class="customChange">change</button>
298298
</div>
299+
<div class="group">
300+
<button class="shareButton">share</button>
301+
</div>
299302
</div>
300303
</dialog>
301304

frontend/src/styles/test.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,10 @@
11441144
transition: opacity 0.125s;
11451145
justify-content: space-around;
11461146
margin-bottom: 1rem;
1147+
width: max-content;
1148+
justify-self: center;
1149+
position: relative;
1150+
11471151
.puncAndNum {
11481152
// transition: 0.25s cubic-bezier(0.37, 0, 0.63, 1);
11491153
// overflow: hidden;
@@ -1154,6 +1158,7 @@
11541158
// padding: 0 0.5rem;
11551159
background: var(--sub-alt-color);
11561160
border-radius: var(--roundness);
1161+
z-index: 2;
11571162
// width: max-content;
11581163
}
11591164
.spacer {
@@ -1217,6 +1222,20 @@
12171222
.customText {
12181223
display: grid;
12191224
}
1225+
.shareButton {
1226+
position: absolute;
1227+
right: 0;
1228+
padding: var(--verticalPadding) var(--horizontalPadding);
1229+
z-index: 1;
1230+
transition: opacity 0.25s, right 0.25s;
1231+
opacity: 0;
1232+
}
1233+
&:hover {
1234+
.shareButton {
1235+
opacity: 1;
1236+
right: -3.25em;
1237+
}
1238+
}
12201239
}
12211240

12221241
.pageTest {

frontend/src/ts/event-handlers/test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import * as CustomTextModal from "../modals/custom-text";
1414
import * as PractiseWordsModal from "../modals/practise-words";
1515
import { navigate } from "../controllers/route-controller";
1616
import { getMode2 } from "../utils/misc";
17+
import * as ShareTestSettingsPopup from "../modals/share-test-settings";
1718

1819
$(".pageTest").on("click", "#testModesNotice .textButton", async (event) => {
1920
const attr = $(event.currentTarget).attr("commands");
@@ -41,6 +42,10 @@ $(".pageTest").on("click", "#testConfig .time .textButton", (e) => {
4142
}
4243
});
4344

45+
$(".pageTest").on("click", "#testConfig .shareButton", (e) => {
46+
ShareTestSettingsPopup.show();
47+
});
48+
4449
$(".pageTest").on("click", ".tags .editTagsButton", () => {
4550
if ((DB.getSnapshot()?.tags?.length ?? 0) > 0) {
4651
const resultid = $(".pageTest .tags .editTagsButton").attr(

frontend/src/ts/modals/mobile-test-config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import AnimatedModal from "../utils/animated-modal";
99
import { QuoteLength, QuoteLengthConfig } from "@monkeytype/schemas/configs";
1010
import { Mode } from "@monkeytype/schemas/shared";
1111
import { areUnsortedArraysEqual } from "../utils/arrays";
12+
import * as ShareTestSettingsPopup from "./share-test-settings";
1213

1314
function update(): void {
1415
const el = $("#mobileTestConfigModal");
@@ -178,6 +179,12 @@ async function setup(modalEl: HTMLElement): Promise<void> {
178179
TestLogic.restart();
179180
});
180181

182+
modalEl.querySelector(".shareButton")?.addEventListener("click", () => {
183+
ShareTestSettingsPopup.show({
184+
modalChain: modal,
185+
});
186+
});
187+
181188
const buttons = modalEl.querySelectorAll("button");
182189
for (const button of buttons) {
183190
button.addEventListener("click", () => {

0 commit comments

Comments
 (0)