fix: clip progress bar width to 100% (#892)
* fix: course progress bar should not go beyond 100% width * refactor: progress bar component should include outer body div
This commit is contained in:
committed by
GitHub
parent
d4a15ade98
commit
326c77cdb9
@@ -80,15 +80,12 @@
|
||||
<div class="short-introduction">
|
||||
{{ course.short_introduction }}
|
||||
</div>
|
||||
<div
|
||||
|
||||
<ProgressBar
|
||||
v-if="user && course.membership"
|
||||
class="w-full bg-gray-200 rounded-full h-1 mb-2"
|
||||
>
|
||||
<div
|
||||
class="bg-gray-900 h-1 rounded-full"
|
||||
:style="{ width: Math.ceil(course.membership.progress) + '%' }"
|
||||
></div>
|
||||
</div>
|
||||
:progress="course.membership.progress"
|
||||
/>
|
||||
|
||||
<div v-if="user && course.membership" class="text-sm mb-4">
|
||||
{{ Math.ceil(course.membership.progress) }}% completed
|
||||
</div>
|
||||
@@ -120,6 +117,7 @@ import UserAvatar from '@/components/UserAvatar.vue'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { Badge, Tooltip } from 'frappe-ui'
|
||||
import CourseInstructors from '@/components/CourseInstructors.vue'
|
||||
import ProgressBar from '@/components/ProgressBar.vue'
|
||||
|
||||
const { user } = sessionStore()
|
||||
|
||||
|
||||
24
frontend/src/components/ProgressBar.vue
Normal file
24
frontend/src/components/ProgressBar.vue
Normal file
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<div class="w-full bg-gray-200 rounded-full h-1 my-2">
|
||||
<div
|
||||
class="bg-gray-900 h-1 rounded-full"
|
||||
:style="{ width: progressBarWidth }"
|
||||
></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
progress: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
})
|
||||
|
||||
const progressBarWidth = computed(() => {
|
||||
const formattedPercentage = Math.min(Math.ceil(props.progress), 100)
|
||||
return `${formattedPercentage}%`
|
||||
})
|
||||
</script>
|
||||
@@ -162,17 +162,11 @@
|
||||
<div v-if="user && lesson.data.membership" class="text-sm mt-3">
|
||||
{{ Math.ceil(lesson.data.membership.progress) }}% completed
|
||||
</div>
|
||||
<div
|
||||
|
||||
<ProgressBar
|
||||
v-if="user && lesson.data.membership"
|
||||
class="w-full bg-gray-200 rounded-full h-1 my-2"
|
||||
>
|
||||
<div
|
||||
class="bg-gray-900 h-1 rounded-full"
|
||||
:style="{
|
||||
width: Math.ceil(lesson.data.membership.progress) + '%',
|
||||
}"
|
||||
></div>
|
||||
</div>
|
||||
:progress="lesson.data.membership.progress"
|
||||
/>
|
||||
</div>
|
||||
<CourseOutline
|
||||
:courseName="courseName"
|
||||
@@ -195,6 +189,7 @@ import { getEditorTools } from '../utils'
|
||||
import EditorJS from '@editorjs/editorjs'
|
||||
import LessonContent from '@/components/LessonContent.vue'
|
||||
import CourseInstructors from '@/components/CourseInstructors.vue'
|
||||
import ProgressBar from '@/components/ProgressBar.vue'
|
||||
|
||||
const user = inject('$user')
|
||||
const route = useRoute()
|
||||
|
||||
Reference in New Issue
Block a user