Skip to content

Commit

Permalink
chore: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ydcjeff committed Feb 6, 2024
1 parent ccc9f2f commit f187056
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 2 deletions.
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,87 @@
<a href="https://www.npmjs.com/package/unocss-preset-one" target="_blank">
<img src="https://img.shields.io/npm/v/unocss-preset-one">
</a>

# unocss-preset-one

> `1` to `1rem` UnoCSS preset.
When you write `1`, it will generate `1rem`. That's it.

See why on https://github.com/tailwindlabs/tailwindcss/discussions/11439.

## Docs

```sh
pnpm add unocss-preset-one -D
```

### Usage

This preset is an opt-in preset if using the default preset options. Otherwise,
this preset must come last if you want to omit `prefix`.

```ts
// uno.config.js
import { presetUno, defineConfig } from 'unocss';
import { presetOne } from 'unocss-preset-one';

export default defineConfig({
presets: [
presetUno(),
// must come last to take precedence if omit prefix, otherwise any order.
presetOne({ prefix: '' }),
],
});
```

<table>
<thead>
<tr style="text-align: center">
<th>With prefix</th>
<th>Without prefix</th>
</tr>
</thead>
<tbody>
<tr>
<td>

```html
<div class="one-p-1 one-text-2">
The classes `one-p-1` and `one-text-2` will generate `padding: 1rem` and
`font-size: 2rem` respectively.
</div>
```

</td>

<td>

```html
<div class="p-1 text-2">
The classes `p-1` and `text-2` will generate `padding: 1rem` and `font-size:
2rem` respectively.
</div>
```

</td>
</tr>
</tbody>
</table>

### Types

```ts
export interface PresetOneOptions {
/**
* Prefix for the utilities of this preset.
*
* @default 'one-'
*/
prefix?: string;
}
```

## License

[MIT](./LICENSE)
4 changes: 2 additions & 2 deletions src/mod.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Preset, Rule } from '@unocss/core';

export type PresetOneOptions = {
export interface PresetOneOptions {
/**
* Prefix for the utilities of this preset.
*
* @default 'one-'
*/
prefix?: string;
};
}

const NUMBER_RE_SOURCE = /(-?\d*(?:\.\d+)?)/.source;
const DIRECTION_MAP = {
Expand Down

0 comments on commit f187056

Please sign in to comment.