Skip to content

Commit 157391a

Browse files
committed
Use CSS for colors of VWordPress and VHomeLink
1 parent c4acdf8 commit 157391a

File tree

17 files changed

+58
-69
lines changed

17 files changed

+58
-69
lines changed

frontend/src/components/VAudioTrack/VAudioTrack.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ const layoutBasedProps = computed(() =>
431431
"cursor-pointer",
432432
{
433433
"focus-visible:focus-bold-filled": props.layout === "box",
434-
"focus-slim-tx": props.layout === "row",
434+
"focus-visible:focus-slim-tx": props.layout === "row",
435435
},
436436
],
437437
}

frontend/src/components/VBanner/VNotificationBanner.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const iconClassNames = computed(() =>
6565
6666
const closeButtonClassNames = computed(() =>
6767
props.variant === "dark"
68-
? "focus-slim-tx-bg-complementary hover:bg-tertiary-hover"
68+
? "focus-visible:focus-slim-tx hover:bg-tertiary-hover"
6969
: {
7070
info: "hover:!bg-info-3",
7171
warning: "hover:!bg-warning-3",

frontend/src/components/VButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ watch(
225225
border: !isPlainDangerous,
226226
'focus-visible:outline-tx': isPlainDangerous,
227227
'focus-slim-filled': isFocusSlimFilled,
228-
'focus-slim-tx': isFocusSlimTx,
228+
'focus-visible:focus-slim-tx': isFocusSlimTx,
229229
},
230230
]"
231231
:aria-pressed="pressed"

frontend/src/components/VCheckbox/VCheckbox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const onChange = () => {
121121
'h-5',
122122
'w-5',
123123
'rounded-sm',
124-
'focus-slim-tx',
124+
'focus-visible:focus-slim-tx',
125125
'checked:focus-visible:border-bg-ring',
126126
]
127127
"

frontend/src/components/VFooter/VFooter.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const linkColumnHeight = computed(() => ({
9696
<!-- Locale chooser and WordPress affiliation graphic -->
9797
<div class="locale-and-wp flex flex-col justify-between">
9898
<template v-if="showThemeSwitcher">
99-
<VWordPressLink mode="light" />
99+
<VWordPressLink />
100100
<div class="flex flex-row items-center gap-6">
101101
<VLanguageSelect
102102
v-bind="languageProps"
@@ -110,7 +110,7 @@ const linkColumnHeight = computed(() => ({
110110
v-bind="languageProps"
111111
class="language max-w-full border-secondary"
112112
/>
113-
<VWordPressLink mode="light" />
113+
<VWordPressLink />
114114
</template>
115115
</div>
116116
</footer>

frontend/src/components/VHeader/VHeaderInternal.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ watch(route, () => {
7979
ref="nodeRef"
8080
class="main-header z-30 flex h-20 w-full items-stretch justify-between gap-x-2 border-b border-tx px-2 py-4 md:py-4 lg:pe-10 lg:ps-6"
8181
>
82-
<VHomeLink variant="dark" />
82+
<VHomeLink />
8383
<nav class="hidden lg:flex">
8484
<VPageLinks
8585
mode="light"
@@ -125,18 +125,18 @@ watch(route, () => {
125125
:hide="closePageMenu"
126126
variant="full"
127127
mode="dark"
128-
modal-content-classes="flex sm:hidden"
128+
content-classes="flex sm:hidden"
129129
:visible="isModalVisible"
130130
@open="openPageMenu"
131131
>
132132
<template #top-bar>
133133
<div class="flex h-20 w-full justify-between px-2 py-4">
134-
<VHomeLink variant="light" />
134+
<VHomeLink />
135135
<VIconButton
136136
variant="transparent-tx"
137137
size="large"
138138
:icon-props="{ name: 'close' }"
139-
class="text-white focus-slim-tx hover:bg-tertiary hover:text-over-negative"
139+
class="text-white hover:bg-tertiary hover:text-over-negative focus-visible:focus-slim-tx"
140140
:label="$t('modal.closePagesMenu')"
141141
@click="closePageMenu"
142142
/>
@@ -152,7 +152,7 @@ watch(route, () => {
152152
@close="closePageMenu"
153153
/>
154154
</nav>
155-
<VWordPressLink class="mt-auto" mode="dark" />
155+
<VWordPressLink class="mt-auto" />
156156
</template>
157157
</VModalContent>
158158
</template>

frontend/src/components/VHeader/VHomeLink.vue

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,8 @@
33
* The home link for the internal header. Shows the Openverse logo and wordmark,
44
* and does not have a loading state.
55
*/
6-
76
import VButton from "~/components/VButton.vue"
87
import VSvg from "~/components/VSvg/VSvg.vue"
9-
10-
withDefaults(
11-
defineProps<{
12-
/**
13-
* In `light` mode, the links are white and the background is dark charcoal.
14-
* In `dark` mode, the links are dark charcoal and the background is transparent.
15-
*
16-
* @default 'light'
17-
*/
18-
variant?: "light" | "dark"
19-
}>(),
20-
{ variant: "light" }
21-
)
228
</script>
239

2410
<template>
@@ -28,12 +14,7 @@ withDefaults(
2814
:aria-label="$t('header.homeLink', { openverse: 'Openverse' })"
2915
variant="transparent-tx"
3016
size="disabled"
31-
:class="
32-
variant === 'dark'
33-
? 'text-default hover:bg-complementary'
34-
: 'focus-slim-tx-bg-complementary text-white'
35-
"
36-
class="h-12 px-4 text-[1.125rem]"
17+
class="h-12 px-4 text-[1.125rem] text-contrast"
3718
>
3819
<VSvg
3920
name="logo_and_wordmark"

frontend/src/components/VHeader/VWordPressLink.vue

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
<script setup lang="ts">
22
import VLink from "~/components/VLink.vue"
33
import VSvg from "~/components/VSvg/VSvg.vue"
4-
5-
withDefaults(
6-
defineProps<{
7-
mode?: "dark" | "light"
8-
}>(),
9-
{ mode: "light" }
10-
)
114
</script>
125

136
<template>
147
<VLink
158
href="https://wordpress.org"
169
:aria-label="$t('footer.wordpressAffiliation', { wordpress: 'WordPress' })"
17-
class="hover:no-underline"
18-
:class="
19-
mode === 'dark'
20-
? 'text-white focus-visible:outline-yellow-3'
21-
: 'text-default'
22-
"
10+
class="text-contrast hover:no-underline focus-visible:outline-focus-ring"
2311
>
2412
<i18n-t
2513
scope="global"

frontend/src/components/VHeader/meta/VHomeLink.stories.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ import type { Meta, StoryObj } from "@storybook/vue3"
77
const meta = {
88
title: "Components/VHeader/HomeLinks/VHomeLink",
99
component: VHomeLink,
10-
11-
argTypes: {
12-
variant: {
13-
control: "select",
14-
options: ["dark", "light"],
15-
},
16-
},
17-
args: {
18-
variant: "dark",
19-
},
2010
} satisfies Meta<typeof VHomeLink>
2111

2212
export default meta
@@ -26,9 +16,7 @@ export const Default: Story = {
2616
render: (args) => ({
2717
components: { VHomeLink },
2818
setup() {
29-
const bg = args.variant === "dark" ? "bg-default" : "bg-black"
30-
return () =>
31-
h("div", { class: `flex p-4 ${bg}` }, h(VHomeLink, { ...args }))
19+
return () => h("div", { class: `flex p-4` }, h(VHomeLink, { ...args }))
3220
},
3321
}),
3422
name: "Default",

frontend/src/components/VImageCell/VImageCell.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const { isHidden: shouldBlur } = useSensitiveMedia(props.image)
147147
:class="
148148
isSquare
149149
? 'focus-visible:focus-bold-filled'
150-
: 'focus-slim-tx focus-visible:-m-2 focus-visible:w-[calc(100%+theme(spacing.4))] focus-visible:p-2 sm:focus-visible:m-0 sm:focus-visible:w-full sm:focus-visible:p-0 focus-visible:sm:focus-bold-filled'
150+
: 'focus-visible:-m-2 focus-visible:w-[calc(100%+theme(spacing.4))] focus-visible:p-2 focus-visible:focus-slim-tx sm:focus-visible:m-0 sm:focus-visible:w-full sm:focus-visible:p-0 focus-visible:sm:focus-bold-filled'
151151
"
152152
:aria-label="contextSensitiveLabel"
153153
@mousedown="sendSelectSearchResultEvent"

frontend/src/components/VMediaInfo/VMetadataValue.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defineEmits<{
1818
<VLink
1919
v-if="datum.url"
2020
:href="datum.url"
21-
class="focus-visible:ring-border-focus flex text-link focus-visible:rounded-sm focus-visible:outline-none focus-visible:ring focus-visible:ring-offset-1"
21+
class="flex text-link focus-visible:rounded-sm focus-visible:outline-none focus-visible:ring focus-visible:ring-focus-ring focus-visible:ring-offset-1"
2222
:send-external-link-click-event="false"
2323
@click="$emit('click', datum.source)"
2424
><span

frontend/src/components/VModal/VModalContent.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ const { height: modalHeaderHeight } = useElementSize(
9696
{ box: "border-box" }
9797
)
9898
99+
const modalStyle = computed(() => {
100+
const height = modalHeaderHeight.value
101+
const mode = props.mode
102+
const style = {
103+
"--modal-header-height": `${height}px`,
104+
}
105+
if (mode !== "dark") {
106+
return style
107+
}
108+
return {
109+
...style,
110+
"--color-contrast": "var(--color-white)",
111+
"--color-focus-ring": "var(--color-yellow-4)",
112+
}
113+
})
114+
99115
defineExpose({
100116
dialogRef,
101117
deactivateFocusTrap,
@@ -134,7 +150,7 @@ defineExpose({
134150
'm-6 max-w-90 rounded sm:m-0 sm:w-90': variant === 'centered',
135151
},
136152
]"
137-
:style="`--modal-header-height: ${modalHeaderHeight}px;`"
153+
:style="modalStyle"
138154
role="dialog"
139155
aria-modal="true"
140156
@keydown="onKeyDown"
@@ -201,6 +217,7 @@ defineExpose({
201217
: mode === 'dark'
202218
? 'bg-black'
203219
: 'bg-overlay',
220+
`modal-content-${mode}`,
204221
]"
205222
>
206223
<slot />
@@ -229,4 +246,8 @@ by the address bar.
229246
max-height: calc(100vh - var(--modal-header-height, 0) - 6rem);
230247
overflow-y: scroll;
231248
}
249+
.modal-content-dark {
250+
--color-outline-focus: var(--color-yellow-3);
251+
--color-contrast: var(--color-white);
252+
}
232253
</style>

frontend/src/components/VRadio/VRadio.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const handleInput = () => {
4242
:id="id"
4343
v-bind="$attrs"
4444
:value="value"
45-
class="radio focus-visible:ring-border-focus relative me-3 h-5 w-5 flex-shrink-0 appearance-none rounded-full border border-tertiary bg-default focus-visible:outline-none focus-visible:ring focus-visible:ring-offset-2 disabled:border-disabled disabled:bg-secondary"
45+
class="radio relative me-3 h-5 w-5 flex-shrink-0 appearance-none rounded-full border border-tertiary bg-default focus-visible:outline-none focus-visible:ring focus-visible:ring-focus-ring focus-visible:ring-offset-2 disabled:border-disabled disabled:bg-secondary"
4646
type="radio"
4747
:checked="isChecked"
4848
@input="handleInput"

frontend/src/components/VTabs/VTab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const variant = computed(() => tabContext.variant.value)
159159
size="disabled"
160160
variant="plain--avoid"
161161
v-bind="tabProps"
162-
class="rounded-none bg-default focus-slim-tx focus:z-10"
162+
class="rounded-none bg-default focus:z-10 focus-visible:focus-slim-tx"
163163
:class="[variant, `size-${size}`, { [`${variant}-selected`]: isSelected }]"
164164
@click="handleSelection"
165165
@focus="handleFocus"

frontend/src/components/meta/Focus.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const SlimTransparent = {
2727
name: "Slim transparent",
2828

2929
args: {
30-
classNames: ["focus-slim-tx"],
30+
classNames: ["focus-visible:focus-slim-tx"],
3131
},
3232
}
3333

frontend/src/styles/tailwind.css

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
--color-border-focus: var(--color-pink-8);
178178
--color-border-bg-ring: var(--color-white);
179179
--color-border-disabled: var(--color-gray-5);
180+
--color-focus-ring: var(--color-pink-8);
180181

181182
/* Text */
182183
--color-text: var(--color-gray-12);
@@ -236,6 +237,7 @@
236237
--color-border-focus: var(--color-yellow-4);
237238
--color-border-bg-ring: var(--color-gray-13);
238239
--color-border-disabled: var(--color-gray-8);
240+
--color-focus-ring: var(--color-yellow-4);
239241

240242
/* Text */
241243
--color-text: var(--color-gray-1);
@@ -297,6 +299,7 @@
297299
--color-border-focus: var(--color-pink-8);
298300
--color-border-bg-ring: var(--color-white);
299301
--color-border-disabled: var(--color-gray-5);
302+
--color-focus-ring: var(--color-pink-8);
300303

301304
/* Text */
302305
--color-text: var(--color-gray-12);
@@ -357,6 +360,7 @@
357360
--color-border-focus: var(--color-yellow-4);
358361
--color-border-bg-ring: var(--color-gray-13);
359362
--color-border-disabled: var(--color-gray-8);
363+
--color-focus-ring: var(--color-yellow-4);
360364

361365
/* Text */
362366
--color-text: var(--color-gray-1);
@@ -532,13 +536,14 @@ Time - 11px - xs semibold (default leading-tight)
532536
@apply ring-offset-1;
533537
}
534538

535-
[class*="focus-slim-tx"] {
536-
@apply focus-visible:outline-none; /* UA styles: none */
537-
@apply focus-visible:ring; /* outer-stroke: box-shadow */
538-
@apply focus-visible:border-tx; /* inner-stroke: transparent border */
539+
.focus-slim-tx {
540+
@apply outline-style-none; /* UA styles: none */
541+
@apply ring; /* outer-stroke: box-shadow */
542+
@apply border-tx; /* inner-stroke: transparent border */
539543

540544
/* It is up to the component to apply border utilities. */
541-
@apply focus-visible:hover:border-tx; /* focus prevails over hover */
545+
@apply hover:border-tx; /* focus prevails over hover */
546+
@apply ring-[--color-focus-ring]; /* default ring color */
542547
}
543548

544549
[class*="focus-slim-filled"] {
@@ -565,6 +570,8 @@ Time - 11px - xs semibold (default leading-tight)
565570

566571
@apply after:pointer-events-none after:absolute after:inset-0 after:rounded-inherit;
567572
@apply after:z-10 after:shadow-bold-filled; /* inner-stroke: pseudo-element */
573+
574+
@apply ring-[--color-focus-ring]; /* default ring color */
568575
}
569576

570577
/**

frontend/tailwind.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ export default {
109109
tx: "transparent",
110110
curr: "currentColor",
111111
current: "currentColor",
112+
113+
contrast: "var(--color-contrast, var(--color-text))",
114+
"focus-ring": "var(--color-focus-ring, var(--color-border-focus))",
112115
},
113116
placeholderColor: {
114117
default: "var(--color-text-secondary)",
@@ -254,6 +257,7 @@ export default {
254257
"over-dark": "var(--color-text-over-dark)",
255258
"over-negative": "var(--color-text-over-negative)",
256259
"secondary-over-dark": "var(--color-text-secondary-over-dark)",
260+
contrast: "var(--color-contrast, var(--color-text))",
257261
},
258262
backgroundColor: {
259263
default: "var(--color-bg)",
@@ -360,7 +364,7 @@ export default {
360364
item,
361365
(value) => ({
362366
"--tw-ring-offset-color": "var(--color-bg-curr-page)",
363-
"--tw-ring-color": value,
367+
"--tw-ring-color": `var(--color-accent, var(${value}))`,
364368
"--tw-outline-color": value,
365369
}),
366370
])

0 commit comments

Comments
 (0)