Skip to content

Commit 9823b76

Browse files
reininkadamwathandanhollick
authored
v3.4 (#1745)
* Use insiders build * add subgrid examples * fix example * test out animation * Add examples * clean up example * light mode pass * change icon * add some examples * add text-wrap page * document size * Documents min/max height/width default scales * Documents appearance-auto * adds a text description * flesh out example * Revert "change icon" This reverts commit 8399c33. * Changes customisation example (#1733) * Stashing some work * some small fixes * removes percentage examples * Fleshes out examples * messing around with the examples * tweak example * Flesh out examples * add `forced-color-adjust` page * fix examples based on feedback * Some small edits * Update insiders version * Revert "Update insiders version" This reverts commit fcbf4d1. * .4: Auto stash before revert of "Update insiders version" * Add examples * Documents * modifier (#1744) * documents * modifier * Updates appendix * Update to latest insiders * Add `@heroicons/react` package * Fix `forced-color-adjust` class table * Update `className` instead of `class` * Move `overscroll-none` to parent in `DynamicViewportExample` * Dynamically generate `text-wrap` utilities * Formatting * Formatting * Formatting * Formatting * Improve v3.4 docs * WIP * WIP * v3.4 draft * WIP * More blog postin * Update to Tailwind CSS v3.4 * Update package-lock.json --------- Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com> Co-authored-by: Daniel Hollick <danhollick@users.noreply.github.com>
1 parent ad44d7e commit 9823b76

22 files changed

+3052
-10952
lines changed

package-lock.json

Lines changed: 1188 additions & 10879 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@badrap/bar-of-progress": "^0.1.1",
1616
"@docsearch/react": "^3.3.3",
1717
"@headlessui/react": "^1.7.2",
18-
"@heroicons/react": "^0.0.0-insiders.9600adb",
18+
"@heroicons/react": "^2.1.1",
1919
"@mdx-js/loader": "^2.3.0",
2020
"@mdx-js/react": "^2.3.0",
2121
"@silvenon/remark-smartypants": "^1.0.0",
@@ -60,6 +60,7 @@
6060
"seedrandom": "^3.0.5",
6161
"simple-functional-loader": "^1.2.1",
6262
"stringify-object": "^3.3.0",
63+
"tailwindcss": "^3.4.0",
6364
"tinytime": "^0.2.6",
6465
"unified": "^10.1.2",
6566
"unist-util-filter": "^4.0.1",
@@ -78,7 +79,6 @@
7879
"eslint-plugin-react": "7.x",
7980
"eslint-plugin-react-hooks": "2.x",
8081
"glyphhanger": "^5.0.0",
81-
"prettier": "^2.5.0",
82-
"tailwindcss": "^3.3.7"
82+
"prettier": "^2.5.0"
8383
}
8484
}
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
import React, { useState, useRef, useEffect } from 'react'
2+
import { motion, useElementScroll } from 'framer-motion'
3+
import clsx from 'clsx'
4+
5+
const viewport = {
6+
lvh: 491,
7+
svh: 443,
8+
navBarHeight: 48,
9+
width: 300,
10+
padding: 5,
11+
}
12+
13+
const transition = {
14+
duration: 0.2,
15+
ease: 'linear',
16+
type: 'tween',
17+
}
18+
export function DynamicViewportExample({
19+
unit = 'dvh',
20+
colorStyles = 'dark:bg-blue-500 bg-blue-500 border border-blue-400',
21+
containerBackground = 'bg-stripes-blue',
22+
}) {
23+
const [hidden, setHidden] = useState(false)
24+
const parent = useRef(null)
25+
26+
const { scrollY } = useElementScroll(parent)
27+
28+
useEffect(() => {
29+
const unsub = scrollY.onChange((latest) => {
30+
const previous = scrollY.getPrevious()
31+
if (latest > previous) {
32+
setHidden(true)
33+
} else {
34+
setHidden(false)
35+
}
36+
})
37+
38+
return () => unsub()
39+
})
40+
41+
// NOTE:When upgrading Framer Motion we can use useMotionValueEvent instead:
42+
43+
// import { motion, useScroll, useMotionValueEvent } from 'framer-motion'
44+
45+
// const { scrollY } = useScroll({ container: parent })
46+
47+
// useMotionValueEvent(scrollY, 'change', (latest) => {
48+
// const previous = scrollY.getPrevious()
49+
// if (latest > previous) {
50+
// setHidden(true)
51+
// } else {
52+
// setHidden(false)
53+
// }
54+
// })
55+
56+
return (
57+
<>
58+
<div className="not-prose mb-4">
59+
<div className="flex space-x-2">
60+
<svg
61+
className="flex-none w-5 h-5"
62+
viewBox="0 0 20 20"
63+
fill="none"
64+
strokeWidth="1.5"
65+
strokeLinecap="round"
66+
strokeLinejoin="round"
67+
aria-hidden="true"
68+
>
69+
<path
70+
d="m9.813 9.25.346-5.138a1.276 1.276 0 0 0-2.54-.235L6.75 11.25 5.147 9.327a1.605 1.605 0 0 0-2.388-.085.018.018 0 0 0-.004.019l1.98 4.87a5 5 0 0 0 4.631 3.119h3.885a4 4 0 0 0 4-4v-1a3 3 0 0 0-3-3H9.813Z"
71+
className="stroke-slate-400 dark:stroke-slate-300"
72+
/>
73+
<path
74+
d="M3 5s.35-.47 1.25-.828m9.516-.422c2.078.593 3.484 1.5 3.484 1.5"
75+
className="stroke-slate-400 dark:stroke-sky-400"
76+
/>
77+
</svg>
78+
<p className="text-slate-700 text-sm font-medium dark:text-slate-200">
79+
Scroll up and down in the viewport to hide/show the browser UI
80+
</p>
81+
</div>
82+
</div>
83+
<div className="not-prose relative bg-slate-50 rounded-xl overflow-hidden dark:bg-slate-800/25 md:px-8 py-8 px-4">
84+
<div className="relative grid justify-items-center">
85+
<div
86+
ref={parent}
87+
style={{ width: `${viewport.width}px`, height: `${viewport.lvh}px` }}
88+
className={clsx(
89+
containerBackground,
90+
'relative rounded-lg border dark:border-slate-700 overscroll-none border-slate-300 text-center text-xs overflow-y-scroll no-scrollbar'
91+
)}
92+
>
93+
<motion.div
94+
className="absolute w-full overflow-hidden snap-start"
95+
transition={{
96+
...transition,
97+
}}
98+
variants={{
99+
visible: {
100+
y: 0,
101+
height: `${viewport.lvh}px`,
102+
},
103+
hidden: {
104+
y: `-${viewport.navBarHeight - 2}px`,
105+
height: `${viewport.lvh + viewport.navBarHeight - 1}px`,
106+
},
107+
}}
108+
initial="visible"
109+
animate={hidden ? 'hidden' : 'visible'}
110+
>
111+
<div className=" w-full grid grid-cols-[auto,1fr,auto] items-center justify-start gap-4 rounded-t-lg border-b border-slate-300 dark:border-slate-600 dark:bg-slate-800 bg-slate-100 px-3 h-[48px]">
112+
<svg
113+
xmlns="http://www.w3.org/2000/svg"
114+
fill="none"
115+
viewBox="0 0 24 24"
116+
strokeWidth="1.5"
117+
stroke="currentColor"
118+
className="h-5 w-5 text-slate-600 dark:text-slate-400"
119+
>
120+
<path
121+
strokeLinecap="round"
122+
strokeLinejoin="round"
123+
d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25"
124+
/>
125+
</svg>
126+
<div className="w-full rounded-full border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-700 px-4 py-1 text-slate-600 dark:text-slate-400">
127+
tailwindcss.com
128+
</div>
129+
<svg
130+
xmlns="http://www.w3.org/2000/svg"
131+
fill="none"
132+
viewBox="0 0 24 24"
133+
strokeWidth="1.5"
134+
stroke="currentColor"
135+
className="h-5 w-5 text-slate-600 dark:text-slate-400"
136+
>
137+
<path
138+
strokeLinecap="round"
139+
strokeLinejoin="round"
140+
d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"
141+
/>
142+
</svg>
143+
</div>
144+
<motion.div
145+
className="w-full p-[7px] h-full pointer-events-none "
146+
transition={{
147+
...transition,
148+
duration: 0.2,
149+
// duration: unit === 'dvh' ? 0.4 : 0.2,
150+
delay: unit === 'dvh' ? 0.4 : 0,
151+
}}
152+
variants={{
153+
visible: {
154+
maxHeight: `${unit === 'lvh' ? viewport.lvh : viewport.svh - 2}px`,
155+
},
156+
hidden: {
157+
maxHeight: `${unit === 'svh' ? viewport.svh : viewport.lvh - 1}px`,
158+
},
159+
}}
160+
initial="visible"
161+
animate={hidden ? 'hidden' : 'visible'}
162+
>
163+
<div
164+
className={clsx(
165+
colorStyles,
166+
'text-slate-50 font-mono font-bold py-4 w-full h-full gap-5 rounded-md grid grid-rows-[1fr_auto_1fr] items-center content-center self-center justify-items-center overflow-hidden'
167+
)}
168+
>
169+
{/* <div className="grid grid-rows-[1fr] h-full items-start overflow-y-hidden">
170+
<svg
171+
className="w-[12px] text-pink-300"
172+
viewBox="0 0 9 162"
173+
fill="none"
174+
xmlns="http://www.w3.org/2000/svg"
175+
>
176+
<path
177+
d="M4.5 161.5V1M4.5 1L8.5 5M4.5 1L0.5 5"
178+
stroke="currentColor"
179+
// strokeWidth={1.5}
180+
stroke-linecap="round"
181+
stroke-linejoin="round"
182+
/>
183+
</svg>
184+
</div> */}
185+
<div className="grid grid-rows-[1px_1fr] h-full justify-items-center">
186+
<div className="bg-white/60 w-[12px] h-full"></div>
187+
<div className="bg-white/40 w-[1.5px] h-full"></div>
188+
</div>
189+
<p>h-{unit}</p>
190+
191+
{/* <div className="grid grid-rows-[1fr] h-full items-end overflow-y-hidden">
192+
<svg
193+
className="w-[12px] text-pink-300"
194+
viewBox="0 0 10 162"
195+
fill="none"
196+
xmlns="http://www.w3.org/2000/svg"
197+
>
198+
<path
199+
d="M5.00001 1L5 161.5M5 161.5L1 157.5M5 161.5L9 157.5"
200+
stroke="currentColor"
201+
// strokeWidth={1.5}
202+
stroke-linecap="round"
203+
stroke-linejoin="round"
204+
/>
205+
</svg>
206+
</div> */}
207+
<div className="grid grid-rows-[1fr_1px] h-full justify-items-center">
208+
<div className="bg-white/40 w-[1.5px] h-full"></div>
209+
<div className="bg-white/60 w-[12px] h-full"></div>
210+
</div>
211+
</div>
212+
</motion.div>
213+
</motion.div>
214+
</div>
215+
{unit === 'lvh' && (
216+
<motion.div
217+
transition={{
218+
...transition,
219+
}}
220+
variants={{
221+
visible: {
222+
bottom: `-${viewport.navBarHeight}px`,
223+
height: `${viewport.navBarHeight}px`,
224+
},
225+
hidden: {
226+
bottom: '5px',
227+
height: '0px',
228+
},
229+
}}
230+
initial="visible"
231+
animate={hidden ? 'hidden' : 'visible'}
232+
// For some reason putting this in a tailwind class doesn't work
233+
style={{ width: `${viewport.width - 12}px` }}
234+
className={clsx(
235+
colorStyles,
236+
'opacity-20 rounded-b-md absolute left-0 right-0 mx-auto'
237+
)}
238+
></motion.div>
239+
)}{' '}
240+
</div>
241+
<div
242+
style={{ backgroundPosition: '10px 10px' }}
243+
className=" z-[-1] pointer-events-none absolute inset-0 bg-grid-slate-100 [mask-image:linear-gradient(0deg,#fff,rgba(255,255,255,0.6))] dark:bg-grid-slate-700/25 dark:[mask-image:linear-gradient(0deg,rgba(255,255,255,0.1),rgba(255,255,255,0.5))]"
244+
/>
245+
<div className="z-[-1] pointer-events-none absolute inset-0 border border-black/5 rounded-xl dark:border-white/5" />
246+
</div>
247+
</>
248+
)
249+
}

