Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <!-- <html> -->
- <head>
- <meta charset='utf-8'>
- <meta http-equiv='X-UA-Compatible' content='IE=edge'>
- <title>MengCode</title><link rel="stylesheet" href="styles.css">
- <meta name='viewport' content='width=device-width, initial-scale=1'>
- <link rel='stylesheet' type='text/css' media='screen' href='main.css'>
- <link rel="icon" href="./src/MengCode.svg" type="image/icon type">
- <link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css">
- <link rel="stylesheet" href="styles.css">
- </head>
- <body>
- <!-- Apps -->
- <div class="apps">
- <!-- Header -->
- <div class="header">
- <div class="header-logo">
- <img src="./logo.svg" alt="">
- </div>
- </div>
- <!-- End of Header -->
- <!-- Search Bar -->
- <div class="search">
- <div id="searchWrapper">
- <input
- type="text"
- style="color: #FDFCFC; font-family: 'IBM Plex Mono', monospace; font-size: 2rem; background-color:#504E4E ";
- name="searchBar"
- id="searchBar"
- placeholder="Start typing ..."
- />
- </div>
- </div>
- <!-- End Search Bar -->
- <!-- Button Category -->
- <div class="btn-container">
- <!-- <button type="button" class="filter-btn" data-id="all"
- >All</button>
- <button type="button" class="filter-btn" data-id="course"
- >course</button>
- <button type="button" class="filter-btn" data-id="cheatsheet"
- >cheatsheet</button> -->
- </div>
- <!-- Button End -->
- <!-- Content -->
- <div class="section-center">
- <!-- Single Content -->
- <div class="item-content">
- <!-- image -->
- <div class="photo-box">
- <img src="./src/asset-01.png" alt="">
- </div>
- <!-- box title and icon -->
- <div class="title-and-icon">
- <!-- text body -->
- <div class="title">
- <h1>Coloors</h1>
- <p>Generate color to find your pallete.</p>
- </div>
- <div class="icon">
- <button type="button" class="btn btn-dark"
- class="filter-btn">Visit</button>
- </div>
- </div>
- </div>
- <!-- End Single Content -->
- </div>
- <!-- End Content -->
- <!-- Footer -->
- <!-- End Footer -->
- </div>
- <!-- End Apps -->
- </body>
- <script src="app.js"></script>
- </html>
- ---------------------------------------------------------------------
- :root {
- background-color: #26272b;
- font-family: "IBM Plex Mono", monospace;
- }
- ::-webkit-scrollbar {
- width: 0.25rem;
- }
- ::-webkit-scrollbar-track {
- background: #1e1e24;
- }
- ::-webkit-scrollbar-thumb {
- background: rgba(56, 117, 208);
- }
- .apps {
- padding: 2rem 7rem 2rem 7rem;
- background-color: #26272b;
- }
- p {
- font-family: "IBM Plex Mono", monospace;
- color: #fdfcfc;
- font-size: 1rem;
- }
- h1 {
- font-family: "IBM Plex Mono", monospace;
- color: #fdfcfc;
- font-size: 1.5rem;
- font-weight: 800;
- }
- .search {
- padding-top: 2rem;
- padding-bottom: 2rem;
- }
- #searchBar {
- width: 100%;
- height: 3rem;
- border-radius: 3px;
- border: 1px solid #eaeaea;
- padding: 5px 10px;
- font-size: 2rem;
- }
- #searchWrapper {
- position: relative;
- }
- .btn-dark {
- background-color: #504e4e;
- color: #fdfcfc;
- font-family: "IBM Plex Mono", monospace;
- font-size: 1rem;
- border-radius: 10px;
- justify-content: center;
- align-items: flex-end;
- }
- .btn-container {
- display: flex;
- flex-direction: row;
- padding-top: 2rem;
- padding-bottom: 2rem;
- }
- .filter-btn {
- color: #fdfcfc;
- text-decoration: none;
- background-color: #504e4e;
- font-family: "IBM Plex Mono", monospace;
- font-weight: 700;
- font-size: 1em;
- margin: 0.2%;
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
- border-radius: 10px;
- /* -webkit-box-shadow: 0px 9px 0px, 0px 9px 25px;
- -moz-box-shadow: 0px 9px 0px, 0px 9px 25px;
- box-shadow: 0px 9px 0px, 0px 9px 25px; */
- display: block;
- border: none;
- -webkit-transition: all 0.1s ease;
- -moz-transition: all 0.1s ease;
- -ms-transition: all 0.1s ease;
- -o-transition: all 0.1s ease;
- transition: all 0.1s ease;
- }
- .filter-btn:active {
- -webkit-box-shadow: 0px 3px 0px rgba(56, 117, 208),
- 0px 3px 6px rgba(0, 0, 0, 0.9);
- -moz-box-shadow: 0px 3px 0px rgba(56, 117, 208),
- 0px 3px 6px rgba(0, 0, 0, 0.9);
- box-shadow: 0px 3px 0px rgba(56, 117, 208), 0px 3px 6px rgba(0, 0, 0, 0.9);
- position: relative;
- top: 6px;
- }
- .section-center {
- justify-content: flex-start;
- flex-wrap: wrap;
- display: flex;
- /* border: 2px solid red; */
- }
- .item-content {
- width: 22.5em;
- flex-basis: 32.4%;
- height: 18em;
- /* border: 2px solid green; */
- margin: 0.3em;
- position: relative;
- background-color: rgba(56, 117, 208);
- }
- .title button {
- display: flex;
- justify-content: flex-end;
- align-items: flex-end;
- }
- .photo-box {
- /* border: 3px solid pink; */
- height: 60%;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .photo-box img {
- height: 10.5em;
- width: 22.5em;
- object-fit: fill;
- }
- .title-and-icon {
- display: flex;
- flex-direction: row;
- align-items: flex-end;
- }
- .title {
- margin: 0.2em 0 0 0;
- width: 80%;
- /* border: 2px solid blue; */
- }
- .title p {
- height: 3em;
- overflow: auto;
- }
- .icon {
- /* border: 3px solid yellow; */
- height: 20%;
- }
- -------------------------------------------------------------------
- const menu = [
- {
- id: 1,
- title: "Coolors",
- category: "course",
- link: "http://coolors.co/",
- img: "./src/asset-01.png",
- desc: `Generate color to find your Pallete `,
- },
- {
- id: 2,
- title: "CSS Layout",
- category: "cheatsheet",
- link: "https://csslayout.io",
- img: "./src/asset-02.png",
- desc: `Free template CSS layout`,
- },
- {
- id: 3,
- title: "Code Pen",
- category: "editor",
- link: 'https://codepen.io',
- img: "./src/asset-03.png",
- desc: `Code Pen is an online community for testing and showcasing user-created HTML, CSS and JavaScript code snippets..`,
- }
- ];
- // get parent element
- const sectionCenter = document.querySelector(".section-center");
- const btnContainer = document.querySelector(".btn-container");
- // display all items when page loads
- window.addEventListener("DOMContentLoaded", function () {
- diplayMenuItems(menu);
- displayMenuButtons();
- dislaySearch();
- });
- // Menu
- function diplayMenuItems(menuItems) {
- let displayMenu = menuItems.map(function (item) {
- // console.log(item);
- return `<!-- Single Content -->
- <div class="item-content">
- <!-- image -->
- <div class="photo-box">
- <img src=${item.img} alt=${item.title}>
- </div>
- <!-- box title and icon -->
- <div class="title-and-icon">
- <!-- text body -->
- <div class="title">
- <h1>${item.title}</h1>
- <p>${item.desc}</p>
- </div>
- <div class="icon">
- <a href=${item.link} target="_blank" rel="noopener"
- <button type="button" class="filter-btn"
- >Visit</button>
- </a>
- </div>
- </div>
- </div>
- <!-- End Single Content -->` ;
- });
- displayMenu = displayMenu.join("");
- // console.log(displayMenu);
- sectionCenter.innerHTML = displayMenu;
- }
- // Button Category
- function displayMenuButtons() {
- const categories = menu.reduce(
- function (values, item) {
- if (!values.includes(item.category)) {
- values.push(item.category);
- }
- return values;
- },
- ["all"]
- );
- const categoryBtns = categories
- .map(function (category) {
- return `<button type="button" class="filter-btn" data-id=${category}>
- ${category}
- </button>`;
- })
- .join("");
- btnContainer.innerHTML = categoryBtns;
- const filterBtns = btnContainer.querySelectorAll(".filter-btn");
- console.log(filterBtns);
- filterBtns.forEach(function (btn) {
- btn.addEventListener("click", function (e) {
- // console.log(e.currentTarget.dataset);
- const category = e.currentTarget.dataset.id;
- const menuCategory = menu.filter(function (menuItem) {
- // console.log(menuItem.category);
- if (menuItem.category === category) {
- return menuItem;
- }
- });
- if (category === "all") {
- diplayMenuItems(menu);
- } else {
- diplayMenuItems(menuCategory);
- }
- });
- });
- }
- //Search Bar
- function dislaySearch(){
- const searchBar = document.getElementById('searchBar');
- searchBar.addEventListener('keyup',function(e){
- const searchString = e.target.value.toLowerCase();
- const searchFilter = menu.filter(function(displaySearch) {
- return (
- displaySearch.title.toLowerCase().includes(searchString) ||
- displaySearch.desc.toLowerCase().includes(searchString)
- );
- });
- diplayMenuItems(searchFilter);
- });
- }
- ----------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement