Skip to content

Commit 360275a

Browse files
committed
Update Tailwind instructions for README
1 parent 7f06d82 commit 360275a

File tree

2 files changed

+24
-28
lines changed

2 files changed

+24
-28
lines changed

README.md

+16-20
Original file line numberDiff line numberDiff line change
@@ -134,41 +134,37 @@ alias PetalComponents.Button
134134
```
135135

136136
**Q: Does this increase my CSS filesize?**
137-
A: Tailwind will scan any folders you specify and hoover up CSS classes from files to include in your final CSS file. You specify the folders in `tailwind.config.js`. By default, we instruct you to just scan the whole Petal Components library:
137+
A: Tailwind will scan any folders you specify and hoover up CSS classes from files to include in your final CSS file. You specify the folders in `assets/app.css`. By default, we instruct you to just scan the whole Petal Components library:
138138

139-
```js
140-
const colors = require("tailwindcss/colors");
141-
142-
module.exports = {
143-
purge: [
144-
"../lib/*_web/**/*.*ex",
145-
"./js/**/*.js",
139+
```css
140+
@import "tailwindcss";
146141

147-
// We need to include the Petal dependency so the classes get picked up by JIT.
148-
"../deps/petal_components/**/*.*ex"
149-
],
142+
@source "../deps/petal_components/**/*.*ex";
143+
@import "../deps/petal_components/assets/default.css";
150144

151-
... rest of file omitted
145+
... rest of file omitted
152146
```
153147

154148
You might be worried that if you don't use every component you'll have unused CSS classes. But we believe it's so small it won't matter. Our petal.build site's CSS file totals just 25kb.
155149

156150
If you really want to you can instruct Tailwind to just scan the components you use:
157151

158-
```
159-
"../deps/petal_components/lib/button.ex",
160-
"../deps/petal_components/lib/alert.ex",
152+
```css
153+
@source "../deps/petal_components/lib/button.ex",
154+
@source "../deps/petal_components/lib/alert.ex",
161155
```
162156

163157
**Q: Can I customize the components?**
164158
A: Yes! You can customize the components by overriding the CSS classes. For example, if you want to change the color of the button you can do this:
165159

166160
```css
167-
.pc-button {
168-
@apply inline-flex items-center justify-center font-semibold tracking-wider uppercase transition duration-150 ease-in-out border-2 rounded-none focus:outline-hidden;
169-
}
170-
.pc-button--primary {
171-
@apply text-black border-black bg-primary-400 hover:bg-primary-700 focus:bg-primary-700 active:bg-primary-800 focus:shadow-primary-500/50;
161+
@layer components {
162+
.pc-button {
163+
@apply inline-flex items-center justify-center font-semibold tracking-wider uppercase transition duration-150 ease-in-out border-2 rounded-none focus:outline-hidden;
164+
}
165+
.pc-button--primary {
166+
@apply text-black border-black bg-primary-400 hover:bg-primary-700 focus:bg-primary-700 active:bg-primary-800 focus:shadow-primary-500/50;
167+
}
172168
}
173169
```
174170

UPGRADE_GUIDE.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mix tailwind.install
3838

3939
`tailwind.config.js` is now considered legacy and is no longer automatically loaded. However, it is still supported and you can manually load it by adding the following to your `app.css`:
4040

41-
```CSS
41+
```css
4242
@config "../tailwind.config.js";
4343
```
4444

@@ -50,7 +50,7 @@ Here are some tips on how to integrate Petal Components if you are no longer usi
5050

5151
To reference Petal Components CSS and include it as a source for Tailwind utility classes, use the `@source` and `@import` directives:
5252

53-
```CSS
53+
```css
5454
@import "tailwindcss";
5555

5656
@source "../../deps/petal_components/**/*.*ex";
@@ -59,13 +59,13 @@ To reference Petal Components CSS and include it as a source for Tailwind utilit
5959

6060
The CSS file equivalent of `darkMode: 'class'` is:
6161

62-
```CSS
62+
```css
6363
@custom-variant dark (&:where(.dark, .dark *));
6464
```
6565

6666
In Tailwind 4 buttons now use `cursor: default` instead of `cursor: pointer`. If you would like the old behaviour:
6767

68-
```CSS
68+
```css
6969
@layer base {
7070
/* Use the pointer for buttons */
7171
button:not(:disabled),
@@ -77,13 +77,13 @@ In Tailwind 4 buttons now use `cursor: default` instead of `cursor: pointer`. If
7777

7878
To configure Petal Component colours add an `@import`:
7979

80-
```CSS
80+
```css
8181
@import "./colors.css";
8282
```
8383

8484
Then create the `colors.css` file:
8585

86-
```CSS
86+
```css
8787
@theme inline {
8888
--color-primary-50: var(--color-blue-50);
8989
--color-primary-100: var(--color-blue-100);
@@ -173,14 +173,14 @@ Then create the `colors.css` file:
173173

174174
To add the "typography" and "form" plug-ins:
175175

176-
```CSS
176+
```css
177177
@plugin "@tailwindcss/typography";
178178
@plugin "@tailwindcss/forms";
179179
```
180180

181181
To re-create the heroicons JavaScript:
182182

183-
```CSS
183+
```css
184184
@plugin "./tailwind_heroicons.js";
185185
```
186186

0 commit comments

Comments
 (0)