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 RTL Styles #3

Open
craigsimps opened this issue Oct 14, 2016 · 3 comments
Open

Add RTL Styles #3

craigsimps opened this issue Oct 14, 2016 · 3 comments

Comments

@craigsimps
Copy link
Owner

https://github.com/MohammadYounes/gulp-rtlcss

Some themes need right-to-left styles, and this package can help generate them.

The gotcha here, is being able to generate the right sourcemap when building SCSS into CSS, AND minifying, AND producing RTL versions.. Separating the styles task up into subtasks that save an intermediary file might be needed.

craigsimps added a commit that referenced this issue Oct 16, 2016
When the LTR stylesheet has been generated, the RTL task runs and converts `style.css` to `rtl.css`.

See #3
@GaryJones
Copy link
Contributor

Like I did with my separate zip tasks, we could have two separate tasks (build:cssleft, build:cssright, and either a master task (build:css) that does both, or otherwise checks for a config flag that will produce just one or both.

@GaryJones
Copy link
Contributor

Now we've got #41 (Allow multiple CSS files), we may have more flexibility to identify those which should have RTL files generated as well.

@GaryJones
Copy link
Contributor

GaryJones commented Sep 6, 2017

The default behaviour is to save the output to rtl.css, which WordPress will autoload if it exists.

rtl.css is meant to contain the additional changes, such that style.css followed by rtl.css gives the styles needed for an RTL site.

However, this not only means loading two stylesheets, but the rtl.css generated is not just the additions, but the original style.css with a few changes made, such is rtlcss()'s behaviour.

We might consider outputting to style-rtl.css, but we'd need to direct theme authors to add in something like the following, so that style-rtl.css is loaded instead of style.css when in an RTL context:

\add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\enqueue_assets' );
/**
 * Allow style-rtl.css to be referenced instead of style.css.
 *
 * @since 1.0.0
 *
 * @link http://www.poststat.us/automating-i18n-wordpress-themes/
 */
function enqueue_assets(): void {
	$handle = defined( 'CHILD_THEME_NAME' ) && CHILD_THEME_NAME ? \sanitize_title_with_dashes( CHILD_THEME_NAME ) : 'child-theme';
	\wp_style_add_data( $handle, 'rtl', 'replace' );
}

Either way, the name of the RTL CSS file should be configurable, instead of being hard-coded as it is currently in the rtl task.

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

No branches or pull requests

2 participants