How to use direction - 6 common examples

To help you get started, we’ve selected a few direction examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ianstormtaylor / slate / packages / slate-react / src / components / element.tsx View on Github external
dir?: 'rtl'
    ref: any
  } = {
    'data-slate-node': 'element',
    ref,
  }

  if (isInline) {
    attributes['data-slate-inline'] = true
  }

  // If it's a block node with inline children, add the proper `dir` attribute
  // for text direction.
  if (!isInline && Editor.hasInlines(editor, element)) {
    const text = Node.string(element)
    const dir = getDirection(text)

    if (dir === 'rtl') {
      attributes.dir = dir
    }
  }

  // If it's a void node, wrap the children in extra void-specific elements.
  if (Editor.isVoid(editor, element)) {
    attributes['data-slate-void'] = true

    if (!readOnly && isInline) {
      attributes.contentEditable = false
    }

    const Tag = isInline ? 'span' : 'div'
    const [[text]] = Node.texts(element)
github ianstormtaylor / slate / packages / slate / src / interfaces / element.js View on Github external
getTextDirection() {
    const dir = getDirection(this.text)
    return dir === 'neutral' ? null : dir
  }
github milesj / aesthetic / packages / react / src / DirectionProvider.tsx View on Github external
export default function DirectionProvider({
  children,
  dir,
  inline,
  value,
}: DirectionProviderProps) {
  const Tag = inline ? 'span' : 'div';
  let direction: Direction = dir || getDirection(value);

  if (!direction || direction === 'neutral') {
    direction = aesthetic.options.rtl ? 'rtl' : 'ltr';
  }

  return (
    
      {children}
    
  );
}
github enactjs / enact / packages / ui / Marquee / MarqueeDecorator.js View on Github external
	marqueeDirection: (str) => direction(str) === 'rtl' ? 'rtl' : 'ltr'
};
github airbnb / react-with-direction / src / AutoDirectionProvider.jsx View on Github external
function AutoDirectionProvider({
  children,
  direction,
  inline,
  text,
}) {
  const textDirection = getDirection(text);
  const dir = textDirection === 'neutral' ? direction : textDirection;

  return (
    
      {React.Children.only(children)}
    
  );
}

direction

Detect the direction of text: left-to-right, right-to-left, or neutral

MIT
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis

Popular direction functions