Enact Framework

repository·master·Indexed 43 days ago

https://github.com/enactjs/enact

A React-based framework for building high-performance, accessible, and customizable applications, featuring specialized support for webOS and 5-way navigation. The ecosystem includes @enact/core for essential building blocks, @enact/ui for unstyled components, @enact/spotlight for focus management, @enact/i18n for internationalization, and @enact/webos for device-specific utilities.

Tokens
93.6K
Snippets
297
Records
418
Agent score
55%

What's inside Enact

  1. Overview of @enact/ui

    master
    The @enact/ui library provides a set of reusable behaviors and a library of unstyled components designed for creating Enact themes. It includes various Higher Order Components (HOCs) that implement common usage patterns and behaviors, such as Pickable and Pressable.
  2. Overview of the Enact framework

    master

    Enact is an app development framework built on top of React designed for performance, customizability, and ease of use. It provides a cohesive ecosystem of building blocks for creating robust applications by integrating solutions for:

    • Internationalization (i18n)
    • Accessibility (a11y)
    • Focus management
    • Linting, testing, and building

    The framework is distributed as a collection of specialized modules under the @enact npm namespace.

  3. Unit testing tools in Enact

    master

    Enact utilizes the following core tools for unit testing:

    • Jest: The primary test framework used for setting up, asserting, and running tests, as well as providing mocking capabilities.
    • React Testing Library: A library specifically for testing React components, allowing you to render components and inspect their output.
    • jsdom: A pure-JavaScript implementation of web standards (DOM and HTML) used to provide a browser-like environment within Node.js.
  4. Core abstractions in @enact/core

    master

    The @enact/core package provides several fundamental abstractions designed for use within React-based applications:

    • core/kind: A factory for creating stateless functional components (SFCs).
    • core/jobs: A smart wrapper for window.setTimeout to manage asynchronous tasks.
    • core/hoc: A factory for creating Higher Order Components (HOCs).
  5. Use the @enact/webos library features

    master

    The @enact/webos library provides specialized modules for interacting with the webOS platform. Use these modules to access platform-specific APIs and metadata.

    Available modules:

    • @enact/webos/application: Access application metadata.
    • @enact/webos/deviceinfo: Retrieve details about the specific webOS device.
    • @enact/webos/keyboard: Check if the on-screen keyboard is currently visible.
    • @enact/webos/LS2Request: Interface for communicating with webOS Luna Services (required for most platform service integrations).
    • @enact/webos/platform: Retrieve details about the webOS platform type (e.g., SmartTV, Open webOS, legacy devices).
    • @enact/webos/pmloglib: Access system-level logging for your application.
    • @enact/webos/speech: Interface for working with webOS speech APIs.
  6. What is Spotlight?

    master
    Spotlight is an extensible utility for enabling application navigation via keyboard or television remote controls. It responds to UP, DOWN, LEFT, RIGHT, and RETURN inputs to provide a spatial navigation experience. While developed for the Enact JavaScript framework, it can be used as a standalone library.
  7. What is kind() and why use it?

    master

    The kind() method from @enact/core/kind is a factory for creating React components. It is designed to reduce mental load by providing a consistent structure for component creation, making components more readable and maintainable.

    Instead of writing a standard Stateless Functional Component (SFC) or a Class component, you pass a configuration object to kind(). This object defines how props are transformed, how styles are applied, and how the component renders. The result is a standard React component that can be used anywhere in your application.

    import kind from '@enact/core/kind';
    
    export default kind({
    	render: (props) => <div {...props}>Hooray!</div>
    });
  8. What is a kind and how do computed properties work?

    master

    A kind is a component constructor created using the @enact/core/kind factory method.

    When using kind, you can define computed properties. These are functions that receive the component's props (but not other computed properties) and return a value. These computed values are then automatically made available in the props object at render time.

  9. Manage application state with Redux

    master

    For non-trivial applications, the Enact framework team recommends using Redux for state management. This helps maintain a predictable state container across complex component trees. Recommended learning resources include:

  10. Behavior change in `kind`

    master
    In Enact 2.0, kind always returns a component, regardless of the configuration options provided. In versions prior to 2.0, kind could return either a component or a stateless functional component (SFC). This change primarily affects edge cases where developers were relying on a reference to a contained component or caching the result of calling the SFC directly.
  11. Understand the 'Visually Divorced' naming concept

    master

    Enact components follow a 'visually divorced' naming strategy. This means APIs, classes, and components are named using semantic concepts rather than visual ones.

    For example, instead of naming a prop isBold, you would use a semantic name like strong. This allows a theme to decide exactly how that semantic concept is visually represented (e.g., bold text, a different color, or a specific font weight) without being constrained by the component's internal naming.