generated from pixel-perfect-agency/next-foundation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from Willem-Jaap/preview-rework
Preview rework
- Loading branch information
Showing
11 changed files
with
256 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use client'; | ||
|
||
import useSettings from '~/hooks/useSettings'; | ||
|
||
const PreviewElement = () => { | ||
const { watch } = useSettings(); | ||
|
||
return ( | ||
<div | ||
className="h-20 rounded-lg border border-dashed border-neutral-400 bg-neutral-200 px-2 py-1" | ||
style={{ margin: `0 ${watch('clamp').replace('vw', '%')}` }} | ||
/> | ||
); | ||
}; | ||
|
||
export default PreviewElement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use client'; | ||
|
||
import { type Dispatch, type SetStateAction } from 'react'; | ||
import { type SpringRef } from '@react-spring/web'; | ||
|
||
import { Slider } from '~/components/ui/slider'; | ||
|
||
interface Props { | ||
api: SpringRef<{ | ||
width: number; | ||
}>; | ||
percentage: number; | ||
setPercentage: Dispatch<SetStateAction<number>>; | ||
} | ||
|
||
const PreviewHeader = ({ api, percentage, setPercentage }: Props) => { | ||
const onChange = (values: number[]) => { | ||
const [value] = values; | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
api.start({ width: value }); | ||
setPercentage(value); | ||
}; | ||
|
||
return ( | ||
<div className="flex w-full items-center justify-between gap-4 border-b border-b-neutral-100 p-5"> | ||
<h2 className="text-lg font-medium">Emulated screen width</h2> | ||
<div className="flex items-center gap-4"> | ||
<Slider | ||
className="w-40" | ||
min={0} | ||
max={100} | ||
step={1} | ||
defaultValue={[60]} | ||
onValueChange={onChange} | ||
/> | ||
<div className="w-[calc(1.2rem_+_6ch)] rounded-lg border border-neutral-100 px-3 py-2 text-right font-medium text-neutral-600"> | ||
{Math.round((1920 / 100) * percentage)}px | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PreviewHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use client'; | ||
|
||
import useSettings from '~/hooks/useSettings'; | ||
|
||
const PreviewText = () => { | ||
const { watch } = useSettings(); | ||
|
||
return ( | ||
<div | ||
className="h-20 rounded-lg border border-dashed border-neutral-400 bg-neutral-200 px-2 py-1" | ||
style={{ margin: `0 ${watch('clamp').replace('vw', '%')}` }}> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor | ||
</div> | ||
); | ||
}; | ||
|
||
export default PreviewText; |
Oops, something went wrong.