/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/element/src/platform.ts
43 строки
1 KB
Marin Atanasov
Remove React Native implementation, framework, and dependencies (#78747)
09 июн 2026, 10:40
Не верифицирован
09 июн 2026, 10:40
6d5f87f
Код
Авторство
О чём код?
/** * Specification for platform-specific value selection. */ type PlatformSelectSpec< T > = { web?: T; default?: T; }; /** * Component used to detect the current Platform being used. * Use Platform.OS === 'web' to detect if running on web environment. * * Here is an example of how to use the select method: * @example * ```js * import { Platform } from '@wordpress/element'; * * const placeholderLabel = Platform.select( { * web: __( 'Drag images, upload new ones or select files from your library.' ), * default: __( 'Add media' ), * } ); * ``` */ const Platform = { /** Platform identifier. Will always be `'web'` in this module. */ OS: 'web' as const, /** * Select a value based on the platform. * * @template T * @param spec - Object with optional platform-specific values. * @return The selected value. */ select< T >( spec: PlatformSelectSpec< T > ): T | undefined { return 'web' in spec ? spec.web : spec.default; }, /** Whether the platform is web */ isWeb: true, }; export default Platform;