Skip to content

Commit

Permalink
Bump to v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
woofers committed Mar 28, 2024
1 parent b2a7c66 commit a962219
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-sheet-slide-demo",
"homepage": "http://woofers.github.io/react-sheet-slide",
"version": "1.3.0",
"version": "1.4.0",
"author": "Jaxson Van Doorn <jaxson.vandoorn@gmail.com>",
"license": "MIT",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions demo/src/app/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ ul {

#react-sheet-slide > div > div {
--width: min(100%, 640px);
--modal-width: 492px;
}

@layer base {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-sheet-slide",
"version": "1.3.0",
"version": "1.4.0",
"description": "A responsive React draggable sheet and dialog component",
"src": "src/index.tsx",
"main": "lib/index.cjs",
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/use-spring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const useSpringWrapper = () =>
type AsyncType = { config?: SpringConfig } & Record<string, unknown>
type SpringSetAsync = (e: AsyncType) => Promise<unknown>

const useSpring = (): [Spring, SpringSet, SpringSetAsync] => {
const useSpring = ({ velocity: defaultVelocity } = { velocity: 1 }): [Spring, SpringSet, SpringSetAsync] => {
const [spring, api] = useSpringWrapper()
const set = useMemo(() => api.start.bind(api), [api])
const asyncSet = useCallback(
({ config: { velocity = 1, ...rest } = {}, ...opts }: AsyncType) =>
({ config: { velocity = defaultVelocity, ...rest } = {}, ...opts }: AsyncType) =>
new Promise(resolve =>
set({
...opts,
Expand All @@ -51,7 +51,7 @@ const useSpring = (): [Spring, SpringSet, SpringSetAsync] => {
}
})
),
[set]
[set, defaultVelocity]
)
return [spring, set, asyncSet]
}
Expand Down
2 changes: 1 addition & 1 deletion src/sheet.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ body[style].sheet-open {

.modal-modal {
max-height: calc(100% - var(--padding) * 2);
max-width: 492px;
max-width: var(--modal-width, 492px);
border-radius: var(--radius);
display: flex;
background: var(--background);
Expand Down
6 changes: 4 additions & 2 deletions src/sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ type BaseProps = {
selectedDetent?: SelectedDetent
useModal?: boolean
useDarkMode?: boolean
velocity?: number
}

type InteralSheetProps = Callbacks & BaseProps & { close: () => void }
Expand Down Expand Up @@ -200,7 +201,8 @@ const BaseSheet = forwardRef<HTMLDivElement, InteralSheetProps>(
detents: getDetents = detents.fit,
selectedDetent: getSelectedDetent = _selectedDetent,
useModal: useModalInitial,
useDarkMode: useDarkModeInitial,
useDarkMode: useDarkModeInitial,
velocity = 1,
...rest
},
ref
Expand Down Expand Up @@ -236,7 +238,7 @@ const BaseSheet = forwardRef<HTMLDivElement, InteralSheetProps>(
const headerRef = useRef<HTMLDivElement | null>(null)
const footerRef = useRef<HTMLDivElement | null>(null)

const [spring, set, asyncSet] = useSpring()
const [spring, set, asyncSet] = useSpring({ velocity })
const { modal, backdrop } = useSpringInterpolations({ spring })

const resizeSourceRef = useRef<ResizeSource>()
Expand Down

0 comments on commit a962219

Please sign in to comment.