Skip to content

Commit

Permalink
fix : gitpage 테스트3
Browse files Browse the repository at this point in the history
  • Loading branch information
changchangwoo committed Jan 16, 2024
1 parent 28a70f3 commit ece6d82
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 103 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { init } from "./Utils/router.js";
import { init } from "./utils/router.js";
import MainPage from "./MainPage/MainPage.js";
import DetailPage from "./DetailPage/DetailPage.js";

Expand Down
64 changes: 32 additions & 32 deletions src/DetailPage/DescriptionOnOff.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
import { delay } from "../Utils/delay.js"
import { delay } from "../utils/delay.js";

export default function DescriptionOnOff({ $parent }) {
const $descriptionOnOff = document.createElement('div')
$descriptionOnOff.id = "descriptionOnOff"
$descriptionOnOff.innerHTML = `visible check`
const $descriptionOnOff = document.createElement("div");
$descriptionOnOff.id = "descriptionOnOff";
$descriptionOnOff.innerHTML = `visible check`;

var visible = true
var visible = true;

$descriptionOnOff.addEventListener('click', () => {
const $mainLogo = document.querySelector('#mainLogo')
const $detailDescriptionContainer = document.querySelector('#detailDescriptionContainer')
const $sublogo = document.querySelector('#subLogo')


if (visible) {
$mainLogo.classList.remove('show')
$detailDescriptionContainer.classList.remove('show')
$sublogo.classList.remove('show')
$descriptionOnOff.classList.remove('show')
visible = false
} else if (!visible) {
$mainLogo.classList.add('show')
$detailDescriptionContainer.classList.add('show')
$sublogo.classList.add('show')
$descriptionOnOff.classList.add('show')
visible = true
}
})

this.render = async () => {
$parent.appendChild($descriptionOnOff)
$descriptionOnOff.classList.remove("show")
await delay(500);
$descriptionOnOff.classList.add("show")
$descriptionOnOff.addEventListener("click", () => {
const $mainLogo = document.querySelector("#mainLogo");
const $detailDescriptionContainer = document.querySelector(
"#detailDescriptionContainer"
);
const $sublogo = document.querySelector("#subLogo");

if (visible) {
$mainLogo.classList.remove("show");
$detailDescriptionContainer.classList.remove("show");
$sublogo.classList.remove("show");
$descriptionOnOff.classList.remove("show");
visible = false;
} else if (!visible) {
$mainLogo.classList.add("show");
$detailDescriptionContainer.classList.add("show");
$sublogo.classList.add("show");
$descriptionOnOff.classList.add("show");
visible = true;
}
}
});

this.render = async () => {
$parent.appendChild($descriptionOnOff);
$descriptionOnOff.classList.remove("show");
await delay(500);
$descriptionOnOff.classList.add("show");
};
}
2 changes: 1 addition & 1 deletion src/DetailPage/DetailDescription.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { delay } from "../Utils/delay.js";
import { delay } from "../utils/delay.js";
import ImageController from "./ImageController.js";

