@workday/canvas-kit-react
Version:
The parent module that contains all Workday Canvas Kit React components
17 lines (16 loc) • 547 B
JavaScript
import * as React from 'react';
import { ThemeContext } from '@emotion/react';
import { ContentDirection } from './types';
function useDefaultTheme(theme, config, fn) {
return theme || fn(config);
}
/**
* This is a small hook to support right-to-left logic.
* It returns a boolean
* @example
* const isRTL = useIsRTL();
*/
export const useIsRTL = (partialTheme) => {
const theme = useDefaultTheme(partialTheme, ThemeContext, React.useContext);
return (theme && theme.canvas && theme.canvas.direction) === ContentDirection.RTL;
};