diff --git a/hbshelpers/isRTL.js b/hbshelpers/isRTL.js new file mode 100644 index 000000000..b33118d89 --- /dev/null +++ b/hbshelpers/isRTL.js @@ -0,0 +1,11 @@ +const checkRTL = require('../static/webpack/rtl'); + +/** + * Returns true if the given language is written from right to left (requires rtl css) + * + * @param {string} locale + * @returns {boolean} + */ +module.exports = function isRTL(locale) { + return checkRTL(locale); +} diff --git a/layouts/html.hbs b/layouts/html.hbs index 06802b255..c2ff37b75 100644 --- a/layouts/html.hbs +++ b/layouts/html.hbs @@ -144,7 +144,13 @@ - + {{#if global_config.googleTagManagerId}} @@ -153,7 +159,7 @@ height="0" width="0" style="display:none;visibility:hidden"> {{/if}} -
+
{{> overlay/markup/overlay-header }} {{> layouts/header }}
diff --git a/static/package-lock.json b/static/package-lock.json index b2090e96d..98ca277bf 100644 --- a/static/package-lock.json +++ b/static/package-lock.json @@ -995,6 +995,23 @@ "to-fast-properties": "^2.0.0" } }, + "@choojs/findup": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@choojs/findup/-/findup-0.2.1.tgz", + "integrity": "sha512-YstAqNb0MCN8PjdLCDfRsBcGVRN41f3vgLvaI0IrIcBp4AqILRSS0DeWNGkicC+f/zRIPJLc+9RURVSepwvfBw==", + "dev": true, + "requires": { + "commander": "^2.15.1" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + } + } + }, "@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -1639,6 +1656,30 @@ "object.assign": "^4.1.0" } }, + "babel-runtime": { + "version": "6.25.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.25.0.tgz", + "integrity": "sha1-M7mOql1IK7AajRqmtDetKwGuxBw=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.10.0" + }, + "dependencies": { + "core-js": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", + "dev": true + }, + "regenerator-runtime": { + "version": "0.10.5", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz", + "integrity": "sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=", + "dev": true + } + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -5560,6 +5601,48 @@ "integrity": "sha1-mUWygD8hni96ygCtuLyfZA+ELJo=", "dev": true }, + "rtlcss": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-2.6.2.tgz", + "integrity": "sha512-06LFAr+GAPo+BvaynsXRfoYTJvSaWRyOhURCQ7aeI1MKph9meM222F+Zkt3bDamyHHJuGi3VPtiRkpyswmQbGA==", + "dev": true, + "requires": { + "@choojs/findup": "^0.2.1", + "chalk": "^2.4.2", + "mkdirp": "^0.5.1", + "postcss": "^6.0.23", + "strip-json-comments": "^2.0.0" + }, + "dependencies": { + "postcss": { + "version": "6.0.23", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.23.tgz", + "integrity": "sha512-soOk1h6J3VMTZtVeVpv15/Hpdl2cBLX3CAw4TAbkpTJiNPk9YP/zWcD1ND+xEtvyuuvKzbxliTOIyvkSeSJ6ag==", + "dev": true, + "requires": { + "chalk": "^2.4.1", + "source-map": "^0.6.1", + "supports-color": "^5.4.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "rtlcss-webpack-plugin": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/rtlcss-webpack-plugin/-/rtlcss-webpack-plugin-4.0.6.tgz", + "integrity": "sha512-sWWr/SPVGckqniXpTXWZqh1tDh9LghlUygtnAeNKMrHEiq6xoPDWQo+/0NCZ8KPsju0hovWtvI+jS1kYjTDZwQ==", + "dev": true, + "requires": { + "babel-runtime": "~6.25.0", + "rtlcss": "^2.2.1" + } + }, "run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -5850,6 +5933,12 @@ "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "dev": true }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", diff --git a/static/package.json b/static/package.json index 5c8ff816d..59e6723bd 100644 --- a/static/package.json +++ b/static/package.json @@ -35,6 +35,7 @@ "mini-css-extract-plugin": "^1.6.0", "postcss": "^8.3.1", "resolve-url-loader": "^3.1.1", + "rtlcss-webpack-plugin": "^4.0.6", "sass": "^1.34.0", "sass-loader": "^8.0.2", "simple-git": "^2.15.0", diff --git a/static/scss/answers/theme.scss b/static/scss/answers/theme.scss index 130a4a36d..16be2fb7a 100644 --- a/static/scss/answers/theme.scss +++ b/static/scss/answers/theme.scss @@ -119,6 +119,10 @@ margin-top: calc(var(--yxt-base-spacing) / 2); margin-bottom: calc(var(--yxt-base-spacing) / 4); } + + span { + display: inline-block; + } } &-results { diff --git a/static/webpack-config.js b/static/webpack-config.js index 4f8999949..d6d425ce9 100644 --- a/static/webpack-config.js +++ b/static/webpack-config.js @@ -6,6 +6,7 @@ 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'); module.exports = function () { const jamboConfig = require('./jambo.json'); @@ -33,6 +34,20 @@ module.exports = function () { globalConfig = parse(globalConfigRaw); } + const cssRtlPlugin = []; + const isRTL = require(`./${jamboConfig.dirs.output}/static/webpack/rtl`); + const localeConfigPath = `./${jamboConfig.dirs.config}/locale_config.json`; + if (fs.existsSync(localeConfigPath)) { + localeConfigRaw = fs.readFileSync(localeConfigPath, 'utf-8'); + localeConfig = parse(localeConfigRaw); + const hasRtlLocale = Object.keys(localeConfig.localeConfig).some((locale) => isRTL(locale)); + if(hasRtlLocale) { + cssRtlPlugin.push(new RtlCssPlugin({ + filename: '[name].rtl.css' + })); + } + } + const { useJWT } = globalConfig; let jamboInjectedData = process.env.JAMBO_INJECTED_DATA || null; @@ -53,6 +68,7 @@ module.exports = function () { }[chunkName] || '[name].css' } }), + ...cssRtlPlugin, ...htmlPlugins, new webpack.DefinePlugin({ 'process.env.JAMBO_INJECTED_DATA': JSON.stringify(jamboInjectedData) diff --git a/static/webpack/rtl.js b/static/webpack/rtl.js new file mode 100644 index 000000000..8ff558aaf --- /dev/null +++ b/static/webpack/rtl.js @@ -0,0 +1,12 @@ +/** + * Returns true if the given language is written from right to left (requires rtl css) + * + * @param {string} locale + * @returns {boolean} + */ +module.exports = function isRTL (locale) { + if (locale === 'ar') { + return true; + } + return false; +} \ No newline at end of file