Skip to content

Commit 606bc16

Browse files
authored
Merge pull request #96 from Upstatement/feat/hocus
2 parents f4f1a3d + cd4bf78 commit 606bc16

File tree

23 files changed

+81
-67
lines changed

23 files changed

+81
-67
lines changed

web/wp-content/themes/mozilla-builders/blocks/advanced-code/advanced-code.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
<button
1111
x-clipboard:trigger
12-
:data-copied="copied"
12+
:data-state="copied ? 'active' : 'inactive'"
1313
aria-live="polite"
14-
class="p-1 transition-colors bg-action text-action-reverse data-[copied=true]:bg-action-focus data-[copied=true]:text-action-focus-reverse"
14+
class="p-1 bg-action text-action-reverse data-active:bg-action-focus data-active:text-action-focus-reverse"
1515
>
1616
<span class="sr-only" x-text="copied ? 'Copied' : 'Copy'">Copy</span>
1717
<svg class="w-5 h-5" aria-hidden="true">

web/wp-content/themes/mozilla-builders/blocks/mozilla-newsletter-signup-form/mozilla-newsletter-signup-form.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,29 @@
6565
<fieldset class="mzp-u-inline mt-6">
6666
<legend>I want information about:</legend>
6767
<p class="flex max-sm:flex-col gap-0.5 sm:gap-2 mt-2">
68-
<label for="id_newsletters_0" class="mzp-u-inline sm:w-1/2 font-bold relative flex items-center hover:cursor-pointer pl-[70px] min-h-[60px]">
68+
<label for="id_newsletters_0" class="mzp-u-inline sm:w-1/2 font-bold relative flex items-center hocus:cursor-pointer pl-[70px] min-h-[60px]">
6969
<input type="checkbox" name="newsletters" value="mozilla-foundation" id="id_newsletters_0" class="appearance-none peer" checked> Mozilla Foundation
7070
<span class="absolute left-0 top-0 size-[60px] transition-shadow shadow-inner shadow-content peer-focus:shadow-inner-thick peer-focus:shadow-content focus:outline-0 after:hidden after:w-[20px] after:h-[35px] after:absolute after:block after:top-[5px] after:left-[20px] after:border-content after:border-t-0 after:border-r-[3px] after:border-b-[3px] after:border-l-0 after:rotate-45 peer-checked:after:block"></span>
7171
</label>
7272

73-
<label for="id_newsletters_1" class="mzp-u-inline sm:w-1/2 font-bold relative flex items-center hover:cursor-pointer pl-[70px] min-h-[60px]">
73+
<label for="id_newsletters_1" class="mzp-u-inline sm:w-1/2 font-bold relative flex items-center hocus:cursor-pointer pl-[70px] min-h-[60px]">
7474
<input type="checkbox" name="newsletters" value="mozilla-and-you" id="id_newsletters_1" class="appearance-none peer" checked> Firefox
7575
<span class="absolute left-0 top-0 size-[60px] transition-shadow shadow-inner shadow-content peer-focus:shadow-inner-thick peer-focus:shadow-content focus:outline-0 after:hidden after:w-[20px] after:h-[35px] after:absolute after:block after:top-[5px] after:left-[20px] after:border-content after:border-t-0 after:border-r-[3px] after:border-b-[3px] after:border-l-0 after:rotate-45 peer-checked:after:block"></span>
7676
</label>
7777
</p>
7878
</fieldset>
7979

8080
<p class="mt-6">
81-
<label for="privacy" class="mzp-u-inline relative flex items-center hover:cursor-pointer pl-[70px] min-h-[60px]">
81+
<label for="privacy" class="mzp-u-inline relative flex items-center hocus:cursor-pointer pl-[70px] min-h-[60px]">
8282
<input type="checkbox" id="privacy" name="privacy" class="appearance-none peer" required aria-required="true">
83-
<span>I’m okay with Mozilla handling my info as explained in <a href="https://www.mozilla.org/privacy/websites/" class="underline hover:no-underline">this Privacy Notice</a></span>
83+
<span>I’m okay with Mozilla handling my info as explained in <a href="https://www.mozilla.org/privacy/websites/" class="underline hocus:no-underline">this Privacy Notice</a></span>
8484
<span class="absolute left-0 top-0 size-[60px] transition-shadow shadow-inner shadow-content peer-focus:shadow-inner-thick peer-focus:shadow-content focus:outline-0 after:hidden after:w-[20px] after:h-[35px] after:absolute after:top-[5px] after:left-[20px] after:border-content after:border-t-0 after:border-r-[3px] after:border-b-[3px] after:border-l-0 after:rotate-45 peer-checked:after:block"></span>
8585
</label>
8686
</p>
8787
</div>
8888

