Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marcbouchenoire/dimmmensions

πŸ“ A collection of dimensions from iOS and iPadOS devices.
https://github.com/marcbouchenoire/dimmmensions

guides ios ipados safe-area

Last synced: 3 months ago
JSON representation

πŸ“ A collection of dimensions from iOS and iPadOS devices.

Awesome Lists containing this project

README

        

> [!IMPORTANT]
> This project is no longer maintained.

# Dimmmensions

πŸ“ A collection of dimensions from iOS and iPadOS devices.

- πŸ€– [**Automated**](#automation): Authored and updated automatically
- πŸ§ͺ **Reliable**: Fully tested with [100% code coverage](https://codecov.io/gh/marcbouchenoire/dimmmensions)
- πŸ“¦ **Typed**: Written in [TypeScript](https://www.typescriptlang.org/) and includes definitions out-of-the-box
- πŸ’¨ **Zero dependencies**

[![build](https://img.shields.io/github/actions/workflow/status/marcbouchenoire/dimmmensions/.github/workflows/ci.yml?color=%2395f)](https://github.com/marcbouchenoire/dimmmensions/actions/workflows/ci.yml)
[![npm](https://img.shields.io/npm/v/dimmmensions?color=%2395f)](https://www.npmjs.com/package/dimmmensions)
[![size](https://img.shields.io/bundlephobia/minzip/dimmmensions?label=size&color=%2395f)](https://bundlephobia.com/package/dimmmensions)
[![coverage](https://img.shields.io/codecov/c/github/marcbouchenoire/dimmmensions?color=%2395f)](https://codecov.io/gh/marcbouchenoire/dimmmensions)
[![license](https://img.shields.io/github/license/marcbouchenoire/dimmmensions?color=%2395f)](https://github.com/marcbouchenoire/dimmmensions/blob/main/LICENSE)

## Introduction

Dimmmensions collects dimensions as objects for each device.

```typescript
interface Dimensions {
device: "iPhone" | "iPad"
name: string
radius: number
scale: number
landscape: OrientedDimensions
portrait: OrientedDimensions
}
```

`landscape` and `portrait` both contain orientation-specific dimensions and size classes.

```typescript
interface OrientedDimensions {
screen: {
width: number
height: number
}
layoutMargins: {
top: number
left: number
right: number
bottom: number
}
readableContent: {
top: number
left: number
right: number
bottom: number
}
safeArea: {
top: number
left: number
right: number
bottom: number
}
sizeClass: {
horizontal: "compact" | "regular"
vertical: "compact" | "regular"
}
}
```

#### Examples

iPhone 11

```json
{
"device": "iPhone",
"name": "iPhone 11",
"radius": 41.5,
"scale": 2,
"landscape": {
"screen": {
"width": 896,
"height": 414
},
"layoutMargins": {
"top": 0,
"left": 64,
"right": 64,
"bottom": 21
},
"readableContent": {
"top": 0,
"left": 116,
"right": 116,
"bottom": 21
},
"safeArea": {
"top": 0,
"left": 48,
"right": 48,
"bottom": 21
},
"sizeClass": {
"horizontal": "regular",
"vertical": "compact"
}
},
"portrait": {
"screen": {
"width": 414,
"height": 896
},
"layoutMargins": {
"top": 48,
"left": 20,
"right": 20,
"bottom": 34
},
"readableContent": {
"top": 48,
"left": 20,
"right": 20,
"bottom": 34
},
"safeArea": {
"top": 48,
"left": 0,
"right": 0,
"bottom": 34
},
"sizeClass": {
"horizontal": "compact",
"vertical": "regular"
}
}
}
```

iPad mini

```json
{
"device": "iPad",
"name": "iPad mini (6th generation)",
"radius": 21.5,
"scale": 2,
"landscape": {
"screen": {
"width": 1133,
"height": 744
},
"sizeClass": {
"horizontal": "regular",
"vertical": "regular"
},
"layoutMargins": {
"top": 24,
"left": 20,
"right": 20,
"bottom": 20
},
"readableContent": {
"top": 24,
"left": 234.5,
"right": 234.5,
"bottom": 20
},
"safeArea": {
"top": 24,
"left": 0,
"right": 0,
"bottom": 20
}
},
"portrait": {
"screen": {
"width": 744,
"height": 1133
},
"sizeClass": {
"horizontal": "regular",
"vertical": "regular"
},
"layoutMargins": {
"top": 24,
"left": 20,
"right": 20,
"bottom": 20
},
"readableContent": {
"top": 24,
"left": 20,
"right": 20,
"bottom": 20
},
"safeArea": {
"top": 24,
"left": 0,
"right": 0,
"bottom": 20
}
}
}
```

## Installation

```bash
npm install dimmmensions
```

## Usage

#### `dimensions`

Import `dimensions`.

```typescript
import { dimensions } from "dimmmensions"

// dimensions: [Dimensions, Dimensions, Dimensions...]
```

#### `getDimensions`

Import `getDimensions`.

```typescript
import { getDimensions } from "dimmmensions"
```

Given no arguments, `getDimensions` will also return all dimensions.

```typescript
const dimensions = getDimensions()

// dimensions: [Dimensions, Dimensions, Dimensions...]
```

Given a specific `width` and `height`, `getDimensions` will return dimensions that match the specified screen size, either in portrait or landscape.

```typescript
const dimensions = getDimensions(320, 568)

// dimensions: [Dimensions]
```

## Automation

Dimensions are extracted from iOS and iPadOS with the `generate` commandβ€”using Xcode and Simulator.