Skip to content

Commit dc2b126

Browse files
authored
fix: API cleanup
1 parent fc22e0d commit dc2b126

24 files changed

+2273
-917
lines changed

.eslintignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Ignore nested node_modules
2+
node_modules/
3+
coverage/
4+
dist/
5+
.cache
6+
.next
7+
.vercel

.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const { version: reactVersion } = require('react/package.json')
2+
3+
module.exports = {
4+
extends: ['react-app'],
5+
settings: { react: { version: reactVersion } },
6+
rules: {
7+
'jsx-a11y/anchor-is-valid': ['off'],
8+
},
9+
}

TODO.md

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,31 @@ Stop relying on memo stuff.
33
If react's render loop triggers, communicate to outside fn's via refs and the like.
44
A change to snap points affects how far one can drag.
55

6-
- minHeight should be renamed safeHeight or similar, as it denotes the smallest height while still being able to render the drag handle. Isn't it header height technically?
7-
- maxHeight renamed to contentHeight, as that's what it is.
8-
- rename initialHeight to initialSnapPoint.
9-
- rename viewportHeight to maxHeight?
10-
- rename isOpen to open, like the <details> tag works.
11-
- rename setHeight to setSnapPoint
6+
```
7+
max-content
8+
The intrinsic preferred width.
9+
min-content
10+
The intrinsic minimum width.
11+
fit-content(<length-percentage>)
12+
Uses the fit-content formula with the available space replaced by the specified argument, i.e. min(max-content, max(min-content, <length-percentage>)).
13+
14+
```
15+
16+
hmmmm
17+
18+
- currentHeight => height
19+
- footerHeight => added
20+
- headerHeight => added
21+
- maxHeight => minHeight, includes header and footer heights, it tries to avoid a scrollbar
22+
- minHeight => gone, used to be header + footer
23+
- viewportHeight => maxHeight
24+
- snap points array is optional
25+
26+
footerHeight
27+
headerHeight
28+
height
29+
maxHeight
30+
minHeight
1231

1332
## package.json stuffs
1433

@@ -21,3 +40,53 @@ A change to snap points affects how far one can drag.
2140
- Play icon: https://fontawesome.com/icons/play-circle?style=regular
2241
- Phone frame used in logo: https://www.figma.com/community/file/896042888090872154/Mono-Devices-1.0
2342
- iPhone frame used to wrap examples: https://www.figma.com/community/file/858143367356468985/(Variants)-iOS-%26-iPadOS-14-UI-Kit-for-Figma
43+
44+
# Ok let's map this nonsense
45+
46+
Consider using a
47+
48+
```js
49+
const [, nextTick] = useState(0)
50+
nextTick((_) => ++_)
51+
```
52+
53+
to force updates.
54+
Fast way to check if there's new snapPoints generated:
55+
56+
```js
57+
var arr1 = [1, 2, 3, 4, 5]
58+
var arr2 = [1, 2, 3, 4, 5]
59+
60+
if (JSON.stringify(arr1) === JSON.stringify(arr2)) {
61+
console.log('They are equal!')
62+
}
63+
```
64+
65+
Faux plugin architecture. "Plugins" or "hooks" can register in an es6 map if they want to do work before the animation starts, while the bottom sheet is resting in the final state but opacity: 0. This allows setting up focus lock, scroll lock and more ahead of time. Hopefully alleviating a lot of jank.
66+
67+
a transition to close can be cancelled if the open state is changed back to `true`.
68+
open/close is fairly easy and stabl. snap to snap on the other hand, require diligence in making sure whoever cancels a snap transition, makes sure to send the animation on the right direction.
69+
70+
## Changes that can happen from React's side of things at any time by means of a prop change
71+
72+
And that may affect side effects that are running atm
73+
74+
- isOpen
75+
- snapPoints
76+
- initialHeight
77+
78+
## Big picture state machines
79+
80+
- transitioning from closed to open.
81+
- transition to closed while opening but not open.
82+
- transition to open while closing.
83+
- transition to closed after finished opening.
84+
- while opening the user interrupts and starts dragging (should be fine, all work should be done by now.).
85+
- while opening the user keyboard navs, maybe even fucks the scroll.
86+
87+
- Some hooks care only about if we're on our way to open, or on our way to close.
88+
- Other hooks care about the current drag state.
89+
- Dragging is king, should not be interruptible, but may allow side effects that affect where/how dragging happens.
90+
- Except if the window changes height, maybe respond to header and footer height changes too by interrupting.
91+
- Focus set by keyboard nav or a screen reader can fuck things up.
92+
- Consider two drag modes? One fast, but can get scroll fuckups, one that's like the current one, safe because it changes the height property.

docs/StickyNugget.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function StickyNugget({
1010
example,
1111
}: {
1212
flip?: boolean
13-
heading: React.ReactNode
13+
heading: string
1414
lead: React.ReactNode
1515
example: string
1616
}) {
@@ -64,6 +64,7 @@ export default function StickyNugget({
6464
<div className={styles.phoneframe}>
6565
{active && (
6666
<iframe
67+
title={heading}
6768
className={cx('z-10 transition-opacity duration-300', {
6869
'opacity-0': !loaded,
6970
})}

docs/fixtures/Container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function Container({ children }: { children: React.ReactNode }) {
1212
}, [env])
1313

1414
return (
15-
<main className="grid place-items-center min-h-screen bg-white">
15+
<main className="grid place-content-evenly min-h-screen bg-white">
1616
{children}
1717
</main>
1818
)

docs/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
@tailwind base;
22

3+
:root {
4+
--rsbs-backdrop-bg: rgba(15, 23, 42, 0.7);
5+
}
6+
37
html,
48
body {
59
@apply font-body overscroll-y-none snap snap-proximity snap-y;

next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {}

0 commit comments

Comments
 (0)