|
1 | 1 | <script lang="ts" setup>
|
2 | 2 | import { chromeRuntimeId } from '@dvcol/web-extension-utils/chrome/runtime';
|
3 |
| -import { NIcon, NSelect, NSwitch, type SelectOption } from 'naive-ui'; |
| 3 | +import { |
| 4 | + NButton, |
| 5 | + NButtonGroup, |
| 6 | + NIcon, |
| 7 | + NSelect, |
| 8 | + NSwitch, |
| 9 | + type SelectOption, |
| 10 | +} from 'naive-ui'; |
4 | 11 |
|
5 | 12 | import { type Component, computed, h, onBeforeMount, ref, watch } from 'vue';
|
6 | 13 |
|
| 14 | +import IconClose from '~/components/icons/IconCloseSmall.vue'; |
| 15 | +import IconPencil from '~/components/icons/IconPencil.vue'; |
| 16 | +
|
7 | 17 | import SettingsFormItem from '~/components/views/settings/SettingsFormItem.vue';
|
8 | 18 | import { pageSizeOptions, pageSizeOptionsWithZero } from '~/models/page-size.model';
|
9 | 19 | import { ProgressType } from '~/models/progress-type.model';
|
@@ -42,6 +52,7 @@ const {
|
42 | 52 | loadListsPageSize,
|
43 | 53 | progressType,
|
44 | 54 | enableRatings,
|
| 55 | + backgroundColor, |
45 | 56 | } = useExtensionSettingsStoreRefs();
|
46 | 57 |
|
47 | 58 | const { getIcon, fetchLists } = useListsStore();
|
@@ -119,10 +130,38 @@ const { extended: calendarExtended } = useCalendarStoreRefs();
|
119 | 130 | const { extended: historyExtended } = useHistoryStoreRefs();
|
120 | 131 |
|
121 | 132 | const container = ref();
|
| 133 | +const picker = ref<HTMLInputElement>(); |
| 134 | +const onColor = () => { |
| 135 | + picker.value?.focus(); |
| 136 | + picker.value?.click(); |
| 137 | +}; |
122 | 138 | </script>
|
123 | 139 |
|
124 | 140 | <template>
|
125 | 141 | <div ref="container" class="tabs-container">
|
| 142 | + <!-- Default tab --> |
| 143 | + <SettingsFormItem :label="i18n('label_default_tab')"> |
| 144 | + <div class="form-button"> |
| 145 | + <input ref="picker" v-model="backgroundColor" type="color" class="color-picker" /> |
| 146 | + <NButtonGroup |
| 147 | + class="color-picker-button-group" |
| 148 | + :style="{ '--color-picker': backgroundColor }" |
| 149 | + > |
| 150 | + <NButton round tertiary @click="onColor"> |
| 151 | + Picker |
| 152 | + <template #icon> |
| 153 | + <NIcon><IconPencil /></NIcon> |
| 154 | + </template> |
| 155 | + </NButton> |
| 156 | + <NButton circle tertiary type="error" @click="backgroundColor = 'transparent'"> |
| 157 | + <template #icon> |
| 158 | + <NIcon><IconClose /></NIcon> |
| 159 | + </template> |
| 160 | + </NButton> |
| 161 | + </NButtonGroup> |
| 162 | + </div> |
| 163 | + </SettingsFormItem> |
| 164 | + |
126 | 165 | <!-- Default tab -->
|
127 | 166 | <SettingsFormItem :label="i18n('label_default_tab')">
|
128 | 167 | <NSelect
|
@@ -331,6 +370,7 @@ const container = ref();
|
331 | 370 | flex-direction: column;
|
332 | 371 | gap: 1.5rem;
|
333 | 372 |
|
| 373 | + .form-button, |
334 | 374 | .form-switch {
|
335 | 375 | display: flex;
|
336 | 376 | flex: 1 1 auto;
|
@@ -378,4 +418,31 @@ const container = ref();
|
378 | 418 | .progress-type {
|
379 | 419 | width: 6rem;
|
380 | 420 | }
|
| 421 | +
|
| 422 | +.color-picker { |
| 423 | + width: 0; |
| 424 | + height: 2.5rem; |
| 425 | + padding: 0; |
| 426 | + border: none; |
| 427 | + border-radius: 0; |
| 428 | +
|
| 429 | + &-button-group { |
| 430 | + button { |
| 431 | + border: 2px solid var(--color-picker, transparent); |
| 432 | + transition: border-color 0.3s var(--n-bezier); |
| 433 | +
|
| 434 | + i { |
| 435 | + margin-left: -2px; |
| 436 | + } |
| 437 | + } |
| 438 | +
|
| 439 | + :first-child { |
| 440 | + border-right: none; |
| 441 | + } |
| 442 | +
|
| 443 | + :last-child { |
| 444 | + border-left: none; |
| 445 | + } |
| 446 | + } |
| 447 | +} |
381 | 448 | </style>
|
0 commit comments