8989
<p class="mzp-c-form-submit mt-6">
90-
<button type="submit" class="mzp-c-button w-full p-10 uppercase text-center text-action-reverse bg-action border border-action transition-colors hover:text-action-focus-reverse focus:text-action-focus-reverse hover:bg-action-focus focus:bg-action-focus hover:border-action-focus focus:border-action-focus" id="newsletter-submit">Sign up now</button>
90+
<button type="submit" class="mzp-c-button w-full p-10 uppercase text-center text-action-reverse bg-action border border-action transition-colors hocus:text-action-focus-reverse hocus:bg-action-focus hocus:border-action-focus" id="newsletter-submit">Sign up now</button>
9191
<span class="mzp-c-fieldnote block mt-6">We will only send you Mozilla-related information.</span>
9292
</p>
9393
</fieldset>

web/wp-content/themes/mozilla-builders/blocks/related-articles/related-articles.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{% for post in related_articles %}
1212
<li class="relative grid auto-rows-[min-content_1fr] max-md:grid-cols-6 md:grid md:grid-cols-10 gap-x-grid-site-gutter py-4 border-b border-content">
1313
<a class="max-md:col-span-4 md:col-span-5 mt-2 leading-tighter before:absolute before:inset-0 before:z-10 group" href="{{ post.link }}">
14-
<span class="uppercase font-bold group-hover:bg-content group-hover:text-main">{{ post.title }}</span>
14+
<span class="uppercase font-bold group-hocus:bg-content group-hocus:text-main">{{ post.title }}</span>
1515
</a>
1616

1717
<div class="max-md:col-span-2 max-md:row-start-1 max-md:row-span-2 max-md:col-start-5 md:col-span-3">
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import plugin from 'tailwindcss/plugin';
2+
3+
export default plugin(({ addVariant }) => {
4+
addVariant('hocus', ['&:hover', '&:focus-visible']);
5+
addVariant('group-hocus', [':merge(.group):hover &', ':merge(.group):has(*:focus-visible) &']);
6+
});

