Skip to content

Commit bfb2913

Browse files
authored
refactor: separete the selector utilities function and clean the entry point
2 parents 14ef94a + c79decf commit bfb2913

5 files changed

Lines changed: 74 additions & 50 deletions

File tree

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "tailwindcss-flow",
3-
"version": "0.0.8",
4-
"description": "Is a plugin designed to improve productivity in application development by providing additional utilities.",
2+
"name": "@halvaradop/tailwindcss-flow",
3+
"version": "0.0.1",
4+
"description": "A TailwindCSS plugin that provides a set of utilities to enhance the default functionalities and offer additional customization options.",
55
"main": "src/index.ts",
66
"types": "src/index.d.ts",
77
"scripts": {
@@ -10,7 +10,8 @@
1010
"build": "tsc && npm run build:css"
1111
},
1212
"publishConfig": {
13-
"access": "public"
13+
"access": "public",
14+
"registry": "https://registry.npmjs.org/@halvaradop/tailwindcss-flow@0.0.1"
1415
},
1516
"repository": {
1617
"type": "git",

src/index.ts

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,17 @@
11
import plugin from "tailwindcss/plugin"
22
import { PluginCreator } from "tailwindcss/types/config"
3-
import { verifySelectorsTheme } from "./utils";
43
import { scrollUtilities } from "./scroll-utilities";
54
import { fluencyUtilities } from "./fluency-utilities";
5+
import { selectorUtilities } from "./selector-utilities";
66

7-
8-
const tags = [
9-
"div",
10-
"span",
11-
"a",
12-
"p",
13-
"img",
14-
"h1",
15-
"h2",
16-
"h3",
17-
"h4",
18-
"h5",
19-
"h6",
20-
"ul",
21-
"ol",
22-
"li",
23-
"table",
24-
"tr",
25-
"td",
26-
"form",
27-
"input",
28-
"button",
29-
"section",
30-
"main",
31-
"body",
32-
"article",
33-
"label",
34-
"img",
35-
"figure",
36-
"picture",
37-
"caption",
38-
"footer"
39-
]
40-
41-
7+
/**
8+
* Entry point of the application. This encapsulates the utilities offered
9+
* by the plugin.
10+
*
11+
* @param configApi The configuration API object obtained from tailwindcss.config.ts
12+
*/
4213
export const creator: PluginCreator = (configApi) => {
43-
const { addVariant, theme } = configApi
44-
45-
const selectors = verifySelectorsTheme(theme("selectors")).concat(tags)
46-
selectors.forEach(tag => addVariant(tag, `:where(&:is(${tag}), & > ${tag})`))
47-
14+
selectorUtilities(configApi)
4815
fluencyUtilities(configApi)
4916
scrollUtilities(configApi)
5017
}

src/selector-utilities.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { PluginAPI } from "tailwindcss/types/config"
2+
import { verifySelectorsTheme } from "./utils"
3+
4+
/**
5+
* This array contains the default tags supported by the selector variant
6+
* utilities. It provides a list of commonly used tags.
7+
*/
8+
const tags: string[] = [
9+
"div",
10+
"span",
11+
"a",
12+
"p",
13+
"img",
14+
"h1",
15+
"h2",
16+
"h3",
17+
"h4",
18+
"h5",
19+
"h6",
20+
"ul",
21+
"ol",
22+
"li",
23+
"table",
24+
"tr",
25+
"td",
26+
"form",
27+
"input",
28+
"button",
29+
"section",
30+
"main",
31+
"body",
32+
"article",
33+
"label",
34+
"img",
35+
"figure",
36+
"picture",
37+
"caption",
38+
"footer"
39+
]
40+
41+
42+
/**
43+
* Defines a set of tag variant utilities that allow you to customize different
44+
* HTML tags within a project. This enables more specific styling of elements.
45+
* The plugin also allows users to extend the default set of supported tags.
46+
*
47+
* To extend the default tags, you can add an array of new tags within the theme
48+
* property and set a `selectors` property in the Tailwind configuration file.
49+
*
50+
* @param configApi The configuration API object obtained from tailwindcss.config.ts
51+
*/
52+
export const selectorUtilities = (configApi: PluginAPI) => {
53+
const { addVariant, theme } = configApi
54+
55+
const selectors = verifySelectorsTheme(theme("selectors")).concat(tags)
56+
selectors.forEach(tag => addVariant(tag, `:where(&:is(${tag}), & > ${tag})`))
57+
}

src/utilities.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

1313
/* Language and Environment */
14-
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
14+
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
1515
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
1616
// "jsx": "preserve", /* Specify what JSX code is generated. */
1717
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
@@ -106,5 +106,7 @@
106106
/* Completeness */
107107
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
108108
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
109-
}
109+
},
110+
"include": ["src/"],
111+
"exclude": ["src/page"]
110112
}

0 commit comments

Comments
 (0)