html looks like:
<div class='a'>
<p class='subA'><p>
<p class='subA'><p>
</div>
<div class='b'>
<p class='subA'><p>
<p class='subA'><p>
<div>
how to remove .subA::after styles for only div with class ‘a’?
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
html looks like:
<div class='a'>
<p class='subA'><p>
<p class='subA'><p>
</div>
<div class='b'>
<p class='subA'><p>
<p class='subA'><p>
<div>
how to remove .subA::after styles for only div with class ‘a’?
I am an absolute beginner in Javascript writing. I would like to create a code that would display a text in a given date interval (e.g. 2022.10.23-2022.11.25), but not in any other date interval. Try as I might with this code, it fails. Thanks in advance for your help.
<label id="lblGreetings"></label> <script> var myDate = new Date(); var hrs = myDate.getHours(); var greet;
if ((myDate = 'October 24, 2022')) greet = 'Good Morning'; document.getElementById('lblGreetings').innerHTML = '<b>' + greet + '</b> and welcome to Encodedna.com!'; </script>
If I add the same data inside the same array in Firestore, it not creates more indexes in the array because it has the same data.
I want it to create more indexed when the same data is entered inside the array.
for example:
expected result:
code:
// collection reference
const collectionRef = collection(db, 'exercises data');
// submit function to add the exercises data
const handleSubmit = async (e) => {
e.preventDefault();
const usr = auth.currentUser;
await setDoc(doc(collectionRef, usr.uid), {
exercise: arrayUnion(exercise),
sets: arrayUnion(Number(sets)),
reps: arrayUnion(Number(reps)),
}, { merge: true })
}
I want to create responsive multiple forms (form1, form2, and form3) with the same pages using framer motion. However, when I create the state value
and want to make it change when the user fills the form by using setValue in handleChange, the value of the state is not updated correctly as I want. When the user fills Select Protocol
the filled form is not updated on the user screen but the state is changed. Moreover, when the user fills Select number of hops
after that, the link level
state is deleted. I have no idea how to fix this problem.
import React, { useState, useEffect } from "react";
import { motion, AnimatePresence } from "framer-motion";
export default function ExperC() {
// state that I want to collect user fill form
const [value, setValue] = useState({
link_level: "",
hop_select: "",
num_hop: "",
location_1: "",
location_2: "",
photon_loss: "",
dep: "",
gate_error: "",
coherent: "",
mea_error: "",
trajectory: "",
});
const handleChangeLinklevel = (e) => {
setValue({ ...value, link_level: e.target.value });
};
const handleChangeHop = (e) => {
setValue({ ...value, hop_select: e.target.value });
};
// jsx of form 1
const form1 = (
<form action="" className="w-[140%]">
<div className="flex space-x-2">
<h1 className="text-[#fff] text-4xl">Configure your </h1>
<h1 className="text-[#ad73f1] text-4xl">Qwanta network</h1>
</div>
<p className="mt-5 mb-2 text-gray-400">Select Protocol</p>
<select
className="w-full h-8 text-black bg-white"
onChange={handleChangeLinklevel}
value={value.link_level}
>
<option value="" disabled selected>
Select your protocol
</option>
<option value="0G">0 Generation (0G)</option>
<option value="1G">1G-Ss-Dp (1G)</option>
<option value="2G-NCX">2G-NonLocal-CNOT (2G-NCX)</option>
<option value="HG-DE">1-2G-Directed-Encoded, (HG-DE)</option>
<option value="HG-E2E-PE">HG-E2E-PurifiedEncoded</option>
<option value="Design own protocol">Design own protocol</option>
</select>
{useEffect(() => {
console.log("test", value);
})}
<p className="mt-5 mb-2 text-gray-400">Select number of hops</p>
<select
className="w-full h-8 text-black bg-white"
onChange={handleChangeHop}
value={value.hop_select}
>
<option value="" disabled selected>
2^n hops
</option>
<option value="2">2 hops, 3 nodes</option>
<option value="4">4 hops, 5 nodes</option>
<option value="8">8 hops, 9 nodes</option>
</select>
</form>
);
const form2 = <>This is form 2</>
const form3 = <>This is form 3</>;
// for responsive slide between form using framer motion
const experitem = [
{ name: "config1", icon: "test1", form: form1 },
{ name: "config2", icon: "test2", form: form2 },
{ name: "config3", icon: "test3", form: form3 },
];
const [selectedTab, setSelectedTab] = useState(experitem[0]);
return (
<div className="flex flex-col w-[800px] h-[600px] absolute top-[150px] bg-[#262626] left-1/3 rounded-xl overflow-hidden">
<nav className="bg-gray1 pt-3 px-3 rounded-t-xl h-[60px]">
<ul className="flex w-full">
{experitem.map((item, index) => (
<motion.li
key={index}
className={`text-white list-none cursor-pointer rounded-t-xl w-full p-3 relative bg-[#262626] h-[70px] flex justify-between align-middle flex-1 min-w-0
`}
onClick={() => setSelectedTab(item)}
initial={{ y: 0 }}
whileHover={{ y: -5 }}
>
{item.name}
{/* {item == selectedTab ? (
<div className="absolute -bottom-[2px] left-0 right-0 h-[1px] bg-blue-500" />
) : null} */}
</motion.li>
))}
</ul>
</nav>
<main className="bg-[#262626] flex justify-left align-middle flex-grow mt-6 ml-5">
<AnimatePresence exitBeforeEnter>
<motion.div
key={selectedTab ? selectedTab.name : "empty"}
initial={{ x: -100, opacity: 0 }}
animate={{ x: 0, opacity: 1 }}
exit={{ x: -10, opacity: 0 }}
transition={{ duration: 0.2 }}
>
{selectedTab ? selectedTab.form : null}
</motion.div>
</AnimatePresence>
</main>
</div>
);
}
i was making my Scroll project,with all transitions etc. I started with responsive Navbar,everyrhing was good but the moment when I press the button and my lists open doesn’t work, how I can fix it?
here is my js code:
const btn = document.getElementsByClassName('nav-btn')[0];
const links = document.getElementsByClassName('navbar-links')[0];
btn.addEventListener('click',()=>{
links.classList.toggle('active')
})
here is css:
.bar1, .bar2, .bar3 {
width: 35px;
height: 5px;
background-color: #333;
margin: 6px 0;
transition: 0.4s;
}
body{
margin: 0;
padding: 0;
}
.change .bar1 {
transform: translate(0, 11px) rotate(-45deg);
}
.change .bar2 {opacity: 0;}
.change .bar3 {
transform: translate(0, -11px) rotate(45deg);
}
#nav{
background-image: url("images/page.jpg");
height: 800px;
background-repeat:no-repeat;
-webkit-background-size:cover;
-moz-background-size:cover;
-o-background-size:cover;
background-size:cover;
background-position:center;
}
.nav-header h1{
padding-left: 10px;
font-size: 1.6rem;
}
.navbar{
display: flex;
justify-content: space-between;
align-items: center;
background-color: white;
}
.navbar-links ul{
margin: 0;
padding: 0;
display: flex;
font-size: 1.2rem;
}
.navbar-links li{
list-style: none;
}
.navbar-links li a{
text-decoration: none;
color: black;
display: block;
padding: 1rem;
}
.nav-btn{
background-color: white;
display: none;
cursor: pointer;
border: none;
position: absolute;
right: 5px;
top: 12px;
}
and here is html:
<header id="home">
<div id="nav">
<nav class="navbar">
<div class="nav-header">
<h1>Menu</h1>
<button class="nav-btn" onclick="this.classList.toggle('change');">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</button>
</div>
<div class="navbar-links">
<ul>
<li><a href="#home" class="scroll">home</a></li>
<li><a href="#about" class="scroll">about</a></li>
<li><a href="#services" class="scroll">services</a></li>
</ul>
</div>
</nav>
</div>
<div class="banner">
<div class="container">
<h1>scroll project</h1>
<p>wsjnciunclsnjiemc ljfnjdc cinufifl,vlfldlvlekfopec ciun ck cipn i inrc cijan9pnc cipqe</p>
<button class="scroll-link-btn"><a href="#tursr">Explore Tours</a></button>
</div>
</div>
</header>
so,how can I fix it?Will be pleased for the solution!
Thank you for help!
I am using redux-tookit
, rtk-query
(for querying other api’s and not just Firebase) and Firebase
(for authentication and db).
The code below works just fine for retrieving and caching the data but I wish to take advantage of both rtk-query
caching as well as Firebase
event subscribing, so that when ever a change is made in the DB (from any source even directly in firebase console) the cache is updated.
I have tried both updateQueryCache
and invalidateTags
but so far I am not able to find an ideal approach that works.
Any assistance in pointing me in the right direction would be greatly appreciated.
// firebase.ts
export const onRead = (
collection: string,
callback: (snapshort: DataSnapshot) => void,
options: ListenOptions = { onlyOnce: false }
) => onValue(ref(db, collection), callback, options);
export async function getCollection<T>(
collection: string,
onlyOnce: boolean = false
): Promise<T> {
let timeout: NodeJS.Timeout;
return new Promise<T>((resolve, reject) => {
timeout = setTimeout(() => reject('Request timed out!'), ASYNC_TIMEOUT);
onRead(collection, (snapshot) => resolve(snapshot.val()), { onlyOnce });
}).finally(() => clearTimeout(timeout));
}
// awards.ts
const awards = dbApi
.enhanceEndpoints({ addTagTypes: ['Themes'] })
.injectEndpoints({
endpoints: (builder) => ({
getThemes: builder.query<ThemeData[], void>({
async queryFn(arg, api) {
try {
const { auth } = api.getState() as RootState;
const programme = auth.user?.unit.guidingProgramme!;
const path = `/themes/${programme}`;
const themes = await getCollection<ThemeData[]>(path, true);
return { data: themes };
} catch (error) {
return { error: error as FirebaseError };
}
},
providesTags: ['Themes'],
keepUnusedDataFor: 1000 * 60
}),
getTheme: builder.query<ThemeData, string | undefined>({
async queryFn(slug, api) {
try {
const initiate = awards.endpoints.getThemes.initiate;
const getThemes = api.dispatch(initiate());
const { data } = (await getThemes) as ApiResponse<ThemeData[]>;
const name = slug
?.split('-')
.map(
(value) =>
value.substring(0, 1).toUpperCase() +
value.substring(1).toLowerCase()
)
.join(' ');
return { data: data?.find((theme) => theme.name === name) };
} catch (error) {
return { error: error as FirebaseError };
}
},
keepUnusedDataFor: 0
})
})
});
My employer gave me a task that when the user writes in a checkbox if the first letter is M or N then an alert will generate. I Have checked this solution but founds nothing in the PHP and Javascript.
@react-google-maps/api”: “^2.13.1” | https://www.npmjs.com/package/@react-google-maps/api
Hi Everybody. My name is Hassan & I’m a freelance React JS developer. I have been working with this API to build project for a client on Upwork. What I want to achieve is
A Google Map with a button to toggle custom Polygon Shapes’s visibility on & off. The components first render with out a polygon and when the user clicks on the button the polygon loads up to highlight USA states where the health centers are.
It is working till here. However when again clicking on the button I want the polygon to be removed/hidden from Map. However once mounted to the Map the polygon does not go away. It changes opacity of fill color of polygon but does not go away.
Here is what I have tried already
Passing true/false as “visible” Prop value to Polygon component based on state. But once rendered the Polygon is not removed even after passing false as a prop.
The second method I tried is using State to conditionally render the Polygon.
i.e showPolygon ? : null
This did not work either, I even tried this with Whole Map components. i.e load Simple Component or loading Map Component with Polygon as child component.
Please see my code in the screenshot below. The State changes as expected. The Polygon component just won’t go away with a re-render.
So here is my codes and I declared a function in index.js called setupGuides(). I wanted to call this function in another file called auth.js. However, I am getting this error:
enter image description here
Rather than having the user call the api to get the data, we are trying to get the data updated once a day automatically and stored in Firestore. This way the calls will just be made to Firestore to retrieve the correct data. Is there anyway to accomplish this.
I am trying to use Formik with React to crete a form. However, I am having a problem displaying a Drop Down list with errors if nothing is selected i.e., Both the Input and Select fields are mandatory.
So Firstly I have created a custom Input and Select component where props like classNames
and Invalid
are passed.
Custom Input [OnClick and ntohing entered, turn the border red and validation error = true]
Custom Input
export interface IInputProps extends InputProps{
children?: ReactNode,
className?:string
}
export default ({className, ...props}: IInputProps) => {
if(props.invalid)
className += ' is-invalid'
return(
<Input className={className} {...props} />
)
}
Custom Select [OnClick and ntohing selected, turn the border red and validation error = true]
import Select from "react-select"
import { StateManagerProps } from "react-select/dist/declarations/src/useStateManager";
export interface IStateManagerProps extends StateManagerProps{
children?: ReactNode,
className?:string
invalid?:boolean
}
export default ({className, ...props}: IStateManagerProps ) => {
if(props.invalid)
className += ' is-invalid'
return(
<Select className={className} {...props} />
)
}
CSS
.form-control.is-invalid {
border-color: $danger !important;
}
.border-bottom{
border-color: transparent !important;
border-bottom: 2px solid red !important;
}
Main Form.
export function Validation() {
return useFormik({
enableReinitialize: true,
initialValues: {
name: "" ,
country:""
},
validationSchema: validationSchema(),
onSubmit: (values) => {
}
});
}
export function validationSchema() {
return Yup.object({
name: Yup.string().required("Name field is required"),
country: Yup.string().required("Country field is required"),
});
}
obj = [
{
"id":"qwerc",
"code":"1",
"label":"USA",
"name":"USA"
},
{
"id":"fdf3a96bda",
"code":"CXGD",
"label":"AUS"
"name":"AUS"
}
]
const MainForm = (validation) => {
return
(
<Form>
<Input
className="form-control border-bottom"
onChange={onChange}
value={validation.values?.name || ""}
name="name"
type="text"
placeholder="Enter name"
onBlur={validation.handleBlur}
invalid={validation.touched.name && validation.errors.name? true: false}
/>
{ validation.touched.commodityType && validation.errors.commodityType? (
<FormFeedback type="invalid"> {validation.errors.name}</FormFeedback>
) : null}
//import Select from './custom/Select'
<Select
options={obj}
className="form-control border-bottom"
onChange={() => onChange}
value={validation.values?.country|| ""}
name="country"
type="select"
placeholder="Country"
onBlur={validation.handleBlur}
invalid={validation.touched.country && validation.errors.country? true: false}
/>
{ validation.touched.country && validation.errors.country? (
<FormFeedback type="invalid"> {validation.errors.country}</FormFeedback>
) : null}
</Form>
I have a very large array of objects that I need the keys remove from. I can’t seem to get my head around how to make this happen with list of keys.
https://jsfiddle.net/rgfx_fiddle/cvoz7ygm/15/
const sections = [
{
municipality: "Monte De Oca",
office: "Oficina de la Mujer"
},
{
case_number: "MDO-ABCDEFG",
identification: "Cédula",
id_number: "123456789"
}
];
const removeThis = [
"municipality",
"id_number"
]
function filter(data) {
for(var i in data){
if(removeThis.indexOf(i) != -1){
delete data[i];
}
}
return data;
}
console.log(filter(sections));
I’m posting this here in the hope there are some Braintree/PayPal engineers looking at StackOverflow for support issues. I have submitted a support ticket through their new form twice, but have had no reply.
We have noticed very recently that the “PayPal Credit” button has appeared on our payment page without any code changes by us to turn this on.
How we would disable this?
Also, is it default behaviour to display this on sandbox accounts only? This does not seem to be affecting our production environment (yet).
We are using v4 of the JavaScript SDK:
braintreeClient: "https://js.braintreegateway.com/web/3.87.0/js/client.min",
hosted_fields: "https://js.braintreegateway.com/web/3.87.0/js/hosted-fields.min",
checkoutJs: "https://www.paypalobjects.com/api/checkout.min",
paypalCheckout: "https://js.braintreegateway.com/web/3.87.0/js/paypal-checkout.min"
I have tried passing through offerCredit: false
, but this has had no effect:
// Set up PayPal with the checkout.js library
paypal.Button.render({
env: '{{ braintree_env }}', // 'sandbox' or 'production'
style: {
label: 'paypal',
size: 'responsive', // small | medium | large | responsive
shape: 'rect', // pill | rect
color: 'white', // gold | blue | silver | black
tagline: false,
width: 500,
height: 55
},
payment: function () {
return paypalCheckoutInstance.createPayment({
flow: 'vault', // required to allow us to charge the account in future without re-authentication
offerCredit: false
});
},
Security CodetSecurity NametGrouptLTPtChgt% Chgn533317tOMKARCHEMtBt23.40t3.90t20.00n526576tTECHINtBt14.30t2.38t19.97n543636tDCItBt93.70t15.60t19.97n523007tANSALBUtXt102.95t16.85t19.57n543614tTIPSFILMStBt524.95t84.55t19.20n504648tBOMBWIRtXt37.90t5.65t17.52n543285tRCANtMt105.00t15.50t17.32n526891tMKTCREATtXt11.00t1.48t15.55n522231tCONARTtXt45.90t6.05t15.18n533638tFLEXITUFFtBt29.05t3.55t13.92n540386tONTICtXt1.86t0.21t12.73n524280tKOPRANtBt172.25t18.25t11.85n531543tJINDWORLDtBt277.70t28.90t11.62n500144tFINCABLEStAt493.85t44.95t10.01n531201tSHILCTECHtXt797.20t72.45t10.00n536773tJPOLYINVSTtBt539.15t49.00t10.00n542694tPARSHVAtBt196.35t17.85t10.00n543544tJAYANTtMt607.20t55.20t10.00n514360tKRRAILtXt54.55t4.95t9.98n530271tRICHUNVtXt8.27t0.75t9.97n542842tNIESSPKtBt104.20t9.45t9.97n526473tELEFLORtXt10.42t0.94t9.92n542627tCHANDNIMACHtXt30.50t2.75t9.91n543606tCONTAINEtMt43.30t3.90t9.90n532035tUNISTRMUtXt21.15t1.90t9.87n532005tSAMINDUStXt36.25t3.25t9.85n542808tNIESSPCtBt2.79t0.25t9.84n532406tAVANTELtXt325.65t29.15t9.83n542727tCPMLtMt33.00t2.95t9.82n543176t11MPRtBt8.64t0.77t9.78n540811tDMLtMt13.50t1.20t9.76n524606tBERLDRGtXt9.87t0.87t9.67n532395tAXISCADEStBt214.25t18.60t9.51n531281tMARBLEtXt20.85t1.80t9.45n542146tSKIFLtMt21.00t1.80t9.38n890169tDYNPROPPtBt143.70t12.10t9.19n507828tANSALHSGtXt5.50t0.46t9.13n543177t11QPDtBt1.56t0.13t9.09n523832tMUKATPIPtXt8.29t0.69t9.08n500220tJASCHtXt180.35t14.95t9.04n542651tKPITTECHtAt711.90t58.95t9.03n532215tAXISBANKtAt900.25t74.05t8.96n505250tGGDANDEtXt74.95t6.10t8.86n522074tELGIEQUIPtAt490.90t39.90t8.85n543327tEXXAROtBt137.90t11.20t8.84n541152tGOYALALUMtMt136.10t10.85t8.66n534755tTRIOMERCtXt1.14t0.09t8.57n539725tGOKULAGROtBt138.75t10.95t8.57n505690tBRADYMtXt169.65t13.20t8.44n524628tPARKERACtXt10.34t0.80t8.39