@kevinmarrec/unocss-config 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024-present Kevin Marrec <https://github.com/kevinmarrec>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # @kevinmarrec/unocss-config
2
+
3
+ ## Description
4
+
5
+ Opinionated [UnoCSS](https://unocss.dev) [config](https://unocss.dev/config).
6
+
7
+ ## Opinions
8
+
9
+ - Supports all [UnoCSS config](https://unocss.dev/config) options
10
+
11
+ - Uses the following opinionated [UnoCSS preset](#preset) by default:
12
+ - Extends the following official presets:
13
+ - [UnoCSS Wind preset](https://unocss.dev/presets/wind)
14
+ - [UnoCSS Icons preset](https://unocss.dev/presets/icons)
15
+ - [UnoCSS Web Fonts preset](https://unocss.dev/presets/web-fonts) (with [local fonts](https://unocss.dev/presets/web-fonts#serve-fonts-locally) enabled)
16
+
17
+ - Extends the following official transformers:
18
+ - [UnoCSS Directives transformer](https://unocss.dev/transformers/directives)
19
+ - [UnoCSS Variant group transformer](https://unocss.dev/transformers/variant-group)
20
+
21
+ - Adds a custom layer to enforce full height on top-level elements:
22
+
23
+ ```css
24
+ /* layer: default */
25
+ html,
26
+ body,
27
+ #app {
28
+ height: 100%;
29
+ }
30
+ ```
31
+
32
+ - Hoists `fonts` and `icons` preset options to the config level
33
+
34
+ ## Usage
35
+
36
+ > Requires [UnoCSS](https://unocss.dev) v66 _or later_.
37
+
38
+ ### Default
39
+
40
+ ```ts
41
+ // uno.config.ts
42
+ export { default } from '@kevinmarrec/unocss-config'
43
+ ```
44
+
45
+ ### Extended
46
+
47
+ ```ts
48
+ // uno.config.ts
49
+ import { useConfig } from '@kevinmarrec/unocss-config'
50
+
51
+ export default useConfig({ /* options */ })
52
+ ```
@@ -0,0 +1,16 @@
1
+ import { UserConfig } from "unocss";
2
+ import { IconsOptions } from "@unocss/preset-icons";
3
+ import { WebFontsOptions } from "@unocss/preset-web-fonts";
4
+ import { Theme } from "@unocss/preset-wind4";
5
+
6
+ //#region src/preset.d.ts
7
+ interface PresetOptions {
8
+ icons?: IconsOptions;
9
+ fonts?: WebFontsOptions['fonts'];
10
+ }
11
+ //#endregion
12
+ //#region src/index.d.ts
13
+ declare function useConfig(userConfig?: UserConfig<Theme> & PresetOptions): UserConfig<Theme>;
14
+ declare const _default: UserConfig<Theme>;
15
+ //#endregion
16
+ export { _default as default, useConfig };
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ import { defineConfig } from "unocss";
2
+ import { definePreset } from "@unocss/core";
3
+ import presetIcons from "@unocss/preset-icons";
4
+ import presetWebFonts from "@unocss/preset-web-fonts";
5
+ import { createLocalFontProcessor } from "@unocss/preset-web-fonts/local";
6
+ import presetWind from "@unocss/preset-wind4";
7
+ import transformerDirectives from "@unocss/transformer-directives";
8
+ import transformerVariantGroup from "@unocss/transformer-variant-group";
9
+
10
+ //#region src/preset.ts
11
+ var preset_default = definePreset((options) => ({
12
+ name: "@kevinmarrec/unocss-preset",
13
+ presets: [
14
+ presetWind(),
15
+ presetIcons(options?.icons),
16
+ presetWebFonts({
17
+ processors: createLocalFontProcessor(),
18
+ fonts: options?.fonts
19
+ })
20
+ ],
21
+ transformers: [transformerDirectives(), transformerVariantGroup()],
22
+ preflights: [{
23
+ layer: "default",
24
+ getCSS: () => "html, body, #app {height: 100%;}"
25
+ }]
26
+ }));
27
+
28
+ //#endregion
29
+ //#region src/index.ts
30
+ function useConfig(userConfig = {}) {
31
+ const { fonts, icons,...config } = userConfig;
32
+ return defineConfig({
33
+ presets: [preset_default({
34
+ fonts,
35
+ icons
36
+ })],
37
+ ...config
38
+ });
39
+ }
40
+ var src_default = useConfig();
41
+
42
+ //#endregion
43
+ export { src_default as default, useConfig };
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@kevinmarrec/unocss-config",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "packageManager": "bun@1.2.21",
6
+ "description": "Opinionated UnoCSS config.",
7
+ "author": "Kevin Marrec <kevin@marrec.io>",
8
+ "license": "MIT",
9
+ "homepage": "https://github.com/kevinmarrec/unocss-config#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/kevinmarrec/unocss-config.git"
13
+ },
14
+ "keywords": [
15
+ "unocss",
16
+ "unocss-config"
17
+ ],
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.js"
21
+ }
22
+ },
23
+ "main": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsdown",
30
+ "check": "bun run check:unused && bun run check:eslint && bun run check:types",
31
+ "check:eslint": "eslint . --cache",
32
+ "check:types": "tsc --noEmit",
33
+ "check:unused": "knip -n",
34
+ "lint": "bun run check:eslint",
35
+ "lint:inspect": "bunx @eslint/config-inspector",
36
+ "release": "bumpp",
37
+ "test": "vitest",
38
+ "test:coverage": "vitest run --coverage"
39
+ },
40
+ "peerDependencies": {
41
+ "unocss": ">=66.0.0"
42
+ },
43
+ "dependencies": {
44
+ "@unocss/core": "^66.4.2",
45
+ "@unocss/preset-icons": "^66.4.2",
46
+ "@unocss/preset-web-fonts": "^66.4.2",
47
+ "@unocss/preset-wind4": "^66.4.2",
48
+ "@unocss/transformer-directives": "^66.4.2",
49
+ "@unocss/transformer-variant-group": "^66.4.2"
50
+ },
51
+ "devDependencies": {
52
+ "@kevinmarrec/eslint-config": "^1.0.0",
53
+ "@kevinmarrec/tsconfig": "^1.0.0",
54
+ "@types/bun": "^1.2.21",
55
+ "@vitest/coverage-v8": "^3.2.4",
56
+ "bumpp": "^10.2.3",
57
+ "eslint": "^9.34.0",
58
+ "knip": "^5.63.0",
59
+ "pathe": "^2.0.3",
60
+ "taze": "^19.3.0",
61
+ "tsdown": "^0.14.2",
62
+ "typescript": "^5.9.2",
63
+ "vitest": "^3.2.4"
64
+ }
65
+ }