import React from 'react';
import './Switcher.scss';
export default function Switcher({ ...props }) {
return (
<div className='switcher'>
<h3>{props.title}</h3>
<div className='box'>
<input
type='checkbox'
onClick={props.onClick}
value={props.value}
id={props.id}
/>
<label htmlFor={props.id}></label>
<div className='labels df'>
<p className='label-lt'>{props.label_lt}</p>
<p className='label-rt'>{props.label_rt}</p>
</div>
</div>
</div>
);
}
const langArr = {
h1: {
en: 'Text',
ru: 'Teкст',
},
btn: {
en: 'Learn more',
ru: 'Узнать больше',
},
};
const langEn = document.querySelector('#lang-en');
const langRu = document.querySelector('#lang-ru');
langEn.addEventListener('click', setLang.bind(null, 'en'));
langRu.addEventListener('click', setLang.bind(null, 'ru'));
function setLang() {
let hash = window.location.hash.substr(1);
for (let key in langArr) {
let elem = document.querySelector('.lng-' + key);
if (elem) {
elem.innerHTML = langArr[key][hash];
}
}
}
function createContent() {
console.log('show!');
}