tailwindcss-rtl icon indicating copy to clipboard operation
tailwindcss-rtl copied to clipboard

add transform support

Open sbc640964 opened this issue 3 years ago • 6 comments

example: translate-s-X translate-e-X

sbc640964 avatar Jul 05 '21 08:07 sbc640964

Hi, I don't think this is actually how it should work. https://tailwindcss.com/docs/translate

the translation parameter is the axis (Y or X) so there is no left/right or start/end.

20lives avatar Jul 05 '21 12:07 20lives

Try to imagine this switch:

function Switcher(props)
{
    const {
        checked,
        enabledLabel,
        disabledLabel,
        label,
        onChange,
        errors,
        name,
        description
    } = props;

    return(
        <>
            {label &&
                <div className="font-medium text-gray-700 text-sm">
                    {label}
                </div>
            }
            <div className="mt-1 flex rounded-md">

                <div
                    className={`relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:shadow-outline ${checked ? 'bg-primary-600' : 'bg-gray-200'}`}
                    aria-checked="false"
                    role="checkbox"
                    tabIndex={0}
                    onClick={onChange}
                >
                    <div
                        className={`inline-block h-5 w-5 rounded-full bg-white shadow transform transition ease-in-out duration-200 ${checked ? '-translate-x-5' : '-translate-x-0'}`}
                        aria-hidden="true"
                    >
                    </div>
                </div>
                <div className="ms-3 text-sm text-gray-600">
                    {checked
                        ? <small>{enabledLabel}</small>
                        : <small>{disabledLabel}</small>
                    }
                </div>
            </div>
            {errors &&
                <Error errors={errors}/>
            }
            {description &&
                <Description>{description}</Description>
            }
        </>
    )
}

export default Switcher;

The position on the X axis (left or right) varies depending on the direction.

sbc640964 avatar Jul 05 '21 13:07 sbc640964

I understand the use case, I will consider adding this.

20lives avatar Jul 05 '21 14:07 20lives

@20lives Thank you!

sbc640964 avatar Jul 05 '21 14:07 sbc640964

I know this issue is a little old. But i ran into the same issue, but on further inspection there is a rtl: variant in tailwind (might be new?) so you can just do the opposite transform if you need to.

samjohnduke avatar Feb 20 '22 02:02 samjohnduke

I solve this problem by this way from documentation : To use a negative translate value, prefix the class name with a dash to convert it to a negative value. So you can use class: -translate-y-6 to translate from right to left And: translate-y-6 to translate from left to right

AnasSafi avatar May 17 '22 10:05 AnasSafi