-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from nnivxix/feat/higlight-code
Feat/highlight code
- Loading branch information
Showing
13 changed files
with
217 additions
and
82 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,23 +1,50 @@ | ||
<script setup> | ||
import { ref } from "vue"; | ||
import Switch from "./Switch.vue"; | ||
/** @type {import('@/types').ExampleJsonProp} */ | ||
const { json } = defineProps({ | ||
json: Object, | ||
}); | ||
</script> | ||
<template> | ||
<pre | ||
class="border border-gray-500 border-dashed p-3 rounded-md whitespace-pre-wrap" | ||
v-if="json" | ||
>{{ json }} | ||
</pre | ||
> | ||
<pre class="border border-gray-500 border-dashed p-3 rounded-md" v-else> | ||
const showJson = ref(true); | ||
const example = ` | ||
{ | ||
"id": "", | ||
"name": "", | ||
"description": "", | ||
"todos": [] | ||
} | ||
</pre | ||
> | ||
}`; | ||
</script> | ||
<template> | ||
<div> | ||
<template v-if="json"> | ||
<div class="flex gap-3 items-center py-3"> | ||
<Switch v-model:modelValue="showJson" id="show_json" /> | ||
<label for="show_json"> Show json format </label> | ||
</div> | ||
<highlightjs | ||
:code="JSON.stringify(json, null, 2)" | ||
v-if="showJson" | ||
class="border border-gray-500 border-dashed p-3 rounded-md whitespace-pre-wrap" | ||
> | ||
</highlightjs> | ||
<div v-else> | ||
<TodoItem | ||
v-for="(todo, index) in json.todos" | ||
:key="index" | ||
:todo="todo" | ||
:preview="true" | ||
/> | ||
</div> | ||
</template> | ||
<template v-else> | ||
<highlightjs | ||
:code="example" | ||
lang="json" | ||
class="border border-gray-500 border-dashed p-3 rounded-md whitespace-pre-wrap" | ||
> | ||
</highlightjs> | ||
</template> | ||
</div> | ||
</template> |
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,54 @@ | ||
<script setup> | ||
import { ref, watch, defineProps, defineEmits } from "vue"; | ||
const props = defineProps({ | ||
modelValue: { | ||
type: Boolean, | ||
required: true, | ||
}, | ||
id: { | ||
type: String, | ||
}, | ||
}); | ||
const emit = defineEmits(["update:modelValue"]); | ||
const checked = ref(props.modelValue); | ||
watch( | ||
() => props.modelValue, | ||
(newValue) => { | ||
checked.value = newValue; | ||
} | ||
); | ||
const toggle = () => { | ||
checked.value = !checked.value; | ||
emit("update:modelValue", checked.value); | ||
}; | ||
</script> | ||
<template> | ||
<label class="relative inline-flex items-center cursor-pointer"> | ||
<input | ||
type="checkbox" | ||
class="sr-only" | ||
:checked="checked" | ||
@change="toggle" | ||
:id="props.id" | ||
/> | ||
<div | ||
:class="{ | ||
'bg-[#032836]': checked, | ||
'bg-gray-300': !checked, | ||
}" | ||
class="w-12 h-7 py-1 rounded-full transition-colors duration-300 ease-in-out" | ||
> | ||
<span | ||
:class="{ | ||
'translate-x-6': checked, | ||
'translate-x-1': !checked, | ||
}" | ||
class="inline-block w-5 h-5 py-1 transform bg-white rounded-full transition-transform" | ||
></span> | ||
</div> | ||
</label> | ||
</template> |
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
Oops, something went wrong.