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

use rtl plugin #3283

Draft
wants to merge 1 commit into
base: sw-g3-ie11-styling-fix
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"html-react-parser": "^1.4.14",
"js-cookie": "^3.0.1",
"lodash": "^4.17.21",
"preact": "^10.13.1"
"preact": "^10.13.1",
"stylis": "^4.2.0",
"stylis-plugin-rtl": "^2.1.1"
},
"devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.21.5",
Expand Down Expand Up @@ -89,6 +91,7 @@
"@types/js-cookie": "^3.0.2",
"@types/lodash": "^4.14.172",
"@types/node": "^16.0.0",
"@types/stylis": "^4.2.0",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"axe-core": "^4.3.3",
Expand Down
12 changes: 12 additions & 0 deletions src/v3/src/components/Widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import {
useRef,
useState,
} from 'preact/hooks';
import rtlPlugin from 'stylis-plugin-rtl';
import { CacheProvider } from '@emotion/react';
import createCache from '@emotion/cache';
import { prefixer } from 'stylis';

import Bundles from '../../../../util/Bundles';
import { IDX_STEP } from '../../constants';
Expand Down Expand Up @@ -360,6 +364,12 @@ export const Widget: FunctionComponent<WidgetProps> = (widgetProps) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [responseError]);

// Create rtl cache
const cacheRtl = createCache({
key: 'muirtl',
stylisPlugins: [prefixer, rtlPlugin],
});

return (
<WidgetContextProvider value={{
authClient,
Expand Down Expand Up @@ -387,6 +397,7 @@ export const Widget: FunctionComponent<WidgetProps> = (widgetProps) => {
}}
>
<OdysseyCacheProvider nonce={cspNonce}>
<CacheProvider value={cacheRtl}>
<MuiThemeProvider theme={brandedTheme}>
{/* the style is to allow the widget to inherit the parent's bg color */}
<ScopedCssBaseline
Expand Down Expand Up @@ -417,6 +428,7 @@ export const Widget: FunctionComponent<WidgetProps> = (widgetProps) => {
</AuthContainer>
</ScopedCssBaseline>
</MuiThemeProvider>
</CacheProvider>
</OdysseyCacheProvider>
</WidgetContextProvider>
);
Expand Down
22 changes: 22 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7157,6 +7157,11 @@
dependencies:
"@types/node" "*"

"@types/stylis@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@types/stylis/-/stylis-4.2.0.tgz#199a3f473f0c3a6f6e4e1b17cdbc967f274bdc6b"
integrity sha512-n4sx2bqL0mW1tvDf/loQ+aMX7GQD3lc3fkCMC55VFNDu/vBOabO+LTIeXKM14xK0ppk5TUGcWRjiSpIlUpghKw==

"@types/supports-color@^8.1.0":
version "8.1.1"
resolved "https://registry.yarnpkg.com/@types/supports-color/-/supports-color-8.1.1.tgz#1b44b1b096479273adf7f93c75fc4ecc40a61ee4"
Expand Down Expand Up @@ -10838,6 +10843,11 @@ cssfontparser@^1.2.1:
resolved "https://registry.yarnpkg.com/cssfontparser/-/cssfontparser-1.2.1.tgz#f4022fc8f9700c68029d542084afbaf425a3f3e3"
integrity sha1-9AIvyPlwDGgCnVQghK+69CWj8+M=

cssjanus@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cssjanus/-/cssjanus-2.1.0.tgz#6f99070e0b7cc79f826ea48c63c03cb250713af1"
integrity sha512-kAijbny3GmdOi9k+QT6DGIXqFvL96aksNlGr4Rhk9qXDZYWUojU4bRc3IHWxdaLNOqgEZHuXoe5Wl2l7dxLW5g==

cssnano-preset-default@^4.0.7:
version "4.0.7"
resolved "https://registry.yarnpkg.com/cssnano-preset-default/-/cssnano-preset-default-4.0.7.tgz#51ec662ccfca0f88b396dcd9679cdb931be17f76"
Expand Down Expand Up @@ -23325,11 +23335,23 @@ stylelint@^14.16.1:
v8-compile-cache "^2.3.0"
write-file-atomic "^4.0.2"

stylis-plugin-rtl@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/stylis-plugin-rtl/-/stylis-plugin-rtl-2.1.1.tgz#16707809c878494835f77e5d4aadaae3db639b5e"
integrity sha512-q6xIkri6fBufIO/sV55md2CbgS5c6gg9EhSVATtHHCdOnbN/jcI0u3lYhNVeuI65c4lQPo67g8xmq5jrREvzlg==
dependencies:
cssjanus "^2.0.1"

stylis@4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.3.tgz#fd2fbe79f5fed17c55269e16ed8da14c84d069f7"
integrity sha512-GP6WDNWf+o403jrEp9c5jibKavrtLW+/qYGhFxFrG8maXhwTBI7gLLhiBb0o7uFccWN+EOS9aMO6cGHWAO07OA==

stylis@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.2.0.tgz#79daee0208964c8fe695a42fcffcac633a211a51"
integrity sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==

suffix@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/suffix/-/suffix-0.1.1.tgz#cc58231646a0ef1102f79478ef3a9248fd9c842f"
Expand Down