Skip to content

Commit 555d673

Browse files
author
Adam Plesnik
committed
Update docu to use no-animations:, change code,
1 parent 3eff8a9 commit 555d673

File tree

9 files changed

+26
-20
lines changed

9 files changed

+26
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Tailwind Job Application Microsite
22

3-
`experimental` `chrome 115+`
3+
`experimental` `chrome 116+`
44

55
This is a microsite to introduce myself and give a short explanation with demo of how I'd tackle the scroll-driven animations plugin for Tailwind CSS.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"react-router-dom": "^6.22.3"
2929
},
3030
"devDependencies": {
31-
"@adam.plesnik/tailwindcss-scroll-driven-animations": "^0.2.1",
31+
"@adam.plesnik/tailwindcss-scroll-driven-animations": "^0.2.5",
3232
"@types/node": "^20.11.30",
3333
"@types/prismjs": "^1.26.3",
3434
"@types/react": "^18.2.66",

src/demos/RangeDemo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ const skeletonCollection = ['96%', '100%', '92%', '100%', '93%', '87%', '55%']
99
const RangeDemo = () => {
1010
return (
1111
<DemoWrapper>
12-
<div className="text-sm scope/navbar supports-animations:-mt-14 supports-animations:sm:-mt-8">
13-
<div className="sticky top-0 z-10 flex animate-translate-down flex-wrap gap-1 bg-sky-400/60 p-4 backdrop-blur timeline/navbar range-on-exit supports-animations:-translate-y-16 dark:bg-fuchsia-600/60 ">
12+
<div className="no-animations:mt-0 -mt-14 text-sm scope/navbar sm:-mt-8">
13+
<div className="no-animations:translate-y-0 sticky top-0 z-10 flex -translate-y-16 animate-translate-down flex-wrap gap-1 bg-sky-400/60 p-4 backdrop-blur timeline/navbar range-on-exit dark:bg-fuchsia-600/60 ">
1414
<Code>.animate...</Code>
1515
<Code>.timeline/navbar</Code>
1616
<Code>.range-on-exit</Code>
1717
</div>
18-
<div className="mt-4 px-4 sm:px-8">
18+
<div className="no-animations:mt-12 mt-4 px-4 sm:px-8">
1919
<Code>.scope/navbar</Code>
2020
</div>
2121
<DemoPlaceholderContent>

src/docs/Docs.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Code from '../components/Code'
12
import CodeBlock from '../components/CodeBlock'
23
import Heading from '../components/Heading'
34
import Paragraph from '../components/Paragraph'
@@ -39,6 +40,10 @@ const viewTimelineClasses = [
3940
{ className: 'view-timeline-block/{name}', code: 'view-timeline: --{name} block' },
4041
]
4142

43+
const supportsClasses = [
44+
{ className: 'no-animations:...', code: '@supports not (animation-range: cover) { ... }' },
45+
]
46+
4247
const Docs = () => {
4348
return (
4449
<div>
@@ -92,6 +97,14 @@ const Docs = () => {
9297
Timeline scope allows to control animations outside the element which defines the timeline.
9398
</Paragraph>
9499
<DocsTable items={scopeClasses} />
100+
<Heading size={3} id="documentation-fallback">
101+
Fallback Styling
102+
</Heading>
103+
<Paragraph>
104+
Use the modifier <Code>no-animations:</Code> to apply fallback styling in browsers which do
105+
not support scroll-driven animations yet.
106+
</Paragraph>
107+
<DocsTable items={supportsClasses} />
95108
</div>
96109
)
97110
}

src/partials/Animations.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,16 @@ const Animations = () => {
110110
</CodeBlock>
111111
<Heading size={3}>Browser Support</Heading>
112112
<Paragraph>
113-
Scroll-driven animations are not broadly supported yet. I added two <Code>@supports</Code>{' '}
114-
rules to use them as modifiers for fallback styling.
113+
Scroll-driven animations are not broadly supported yet. I decided to apply an
114+
animation-first approach. Use a modifier <Code>no-animations</Code>
115+
for fallback styling.
115116
</Paragraph>
116117
<CodeBlock
117118
Icon={Github}
118119
linkHref={
119-
'https://github.com/adamplesnik/tailwind-job-application/blob/main/tailwind.config.js#L28'
120+
'https://github.com/adamplesnik/tailwindcss-scroll-driven-animations/blob/main/src/index.ts#L73'
120121
}
121-
linkText={'tailwind-job-application/tailwind.config.js'}
122+
linkText={'tailwindcss-scroll-driven-animations/src/index.ts'}
122123
>
123124
{codeExampleSupports}
124125
</CodeBlock>

src/partials/Nav.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import HeaderNavAnchor from '../components/HeaderNavAnchor.tsx'
44

55
const Nav = () => {
66
return (
7-
<div
8-
className="sticky top-0 z-20 flex w-full animate-translate-down items-stretch justify-center border-b border-b-slate-200/50 bg-white/20 p-1 text-zinc-800 shadow-lg
9-
backdrop-blur-sm timeline range/0%,200px supports-animations:-translate-y-24 md:px-1 supports-animations:md:-translate-y-32 supports-animations:lg:-translate-y-40 dark:border-b-slate-600/50
10-
dark:bg-slate-800/60 dark:text-zinc-300"
11-
>
7+
<div className="no-animations:translate-y-0 sticky top-0 z-20 flex w-full -translate-y-24 animate-translate-down items-stretch justify-center border-b border-b-slate-200/50 bg-white/20 text-zinc-800 shadow-lg backdrop-blur-sm timeline range/0%,200px dark:border-b-slate-600/50 dark:bg-slate-800/60 dark:text-zinc-300">
128
<div className="flex w-full max-w-screen-lg items-stretch gap-2 px-8 py-2 md:px-16 lg:px-20">
139
<HeaderNavAnchor to="/#plugin">Plugin</HeaderNavAnchor>
1410
<HeaderNavAnchor to="/docs#documentation">Docs</HeaderNavAnchor>

src/utils/codeExamples.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,4 @@ export const codeExampleScope = `scope: (value, { modifier }) => ({
4141
timelineScope: \`--\${modifier}\`,
4242
}),`
4343

44-
export const codeExampleSupports = `supports: {
45-
animations: 'animation-timeline: scroll(y)',
46-
'no-animations': 'not(animation-timeline: scroll(y))',
47-
}`
44+
export const codeExampleSupports = `addVariant('no-animations', '@supports not (animation-range: cover)')`

src/views/DocsView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const DocsView = () => {
1212
<Paragraph size="small" className="opacity-50">
1313
Tailwind CSS Plugin
1414
</Paragraph>
15-
<div className="mt-12 hidden gap-4 rounded-lg border border-amber-400 bg-amber-50 p-4 text-sm supports-no-animations:flex dark:border-amber-600 dark:bg-stone-700/30">
15+
<div className="no-animations:flex mt-12 hidden gap-4 rounded-lg border border-amber-400 bg-amber-50 p-4 text-sm dark:border-amber-600 dark:bg-stone-700/30">
1616
<WandSparkles
1717
className="size-6 shrink-0 text-amber-500 dark:text-amber-600"
1818
strokeWidth="1"

tailwind.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ module.exports = {
2727
},
2828
supports: {
2929
animations: 'animation-timeline: scroll(y)',
30-
'no-animations': 'not(animation-timeline: scroll(y))',
3130
},
3231
},
3332
plugins: [require('@adam.plesnik/tailwindcss-scroll-driven-animations')],

0 commit comments

Comments
 (0)