data: () => ({
selected: null,
items: [
{ title: 'hello, world!!', value: '' },
{ title: 'fuck the world', value: '' },
{ title: 'fuck everything', value: '' },
],
}),<div v-for="n in items">
<label>
<input type="radio" :value="n.title" v-model="selected">
{{ n.title }}
</label>
<input type="text" v-model="n.value" :disabled="selected !== n.title">
</div>
const filterAndGroupAdjacent = (data, filterFn) =>
Array.prototype.reduce.call(
data,
(acc, n, i, a) => {
if (filterFn(n, i, a)) {
const len = acc[0].length;
(acc[1] === ~-i ? acc[0][~-len] : (acc[0][len] = [])).push(n);
acc[1] = i;
}
return acc;
},
[ [], null ]
)[0];// достаём нечётные числа
filterAndGroupAdjacent(
[ 1, 7, 3, 2, 3, 4, 4, 9, 5 ],
n => n & 1
) // [ [1,7,3], [3], [9,5] ]
// буквы в верхнем регистре
filterAndGroupAdjacent(
'1_Df+HNU*@qpJM!x',
RegExp.prototype.test.bind(/[A-Z]/)
) // [ ["D"], ["H","N","U"], ["J","M"] ]
.fade-leave-active {
transition: opacity 1s;
}
.fade-leave-to {
opacity: 0;
}mounted() {
this.show = false;
},
phone.value = phone.value.replace(/[^+0-9]/g, '').slice(0, 11);
const canvas = document.querySelector('#canvas');
const ctx = canvas.getContext('2d');
const TILE_SIDE = 32;
let pickX = 0;
let pickY = 0;
const ground = new Image();
ground.src = 'Ground.png';
const pick = new Image();
pick.src = 'Pick.png';
document.addEventListener('keydown', function(e) {
switch (e.key) {
case 'w': pickY -= TILE_SIDE; break;
case 'a': pickX -= TILE_SIDE; break;
case 's': pickY += TILE_SIDE; break;
case 'd': pickX += TILE_SIDE; break;
default: return;
}
draw();
});
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
for (let x = 0; x < canvas.width; x += TILE_SIDE) {
for (let y = 0; y < canvas.height; y += TILE_SIDE) {
ctx.drawImage(ground, x, y);
}
}
ctx.drawImage(pick, pickX, pickY);
}
draw();
<div class="accordionFaq"></div>const playersOptions = [
{ source: '...' },
{ source: '...' },
...
];
$('.accordionFaq').html(playersOptions.map((n, i) => `
<div class="accordionFaq-item">
<div class="accordionFaq-head js-accordionFaq-head">
Video #${i}
</div>
<div class="accordionFaq-body">
<div id="player${i}"></div>
</div>
</div>
`).join('')).on('click', '.accordionFaq-head', function(e) {
const index = $(this).closest('.accordionFaq-item').index();
$('.accordionFaq-item', e.delegateTarget).each(function(i) {
const
$this = $(this),
isClicked = i === index,
active = isClicked && !$this.hasClass('active');
$(this)
.toggleClass('active', active)
.find('.accordionFaq-body')
[isClicked ? 'slideToggle' : 'slideUp']();
playersOptions[i].player[active ? 'play' : 'pause']();
});
});
playersOptions.forEach((n, i) => {
n.player = new Clappr.Player({
source: n.source,
parentId: `#player${i}`,
});
});
<Wrapper itemHeight="300px">height: ${p => p.itemHeight}; будет height: ${p => p.itemHeight || '200px'};, например. Или можно переписать компонент так:export const Wrapper = styled.article(({
itemWidth,
itemHeight = '200px',
}) => ({
backgroundColor: '#efefef',
margin: '5px',
height: itemHeight,
width: itemWidth,
}));
const ItemComponent = props => (
<div>
<p>{props.title}</p>
</div>
);
...
<Carousel
items={items}
ItemComponent={ItemComponent}
/>