web/wp-content/themes/mozilla-builders/static/scss/app.scss

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ body {
196196
.hover-link {
197197
@apply md:before:content-['\['] md:after:content-['\]'];
198198
@apply max-md:underline;
199-
@apply hover:bg-action-focus focus:bg-action-focus;
200-
@apply hover:no-underline focus:no-underline;
201-
@apply hover:text-action-focus-reverse focus:text-action-focus-reverse;
199+
@apply hocus:bg-action-focus hocus:no-underline hocus:text-action-focus-reverse;
202200
}
203201

204202
// Grid utilities
@@ -382,7 +380,7 @@ body {
382380

383381
// Inline links
384382
a {
385-
@apply underline hover:bg-action-focus focus:bg-action-focus hover:no-underline focus:no-underline hover:text-action-focus-reverse focus:text-action-focus-reverse;
383+
@apply underline hocus:bg-action-focus hocus:no-underline hocus:text-action-focus-reverse;
386384
}
387385
}
388386

@@ -621,11 +619,11 @@ body {
621619
}
622620
.wp-block-button__link {
623621
@apply w-full p-10 uppercase text-center text-action-reverse bg-action border border-action transition-colors;
624-
@apply hover:text-action-focus-reverse focus:text-action-focus-reverse hover:bg-action-focus focus:bg-action-focus hover:border-action-focus focus:border-action-focus;
622+
@apply hocus:text-action-focus-reverse hocus:bg-action-focus hocus:border-action-focus;
625623
}
626624
.is-style-outline .wp-block-button__link {
627625
@apply bg-transparent border-none text-action transition-shadow shadow-inner shadow-action;
628-
@apply hover:shadow-inner-thick hover:shadow-action focus:shadow-inner-thick focus:shadow-action;
626+
@apply hocus:shadow-inner-thick hocus:shadow-action;
629627
}
630628

631629
// Files
@@ -651,15 +649,15 @@ body {
651649
@apply flex items-center justify-between gap-10 w-full p-10;
652650
@apply uppercase font-semibold;
653651
@apply bg-action text-action-reverse transition duration-300;
654-
@apply hover:text-action-focus-reverse focus:text-action-focus-reverse hover:bg-action-focus focus:bg-action-focus;
652+
@apply hocus:text-action-focus-reverse hocus:bg-action-focus;
655653

656654
&:has(+ a.wp-block-file__button) {
657655
@apply md:py-8;
658656

659657
&::after {
660658
content: '';
661659
@apply block shrink-0 bg-current mask-arrow-down size-8 md:size-10;
662-
@apply transition-transform duration-300 hover:translate-y-1 focus:translate-y-1.5;
660+
@apply transition-transform duration-300 hocus:translate-y-1.5;
663661
}
664662
}
665663
}
@@ -749,7 +747,7 @@ body {
749747
}
750748

751749
summary {
752-
@apply hover:cursor-pointer font-bold uppercase;
750+
@apply hocus:cursor-pointer font-bold uppercase;
753751

754752
&::marker,
755753
&::-webkit-details-marker {

web/wp-content/themes/mozilla-builders/tailwind.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import theme from 'tailwindcss/defaultTheme';
22
import utilitiesScss from './plugins/utilities-scss';
3+
import hocus from './plugins/hocus';
34
import path from 'path';
45

56
function color(name) {
@@ -8,6 +9,9 @@ function color(name) {
89

910
/** @type {import('tailwindcss').Config} */
1011
module.exports = {
12+
future: {
13+
hoverOnlyWhenSupported: true,
14+
},
1115
content: ['./**/*.twig', './**/*.js'],
1216
theme: {
1317
colors: {
@@ -120,6 +124,10 @@ module.exports = {
120124
arrow: `url('data:image/svg+xml,<svg viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M69.4914 37.7055L35.9853 71.2097L2.45057 37.675L6.99568 33.1299L32.834 58.9683L32.8349 3.65135L39.1375 3.65125L39.1366 58.9676L65.0628 33.2765L69.4914 37.7055Z" fill="currentColor"/></svg>')`,
121125
},
122126

127+
data: {
128+
active: 'state=active',
129+
},
130+
123131
flex: {
124132
2: '2 2 0%',
125133
},
@@ -180,5 +188,5 @@ module.exports = {
180188
},
181189
},
182190
},
183-
plugins: [utilitiesScss({ filename: path.resolve(__dirname, 'static/scss/app.scss') })],
191+
plugins: [hocus, utilitiesScss({ filename: path.resolve(__dirname, 'static/scss/app.scss') })],
184192
};

web/wp-content/themes/mozilla-builders/templates/components/accelerator/topper.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<path x-accelerator:path d="M1 204.735C138 217.235 172.5 -7.2644 314 1.23549" />
3434
</svg>
3535

36-
<div x-accelerator:targets class="opacity-0 data-[state=active]:opacity-100">
36+
<div x-accelerator:targets class="opacity-0 data-active:opacity-100">
3737
{% for i in 1..20 %}
3838
<div class="absolute top-0 left-0 w-72 z-10 {% if loop.index > 8 %}hidden md:block{% endif %}" {% if not loop.first %}aria-hidden="true"{% endif %}>
3939
{% include "components/lazy-img.twig" with { img: img } %}

web/wp-content/themes/mozilla-builders/templates/components/articles/overline.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
{% endif %}
4040

4141
<p class="text-xs uppercase">
42-
<a class="py-1 px-1.5 transition-colors hover:bg-main hover:text-content {{ overline_class }}" href="{{ overline.link }}">{{ overline.name }}</a>
42+
<a class="py-1 px-1.5 hocus:bg-main hocus:text-content {{ overline_class }}" href="{{ overline.link }}">{{ overline.name }}</a>
4343
</p>
4444

4545
{% endif %}

web/wp-content/themes/mozilla-builders/templates/components/articles/previews/preview--small_image-alt.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{% include 'components/articles/overline.twig' with { overline: post.categories[0] } %}
1111
</div>
1212
<h3 class="flex-1 font-bold uppercase text-balance leading-tighter">
13-
<a class="before:absolute before:inset-0 before:z-10 hover:before:shadow-inner" href="{{ post.link }}">{{ post.title }}</a>
13+
<a class="before:absolute before:inset-0 before:z-10 hocus:before:shadow-inner" href="{{ post.link }}">{{ post.title }}</a>
1414
</h3>
1515
</div>
1616
</div>

web/wp-content/themes/mozilla-builders/templates/components/articles/previews/preview--small_image-feature.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</div>
1818

1919
<h3 class="mt-3 type-headline-xl text-center text-balance leading-tighter">
20-
<a class="before:absolute before:inset-0 before:z-10 hover:before:shadow-inner" href="{{ post.link }}">{{ post.title }}</a>
20+
<a class="before:absolute before:inset-0 before:z-10 hocus:before:shadow-inner" href="{{ post.link }}">{{ post.title }}</a>
2121
</h3>
2222
<p class="type-sans-sm text-center text-balance">{{ post.subtitle }}</p>
2323
</div>

0 commit comments

Comments
 (0)