Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LengthCorners<All, TopLeft, TopRight, BottomLeft, BottomRight>

A base class that can be used to create mixin aliases for styles that have 'corners', such as borderRadius. To use the base class five ViewStyle interfaces need to be created; one for each corner and one that represents all corners:

example
Style Interfaces ```ts import { ViewStyle } from 'react-native'; export interface ITopLeft extends ViewStyle { borderTopLeftRadius: number; } export interface ITopRight extends ViewStyle { borderTopRightRadius: number; } export interface IBottomLeft extends ViewStyle { borderBottomLeftRadius: number; } export interface IBottomRight extends ViewStyle { borderBottomRightRadius: number; } export interface IAll extends ViewStyle { borderRadius: number; } ``` A function must then be created that can convert the corner and value into a style mixin:
example
Example Conversion function ```ts import { LengthCornersCorner } from '@ef-carbon/react-native-style'; function convert(corner: LengthCornersCorner, value: number): IAll | ITop | ILeft | IRight | IBottom { switch (corner) { case 'all': return { borderRadius: value }; case 'topLeft': return { borderTopLeftRadius: value }; case 'topRight': return { borderTopRightRadius: value }; case 'bottomLeft': return { borderBottomLeftRadius: value }; case 'bottomRight': return { borderBottomRightRadius: value }; default: return assertNever(corner); } } ``` Then the base class can be extended:
example
Derived class ```ts import { LengthCorners } from '@ef-carbon/react-native-style'; export interface IBorderRadiusCornersOptions { radius: ILength; } export class BorderRadiusCorners extends LengthCorners implements ICorners { constructor({ radius }: IBorderRadiusCornersOptions) { super({ length: radius, convert }); } } ```

Type parameters

  • All: ViewStyle

  • TopLeft: ViewStyle

  • TopRight: ViewStyle

  • BottomLeft: ViewStyle

  • BottomRight: ViewStyle

Hierarchy

  • LengthCorners

Implements

Index

Constructors

constructor

Properties

all

all: Readonly<ILength<All>>

bottomLeft

bottomLeft: Readonly<ILength<BottomLeft>>

bottomRight

bottomRight: Readonly<ILength<BottomRight>>

topLeft

topLeft: Readonly<ILength<TopLeft>>

topRight

topRight: Readonly<ILength<TopRight>>

Accessors

huge

  • get huge(): All

large

  • get large(): All

larger

  • get larger(): All

largest

  • get largest(): All

normal

  • get normal(): All

small

  • get small(): All

smaller

  • get smaller(): All

smallest

  • get smallest(): All

tiny

  • get tiny(): All