This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
-
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.
- Loading branch information
1 parent
e893a3d
commit 6399c9b
Showing
5 changed files
with
196 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
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,31 +1,59 @@ | ||
import ResponsiveDOM from "./src/ResponsiveDOM.js"; | ||
|
||
ResponsiveDOM.onMediaQueryChange( | ||
["(max-width: 768px)", "(min-width: 769px)"], | ||
[ | ||
() => { | ||
console.log("Width is less than or equal to 768px"); | ||
}, | ||
() => { | ||
console.log("Width is greater than or equal to 769px"); | ||
}, | ||
] | ||
); | ||
const DestroyBtn = document.getElementById("destroy"); | ||
const InitBtn = document.getElementById("init"); | ||
|
||
if (ResponsiveDOM.isMobile()) { | ||
console.log("Its Mobile"); | ||
} else if (ResponsiveDOM.isTablet()) { | ||
console.log("Its Tablet"); | ||
} else if (ResponsiveDOM.isDesktop()) { | ||
console.log("Its Desktop"); | ||
} else if (ResponsiveDOM.isTV()) { | ||
console.log("Its TV"); | ||
} | ||
// ResponsiveDOM.onMediaQueryChange( | ||
// ["(max-width: 768px)", "(min-width: 769px)"], | ||
// [ | ||
// () => { | ||
// console.log("Width is less than or equal to 768px"); | ||
// }, | ||
// () => { | ||
// console.log("Width is greater than or equal to 769px"); | ||
// }, | ||
// ] | ||
// ); | ||
|
||
const btn = ResponsiveDOM.createComponent(".button"); | ||
// if (ResponsiveDOM.isMobile()) { | ||
// console.log("Its Mobile"); | ||
// } else if (ResponsiveDOM.isTablet()) { | ||
// console.log("Its Tablet"); | ||
// } else if (ResponsiveDOM.isDesktop()) { | ||
// console.log("Its Desktop"); | ||
// } else if (ResponsiveDOM.isTV()) { | ||
// console.log("Its TV"); | ||
// } | ||
|
||
btn.options.darkmode(); | ||
const card = ResponsiveDOM.createComponent(".card", { | ||
breakpoints: { | ||
mobile: (component) => { | ||
component.element.style.backgroundColor = "red"; | ||
console.log("Mobile view"); | ||
}, | ||
tablet: (component) => { | ||
component.element.style.backgroundColor = "green"; | ||
console.log("Tablet view"); | ||
}, | ||
desktop: (component) => { | ||
component.element.style.backgroundColor = "blue"; | ||
console.log("Desktop view"); | ||
}, | ||
}, | ||
onResize: (component) => { | ||
console.log("Resized"); | ||
}, | ||
onInit: (component) => { | ||
console.log("Initialized"); | ||
}, | ||
onDestroy: (component) => { | ||
console.log("Destroyed"); | ||
}, | ||
}); | ||
|
||
btn.element.addEventListener("click", () => { | ||
btn.options.lightmode(); | ||
DestroyBtn.addEventListener("click", () => { | ||
card.destroy(); | ||
}); | ||
InitBtn.addEventListener("click", () => { | ||
card.init(); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
.rd-dark { | ||
background-color: black; | ||
color: white; | ||
.card { | ||
width: 200px; | ||
height: 200px; | ||
border: 5px solid #bbbb; | ||
|
||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
} |