Skip to content

Commit

Permalink
fix: disable test checkbox if no template & fallback to README if no …
Browse files Browse the repository at this point in the history
…code file
  • Loading branch information
ydcjeff committed Jun 3, 2021
1 parent 7132fb4 commit 4420be1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/components/FormCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
type="checkbox"
:id="checkboxId"
:required="required"
:disabled="noTemplate"
v-model="checked"
@change.prevent="saveChecked"
/>
Expand All @@ -18,7 +19,7 @@

<script>
import { ref, toRefs, computed } from 'vue'
import { saveConfig } from '../store.js'
import { saveConfig, store } from '../store.js'
export default {
props: {
Expand All @@ -42,6 +43,7 @@ export default {
const saveChecked = () => saveConfig(saveKey.value, checked.value)
const checkboxId = computed(() => saveKey.value + '-checkbox')
const isRequired = computed(() => (required.value ? '*' : ''))
const noTemplate = computed(() => !store.config.template)
return {
label,
Expand All @@ -50,7 +52,8 @@ export default {
checked,
saveChecked,
checkboxId,
isRequired
isRequired,
noTemplate
}
}
}
Expand Down
19 changes: 17 additions & 2 deletions src/components/PaneRight.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{ tab }}
</div>
</div>
<div class="right-pane-contexts" v-if="store.code[currentTab]">
<div class="right-pane-contexts" v-if="currentCode()">
<KeepAlive>
<CodeBlock :lang="getLang" :code="formattedCode()" />
</KeepAlive>
Expand Down Expand Up @@ -59,7 +59,22 @@ export default {
}
const getLang = computed(() => currentTab.value.split('.')[1])
const formattedCode = () => store.code[currentTab.value].trim()
return { store, currentTab, tabs, getLang, getFileType, formattedCode }
const currentCode = () => {
const code = store.code[currentTab.value]
if (code) {
return code
}
currentTab.value = 'README.md'
return store.code[currentTab.value]
}
return {
currentCode,
currentTab,
tabs,
getLang,
getFileType,
formattedCode
}
}
}
</script>
Expand Down

0 comments on commit 4420be1

Please sign in to comment.