export default function DetailDescription({ $parent }) {
Expand Down
4 changes: 2 additions & 2 deletions src/DetailPage/DetailPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CreateLogo from "../Components/CreateLogo.js";
import { delay } from "../Utils/delay.js";
import CreateLogo from "../components/CreateLogo.js";
import { delay } from "../utils/delay.js";
import DescriptionOnOff from "./DescriptionOnOff.js";
import DetailDescription from "./DetailDescription.js";
import setDetailPage from "./SetDetailPage.js";
Expand Down
53 changes: 28 additions & 25 deletions src/DetailPage/ImageController.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
import { delay } from "../Utils/delay.js";
import { delay } from "../utils/delay.js";

export default async function ImageController(element, imgs, page) {
var current_src = page.style.backgroundImage;
console.log(current_src);
var current_src = page.style.backgroundImage;
console.log(current_src);

const regex = /url\(".*\/([^\/]+)(\d+)\.jpg"\)/;
var imageName = "";
var numberBeforeJpg = 0;
var newNumber = 0;
const regex = /url\(".*\/([^\/]+)(\d+)\.jpg"\)/;
var imageName = "";
var numberBeforeJpg = 0;
var newNumber = 0;

const match = current_src.match(regex);
const match = current_src.match(regex);

if (match) {
imageName = match[1];
numberBeforeJpg = match[2];
console.log(imageName, numberBeforeJpg);
} else {
console.log("매칭되는 문자열이 없습니다.");
}
if (match) {
imageName = match[1];
numberBeforeJpg = match[2];
console.log(imageName, numberBeforeJpg);
} else {
console.log("매칭되는 문자열이 없습니다.");
}

if (element === "next") {
newNumber = Number(numberBeforeJpg) + 1;
if (newNumber > (imgs.length - 1)) newNumber = 0;
} else if (element === "prev") {
newNumber = Number(numberBeforeJpg) - 1;
if (newNumber < 0) newNumber = imgs.length - 1;
}
current_src = current_src.replace(new RegExp(`${imageName}\\d+\\.jpg`), `${imageName}${newNumber}.jpg`);
await delay(500)
page.style.backgroundImage = current_src
if (element === "next") {
newNumber = Number(numberBeforeJpg) + 1;
if (newNumber > imgs.length - 1) newNumber = 0;
} else if (element === "prev") {
newNumber = Number(numberBeforeJpg) - 1;
if (newNumber < 0) newNumber = imgs.length - 1;
}
current_src = current_src.replace(
new RegExp(`${imageName}\\d+\\.jpg`),
`${imageName}${newNumber}.jpg`
);
await delay(500);
page.style.backgroundImage = current_src;
}
10 changes: 5 additions & 5 deletions src/DetailPage/SetDetailPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { delay } from "../Utils/delay.js"
import { delay } from "../utils/delay.js";

export default async function setDetailPage ({imgs, $parent}) {
$parent.style.backgroundImage = `url(${imgs[0]})`
await delay(300)
}
export default async function setDetailPage({ imgs, $parent }) {
$parent.style.backgroundImage = `url(${imgs[0]})`;
await delay(300);
}
4 changes: 2 additions & 2 deletions src/MainPage/GaugeController.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { routeChange } from "../Utils/router.js";
import { setMainAnimation } from "../Utils/setAnimation.js";
import { routeChange } from "../utils/router.js";
import { setMainAnimation } from "../utils/setAnimation.js";

export default function GaugeController({ $parent }) {
const $selectedGauge = document.createElement("div");
Expand Down
17 changes: 10 additions & 7 deletions src/MainPage/MainPage.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import CreateLogo from "../Components/CreateLogo.js";
import CreateLogo from "../components/CreateLogo.js";
import Slider from "./Slider.js";
import SliderController from "./SliderController.js";
import GaugeController from "./GaugeController.js";
import { delay } from "../Utils/delay.js";
import { delay } from "../utils/delay.js";

export default function MainPage({ $target }) {
const $page = document.createElement("div");
$page.className = "mainPage";

let LogoText = 'STUDIO GHIBLI'
let subLogoText = "Quiet beauty that evokes memories";
const createLogo = new CreateLogo({ $parent: $page});
let LogoText = "STUDIO GHIBLI";
let subLogoText = "Quiet beauty that evokes memories";

const createLogo = new CreateLogo({ $parent: $page });
const sliderController = new SliderController({ $parent: $page });
const gaugeController = new GaugeController({ $parent: $page });
const slider = new Slider({ $parent: $page });

this.render = async () => {
$target.appendChild($page);
await createLogo.startAnimation({ mainText : LogoText, subText : subLogoText});
await createLogo.startAnimation({
mainText: LogoText,
subText: subLogoText,
});
await delay(300);
await sliderController.render();
gaugeController.render();
Expand Down
20 changes: 10 additions & 10 deletions src/MainPage/Slider.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { delay } from "../Utils/delay.js";
import { delay } from "../utils/delay.js";

export default function Slider({ $parent }) {
const $sliderContainer = document.createElement("div");
$sliderContainer.id = "sliderContainer";
$sliderContainer.innerHTML = `
const $sliderContainer = document.createElement("div");
$sliderContainer.id = "sliderContainer";
$sliderContainer.innerHTML = `
<div class="hideLeft">
바람이 분다
<img src="./img/carousel/kazetachinu.jpg">
Expand Down Expand Up @@ -46,10 +46,10 @@ export default function Slider({ $parent }) {
</div>
`;

this.render = async () => {
$parent.appendChild($sliderContainer);
$sliderContainer.classList.remove("show");
await delay(500);
$sliderContainer.classList.add("show");
};
this.render = async () => {
$parent.appendChild($sliderContainer);
$sliderContainer.classList.remove("show");
await delay(500);
$sliderContainer.classList.add("show");
};
}
2 changes: 1 addition & 1 deletion src/MainPage/SliderController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { delay } from "../Utils/delay.js";
import { delay } from "../utils/delay.js";
import SliderEvent from "./SliderEvent.js";

export default function SliderController({ $parent }) {
Expand Down
12 changes: 5 additions & 7 deletions src/components/CreateLogo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { delay } from "../Utils/delay.js";
import { delay } from "../utils/delay.js";

export default function CreateLogo({ $parent}) {
export default function CreateLogo({ $parent }) {
const $mainLogo = document.createElement("div");
const $subLogo = document.createElement("div");

Expand All @@ -10,9 +10,9 @@ export default function CreateLogo({ $parent}) {
$parent.appendChild($mainLogo);
$parent.appendChild($subLogo);

this.startAnimation = async ({mainText, subText}) => {
$mainLogo.innerHTML = mainText
$subLogo.innerHTML = subText
this.startAnimation = async ({ mainText, subText }) => {
$mainLogo.innerHTML = mainText;
$subLogo.innerHTML = subText;

const addAndRemoveClass = async (element, className) => {
element.classList.remove(className);
Expand All @@ -22,6 +22,4 @@ export default function CreateLogo({ $parent}) {
await addAndRemoveClass($mainLogo, "show");
await addAndRemoveClass($subLogo, "show");
};


}
15 changes: 7 additions & 8 deletions src/components/Nav.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { routeChange } from "../Utils/router.js";
import { setMainAnimation, setDetailAnimation } from "../Utils/setAnimation.js";

import { routeChange } from "../utils/router.js";
import { setMainAnimation, setDetailAnimation } from "../utils/setAnimation.js";

export default function Nav({ $target }) {
const $navContainer = document.createElement("div");
Expand All @@ -15,11 +14,11 @@ export default function Nav({ $target }) {

const $navHome = document.querySelector("ul li");
$navHome.addEventListener("click", () => {
const { pathname } = location
if(pathname === '/index.html') {
setMainAnimation()
} else if (pathname.indexOf('/detail') === 0) {
setDetailAnimation()
const { pathname } = location;
if (pathname === "/index.html") {
setMainAnimation();
} else if (pathname.indexOf("/detail") === 0) {
setDetailAnimation();
}
routeChange("/index.html");
});
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import App from "./App.js";
import Footer from "./Components/Footer.js";
import Nav from "./Components/Nav.js";
import Footer from "./components/Footer.js";
import Nav from "./components/Nav.js";

new App({ $target: document.getElementById("App") });
new Nav({ $target: document.getElementById("Nav") });
Expand Down

0 comments on commit ece6d82

Please sign in to comment.