Skip to content

Commit 2909875

Browse files
committed
feat(list): create list buttons for list quick actions
1 parent 4853eb0 commit 2909875

File tree

5 files changed

+99
-13
lines changed

5 files changed

+99
-13
lines changed
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<script setup lang="ts">
2+
import { type ButtonProps, NButton } from 'naive-ui';
3+
4+
const { buttonProps } = defineProps<{
5+
buttonProps?: ButtonProps;
6+
disabled?: boolean;
7+
}>();
8+
9+
const emit = defineEmits<{
10+
(e: 'onClick', event: MouseEvent): void;
11+
}>();
12+
13+
const onClick = (e: MouseEvent) => {
14+
e.preventDefault();
15+
e.stopPropagation();
16+
emit('onClick', e);
17+
};
18+
</script>
19+
20+
<template>
21+
<NButton
22+
class="list-button"
23+
quaternary
24+
v-bind="buttonProps"
25+
@click="onClick"
26+
@keydown.enter="onClick"
27+
>
28+
<slot />
29+
</NButton>
30+
</template>
31+
32+
<style scoped lang="scss">
33+
.list-button {
34+
--color: var(--bg-black-80);
35+
--progress: 100%;
36+
37+
display: flex;
38+
flex: 1 1 auto;
39+
box-sizing: border-box;
40+
min-width: min(20vw, 10rem);
41+
padding-left: 20%;
42+
background: linear-gradient(
43+
to right,
44+
transparent 0%,
45+
var(--color) var(--progress)
46+
) !important;
47+
/* stylelint-disable custom-property-no-missing-var-function -- custom property */
48+
transition:
49+
--color 0.25s var(--n-bezier),
50+
--progress 0.25s var(--n-bezier);
51+
52+
// stylelint-disable-next-line selector-class-pattern -- framework override
53+
&:not(.n-button--disabled) {
54+
&:focus-visible,
55+
&:hover {
56+
--color: var(--bg-black-90);
57+
--progress: 70%;
58+
}
59+
60+
&:active {
61+
--color: var(--bg-black);
62+
--progress: 50%;
63+
}
64+
}
65+
}
66+
</style>

src/components/common/list/ListItem.vue

+18-8
Original file line numberDiff line numberDiff line change
@@ -300,28 +300,33 @@ const onClick = (e: MouseEvent | KeyboardEvent) =>
300300
$transition: 0.3s var(--n-bezier)
301301
);
302302
303+
position: relative;
303304
flex: 1 1 auto;
304305
margin: 0.25rem 0;
305306
padding: 0.3rem 0.25rem 0.25rem;
306307
overflow: hidden;
307308
border-radius: 0.75rem;
308309
309-
&:active {
310-
background-color: var(--bg-color-30);
311-
box-shadow: var(--inset-box-shadow);
312-
}
313-
314310
&-buttons {
315311
position: absolute;
316312
right: 0;
317313
z-index: layers.$in-front;
318-
transition: translate 0.25s var(--n-bezier);
319-
translate: 150%;
314+
box-sizing: border-box;
315+
height: calc(var(--list-item-height, 100%) - 0.5rem);
316+
opacity: 0;
317+
transition:
318+
translate 0.25s var(--n-bezier),
319+
opacity 0.25s var(--n-bezier);
320+
translate: 100%;
321+
322+
&:focus-within {
323+
transition: opacity 0.25s var(--n-bezier);
324+
}
320325
321326
&:focus-within,
322327
&.open {
328+
opacity: 1;
323329
translate: 0;
324-
display: flex;
325330
}
326331
327332
:first-child {
@@ -346,6 +351,11 @@ const onClick = (e: MouseEvent | KeyboardEvent) =>
346351
backdrop-filter: var(--bg-blur-hover);
347352
}
348353
354+
.content .tile:active:not(:has(button:active)) {
355+
background-color: var(--bg-color-30);
356+
box-shadow: var(--inset-box-shadow);
357+
}
358+
349359
.header {
350360
position: absolute;
351361
top: 0;

src/components/container/ContainerComponent.ce.vue

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
NNotificationProvider,
1010
} from 'naive-ui';
1111
12-
import { computed, onBeforeMount, ref } from 'vue';
12+
import { computed, ref } from 'vue';
1313
1414
import LoadingBarProvider from '~/components/container/LoadingBarProvider.vue';
1515
import MessageProvider from '~/components/container/MessageProvider.vue';
@@ -19,7 +19,7 @@ import { useAppStateStoreRefs } from '~/stores/app-state.store';
1919
import { useWatchingStoreRefs } from '~/stores/data/watching.store';
2020
import { useExtensionSettingsStoreRefs } from '~/stores/settings/extension.store';
2121
import { lazyComponent } from '~/utils/lazy.utils';
22-
import { addCustomProgressProperty } from '~/utils/style.utils';
22+
import '~/styles/properties.css';
2323
2424
const AppComponent = lazyComponent(() => import('~/components/AppComponent.vue'));
2525
@@ -34,8 +34,6 @@ const { drawer, open, dropdown } = NavbarService;
3434
const { enabledRoutes, backgroundColor, brand } = useExtensionSettingsStoreRefs();
3535
const { root, floating, reverse } = useAppStateStoreRefs();
3636
const { isWatching } = useWatchingStoreRefs();
37-
38-
onBeforeMount(() => addCustomProgressProperty());
3937
</script>
4038

4139
<template>

src/styles/mixin.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
backdrop-filter: blur($blur);
1313
transition: $transition-prop $transition;
1414

15+
&:focus-within,
1516
&:active,
1617
&:hover {
1718
background: $to;
@@ -21,13 +22,13 @@
2122
}
2223
}
2324

24-
2525
@mixin hover-background-only(
2626
$from: var(--custom-bg-color, var(--bg-color)),
2727
$to: var(--custom-bg-color-hover, var(--bg-color-hover)),
2828
) {
2929
background: $from;
3030

31+
&:focus-within,
3132
&:active,
3233
&:hover {
3334
background: $to;

src/styles/properties.css

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@property --color {
2+
syntax: '<color>';
3+
initial-value: transparent;
4+
inherits: false;
5+
}
6+
7+
@property --progress {
8+
syntax: '<percentage>';
9+
inherits: true;
10+
initial-value: 0%;
11+
}

0 commit comments

Comments
 (0)