Skip to content

Commit

Permalink
Fix back button (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
st3v3nmw authored Dec 12, 2022
1 parent 42c3796 commit 53d3201
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 16 deletions.
2 changes: 1 addition & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ esbuild
external: ["obsidian", "electron", ...builtins],
format: "cjs",
watch: !prod,
target: "es2016",
target: "es2018",
logLevel: "info",
sourcemap: "inline",
sourcesContent: !prod,
Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module.exports = {
"src/constants",
"src/icons",
"src/declarations.d.ts",
"build",
],
coverageDirectory: "coverage",
collectCoverage: true,
};
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
"author": "Stephen Mwangi",
"authorUrl": "https://github.com/st3v3nmw",
"isDesktopOnly": false
"isDesktopOnly": false,
"fundingUrl": "https://ko-fi.com/M4M44DEN6"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"build": "node esbuild.config.mjs production",
"dev": "node esbuild.config.mjs",
"format": "npx prettier --write .",
"lint": "npx prettier --check .",
"test": "jest --coverage"
"lint": "npx prettier --check . && npx eslint src/",
"test": "jest --verbose --runInBand"
},
"author": "Stephen Mwangi",
"license": "MIT",
Expand Down
25 changes: 22 additions & 3 deletions src/flashcard-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class FlashcardModal extends Modal {
this.ignoreStats = ignoreStats;

this.titleEl.setText(t("DECKS"));
this.titleEl.addClass("sr-centered");

if (Platform.isMobile) {
this.contentEl.style.display = "block";
Expand Down Expand Up @@ -125,7 +126,7 @@ export class FlashcardModal extends Modal {
<span
style="background-color:#4caf50;color:#ffffff;"
aria-label={t("DUE_CARDS")}
class="tag-pane-tag-count tree-item-flair"
class="tag-pane-tag-count tree-item-flair sr-deck-counts"
>
{this.plugin.deckTree.dueFlashcardsCount.toString()}
</span>
Expand Down Expand Up @@ -155,9 +156,27 @@ export class FlashcardModal extends Modal {

setupCardsView(): void {
this.contentEl.innerHTML = "";
const historyLinkView = this.contentEl.createEl("button");

historyLinkView.setText("〈");
const historyLinkView = this.contentEl.createEl("button");
historyLinkView.addClass("sr-back-btn");
historyLinkView.setAttribute("aria-label", t("BACK"));
historyLinkView.innerHTML += (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewbox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="svg-icon lucide-arrow-left"
>
<line x1="19" y1="12" x2="5" y2="12"></line>
<polyline points="12 19 5 12 12 5"></polyline>
</svg>
);
historyLinkView.addEventListener("click", (e: PointerEvent) => {
if (e.pointerType.length > 0) {
this.plugin.data.historyDeck = "";
Expand Down
1 change: 1 addition & 0 deletions src/lang/locale/cz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
DUE_CARDS: "Kartičky po termínu",
NEW_CARDS: "Nové kartičky",
TOTAL_CARDS: "Kartiček celkem",
BACK: "Back",
EDIT_LATER: "Upravit později",
RESET_CARD_PROGRESS: "Vynulovat pokrok kartičky",
HARD: "Težké",
Expand Down
1 change: 1 addition & 0 deletions src/lang/locale/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default {
DUE_CARDS: "Anstehende Karten",
NEW_CARDS: "Neue Karten",
TOTAL_CARDS: "Alle Karten",
BACK: "Back",
EDIT_LATER: "Später bearbeiten",
RESET_CARD_PROGRESS: "Kartenfortschritt zurücksetzten",
HARD: "Schwer",
Expand Down
1 change: 1 addition & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
DUE_CARDS: "Due Cards",
NEW_CARDS: "New Cards",
TOTAL_CARDS: "Total Cards",
BACK: "Back",
EDIT_LATER: "Edit Later",
RESET_CARD_PROGRESS: "Reset card's progress",
HARD: "Hard",
Expand Down
1 change: 1 addition & 0 deletions src/lang/locale/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
DUE_CARDS: "期日のカード",
NEW_CARDS: "新規のカード",
TOTAL_CARDS: "カード合計",
BACK: "Back",
EDIT_LATER: "後で編集",
RESET_CARD_PROGRESS: "カードの進捗をリセット",
HARD: "Hard",
Expand Down
1 change: 1 addition & 0 deletions src/lang/locale/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
DUE_CARDS: "다시 볼 카드들",
NEW_CARDS: "새로운 카드들",
TOTAL_CARDS: "전체 카드들",
BACK: "Back",
EDIT_LATER: "나중에 편집하기",
RESET_CARD_PROGRESS: "카드의 진행상황을 초기화합니다.",
HARD: "어려움(Hard)",
Expand Down
1 change: 1 addition & 0 deletions src/lang/locale/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
DUE_CARDS: "Cartas para Colocar em Dia",
NEW_CARDS: "Novas Cartas",
TOTAL_CARDS: "Total de Cartas",
BACK: "Back",
EDIT_LATER: "Editar Depois",
RESET_CARD_PROGRESS: "Reiniciar o Progresso da Carta",
HARD: "Difícil",
Expand Down
1 change: 1 addition & 0 deletions src/lang/locale/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
NEW_CARDS: "Новые карточки",
TOTAL_CARDS: "Всего карточек",
EDIT_LATER: "Редактировать после",
BACK: "Back",
RESET_CARD_PROGRESS: "Сбросить прогресс карточки",
HARD: "Сложно",
GOOD: "Нормально",
Expand Down
1 change: 1 addition & 0 deletions src/lang/locale/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
DUE_CARDS: "到期卡片",
NEW_CARDS: "新卡片",
TOTAL_CARDS: "全部卡片",
BACK: "Back",
EDIT_LATER: "稍后编辑",
RESET_CARD_PROGRESS: "重置卡片",
HARD: "较难",
Expand Down
1 change: 1 addition & 0 deletions src/lang/locale/zh-tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
NEW_CARDS: "新卡片",
TOTAL_CARDS: "全部卡片",
EDIT_LATER: "稍後編輯",
BACK: "Back",
RESET_CARD_PROGRESS: "重置卡片",
HARD: "較難",
GOOD: "記得",
Expand Down
2 changes: 1 addition & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const DEFAULT_SETTINGS: SRSettings = {
disableFileMenuReviewOptions: false,
maxNDaysNotesReviewQueue: 365,
// UI settings
initiallyExpandAllSubdecksInTree: true,
initiallyExpandAllSubdecksInTree: false,
// algorithm
baseEase: 250,
lapsesIntervalChange: 0.5,
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ItemView, WorkspaceLeaf, Menu, TFile, Notice } from "obsidian";
import { ItemView, WorkspaceLeaf, Menu, TFile } from "obsidian";

import type SRPlugin from "src/main";
import { COLLAPSE_ICON } from "src/constants";
Expand Down
24 changes: 17 additions & 7 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
.sr-response {
display: inline-grid;
width: 100%;
grid-template-columns: auto auto auto;
grid-template-columns: auto auto auto auto;
position: absolute;
bottom: 0;
}

.sr-ignorestats-btn {
/* Bit of a hack, but it works. */
margin: 0px !important;
margin-right: 12px !important;
}

.sr-ignorestats-response {
grid-template-columns: auto auto !important;
}
Expand All @@ -21,11 +28,20 @@
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}

.sr-deck-counts {
color: #ffffff;
margin-left: 4px;
padding: 4px;
}

.sr-back-btn {
background-color: transparent !important;
box-shadow: none !important;
padding: 0 !important;
margin-right: 4px;
}

#sr-show-answer {
Expand Down Expand Up @@ -79,12 +95,6 @@
height: 80%;
}

.sr-ignorestats-btn {
/* Bit of a hack, but it works. */
margin: 0px !important;
margin-right: 12px !important;
}

@media only screen and (max-width: 600px) {
.sr-modal-content::-webkit-scrollbar,
#sr-flashcard-view::-webkit-scrollbar {
Expand Down

0 comments on commit 53d3201

Please sign in to comment.