How to use @financial-times/x-interaction - 4 common examples

To help you get started, weā€™ve selected a few @financial-times/x-interaction examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Financial-Times / x-dash / components / x-eventpromo / src / ImagesContainer.jsx View on Github external
import { h } from '@financial-times/x-engine';
import Image from './Image';
import styles from './ImagesContainer.scss';
import { withActions } from '@financial-times/x-interaction';

const withPauseActions = withActions(() => ({
	togglePause() {
		return ({ isPaused }) => ({
			isPaused: !isPaused
		});
	}
}));

const BaseImagesContainer = ({ isPaused, actions: { togglePause }, images, link }) => {
	let classNames = styles['pause-button'];

	if (isPaused) {
		classNames = classNames + ' ' + styles['pause-button--paused'];
	}
	return (
		<div>
			<button aria-label="control animation"></button></div>
github Financial-Times / x-dash / components / x-gift-article / src / GiftArticle.jsx View on Github external
import { h } from '@financial-times/x-engine';
import { withActions } from '@financial-times/x-interaction';

import Loading from './Loading';
import Form from './Form';

import ApiClient from './lib/api';
import { copyToClipboard, createMailtoUrl } from './lib/share-link-actions';
import tracking from './lib/tracking';
import * as updaters from './lib/updaters';

const isCopySupported = typeof document !== 'undefined'
	&& document.queryCommandSupported
	&& document.queryCommandSupported('copy');

const withGiftFormActions = withActions(
	initialProps => {
		const api = new ApiClient({
			protocol: initialProps.apiProtocol,
			domain: initialProps.apiDomain
		});

		return {
			showGiftUrlSection() {
				return updaters.showGiftUrlSection;
			},

			showNonGiftUrlSection() {
				return async (state) => {
					const update = updaters.showNonGiftUrlSection(state);

					if (!state.isNonGiftUrlShortened) {
github Financial-Times / x-dash / components / x-increment / src / Increment.jsx View on Github external
import { h } from '@financial-times/x-engine';
import { withActions } from '@financial-times/x-interaction';

const delay = ms =&gt; new Promise(r =&gt; setTimeout(r, ms));

const withIncrementActions = withActions(({timeout}) =&gt; ({
	async increment() {
		await delay(timeout);

		return ({count}) =&gt; ({
			count: count + 1
		});
	},
}));

const BaseIncrement = ({count, actions: {increment}, isLoading}) =&gt; <div>
	<span>{count}</span>
	<button disabled="{isLoading}">
		{isLoading
			? 'Loading...'
			: 'Increment'
		}</button></div>
github Financial-Times / x-dash / tools / x-ssr-demo / index.js View on Github external
app.use((req, res) => {
	const {assetsByChunkName} = res.locals.webpackStats.toJson();
	res.locals.serialiser = new Serialiser();

	res.render('index', {
		publicPath,
		jsAssets: [].concat(assetsByChunkName.main).filter(path => path.endsWith('.js')),
		cssAssets: [].concat(assetsByChunkName.main).filter(path => path.endsWith('.css')),
	});
});

@financial-times/x-interaction

This module enables you to write x-dash components that respond to events and change their own data.

ISC
Latest version published 6 days ago

Package Health Score

76 / 100
Full package analysis