src/components/Editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function Frame({ className, color = 'sky', children }) {
2626
export function EditorPane({ filename, scroll = false, code, children }) {
2727
return (
2828
<div className="pt-2 bg-slate-800 shadow-lg group">
29-
<TabBar primary={{ name: filename }} showTabMarkers={false} />
29+
{filename && <TabBar primary={{ name: filename }} showTabMarkers={false} />}
3030
<div
3131
className={clsx(
3232
'children:my-0 children:!shadow-none children:bg-transparent',

src/css/utilities.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,16 @@
3737
.changing-theme * {
3838
transition: none !important;
3939
}
40+
41+
42+
/* Hide scrollbar for Chrome, Safari and Opera */
43+
.no-scrollbar::-webkit-scrollbar {
44+
display: none;
45+
}
46+
47+
/* Hide scrollbar for IE, Edge and Firefox */
48+
.no-scrollbar {
49+
-ms-overflow-style: none; /* IE and Edge */
50+
scrollbar-width: none; /* Firefox */
51+
}
52+

src/navs/documentation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export const documentationNav = {
103103
pages['height'],
104104
pages['min-height'],
105105
pages['max-height'],
106+
pages['size'],
106107
],
107108
Typography: [
108109
pages['font-family'],
@@ -126,6 +127,7 @@ export const documentationNav = {
126127
pages['text-underline-offset'],
127128
pages['text-transform'],
128129
pages['text-overflow'],
130+
pages['text-wrap'],
129131
pages['text-indent'],
130132
pages['vertical-align'],
131133
pages['whitespace'],
@@ -226,7 +228,7 @@ export const documentationNav = {
226228
pages['will-change'],
227229
],
228230
SVG: [pages['fill'], pages['stroke'], pages['stroke-width']],
229-
Accessibility: [pages['screen-readers']],
231+
Accessibility: [pages['screen-readers'], pages['forced-color-adjust']],
230232
'Official Plugins': [
231233
pages['typography-plugin'],
232234
{
81.7 KB
Loading

0 commit comments

Comments
 (0)