Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add transform support #32

Open
sbc640964 opened this issue Jul 5, 2021 · 6 comments
Open

add transform support #32

sbc640964 opened this issue Jul 5, 2021 · 6 comments

Comments

@sbc640964
Copy link

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

@20lives
Copy link
Owner

20lives commented Jul 5, 2021

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.

@sbc640964
Copy link
Author

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.

@20lives
Copy link
Owner

20lives commented Jul 5, 2021

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

@sbc640964
Copy link
Author

@20lives Thank you!

@samjohnduke
Copy link

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.

@AnasSafi
Copy link

AnasSafi commented May 17, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants