File tree 8 files changed +66
-7
lines changed
8 files changed +66
-7
lines changed Original file line number Diff line number Diff line change
1
+ <script setup lang="ts">
2
+ import type { LineHeight } from ' ~/composables/settings'
3
+
4
+ const userSettings = useUserSettings ()
5
+
6
+ const sizes: LineHeight [] = [' narrow' , ' normal' , ' wide' ]
7
+
8
+ const currentSize = computed (() => userSettings .value .lineHeight || sizes [1 ])
9
+
10
+ function setLineHeight(size : LineHeight ) {
11
+ userSettings .value .lineHeight = size
12
+ }
13
+ </script >
14
+
15
+ <template >
16
+ <section space-y-2 >
17
+ <h2 id =" interface-lh" font-medium >
18
+ {{ $t('settings.interface.line_height') }}
19
+ </h2 >
20
+ <div flex =" ~ gap4 wrap" p2 role =" group" aria-labelledby =" interface-lh" >
21
+ <button
22
+ v-for =" size in sizes"
23
+ :key =" size"
24
+ type =" button"
25
+ btn-text flex-1 flex =" ~ gap-1 center" p4 border =" ~ base rounded" bg-base ws-nowrap
26
+ :aria-pressed =" currentSize === size ? 'true' : 'false'"
27
+ :class =" currentSize === size ? 'pointer-events-none' : 'filter-saturate-0'"
28
+ @click =" setLineHeight(size)"
29
+ >
30
+ {{ $t(`settings.interface.${size}`) }}
31
+ </button >
32
+ </div >
33
+ </section >
34
+ </template >
Original file line number Diff line number Diff line change @@ -26,21 +26,25 @@ const vnode = computed(() => {
26
26
inReplyToStatus: newer ,
27
27
})
28
28
})
29
+
30
+ const userSettings = useUserSettings ()
31
+ const lineHeight = userSettings .value .lineHeight
29
32
</script >
30
33
31
34
<template >
32
35
<div class =" status-body" whitespace-pre-wrap break-words :class =" { 'with-action': withAction }" relative >
33
36
<span
34
37
v-if =" status.content"
35
- class =" content-rich line-compact" dir =" auto"
38
+ class =" content-rich" :class =" [`line-height-${lineHeight}`]"
39
+ dir =" auto"
36
40
:lang =" ('language' in status && status.language) || undefined"
37
41
>
38
42
<component :is =" vnode" v-if =" vnode" />
39
43
</span >
40
44
<div v-else />
41
45
<template v-if =" translation .visible " >
42
46
<div my2 h-px border =" b base" bg-base />
43
- <ContentRich v-if =" translation.success" class =" line-compact " :content =" translation.text" :emojis =" status.emojis" />
47
+ <ContentRich v-if =" translation.success" class =" content-rich " :class = " [` line-height-${lineHeight}`] " :content =" translation.text" :emojis =" status.emojis" />
44
48
<div v-else text-red-4 >
45
49
Error: {{ translation.error }}
46
50
</div >
Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ const vnodeCode = computed(() => {
47
47
})
48
48
return vnode
49
49
})
50
+
51
+ const userSettings = useUserSettings ()
52
+ const lineHeight = userSettings .value .lineHeight
50
53
</script >
51
54
52
55
<template >
@@ -60,7 +63,7 @@ const vnodeCode = computed(() => {
60
63
pb-2
61
64
>
62
65
<div whitespace-pre-wrap break-words >
63
- <span v-if =" vnodeCode" class =" content-rich line-compact " dir =" auto" >
66
+ <span v-if =" vnodeCode" class =" content-rich" :class = " [` line-height-${lineHeight}`] " dir =" auto" >
64
67
<component :is =" vnodeCode" />
65
68
</span >
66
69
</div >
Original file line number Diff line number Diff line change 1
- import { DEFAULT_FONT_SIZE } from '~/constants'
1
+ import { DEFAULT_FONT_SIZE , DEFAULT_LINE_HEIGHT } from '~/constants'
2
2
3
3
export type FontSize = `${number } px`
4
4
5
+ export type LineHeight = 'narrow' | 'normal' | 'wide'
6
+
5
7
// Temporary type for backward compatibility
6
8
export type OldFontSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
7
9
@@ -38,6 +40,7 @@ export interface UserSettings {
38
40
preferences : Partial < PreferencesSettings >
39
41
colorMode ?: ColorMode
40
42
fontSize : FontSize
43
+ lineHeight : LineHeight
41
44
language : string
42
45
disabledTranslationLanguages : string [ ]
43
46
themeColors ?: ThemeColors
@@ -94,6 +97,7 @@ export function getDefaultUserSettings(locales: string[]): UserSettings {
94
97
return {
95
98
language : getDefaultLanguage ( locales ) ,
96
99
fontSize : DEFAULT_FONT_SIZE ,
100
+ lineHeight : DEFAULT_LINE_HEIGHT ,
97
101
disabledTranslationLanguages : [ ] ,
98
102
preferences : DEFAULT__PREFERENCES_SETTINGS ,
99
103
}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export const APP_NAME = 'Elk'
4
4
5
5
export const DEFAULT_POST_CHARS_LIMIT = 500
6
6
export const DEFAULT_FONT_SIZE = '15px'
7
+ export const DEFAULT_LINE_HEIGHT = 'normal'
7
8
8
9
export const ELK_PAGE_LIFECYCLE_FROZEN = 'elk-frozen'
9
10
Original file line number Diff line number Diff line change 462
462
"font_size" : " Font Size" ,
463
463
"label" : " Interface" ,
464
464
"light_mode" : " Light" ,
465
+ "line_height" : " Line Height" ,
466
+ "narrow" : " Narrow" ,
467
+ "normal" : " Normal" ,
465
468
"system_mode" : " System" ,
466
- "theme_color" : " Theme Color"
469
+ "theme_color" : " Theme Color" ,
470
+ "wide" : " Wide"
467
471
},
468
472
"language" : {
469
473
"display_language" : " Display Language" ,
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ useHydratedHead({
15
15
</template >
16
16
<div px-6 pt-3 pb-6 flex =" ~ col gap6" >
17
17
<SettingsFontSize />
18
+ <SettingsLineHeight />
18
19
<SettingsColorMode />
19
20
<SettingsThemeColors />
20
21
<SettingsBottomNav />
Original file line number Diff line number Diff line change @@ -125,8 +125,16 @@ em-emoji-picker {
125
125
}
126
126
}
127
127
128
- .line-compact {
129
- line-height : calc (4 / 3 * 1em );
128
+ .line-height-narrow {
129
+ line-height : 1.15 ;
130
+ }
131
+
132
+ .line-height-normal {
133
+ line-height : calc (4 / 3 );
134
+ }
135
+
136
+ .line-height-wide {
137
+ line-height : 1.5 ;
130
138
}
131
139
132
140
.content-editor {
You can’t perform that action at this time.
0 commit comments