blog mvp completed

This commit is contained in:
mahdiarghyani
2025-11-09 15:31:41 +03:30
parent c7e5eb0713
commit d2333d3db2
24 changed files with 1171 additions and 175 deletions
+42
View File
@@ -0,0 +1,42 @@
<template>
<div :class="alertClass" class="my-4 flex items-center gap-2 rounded-lg px-4 py-3">
<UIcon :name="icon" class="h-5 w-5 flex-shrink-0" />
<div class="flex-1 text-sm">
<slot />
</div>
</div>
</template>
<script setup lang="ts">
const props = withDefaults(
defineProps<{
type?: 'info' | 'warning' | 'success' | 'error'
}>(),
{
type: 'info'
}
)
const typeConfig = {
info: {
icon: 'i-heroicons-information-circle',
class: 'bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-200'
},
warning: {
icon: 'i-heroicons-exclamation-triangle',
class: 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-200'
},
success: {
icon: 'i-heroicons-check-circle',
class: 'bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-200'
},
error: {
icon: 'i-heroicons-x-circle',
class: 'bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-200'
}
}
const config = computed(() => typeConfig[props.type])
const icon = computed(() => config.value.icon)
const alertClass = computed(() => config.value.class)
</script>
+63
View File
@@ -0,0 +1,63 @@
<template>
<UCard :ui="{
base: 'my-6',
body: { padding: 'p-4 sm:p-5' },
ring: 'ring-2',
divide: ''
}" :class="cardClass">
<div class="flex items-start gap-3">
<UIcon :name="icon" :class="iconClass" class="mt-0.5 h-5 w-5 flex-shrink-0" />
<div class="flex-1">
<h4 v-if="title" class="mb-2 font-semibold" :class="titleClass">{{ title }}</h4>
<div class="prose-sm dark:prose-invert">
<slot />
</div>
</div>
</div>
</UCard>
</template>
<script setup lang="ts">
const props = withDefaults(
defineProps<{
type?: 'info' | 'warning' | 'success' | 'error'
title?: string
}>(),
{
type: 'info'
}
)
const typeConfig = {
info: {
icon: 'i-heroicons-information-circle',
cardClass: 'ring-blue-500/20 bg-blue-50 dark:bg-blue-950/20',
iconClass: 'text-blue-600 dark:text-blue-400',
titleClass: 'text-blue-900 dark:text-blue-100'
},
warning: {
icon: 'i-heroicons-exclamation-triangle',
cardClass: 'ring-yellow-500/20 bg-yellow-50 dark:bg-yellow-950/20',
iconClass: 'text-yellow-600 dark:text-yellow-400',
titleClass: 'text-yellow-900 dark:text-yellow-100'
},
success: {
icon: 'i-heroicons-check-circle',
cardClass: 'ring-green-500/20 bg-green-50 dark:bg-green-950/20',
iconClass: 'text-green-600 dark:text-green-400',
titleClass: 'text-green-900 dark:text-green-100'
},
error: {
icon: 'i-heroicons-x-circle',
cardClass: 'ring-red-500/20 bg-red-50 dark:bg-red-950/20',
iconClass: 'text-red-600 dark:text-red-400',
titleClass: 'text-red-900 dark:text-red-100'
}
}
const config = computed(() => typeConfig[props.type])
const icon = computed(() => config.value.icon)
const cardClass = computed(() => config.value.cardClass)
const iconClass = computed(() => config.value.iconClass)
const titleClass = computed(() => config.value.titleClass)
</script>
+91
View File
@@ -0,0 +1,91 @@
<script setup lang="ts">
const props = defineProps<{
code?: string
language?: string
filename?: string
highlights?: number[]
class?: string
}>()
const { t } = useI18n()
const copied = ref(false)
const isHovered = ref(false)
// Copy code to clipboard
const copyCode = async () => {
if (props.code) {
try {
await navigator.clipboard.writeText(props.code)
copied.value = true
setTimeout(() => {
copied.value = false
}, 2000)
} catch (err) {
console.error('Failed to copy code:', err)
}
}
}
// Get language label
const languageLabel = computed(() => {
if (!props.language) return null
const languageMap: Record<string, string> = {
js: 'JavaScript',
ts: 'TypeScript',
vue: 'Vue',
html: 'HTML',
css: 'CSS',
scss: 'SCSS',
bash: 'Bash',
sh: 'Shell',
json: 'JSON',
md: 'Markdown',
yaml: 'YAML',
python: 'Python',
py: 'Python'
}
return languageMap[props.language] || props.language.toUpperCase()
})
</script>
<template>
<div style="position: relative; margin: 1.5rem 0;" @mouseenter="isHovered = true" @mouseleave="isHovered = false">
<!-- Header with filename and language -->
<div v-if="filename || language"
style="display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 1rem; background-color: #1f2937; border-bottom: 1px solid #374151; border-top-left-radius: 0.5rem; border-top-right-radius: 0.5rem;">
<div style="display: flex; align-items: center; gap: 0.75rem;">
<span v-if="filename" style="font-size: 0.875rem; color: #d1d5db; font-family: monospace;">
{{ filename }}
</span>
<span v-if="language && !filename"
style="font-size: 0.75rem; color: #9ca3af; text-transform: uppercase; font-weight: 600;">
{{ languageLabel }}
</span>
</div>
</div>
<!-- Code block -->
<div style="position: relative;">
<pre :class="props.class" style="overflow-x: auto; padding: 1rem; font-size: 0.875rem; margin: 0;"><slot /></pre>
<!-- Copy button -->
<button type="button" :aria-label="copied ? t('blog.codeCopied') : t('blog.copyCode')" :style="{
position: 'absolute',
top: '0.75rem',
right: '0.75rem',
padding: '0.5rem',
borderRadius: '0.375rem',
backgroundColor: 'rgba(55, 65, 81, 0.5)',
border: 'none',
cursor: 'pointer',
transition: 'all 0.2s',
opacity: isHovered || copied ? '1' : '0'
}" @click="copyCode">
<UIcon :name="copied ? 'i-heroicons-check' : 'i-heroicons-clipboard-document'"
style="width: 1rem; height: 1rem; color: rgb(209, 213, 219);" />
</button>
</div>
</div>
</template>