summaryrefslogtreecommitdiff
path: root/src/client/app/common/views/widgets/memo.vue
blob: 30f0d3b0090b39176faef1dcc779c2d5a6f64579 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
<div class="mkw-memo">
	<mk-widget-container :show-header="!props.compact">
		<template slot="header">%fa:R sticky-note%%i18n:@title%</template>

		<div class="mkw-memo--body">
			<textarea v-model="text" placeholder="%i18n:@memo%" @input="onChange"></textarea>
			<button @click="saveMemo" :disabled="!changed">%i18n:@save%</button>
		</div>
	</mk-widget-container>
</div>
</template>

<script lang="ts">
import define from '../../define-widget';

export default define({
	name: 'memo',
	props: () => ({
		compact: false
	})
}).extend({
	data() {
		return {
			text: null,
			changed: false
		};
	},

	created() {
		this.text = this.$store.state.settings.memo;

		this.$watch('$store.state.settings.memo', text => {
			this.text = text;
		});
	},

	methods: {
		func() {
			this.props.compact = !this.props.compact;
			this.save();
		},

		onChange() {
			this.changed = true;
		},

		saveMemo() {
			this.$store.dispatch('settings/set', {
				key: 'memo',
				value: this.text
			});
			this.changed = false;
		}
	}
});
</script>

<style lang="stylus" scoped>
@import '~const.styl'

root(isDark)
	.mkw-memo--body
		padding-bottom 28px + 16px

		> textarea
			display block
			width 100%
			max-width 100%
			min-width 100%
			padding 16px
			color isDark ? #fff : #222
			background isDark ? #282c37 : #fff
			border none
			border-bottom solid 1px isDark ? #1c2023 : #eee
			border-radius 0

		> button
			display block
			position absolute
			bottom 8px
			right 8px
			margin 0
			padding 0 10px
			height 28px
			color $theme-color-foreground
			background $theme-color !important
			outline none
			border none
			border-radius 4px
			transition background 0.1s ease
			cursor pointer

			&:hover
				background lighten($theme-color, 10%) !important

			&:active
				background darken($theme-color, 10%) !important
				transition background 0s ease

			&:disabled
				opacity 0.7
				cursor default

.mkw-memo[data-darkmode]
	root(true)

.mkw-memo:not([data-darkmode])
	root(false)

</style>