-
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.
feat(phone): add (semi) responsiveness & screen dragging
- Loading branch information
Showing
11 changed files
with
80 additions
and
65 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
Binary file not shown.
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 |
---|---|---|
@@ -1,33 +1,33 @@ | ||
import PhoneContainer from "@/components/phone/PhoneContainer"; | ||
import PhoneHeader from "@/components/phone/PhoneHeader"; | ||
import PhoneGrid, { PhoneGridAppList } from "@/components/phone/PhoneGrid"; | ||
import PhoneDock from "@/components/phone/PhoneDock"; | ||
import usePhoneStore from "@/store/phone"; | ||
import defaultPhoneOutline from "@/assets/phone/phone_container.webp"; | ||
import PhoneScreenList from "@/components/phone/PhoneScreenList"; | ||
|
||
export default function Phone() { | ||
const { | ||
views, | ||
viewIndex, | ||
const { | ||
isDiverged, | ||
divergence, | ||
// @ts-ignore | ||
incrementIndex, | ||
// @ts-ignore | ||
decrementIndex | ||
divergence | ||
} = usePhoneStore((state) => state); | ||
const currentView = views[viewIndex] as PhoneGridAppList || []; | ||
|
||
|
||
return ( | ||
<PhoneContainer> | ||
<PhoneHeader /> | ||
{ | ||
isDiverged | ||
? divergence | ||
: <> | ||
<PhoneGrid apps={currentView} /> | ||
<PhoneDock /> | ||
</> | ||
} | ||
</PhoneContainer> | ||
<div className="relative h-[32rem] flex justify-center items-center"> | ||
<img | ||
src={defaultPhoneOutline} | ||
className="z-30 w-full h-full object-contain pointer-events-none" | ||
/> | ||
<div className="absolute top-0 flex h-full w-[90%] pt-[2%] sm:pt-[4%] pb-[4%] pl-[17%] pr-[17%] sm:pr-[1%] sm:pl-[2%] overflow-hidden"> | ||
<div className="h-full min-w-full flex justify-evenly flex-col bg-phone-background bg-cover bg-center"> | ||
<PhoneHeader /> | ||
{isDiverged && | ||
<div className="absolute top-0 h-full w-full pt-[2%] sm:pt-[5%] pb-[4%] pr-[38%] sm:pr-[4%] overflow-hidden z-10"> | ||
{divergence} | ||
</div> | ||
} | ||
<PhoneScreenList /> | ||
<PhoneDock /> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
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 was deleted.
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
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,43 @@ | ||
import PhoneGrid from "@/components/phone/PhoneGrid"; | ||
import { useState } from "react"; | ||
import usePhoneStore from "@/store/phone"; | ||
|
||
export default function PhoneScreenList() { | ||
const { | ||
views, | ||
viewIndex, | ||
// @ts-ignore | ||
incrementIndex, | ||
// @ts-ignore | ||
decrementIndex | ||
} = usePhoneStore((state) => state); | ||
const [dragX, setDragX] = useState(0); | ||
|
||
// Temporary - just to test multiple views with drag | ||
const handleDrag = (event: React.MouseEvent<HTMLDivElement>) => { | ||
if (event.buttons === 1) { | ||
const dx = event.movementX; | ||
setDragX((prev) => prev + dx); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="h-full overflow-hidden"> | ||
<div | ||
className={`flex h-full`} | ||
style={{ | ||
width: `${views.length * 100}%`, | ||
transform: `translateX(${dragX}px)` | ||
}} | ||
onMouseMove={handleDrag} | ||
> | ||
<div className="relative w-full h-full flex justify-start items-center flex-col"> | ||
<PhoneGrid apps={views[viewIndex]} /> | ||
</div> | ||
<div className="relative w-full h-full flex justify-start items-center flex-col"> | ||
<PhoneGrid apps={views[viewIndex+1]} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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