Skip to content

Instantly share code, notes, and snippets.

View Danushka181's full-sized avatar

W D Madushanka Danushka181

View GitHub Profile
@Danushka181
Danushka181 / _media-mixing.scss
Created September 19, 2023 15:51
media mixings for scss
$phone: 320px;
$phone-landscape: 576px;
$tab_portrate: 768px;
$tab_landscape: 992px;
$desktop_medium: 1024px;
$desktop_extra: 1200px;
$desktop_extra-medium: 1400px;
$desktop_large: 1600px;
$desktop_extra_large: 1900px;
@Danushka181
Danushka181 / _bootstrap-grid.scss
Created September 19, 2023 11:41
this is for only bootstrap grid system
$gutters: (
xs: 0,
sm: 0.5rem,
md: 1rem,
lg: 1.5rem,
xl: 2rem,
);
@import "../../node_modules/bootstrap/scss/functions";
@import "../../node_modules/bootstrap/scss/variables";
@Danushka181
Danushka181 / webpack.config.js
Created September 18, 2023 17:14
latest config for webpack to compile js and scss
const miniCss = require("mini-css-extract-plugin");
const browserSyncPlugin = require("browser-sync-webpack-plugin");
module.exports = {
mode: "production",
entry: {
main: ["./assets/js/script.js", "./assets/scss/styles.scss"],
},
output: {
path: __dirname + "/dist/",
@Danushka181
Danushka181 / package.json
Created June 7, 2023 18:49
webpack packages json file
{
"scripts": {
"build": "webpack"
},
"dependencies": {
"browser-sync": "^2.29.3",
"browser-sync-webpack-plugin": "^2.3.0",
"css-loader": "^6.7.3",
"file-loader": "^6.2.0",
"mini-css-extract-plugin": "^2.7.5",
@Danushka181
Danushka181 / create-post-type.php
Created May 23, 2023 08:28
create post type with sub menues
<?php
/**
* circulars post type registration and category registration.
* @since 1.0.0
*/
function custom_post_type() {
$labels = array(
'name' => 'Circulars',
@Danushka181
Danushka181 / webpack.config.js
Created May 18, 2023 17:16
This is for compile js and css using webpack to a one file
const miniCss = require("mini-css-extract-plugin");
const browserSyncPlugin = require("browser-sync-webpack-plugin");
module.exports = {
mode: "production",
entry: {
main: ["./assets/js/index.js", "./assets/scss/styles.scss"],
},
output: {
path: __dirname + "/dist/js/",
@Danushka181
Danushka181 / cards-overlap-scroll-sticky.js
Created February 24, 2023 19:37
overlap cards expanding on scroll
// getting all the cards
const allCards = document.querySelectorAll(".cards-scroll .card");
let containerHeight = document.querySelector(".card-row").getBoundingClientRect().top + window.pageYOffset;
const headerHeight = 70;
const baseWidth = 60;
const cardsClickHandler = (e, index) => {
let topScrollValue = 0;
let headersHeight = 0;
@Danushka181
Danushka181 / Dropdown.vue
Created February 1, 2023 23:03
vue js dropdown custom
<template>
<div class="drop-element" tabindex="0" @blur="closeDrop">
<div class="drop-element__inner" :class="isOpen? 'drop-open': ''">
<span @click="openDrop">{{ selectedItem.label}}</span>
<ul v-show="isOpen">
<li
v-for="(option,i) in options"
:key="i"
:class="selectedItem.value == option.value ? 'active' : ''"
@click="optionSelection(option)">{{ option.label}}</li>
@Danushka181
Danushka181 / email-validation
Created October 3, 2022 11:52
this is email checking function
// check emails address is validity
const checkEmailAddress = (email) => {
let reg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return reg.test(email);
};
// check emails address is validity
const checkEmailAddress = (email) => {
let reg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return reg.test(email);
};