-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add some results display config
- Loading branch information
Showing
7 changed files
with
114 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script setup lang="ts"> | ||
import { resultsConfig } from './results-config' | ||
</script> | ||
|
||
<template> | ||
<div class="config"> | ||
<label><input type="checkbox" v-model="resultsConfig.displayReminderText" /> Display reminder text</label> | ||
<label><input type="checkbox" v-model="resultsConfig.editableContent" /> Manually edit content</label> | ||
<label><input type="checkbox" v-model="resultsConfig.doubleFacedOnTwoCards" /> Display double faced cards on two cards</label> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.config { | ||
font-size: 0.9em; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { reactive, watch } from 'vue' | ||
|
||
type ResultsConfig = { | ||
editableContent: boolean, | ||
displayReminderText: boolean, | ||
doubleFacedOnTwoCards: boolean | ||
} | ||
|
||
const defaultResultsConfig: ResultsConfig = { | ||
editableContent: false, | ||
displayReminderText: true, | ||
doubleFacedOnTwoCards: true | ||
} | ||
|
||
export const resultsConfig = reactive(defaultResultsConfig) | ||
|
||
// Load from local storage on start | ||
loadConfigFromLocalStorage() | ||
|
||
// Store in local storage when config changes | ||
watch(resultsConfig, config => { | ||
localStorage.setItem('resultsConfig', JSON.stringify(config)) | ||
}) | ||
|
||
function loadConfigFromLocalStorage() { | ||
const storedRawConfig = localStorage.getItem('resultsConfig') | ||
|
||
if (storedRawConfig) { | ||
const storedConfig = JSON.parse(storedRawConfig) | ||
|
||
if (storedConfig.editableContent !== undefined) { | ||
resultsConfig.editableContent = storedConfig.editableContent | ||
} | ||
if (storedConfig.displayReminderText !== undefined) { | ||
resultsConfig.displayReminderText = storedConfig.displayReminderText | ||
} | ||
if (storedConfig.doubleFacedOnTwoCards !== undefined) { | ||
resultsConfig.doubleFacedOnTwoCards = storedConfig.doubleFacedOnTwoCards | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* { | ||
font-family: 'Open Sans', sans-serif; | ||
} |