-
Notifications
You must be signed in to change notification settings - Fork 5
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
i18n rtl css support #900
i18n rtl css support #900
Conversation
J=SLAP-1458 TEST=manual
static/webpack-config.js
Outdated
@@ -26,6 +27,19 @@ module.exports = function () { | |||
}); | |||
} | |||
|
|||
const cssrtlPlugins = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I believe this pattern with the array that gets pushed to was created because there can be multiple htmlPlugins. I don't think it's necessary for cssRTL, however it's pretty simple so I'm okay with keeping it as-is if you'd like. Another option would be to make the hasRtlLocale
boolean available in this scope, and then after the plugins array is defined we can add the plugin if hasRtrlLocale
is true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. I think we should keep this pattern so it's easier to see everything that is included in plugins
instead of adding on to it in another chunk of code later in the file. I renamed it to cssRtlPlugin
to indicate there's only one if that's clearer.
static/js/rtl.js
Outdated
* @param {string} locale | ||
* @returns {boolean} | ||
*/ | ||
module.exports = function isRTL (locale) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this can go into static/webpack since it's only used as part of the build? right now static/js is for stuff that goes on the browser
@@ -6,6 +6,8 @@ const HtmlPlugin = require('html-webpack-plugin'); | |||
const RemovePlugin = require('remove-files-webpack-plugin'); | |||
const { merge } = require('webpack-merge'); | |||
const { parse } = require('comment-json'); | |||
const RtlCssPlugin = require('rtlcss-webpack-plugin'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for my edification what kinds of transformations does this do?
does this just auto fix a decent chunk of the sprint items we have?
Maybe a dumb question but I assuuume this is meant to work well with dir="rtl"? Like we won't like double "flip" certain styling properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's use, in addition to mini-css-extract-plugin we already have, to create a second rtl css bundle. It uses the rtlcss library under the hood that tom suggested on slack. I'm not sure if it fix most of the sprint items, this might have to apply to SDK css as well. The map error and the chevron change still needs to be fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand, dir="rtl" affects the direction property in CSS for text content flow within a block-level element. But it doesn't change the other styling like margin left/right and whatnots, which is what this plugin would take care of. so I don't think we will double flip things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
@@ -33,6 +35,19 @@ module.exports = function () { | |||
globalConfig = parse(globalConfigRaw); | |||
} | |||
|
|||
const cssRtlPlugin = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Connor using a list for a single item is strange, can't we just have it be
let cssRtlPlugin;
//...
[
cssRtlPlugin,
...htmlPlugins
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the case that we don't need a cssRtlPlugin, it would have an undefined element in there and would throw an error when running webpack. I could move this chunk of code after plugins
is first set and add to plugins
directly if cssRtlPlugin is required, but then it might not be organize(?) as seeing everything that's suppose to be in plugins to already be there when it's first set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay that's fair!
### Features - Support for new languages including Chinese (Traditional), Chinese (Simplified), Russian, Polish, Portuguese, Dutch, Arabic, Korean, Swedish, and Hindi (#918) (#900) - A loading indicator can now be enabled on the search bar (#875) - Voice search support (#894) - Analytics, session tracking, and query source can now be toggled through Runtime Config (#869) (#879) - Added validation to ensure that parts of global_config and page configs are valid (#888) - Font preloads are now located in the layouts/preload-fonts.hbs file (#893) - Global config now includes "sessionTrackingEnabled" and "analyticsEventsEnabled" (#898) - Added a partial for additional Answers configuration (#903) - Map pins now support custom label colors (#922) ### Enhancements - The full-page-map "Search This Area" functionality is better optimized when a user quickly zooms in or out of the map (#861) - Improved build time during development mode (#865) - Icons were updated from components to Handlebars partials to improve performance (#874) ### Bugfixes - When upgrading the theme version, the global config will no longer contain duplicate options which are commented out (#916) - When upgrading the theme, the tests folders are now removed which improves build performance (#913)
#1169) This PR removes styling that targets arbitrary `span`s in `Answers-resultsHeader`. This styling was being automatically applied to icons using the answers-search-ui partial (or other icons) when the `div`s were changed to `span`s for accessibility reasons, which caused visual regressions. This was only an issue on vertical full page map templates which include the search bar and nav tabs in `Answers-resultsHeader`, instead of just the results count and applied filters. Based on the [PR](#900) that initially added this styling, this was needed to ensure results count elements had the correct ordering on both ltr and rtl experiences. I checked a vertical template and vertical full page map template for `en` and `ar` locales in the test site and the results count elements seem to still be flipped, as expected. The only other `span`s that I saw within `Answers-resultsHeader` seemed to be the nav More icon and applied filters, both of which seemed fine after removing this styling. J=TECHOPS-11042 TEST=manual Since we no longer have a paid Percy subscription, our snapshots are not being generated. So I've included some screenshots of pages after the changes in this PR, pointing to v1.16.6 of answers-search-ui which contains the icon `div` to `span` change: **en:** <img width="1008" alt="Screenshot 2024-02-20 at 9 08 26 AM" src="https://github.com/yext/answers-hitchhiker-theme/assets/88398086/a6165616-2316-43b0-9112-7bedf0912017"> <img width="1159" alt="Screenshot 2024-02-20 at 9 08 01 AM" src="https://github.com/yext/answers-hitchhiker-theme/assets/88398086/4338ec87-7c12-4588-842a-7d7836856f11"> <img width="1157" alt="Screenshot 2024-02-20 at 9 07 39 AM" src="https://github.com/yext/answers-hitchhiker-theme/assets/88398086/8296e98e-d853-48b6-ae41-4decdec084cb"> **ar:** <img width="1007" alt="Screenshot 2024-02-20 at 9 09 00 AM" src="https://github.com/yext/answers-hitchhiker-theme/assets/88398086/159e1481-a389-4738-ae9e-ac9544202787"> <img width="1153" alt="Screenshot 2024-02-20 at 9 09 16 AM" src="https://github.com/yext/answers-hitchhiker-theme/assets/88398086/85d7d97b-a3b1-4b0d-9a2f-8752b2225d8e"> <img width="1157" alt="Screenshot 2024-02-20 at 9 09 37 AM" src="https://github.com/yext/answers-hitchhiker-theme/assets/88398086/b550063b-ff37-411b-91b2-840eeb8cc739">
use rtl css bundle if locale is a language written from right to left
rtlcss-webpack-plugin
to generate a second CSS bundle that's RTL if there's a locale inlocale_config
file that requires such bundle.html.hbs
to update href to bundle.rtl.css and include dir='rtl' if it's a rtl localeJ=SLAP-1458
TEST=manual
launched test site in theme with en, es, and ar locale. See that *.rtl.css bundles are created in public folder. See that en and es pages function normally and ar pages uses rtl format.
launched test site in theme with en and es only. See that no *.rtl.css bundles are created. See that en and es pages function normally.