Skip to content

Commit 691dea0

Browse files
committed
feat: support watermark
1 parent 8f118db commit 691dea0

File tree

12 files changed

+101
-5
lines changed

12 files changed

+101
-5
lines changed

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
65
<title>Code - Estéban Soubiran</title>
76
</head>
87
<body>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"shiki": "^2.1.0",
2424
"tailwind-variants": "^0.3.1",
2525
"tailwindcss": "^4.0.0",
26+
"unplugin-fonts": "^1.3.1",
2627
"vue": "^3.5.13"
2728
},
2829
"devDependencies": {

pnpm-lock.yaml

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/vite.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/App.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import Watermark from '@/code/components/Watermark.vue';
23
import type { Language } from '@/code/types/language'
34
import type { Size } from '@/code/types/size'
45
import { camera as cameraIcon, moon as moonIcon, sun as sunIcon } from '@/icons'
@@ -7,6 +8,8 @@ const app = tv({
78
slots: {
89
base: 'w-screen h-screen p-4 bg-[var(--ui-bg)] text-[var(--ui-text)] flex flex-col items-center justify-center gap-8',
910
container: 'w-full flex flex-col gap-8',
11+
wrapper: 'relative',
12+
watermark: 'absolute inset-x-0 bottom-6 text-center translate-y-1/2',
1013
actions: 'absolute bottom-8 inset-x-0 max-w-screen-sm mx-auto w-full flex justify-between gap-2',
1114
},
1215
variants: {
@@ -62,8 +65,10 @@ const ui = computed(() => app({
6265
<template>
6366
<main :class="ui.base()">
6467
<div :class="ui.container()">
65-
<EditorWrapper ref="editor">
68+
<EditorWrapper ref="editor" :class="ui.wrapper()">
6669
<Editor />
70+
71+
<Watermark :class="ui.watermark()" />
6772
</EditorWrapper>
6873

6974
<div :class="ui.actions()">

src/code/components/Watermark.vue

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<script lang="ts">
2+
const watermark = tv({
3+
base: 'text-sm text-[var(--ui-bg-elevated)] font-sofia',
4+
})
5+
6+
export interface WatermarkProps {
7+
text?: string
8+
class?: any
9+
}
10+
export interface WatermarkEmits {}
11+
export interface WatermarkSlots {}
12+
</script>
13+
14+
<script lang="ts" setup>
15+
const props = defineProps<WatermarkProps>()
16+
defineEmits<WatermarkEmits>()
17+
defineSlots<WatermarkSlots>()
18+
19+
const { watermark: text } = useCode()
20+
21+
const ui = computed(() => watermark({ class: props.class }))
22+
</script>
23+
24+
<template>
25+
<p :class="ui" v-if="text">
26+
{{ text }}
27+
</p>
28+
</template>

src/code/composables/useCode.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const size = ref<Size>(defaultSize)
88
const defaultLanguage = 'markdown'
99
const language = ref<Language>(defaultLanguage)
1010

11+
const watermark = ref<string | undefined>(undefined)
12+
1113
export function useCode() {
1214
const params = useUrlSearchParams<SearchParams>('history')
1315

@@ -26,9 +28,15 @@ export function useCode() {
2628
params.code = base64Encode(code.value)
2729
})
2830

31+
watermark.value = params.watermark
32+
watch(watermark, () => {
33+
params.watermark = watermark.value
34+
})
35+
2936
return {
3037
language,
3138
size,
3239
code,
40+
watermark,
3341
}
3442
}

src/code/types/search-params.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export interface SearchParams {
88
code?: string
99
language?: Language
1010
size?: Size
11+
watermark?: string
1112
}

src/main.css renamed to src/common/styles/main.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
@import "tailwindcss";
2-
@config "../tailwind.config.js";
2+
@config "../../../tailwind.config.js";
33
@import "./shiki.css";
44

5+
@theme {
6+
--font-sans: 'DM Sans', sans-serif;
7+
--font-sofia: 'Sofia sans', sans-serif;
8+
--font-mono: 'DM Mono', monospace;
9+
}
10+
511
:root {
612
--ui-text-dimmed: var(--color-neutral-400);
713
--ui-text-muted: var(--color-neutral-500);
File renamed without changes.

0 commit comments

Comments
 (0)