argyleink / roving-ux

stateful roving index for web ui
130 stars 7 forks source link

Nested Dir #19

Open HamzaAmar opened 1 year ago

HamzaAmar commented 1 year ago

https://github.com/argyleink/roving-ux/blob/bbeb45407c1ead893b2611a42dbed2709ea4b160/index.js#L2

I think is better to make isRtl a function that accepts an element parameter, you can get the computed style of that particular element instead of assuming that the root element is always the relevant one but if the element is omitted we can use document.documentElement as a fallback.

Here's an example implementation of isRtl() as a function that accepts an element parameter and returns true if the element's computed direction style is "rtl" (right-to-left), and false otherwise

function isRtl(element = document.documentElement) {
  const computedStyle = window.getComputedStyle(element);
  const direction = computedStyle.getPropertyValue('direction');
  return direction === 'rtl';
}
argyleink commented 1 year ago

great idea 👍🏻