UNPKG

@cesarfernandoig/alpine-responsive-plugin

Version:

A lightweight Alpine.js plugin that simplifies managing conditional attributes in responsive designs.

13 lines (11 loc) 641 B
"use strict"; /** * Creates a magic helper that allows retrieving conditional values based on whether the device is mobile or not. * This helper returns a mobile value if the device is mobile, and a desktop value otherwise. * * @param {import("./create-media-state").MediaState} mediaState - The media query state. * @returns {() => (mobileValue: string, desktopValue: string) => string} A function that takes a mobile value and an optional desktop value, and returns the appropriate value. */ export default (mediaState) => () => (mobileValue, desktopValue = null) => mediaState.isMobile ? mobileValue : desktopValue;