Skip to content

Commit

Permalink
โœจ Release v1.2.0 (#24)
Browse files Browse the repository at this point in the history
* rename: iPhone.svg to iphone.svg
* feat: ์˜คํƒ€ ์ˆ˜์ •
* feat: update v1.2.0
* rename: iPhone.svg to iphone.svg
* feat: ์—…๋ฐ์ดํŠธ ๊ธฐ๋Šฅ ๋ฌธ์„œ ๋ฐ˜์˜
  • Loading branch information
BangDori authored Jun 1, 2024
1 parent b40c026 commit 322ff0e
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 52 deletions.
1 change: 1 addition & 0 deletions README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $ yarn add react-iphone-layout --dev
- **์›น ๋ทฐ ์ง€์›**: iPhone์„ ์›น์— ์ตœ์ ํ™”ํ•˜์—ฌ ์›ํ™œํ•œ ์›น ๋ทฐ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
- **๋™์  iPhone ๋ทฐ ํฌ๊ธฐ ์กฐ์ •**: iPhone ๋ทฐ์˜ ํฌ๊ธฐ๋ฅผ ๋™์ ์œผ๋กœ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
- **์‹ค์‹œ๊ฐ„ ๋ณด๊ธฐ ์ „ํ™˜**: ์ œ์–ด ๋ฐ•์Šค๋ฅผ ํ†ตํ•ด iPhone ๋ทฐ์™€ ๋…ธํŠธ๋ถ ๋ทฐ๋ฅผ ์‹ค์‹œ๊ฐ„์œผ๋กœ ํ™•์ธํ•˜์—ฌ ๋‹ค์–‘ํ•œ ์žฅ์น˜์—์„œ ๋ ˆ์ด์•„์›ƒ์„ ์›ํ™œํ•˜๊ฒŒ ํ…Œ์ŠคํŠธํ•˜๊ณ  ์ตœ์ ํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
- **ํšŒ์ „ ๊ธฐ๋Šฅ**: iPhone ํ™”๋ฉด์˜ ํšŒ์ „ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. (๋‚ด๋ถ€ ์ฝ˜ํ…์ธ ๋Š” ํšŒ์ „๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค)

## ์‹œ์ž‘ํ•˜๊ธฐ

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $ yarn add react-iphone-layout --dev
- **Web View Support**: Optimize for iPhone on the web to provide a seamless web view.
- **Dynamic iPhone View Resizing**: You can dynamically adjust the size of the iPhone view.
- **Real-Time View Switching**: Check the iPhone view and laptop view in real-time through a control box, allowing for seamless testing and optimization of layouts across different devices.
- **Rotation iPhone**: provide a screen rotation feature for the iPhone. (The internal content does not rotate)

## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-iphone-layout",
"private": false,
"version": "1.1.1",
"version": "1.2.0",
"type": "module",
"description": "React iPhone layout in web browser",
"author": "bangdori <[email protected]>",
Expand Down
12 changes: 6 additions & 6 deletions playground/src/ui/control-box/hooks/useRotate.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { useEffect, useRef } from "react";

const IPHONE_PROTRAIT_MODE = 0; // ์„ธ๋กœ ๋ชจ๋“œ
const IPHONE_PORTRAIT_MODE = 0; // ์„ธ๋กœ ๋ชจ๋“œ
const IPHONE_LANDSCAPE_MODE = -90; // ๊ฐ€๋กœ ๋ชจ๋“œ

export const useRotate = () => {
const iPhoneModeRef = useRef(IPHONE_PROTRAIT_MODE);
const iPhoneModeRef = useRef(IPHONE_PORTRAIT_MODE);

useEffect(() => {
document.documentElement.style.setProperty(
"--iphone-mode",
`${IPHONE_PROTRAIT_MODE}deg`
`${IPHONE_PORTRAIT_MODE}deg`
);
}, []);

const handleRotate = () => {
if (iPhoneModeRef.current === IPHONE_PROTRAIT_MODE) {
if (iPhoneModeRef.current === IPHONE_PORTRAIT_MODE) {
// ๊ฐ€๋กœ ๋ชจ๋“œ๋กœ ๋ณ€๊ฒฝ
iPhoneModeRef.current = IPHONE_LANDSCAPE_MODE;
document.documentElement.style.setProperty(
Expand All @@ -23,10 +23,10 @@ export const useRotate = () => {
);
} else {
// ์„ธ๋กœ ๋ชจ๋“œ๋กœ ๋ณ€๊ฒฝ
iPhoneModeRef.current = IPHONE_PROTRAIT_MODE;
iPhoneModeRef.current = IPHONE_PORTRAIT_MODE;
document.documentElement.style.setProperty(
"--iphone-mode",
`${IPHONE_PROTRAIT_MODE}deg`
`${IPHONE_PORTRAIT_MODE}deg`
);
}
};
Expand Down
15 changes: 7 additions & 8 deletions src/lib/ui/control-box/ControlBox.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
}

.ril-control-list .ril-control-item {
display: flex;
justify-content: center;
align-items: center;

width: 40px;
height: 40px;

Expand All @@ -35,15 +39,10 @@
fill: var(--ril-control-focus);
}

.laptop-icon:hover rect {
fill: var(--ril-control-focus);
}

.plus-icon:hover rect,
.plus-icon:hover line,
.minus-icon:hover rect,
.minus-icon:hover line {
.ril-control-item:hover svg * {
stroke: var(--ril-control-focus);
fill: var(--ril-control-focus);
color: var(--ril-control-focus);
}

.ril-control-list,
Expand Down
12 changes: 9 additions & 3 deletions src/lib/ui/control-box/ControlBox.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import IPhoneIcon from "./assets/iPhone.svg?react";
import IPhoneIcon from "./assets/iphone.svg?react";
import LaptopIcon from "./assets/laptop.svg?react";
import RotationIcon from "./assets/rotation.svg?react";
import PlusIcon from "./assets/plus.svg?react";
import MinusIcon from "./assets/minus.svg?react";

import "./ControlBox.css";
import "./Position.css";
import { useResize } from "./hooks/useResize";
import { useResize } from "./hooks";
import { useRotate } from "./hooks";

interface ControlBoxProps {
position: "top" | "right" | "bottom" | "left";
Expand All @@ -32,6 +34,7 @@ export const ControlBox: React.FC<ControlBoxProps> = ({
minSize,
maxSize
);
const { handleRotate } = useRotate();

if (mode === "laptop") {
return (
Expand All @@ -40,7 +43,7 @@ export const ControlBox: React.FC<ControlBoxProps> = ({
className="iPhone-active-btn"
onClick={() => handleChangeMode("iPhone")}
>
<IPhoneIcon className="iphone-icon" width="64" height="64" />
<IPhoneIcon className="iphone-icon" width="48" height="48" />
</button>
</div>
);
Expand All @@ -65,6 +68,9 @@ export const ControlBox: React.FC<ControlBoxProps> = ({
>
<LaptopIcon className="laptop-icon" />
</li>
<li className="ril-control-item" onClick={handleRotate}>
<RotationIcon className="rotation-icon" />
</li>
<li className="ril-control-item" onClick={handleSizeUp}>
<PlusIcon className="plus-icon" />
</li>
Expand Down
14 changes: 0 additions & 14 deletions src/lib/ui/control-box/assets/iPhone.svg

This file was deleted.

20 changes: 20 additions & 0 deletions src/lib/ui/control-box/assets/iphone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 14 additions & 9 deletions src/lib/ui/control-box/assets/laptop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions src/lib/ui/control-box/assets/minus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions src/lib/ui/control-box/assets/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/lib/ui/control-box/assets/rotation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/lib/ui/control-box/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { useResize } from "./useResize";
export { useRotate } from "./useRotate";
35 changes: 35 additions & 0 deletions src/lib/ui/control-box/hooks/useRotate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { useEffect, useRef } from "react";

const IPHONE_PORTRAIT_MODE = 0; // ์„ธ๋กœ ๋ชจ๋“œ
const IPHONE_LANDSCAPE_MODE = -90; // ๊ฐ€๋กœ ๋ชจ๋“œ

export const useRotate = () => {
const iPhoneModeRef = useRef(IPHONE_PORTRAIT_MODE);

useEffect(() => {
document.documentElement.style.setProperty(
"--iphone-mode",
`${IPHONE_PORTRAIT_MODE}deg`
);
}, []);

const handleRotate = () => {
if (iPhoneModeRef.current === IPHONE_PORTRAIT_MODE) {
// ๊ฐ€๋กœ ๋ชจ๋“œ๋กœ ๋ณ€๊ฒฝ
iPhoneModeRef.current = IPHONE_LANDSCAPE_MODE;
document.documentElement.style.setProperty(
"--iphone-mode",
`${IPHONE_LANDSCAPE_MODE}deg`
);
} else {
// ์„ธ๋กœ ๋ชจ๋“œ๋กœ ๋ณ€๊ฒฝ
iPhoneModeRef.current = IPHONE_PORTRAIT_MODE;
document.documentElement.style.setProperty(
"--iphone-mode",
`${IPHONE_PORTRAIT_MODE}deg`
);
}
};

return { handleRotate };
};
3 changes: 3 additions & 0 deletions src/lib/ui/iPhone-layout/IPhoneLayout.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

aspect-ratio: 256 / 538;
height: var(--iphone-size);
rotate: var(--iphone-mode);

transition: rotate 1.5s;
}

.ril-client-area {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ui/iPhone-layout/IPhoneLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useInitIPhone } from "./hooks/useInitIPhone";
import iPhoneStatus from "./assets/iPhone_status.png";
import { ControlBox } from "../control-box";
import "./IPhoneLayout.css";
import { useLaoyutMode } from "./hooks/useLaoyutMode";
import { useLayoutMode } from "./hooks/useLayoutMode";

interface IPhoneLayoutProps {
children: React.ReactNode;
Expand All @@ -26,7 +26,7 @@ export function IPhoneLayout({
maxSize = 100,
}: IPhoneLayoutProps) {
const { iPhoneLayoutRef, iPhoneSizeRef } = useInitIPhone(defaultSize);
const { currentMode, handleChangeMode } = useLaoyutMode(mode);
const { currentMode, handleChangeMode } = useLayoutMode(mode);

return (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react";

export const useLaoyutMode = (mode: "iPhone" | "laptop") => {
export const useLayoutMode = (mode: "iPhone" | "laptop") => {
const [currentMode, setCurrentMode] = useState<"iPhone" | "laptop">(mode);

const handleChangeMode = (newMode: "iPhone" | "laptop") => {
Expand Down

0 comments on commit 322ff0e

Please sign in to comment.