Skip to content

Commit 1ab447f

Browse files
authored
Merge pull request #96 from jackdomleo7/split-css
2 parents 26bd568 + dcd5ac2 commit 1ab447f

26 files changed

+2012
-450
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ title: '[BUG]: <title>'
2525
Provide screenshots if applicable.
2626
-->
2727
Cooltipz.css version:
28+
Cooltipz.css stylesheet: main | data-attrs | classes
2829

2930
## What is the expected result?
3031

README.md

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ Play with Cooltipz.css on [CodePen](https://codepen.io/JackDomleo/pen/mderEeG).
2828
- Easy and simple tooltips with **quick setup**
2929
- Pure CSS, no JavaScript
3030
- Highly customisable
31+
- **Multiple versions available** - Combined, data attributes only, or classes only for optimal bundle size
3132
- Accessible with `aria-label` attributes
3233
- Automatically disables animation if the user [prefers reduced motion](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion?ref=cooltipz.jackdomleo.dev)
3334
- Options to use classes or `data-` attributes
3435
- Options to import via CDN, npm or yarn
3536
- Options to import SCSS <sub><sup>(npm &amp; yarn only)</sup></sub> or CSS stylesheets <sub><sup>(expanded or minified)</sup></sub>
3637
- Supports a wide range of characters and languages (including emojis, [Font Awesome 4](https://fontawesome.com/v4.7.0?ref=cooltipz.jackdomleo.dev) and [Font Awesome 5](https://fontawesome.com?ref=cooltipz.jackdomleo.dev) icons)
37-
- Uses [Autoprefixer](https://github.com/postcss/autoprefixer?ref=cooltipz.jackdomleo.dev) when generating the CSS stylesheets and [cssnano](https://github.com/cssnano/cssnano?ref=cooltipz.jackdomleo.dev) to minify the minfied stylesheet
38+
- Uses [Autoprefixer](https://github.com/postcss/autoprefixer?ref=cooltipz.jackdomleo.dev) when generating the CSS stylesheets and [cssnano](https://github.com/cssnano/cssnano?ref=cooltipz.jackdomleo.dev) to minify the minified stylesheet
3839

3940
---
4041

@@ -48,11 +49,28 @@ Play with Cooltipz.css on [CodePen](https://codepen.io/JackDomleo/pen/mderEeG).
4849

4950
### CDN
5051

52+
Cooltipz.css is available in three versions:
53+
- **Combined** (`cooltipz.css`/`cooltipz.min.css`) - Full version supporting both data attributes and classes
54+
- **Data attributes only** (`cooltipz-data-attrs.css`/`cooltipz-data-attrs.min.css`) - Lighter version for data-attribute usage only
55+
- **Classes only** (`cooltipz-classes.css`/`cooltipz-classes.min.css`) - Lighter version for class-based usage only
56+
57+
Choose the version that best fits your needs to minimize bundle size.
58+
5159
In the below CDN links:
5260
- Replace `:version` with a version [listed here](https://www.npmjs.com/package/cooltipz-css?activeTab=versions) (latest version is always recommended). If you always want to get the latest stylesheet, remove `@:version` completely (Not recommended).
5361
- Replace `:file` with one of the below:
62+
63+
**Combined (full functionality - 3.06kB when compressed):**
5464
- `cooltipz.css` <sub><sup>(Expanded stylesheet)</sup></sub>
55-
- `cooltipz.min.css` <sub><sup>(Minfied stylesheet)</sup></sub>
65+
- `cooltipz.min.css` <sub><sup>(Minified stylesheet)</sup></sub>
66+
67+
**Data attributes only (smaller bundle - 1.81kB when compressed):**
68+
- `cooltipz-data-attrs.css` <sub><sup>(Expanded stylesheet)</sup></sub>
69+
- `cooltipz-data-attrs.min.css` <sub><sup>(Minified stylesheet)</sup></sub>
70+
71+
**Classes only (smaller bundle - 1.79kB when compressed):**
72+
- `cooltipz-classes.css` <sub><sup>(Expanded stylesheet)</sup></sub>
73+
- `cooltipz-classes.min.css` <sub><sup>(Minified stylesheet)</sup></sub>
5674

5775
```html
5876
<!-- HTML -->
@@ -85,9 +103,19 @@ import 'cooltipz-css';
85103

86104
_Or_ use the SCSS or CSS into your Sass/SCSS
87105
In the below example, replace `:file` with one of the options below:
88-
- `src/cooltipz` <sub><sup>(.scss file)</sup></sub>
89-
- `cooltipz.css` <sub><sup>(Expanded .css)</sup></sub>
90-
- `cooltipz.min.css` <sub><sup>(Minified .css)</sup></sub>
106+
107+
**SCSS source files:**
108+
- `src/cooltipz` <sub><sup>(.scss file - combined version)</sup></sub>
109+
- `src/cooltipz-data-attrs` <sub><sup>(.scss file - data attributes only)</sup></sub>
110+
- `src/cooltipz-classes` <sub><sup>(.scss file - classes only)</sup></sub>
111+
112+
**Compiled CSS files:**
113+
- `cooltipz.css` <sub><sup>(Expanded .css - combined version)</sup></sub>
114+
- `cooltipz.min.css` <sub><sup>(Minified .css - combined version)</sup></sub>
115+
- `cooltipz-data-attrs.css` <sub><sup>(Expanded .css - data attributes only)</sup></sub>
116+
- `cooltipz-data-attrs.min.css` <sub><sup>(Minified .css - data attributes only)</sup></sub>
117+
- `cooltipz-classes.css` <sub><sup>(Expanded .css - classes only)</sup></sub>
118+
- `cooltipz-classes.min.css` <sub><sup>(Minified .css - classes only)</sup></sub>
91119
```scss
92120
/* Webpack */
93121
@use '~cooltipz-css/:file' as *;
@@ -98,6 +126,34 @@ In the below example, replace `:file` with one of the options below:
98126

99127
---
100128

129+
## Choosing the Right Version
130+
131+
Cooltipz.css offers three different versions to help you optimize your bundle size:
132+
133+
### 🎯 **Combined Version** (Default)
134+
- **Files:** `cooltipz.css`, `cooltipz.min.css`, `src/cooltipz.scss`
135+
- **Use when:** You want to use both data attributes and classes in your project
136+
- **Supports:** Both `data-cooltipz="tooltip text"` and `aria-label="tooltip text"` with classes like `.cooltipz--top`
137+
- **Size:** Full feature set
138+
139+
### 📊 **Data Attributes Only**
140+
- **Files:** `cooltipz-data-attrs.css`, `cooltipz-data-attrs.min.css`, `src/cooltipz-data-attrs.scss`
141+
- **Use when:** You only use data attributes like `data-cooltipz="tooltip text"` and `data-cooltipz-dir="top"`
142+
- **Supports:** Only data attribute syntax
143+
- **Size:** ~40% smaller than combined version
144+
- **Example:** `<button data-cooltipz="Save file" data-cooltipz-dir="top">Save</button>`
145+
146+
### 🎨 **Classes Only**
147+
- **Files:** `cooltipz-classes.css`, `cooltipz-classes.min.css`, `src/cooltipz-classes.scss`
148+
- **Use when:** You prefer semantic CSS classes with `aria-label` attributes
149+
- **Supports:** Only class-based syntax with `aria-label`
150+
- **Size:** ~40% smaller than combined version
151+
- **Example:** `<button aria-label="Save file" class="cooltipz--top">Save</button>`
152+
153+
> 💡 **Recommendation:** Start with the **data attributes only** version if you're unsure, as it provides the most intuitive API. You can always switch to the combined version later if needed.
154+
155+
---
156+
101157
## License
102158

103159
Type - **MIT**
@@ -135,7 +191,13 @@ We appreciate any feedback, good or bad and are always looking for new ideas to
135191
- `git clone https://github.com/jackdomleo7/Cooltipz.css.git` or clone your forked repository
136192
- `cd Cooltipz.css`
137193
- `npm ci`
138-
- `npm run build` to compile development SCSS to CSS
194+
- `npm run build` to compile all versions (combined, data-attrs, and classes) from SCSS to CSS
195+
196+
**Build commands:**
197+
- `npm run build` - Build all three versions
198+
- `npm run build:combined` - Build only the combined version (default)
199+
- `npm run build:data-attrs` - Build only the data attributes version
200+
- `npm run build:classes` - Build only the classes version
139201

140202
### Branch
141203

0 commit comments

Comments
 (0)