Skip to content

Commit 2f47dd4

Browse files
fix: simplify copyright component styles and structure (#612)
1 parent 178bc3c commit 2f47dd4

3 files changed

Lines changed: 53 additions & 52 deletions

File tree

app/components/VCopyright.vue

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<script setup lang="ts">
22
import type { ThemeProps } from '~~/types/theme'
33
4-
const props = defineProps<{
4+
defineProps<{
55
content?: string
66
} & ThemeProps>()
77
8-
const { themeClass } = useTheme({ props })
9-
108
const id = useId()
119
1210
const isExpanded = ref(false)
@@ -34,7 +32,7 @@ function onTouchEnd() {
3432

3533
<template>
3634
<div
37-
:class="[$style.root, themeClass]"
35+
:class="$style.root"
3836
:aria-label="$t('copyright.aria_label')"
3937
aria-live="polite"
4038
@mouseleave="onMouseLeave"
@@ -65,55 +63,43 @@ function onTouchEnd() {
6563
</template>
6664

6765
<style lang="scss" module>
68-
@use 'assets/scss/mixins/theme' as *;
69-
70-
$leave-delay: 0.1s;
71-
7266
.root {
73-
position: absolute;
74-
right: var(--v-copyright-right, 16px);
75-
bottom: var(--v-copyright-bottom, 16px);
76-
display: flex;
77-
max-width: 276px;
78-
flex-direction: column-reverse;
79-
border: 1px solid var(--v-copyright-border-color, transparent);
80-
border-radius: 4px;
81-
transition-delay: $leave-delay;
82-
transition-duration: 0.2s;
83-
transition-property: border-color, background-color;
84-
85-
@include theme-variants('copyright' 'colors-surface-primary');
86-
87-
&:has(.button[aria-expanded="false"]) {
88-
pointer-events: none;
89-
}
90-
91-
&:has(.button[aria-expanded="true"]) {
92-
--v-copyright-border-color: var(--colors-copyright-border-dialog, rgb(1, 1, 1, 15%));
93-
94-
background-color: var(--colors-surface-primary, #FFF);
95-
transition-delay: initial;
96-
}
67+
display: grid;
68+
justify-content: end;
69+
row-gap: 6px;
9770
}
9871
9972
.button {
100-
align-self: flex-end;
101-
pointer-events: all;
102-
103-
&:focus {
104-
outline-offset: 0;
105-
}
73+
grid-column: 1;
74+
grid-row: 2;
75+
justify-self: end;
10676
}
10777
10878
.content {
79+
max-width: 276px;
80+
padding: var(--spacing-2xs);
81+
border: 1PX solid #ccc;
82+
border-radius: 4PX;
83+
background: #fff;
84+
color: #000;
85+
grid-column: 1;
86+
grid-row: 1;
10987
opacity: 0;
110-
transition-delay: $leave-delay;
111-
transition-duration: 0.2s;
112-
transition-property: opacity;
88+
transition-delay: 0s, 0.2s;
89+
transition-duration: 0.2s, 0s;
90+
transition-property: opacity, visibility;
91+
visibility: hidden;
92+
93+
p {
94+
&:first-child {
95+
margin: 0;
96+
}
97+
}
11398
11499
.button[aria-expanded="true"] + & {
115100
opacity: 1;
116-
transition-delay: initial;
101+
transition-delay: 0s, 0s;
102+
visibility: inherit;
117103
}
118104
}
119105
</style>

app/components/VCopyrightButton.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,22 @@ defineProps<{
1616
.root {
1717
position: relative;
1818
display: flex;
19-
min-width: var(--v-copyright-button-min-width, 24px);
20-
min-height: var(--v-copyright-button-min-height, 24px);
2119
align-items: center;
2220
justify-content: center;
2321
border: none;
24-
border-radius: 50vmax;
22+
border: 1px solid #ccc;
23+
border-radius: 4PX;
24+
background: #fff;
2525
text-decoration: initial;
2626
27-
&::after {
28-
position: absolute;
29-
width: max(100%, 52px); // Taller clickable zone on mobile
30-
height: max(100%, 52px); // Taller clickable zone on mobile
31-
content: '';
27+
// Taller clickable zone on mobile
28+
@media (hover: none) {
29+
&::after {
30+
position: absolute;
31+
width: max(100%, 52px);
32+
height: max(100%, 52px);
33+
content: '';
34+
}
3235
}
3336
}
3437
</style>

stories/app/components/VCopyright/Default.stories.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
<NuxtStory>
33
<NuxtStoryVariant title="Content - prop">
44
<div :class="$style.container">
5-
<VCopyright content="Lorem ipsum" />
5+
<VCopyright
6+
content="Lorem ipsum"
7+
:class="$style.copyright"
8+
/>
69
</div>
710
</NuxtStoryVariant>
811
<NuxtStoryVariant title="Content - default slot">
912
<div :class="$style.container">
10-
<VCopyright v-slot="{ id, itemClass, isExpanded }">
13+
<VCopyright
14+
v-slot="{ id, itemClass, isExpanded }"
15+
:class="$style.copyright"
16+
>
1117
<span
1218
:id="id"
1319
:class="itemClass"
@@ -28,4 +34,10 @@
2834
height: 100px;
2935
background-color: lightgrey;
3036
}
37+
38+
.copyright {
39+
position: absolute;
40+
right: 12px;
41+
bottom: 12px;
42+
}
3143
</style>

0 commit comments

Comments
 (0)