Skip to content

Commit

Permalink
Use CSS for colors of VWordPress and VHomeLink
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Dec 12, 2024
1 parent c4acdf8 commit 157391a
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 69 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/VAudioTrack/VAudioTrack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ const layoutBasedProps = computed(() =>
"cursor-pointer",
{
"focus-visible:focus-bold-filled": props.layout === "box",
"focus-slim-tx": props.layout === "row",
"focus-visible:focus-slim-tx": props.layout === "row",
},
],
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/VBanner/VNotificationBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const iconClassNames = computed(() =>
const closeButtonClassNames = computed(() =>
props.variant === "dark"
? "focus-slim-tx-bg-complementary hover:bg-tertiary-hover"
? "focus-visible:focus-slim-tx hover:bg-tertiary-hover"
: {
info: "hover:!bg-info-3",
warning: "hover:!bg-warning-3",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/VButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ watch(
border: !isPlainDangerous,
'focus-visible:outline-tx': isPlainDangerous,
'focus-slim-filled': isFocusSlimFilled,
'focus-slim-tx': isFocusSlimTx,
'focus-visible:focus-slim-tx': isFocusSlimTx,
},
]"
:aria-pressed="pressed"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/VCheckbox/VCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const onChange = () => {
'h-5',
'w-5',
'rounded-sm',
'focus-slim-tx',
'focus-visible:focus-slim-tx',
'checked:focus-visible:border-bg-ring',
]
"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/VFooter/VFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const linkColumnHeight = computed(() => ({
<!-- Locale chooser and WordPress affiliation graphic -->
<div class="locale-and-wp flex flex-col justify-between">
<template v-if="showThemeSwitcher">
<VWordPressLink mode="light" />
<VWordPressLink />
<div class="flex flex-row items-center gap-6">
<VLanguageSelect
v-bind="languageProps"
Expand All @@ -110,7 +110,7 @@ const linkColumnHeight = computed(() => ({
v-bind="languageProps"
class="language max-w-full border-secondary"
/>
<VWordPressLink mode="light" />
<VWordPressLink />
</template>
</div>
</footer>
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/VHeader/VHeaderInternal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ watch(route, () => {
ref="nodeRef"
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"
>
<VHomeLink variant="dark" />
<VHomeLink />
<nav class="hidden lg:flex">
<VPageLinks
mode="light"
Expand Down Expand Up @@ -125,18 +125,18 @@ watch(route, () => {
:hide="closePageMenu"
variant="full"
mode="dark"
modal-content-classes="flex sm:hidden"
content-classes="flex sm:hidden"
:visible="isModalVisible"
@open="openPageMenu"
>
<template #top-bar>
<div class="flex h-20 w-full justify-between px-2 py-4">
<VHomeLink variant="light" />
<VHomeLink />
<VIconButton
variant="transparent-tx"
size="large"
:icon-props="{ name: 'close' }"
class="text-white focus-slim-tx hover:bg-tertiary hover:text-over-negative"
class="text-white hover:bg-tertiary hover:text-over-negative focus-visible:focus-slim-tx"
:label="$t('modal.closePagesMenu')"
@click="closePageMenu"
/>
Expand All @@ -152,7 +152,7 @@ watch(route, () => {
@close="closePageMenu"
/>
</nav>
<VWordPressLink class="mt-auto" mode="dark" />
<VWordPressLink class="mt-auto" />
</template>
</VModalContent>
</template>
Expand Down
21 changes: 1 addition & 20 deletions frontend/src/components/VHeader/VHomeLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,8 @@
* The home link for the internal header. Shows the Openverse logo and wordmark,
* and does not have a loading state.
*/
import VButton from "~/components/VButton.vue"
import VSvg from "~/components/VSvg/VSvg.vue"
withDefaults(
defineProps<{
/**
* In `light` mode, the links are white and the background is dark charcoal.
* In `dark` mode, the links are dark charcoal and the background is transparent.
*
* @default 'light'
*/
variant?: "light" | "dark"
}>(),
{ variant: "light" }
)
</script>

<template>
Expand All @@ -28,12 +14,7 @@ withDefaults(
:aria-label="$t('header.homeLink', { openverse: 'Openverse' })"
variant="transparent-tx"
size="disabled"
:class="
variant === 'dark'
? 'text-default hover:bg-complementary'
: 'focus-slim-tx-bg-complementary text-white'
"
class="h-12 px-4 text-[1.125rem]"
class="h-12 px-4 text-[1.125rem] text-contrast"
>
<VSvg
name="logo_and_wordmark"
Expand Down
14 changes: 1 addition & 13 deletions frontend/src/components/VHeader/VWordPressLink.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
<script setup lang="ts">
import VLink from "~/components/VLink.vue"
import VSvg from "~/components/VSvg/VSvg.vue"
withDefaults(
defineProps<{
mode?: "dark" | "light"
}>(),
{ mode: "light" }
)
</script>

<template>
<VLink
href="https://wordpress.org"
:aria-label="$t('footer.wordpressAffiliation', { wordpress: 'WordPress' })"
class="hover:no-underline"
:class="
mode === 'dark'
? 'text-white focus-visible:outline-yellow-3'
: 'text-default'
"
class="text-contrast hover:no-underline focus-visible:outline-focus-ring"
>
<i18n-t
scope="global"
Expand Down
14 changes: 1 addition & 13 deletions frontend/src/components/VHeader/meta/VHomeLink.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ import type { Meta, StoryObj } from "@storybook/vue3"
const meta = {
title: "Components/VHeader/HomeLinks/VHomeLink",
component: VHomeLink,

argTypes: {
variant: {
control: "select",
options: ["dark", "light"],
},
},
args: {
variant: "dark",
},
} satisfies Meta<typeof VHomeLink>

export default meta
Expand All @@ -26,9 +16,7 @@ export const Default: Story = {
render: (args) => ({
components: { VHomeLink },
setup() {
const bg = args.variant === "dark" ? "bg-default" : "bg-black"
return () =>
h("div", { class: `flex p-4 ${bg}` }, h(VHomeLink, { ...args }))
return () => h("div", { class: `flex p-4` }, h(VHomeLink, { ...args }))
},
}),
name: "Default",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/VImageCell/VImageCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const { isHidden: shouldBlur } = useSensitiveMedia(props.image)
:class="
isSquare
? 'focus-visible:focus-bold-filled'
: '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'
: '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'
"
:aria-label="contextSensitiveLabel"
@mousedown="sendSelectSearchResultEvent"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/VMediaInfo/VMetadataValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defineEmits<{
<VLink
v-if="datum.url"
:href="datum.url"
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"
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"
:send-external-link-click-event="false"
@click="$emit('click', datum.source)"
><span
Expand Down
23 changes: 22 additions & 1 deletion frontend/src/components/VModal/VModalContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ const { height: modalHeaderHeight } = useElementSize(
{ box: "border-box" }
)
const modalStyle = computed(() => {
const height = modalHeaderHeight.value
const mode = props.mode
const style = {
"--modal-header-height": `${height}px`,
}
if (mode !== "dark") {
return style
}
return {
...style,
"--color-contrast": "var(--color-white)",
"--color-focus-ring": "var(--color-yellow-4)",
}
})
defineExpose({
dialogRef,
deactivateFocusTrap,
Expand Down Expand Up @@ -134,7 +150,7 @@ defineExpose({
'm-6 max-w-90 rounded sm:m-0 sm:w-90': variant === 'centered',
},
]"
:style="`--modal-header-height: ${modalHeaderHeight}px;`"
:style="modalStyle"
role="dialog"
aria-modal="true"
@keydown="onKeyDown"
Expand Down Expand Up @@ -201,6 +217,7 @@ defineExpose({
: mode === 'dark'
? 'bg-black'
: 'bg-overlay',
`modal-content-${mode}`,
]"
>
<slot />
Expand Down Expand Up @@ -229,4 +246,8 @@ by the address bar.
max-height: calc(100vh - var(--modal-header-height, 0) - 6rem);
overflow-y: scroll;
}
.modal-content-dark {
--color-outline-focus: var(--color-yellow-3);
--color-contrast: var(--color-white);
}
</style>
2 changes: 1 addition & 1 deletion frontend/src/components/VRadio/VRadio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const handleInput = () => {
:id="id"
v-bind="$attrs"
:value="value"
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"
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"
type="radio"
:checked="isChecked"
@input="handleInput"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/VTabs/VTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const variant = computed(() => tabContext.variant.value)
size="disabled"
variant="plain--avoid"
v-bind="tabProps"
class="rounded-none bg-default focus-slim-tx focus:z-10"
class="rounded-none bg-default focus:z-10 focus-visible:focus-slim-tx"
:class="[variant, `size-${size}`, { [`${variant}-selected`]: isSelected }]"
@click="handleSelection"
@focus="handleFocus"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/meta/Focus.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const SlimTransparent = {
name: "Slim transparent",

args: {
classNames: ["focus-slim-tx"],
classNames: ["focus-visible:focus-slim-tx"],
},
}

Expand Down
17 changes: 12 additions & 5 deletions frontend/src/styles/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
--color-border-focus: var(--color-pink-8);
--color-border-bg-ring: var(--color-white);
--color-border-disabled: var(--color-gray-5);
--color-focus-ring: var(--color-pink-8);

/* Text */
--color-text: var(--color-gray-12);
Expand Down Expand Up @@ -236,6 +237,7 @@
--color-border-focus: var(--color-yellow-4);
--color-border-bg-ring: var(--color-gray-13);
--color-border-disabled: var(--color-gray-8);
--color-focus-ring: var(--color-yellow-4);

/* Text */
--color-text: var(--color-gray-1);
Expand Down Expand Up @@ -297,6 +299,7 @@
--color-border-focus: var(--color-pink-8);
--color-border-bg-ring: var(--color-white);
--color-border-disabled: var(--color-gray-5);
--color-focus-ring: var(--color-pink-8);

/* Text */
--color-text: var(--color-gray-12);
Expand Down Expand Up @@ -357,6 +360,7 @@
--color-border-focus: var(--color-yellow-4);
--color-border-bg-ring: var(--color-gray-13);
--color-border-disabled: var(--color-gray-8);
--color-focus-ring: var(--color-yellow-4);

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

[class*="focus-slim-tx"] {
@apply focus-visible:outline-none; /* UA styles: none */
@apply focus-visible:ring; /* outer-stroke: box-shadow */
@apply focus-visible:border-tx; /* inner-stroke: transparent border */
.focus-slim-tx {
@apply outline-style-none; /* UA styles: none */
@apply ring; /* outer-stroke: box-shadow */
@apply border-tx; /* inner-stroke: transparent border */

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

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

@apply after:pointer-events-none after:absolute after:inset-0 after:rounded-inherit;
@apply after:z-10 after:shadow-bold-filled; /* inner-stroke: pseudo-element */

@apply ring-[--color-focus-ring]; /* default ring color */
}

/**
Expand Down
6 changes: 5 additions & 1 deletion frontend/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export default {
tx: "transparent",
curr: "currentColor",
current: "currentColor",

contrast: "var(--color-contrast, var(--color-text))",
"focus-ring": "var(--color-focus-ring, var(--color-border-focus))",
},
placeholderColor: {
default: "var(--color-text-secondary)",
Expand Down Expand Up @@ -254,6 +257,7 @@ export default {
"over-dark": "var(--color-text-over-dark)",
"over-negative": "var(--color-text-over-negative)",
"secondary-over-dark": "var(--color-text-secondary-over-dark)",
contrast: "var(--color-contrast, var(--color-text))",
},
backgroundColor: {
default: "var(--color-bg)",
Expand Down Expand Up @@ -360,7 +364,7 @@ export default {
item,
(value) => ({
"--tw-ring-offset-color": "var(--color-bg-curr-page)",
"--tw-ring-color": value,
"--tw-ring-color": `var(--color-accent, var(${value}))`,
"--tw-outline-color": value,
}),
])
Expand Down

0 comments on commit 157391a

Please sign in to comment.