@codecademy/gamut
68.2.268.2.3-alpha.e3fe3f.0
dist/Popover/utils.js~
dist/Popover/utils.jsModified+18
Index: package/dist/Popover/utils.js
===================================================================
--- package/dist/Popover/utils.js
+++ package/dist/Popover/utils.js
@@ -1,4 +1,22 @@
+/**
+ * Mirrors horizontal `left` / `right` in RTL when `useLogicalProperties` is enabled
+ * (Popover `align` / `beak` resolution). `Popover` passes `isRtl` from
+ * `useElementDir(targetRef)` and document `dir` (see `Popover` implementation).
+ * @param side - The horizontal side to resolve.
+ * @param isRtl - Whether the element is in an RTL context.
+ * @param useLogicalProperties - Whether logical properties are enabled.
+ * @returns The resolved horizontal side.
+ * WARNING : Do not use this function to swap elements that use css logical properties. They will get double-mirrored.
+ */
+export const resolveHorizontalSideForRtl = ({
+ side,
+ isRtl,
+ useLogicalProperties
+}) => {
+ if (!useLogicalProperties) return side;
+ return isRtl ? side === 'left' ? 'right' : 'left' : side;
+};
const offsets = {
primary: 20,
secondary: 15
};