# @platformbuilders/theme-toolkit

> Theme helpers to use combined with Fluid Design System.

Latest version **0.3.0** (published 2023-12-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install @platformbuilders/theme-toolkit
pnpm add @platformbuilders/theme-toolkit
yarn add @platformbuilders/theme-toolkit
bun add @platformbuilders/theme-toolkit
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2023-12-14 |
| First published | 2022-06-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 2 |
| Unpacked size | 2.8 MB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Platform Builders |
| Maintainers | luancteixeira, dev-builders |

## Links

- npm: https://www.npmjs.com/package/@platformbuilders/theme-toolkit
- Repository: https://github.com/platformbuilders/theme-toolkit
- Homepage: https://github.com/platformbuilders/theme-toolkit#readme
- Issues: https://github.com/platformbuilders/theme-toolkit/issues
- npm.io page: https://npm.io/package/@platformbuilders/theme-toolkit

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) 4.17.21
- [@platformbuilders/helpers](https://npm.io/package/@platformbuilders/helpers.md) 0.8.2

## Recent versions

- 0.3.0 (latest) — 2023-12-14
- 0.2.8 — 2023-07-31
- 0.2.7 — 2023-07-31
- 0.2.6 — 2023-07-03
- 0.1.5 — 2023-03-15
- 0.1.4 — 2023-02-06
- 0.1.3 — 2022-11-29
- 0.1.2 — 2022-11-24
- 0.1.1 — 2022-08-06
- 0.1.0 — 2022-08-06
- 0.0.13 — 2022-06-01

## README

# Theme Toolkit

## Descrição

Este toolkit foi desenvolvido para auxiliar na gestão de temas e tornar mais fácil a manipulação de temas em aplicações.

## Instalação

Use o gerenciador de pacotes de sua escolha:

```bash
# Usando npm
npm install @platformbuilders/theme-toolkit

# Usando yarn
yarn add @platformbuilders/theme-toolkit
```

### Breakpoints
A toolkit define uma série de pontos de interrupção para responder a diferentes tamanhos de tela.

Exemplo:
```javascript

    import styled from 'styled-components';
    import { breakpoints } from 'theme-toolkit';
    
    const ResponsiveDiv = styled.div`
      width: 100%;
    
      @media ${breakpoints.inMobile} {
        background-color: blue;
      }
    
      @media ${breakpoints.inDesktop} {
        background-color: red;
      }
    `;
```

### Font Size Helper
getFontSize(props): Retorna o tamanho da fonte baseado na propriedade variant fornecida.

Exemplo:

```javascript
import styled from 'styled-components';
import { getFontSize } from 'theme-toolkit';

const Text = styled.span`
  font-size: ${(props) => getFontSize(props)}px;
`;
```

###  Line Height Helper
getLineHeight(props): Calcula e retorna a altura da linha baseado nas propriedades variant e lineHeightVariant.

Exemplo:

```javascript
import styled from 'styled-components';
import { getLineHeight } from 'theme-toolkit';

const Text = styled.span`
  line-height: ${getLineHeight({ variant: 'medium', lineHeightVariant: 'tight' })}px;
`;

```

### Theme Getter
getTheme(themeProp)(props): Retorna o valor de uma propriedade específica do tema.

Exemplo:

```javascript
import styled from 'styled-components';
import { getTheme } from 'theme-toolkit';

const successMain = getTheme('success.main');

const Button = styled.button`
   background-color: ${successMain};
`;
```

### Conditional Styler
ifStyle(prop)(truthy, falsy): Retorna estilos condicionalmente baseado na existência de uma propriedade.

Exemplo:

```javascript
import { ifStyle } from 'theme-toolkit';

const isActive = ifStyle('$isActive');

const Button = styled.button`
  width: ${isActive('80px', '60px')};
`;
```

### Web Checker
isWeb(): Verifica se o ambiente de execução é web.
Exemplo:

```javascript
import isWeb from 'theme-toolkit';

if (isWeb()) {
  // Lógica específica para a web
}
```

### Pixel to REM converter
pxToRem(pixels, baseline): Converte pixels para a unidade rem.

Exemplo:

```javascript
import styled from 'styled-components';
import { pxToRem } from 'theme-toolkit';

const SpacedDiv = styled.div`
  margin-top: ${pxToRem(20)};
  padding: ${pxToRem(15)} ${pxToRem(30)};
`;
```
### Switch Styler
switchStyle(name)(stylesObj): Retorna estilos com base no valor de uma propriedade específica.

Exemplo:

```javascript
import { switchStyle } from 'theme-toolkit';

const Button = styled.button`
  ${switchStyle('size')({
    small: 'font-size: 12px;',
    medium: 'font-size: 16px;',
    large: 'font-size: 20px;',
  })}
`;
```

### Theme Formatter
themeFormatter(rawTheme): Transforma um tema bruto em um tema fluido.
Exemplo:

```javascript
import { themeFormatter } from 'theme-toolkit';

const fluidTheme = themeFormatter(myRawTheme);
```

## Contribuição
Aceitamos contribuições! Sinta-se à vontade para enviar um Pull Request ou abrir uma Issue.

---
_Source: https://npm.io/package/@platformbuilders/theme-toolkit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
