Skip to main content
Brand and assets
Build
Monitor and contribute
/
Front-end platform
  • Overview
  • Technical architecture
  • Core framework
  • Application
  • global-shell
  • modular-arch
  • Product shells
  • Modules & apps
  • Module directory
  • Apps
  • Bundles
  • Bundle explorer
  • Guides
  • Install Murray
  • Universal components
  • Build a universal component
  • Responsive styles
  • RTL support
  • Translations & i18n
  • When to use Form
  • Positioning elements
  • Add a new icon
  • Utilities
  • Overview
  • Layouts
  • Universal components

Universal

info

Murray aims at being Alan's universal Design System, with components behaving and looking the same way on both mobile and web. As of July 2023, only a subset of components have been migrated to a universal implementation.

Benefits of having universal components​

  • Consistency: by leveraging a single codebase, we can ensure a consistent user interface (UI) and user experience (UX) across both web and mobile applications. This helps in maintaining brand identity and improves usability.
  • Code Reusability: components can be implemented once, and be reused in both web and mobile features. This significantly reduces development time and effort required for maintaining separate codebases.
  • Efficiency: changes made to the component library will be reflected simultaneously on both web and mobile platforms, enabling faster feedback loops and quicker deployment cycles.

Technical implementation​

We rely on React Native for Web to implement universal components once while being able to target both React DOM and React Native.

react-native-web is an accessible implementaion of React Native's components and APIs. It is built on top of a set of sane principles:

  • Accessible HTML: support different devices and input modes, render semantic tags.
  • High-quality interactions: support gestures and multiple input modes (touch, mouse, keyboard)
  • Reliable styles: rely on scoped styles and automatic vendor-prefixing
  • Responsive containers: respond to element resize events
  • Incremental adoption: interoperates with existing React DOM components. Bundle only what you use

It is battle-tested (powering Expo, Twitter, ...) and has significantly impacted the development of React Native (accessibility features were recently introduced thank to react-native-web)

Specificities​

These specificities are mostly abstracted away by Murray's implementation. However they are interesting to know to better understand our systems

Styling​

Web and mobile platforms have different styling and layout systems. While CSS is used for web styling, React Native relies on its own styling system, which encapsulates CSS-like properties. It's important to understand these styling differences and adapt the component library's styles and layouts accordingly to ensure consistent visual rendering.

DOM elements​

Our Universal components are compatible with both web and mobile platforms. As such we can't rely on DOM abstraction such as html tags (div, span, ...). We instead use React Native primitives (View, Text, ...) which are then rendering DOM elements.

Accessibiltiy and semanticics​

This doesn't mean that we don't care about semantics, on the contrary. We can benefit from a single accessibility implementation that will handle specificies of 3 platforms (web, iOS, Android). You can refer to React Native Web documentation on the matter.

Universal Murray components do implement accessibility best practices (e.g. rendering Heading as the proper <h{1|2|...}> tag on web).

Platform-specific behaviors​

While components should mostly look and behave the same way on all platforms, there are platform-specific behaviors (due to OS guidelines, technical constraints, ...). In these situations we can rely on:

  • the Platform module (from "react-native), providing a Platform.OS to know if we're on web | ios or android
  • platform-specific files. Suffixing a file with .web.tsx or .native.tsx will make sure that it is only loaded on the specified platform

You can see such examples in the Loader implementation, which relies on different Lottie libraries for web and mobile.

Edit this page
Previous
Install Murray
Next
Build a universal component
  • Benefits of having universal components
  • Technical implementation
  • Specificities
    • Styling
    • DOM elements
    • Accessibiltiy and semanticics
    • Platform-specific behaviors