Skip to content

Commit 342d3c1

Browse files
committed
make it the same counter app
1 parent 89588d9 commit 342d3c1

File tree

7 files changed

+98
-37
lines changed

7 files changed

+98
-37
lines changed

examples/tailwind/config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
PROJECT_NAME="Tailwind Counter"
12
TAILWIND=on

examples/tailwind/pages/count.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
if [[ ! -f data/count ]]; then
3+
echo "0" > data/count
4+
fi
5+
6+
COUNT=$(cat data/count)
7+
8+
if [[ "$REQUEST_METHOD" == "POST" ]]; then
9+
# increment the count
10+
COUNT=$(( COUNT + 1 ))
11+
echo "$COUNT" > data/count
12+
fi
13+
14+
htmx_page << EOF
15+
<p id="count" class="mt-3" hx-swap-oob="true">$COUNT</p>
16+
EOF

examples/tailwind/pages/index.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

2+
source config.sh
3+
24
htmx_page << EOF
3-
<h1 class="text-green-500 text-3xl font-bold underline">
4-
Hello world!
5-
</h1>
5+
<h1 class="text-blue-500 text-4xl mt-3 mb-3">${PROJECT_NAME}</h1>
6+
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" hx-post="/count" hx-swap="none">Count</button>
7+
<button class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded" hx-post="/reset" hx-swap="none">Reset</button>
8+
$(component '/count')
69
EOF

examples/tailwind/pages/list.sh

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

examples/tailwind/pages/reset.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
if [[ "$REQUEST_METHOD" != "POST" ]]; then
2+
# only allow POST to this endpoint
3+
return $(status_code 405)
4+
fi
5+
6+
echo "0" > data/count
7+
8+
component '/count'

examples/tailwind/static/tailwind.css

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,22 +534,73 @@ video {
534534
--tw-backdrop-sepia: ;
535535
}
536536

537+
.mt-2 {
538+
margin-top: 0.5rem;
539+
}
540+
541+
.mt-3 {
542+
margin-top: 0.75rem;
543+
}
544+
545+
.mb-3 {
546+
margin-bottom: 0.75rem;
547+
}
548+
549+
.rounded {
550+
border-radius: 0.25rem;
551+
}
552+
553+
.border-2 {
554+
border-width: 2px;
555+
}
556+
557+
.bg-blue-500 {
558+
--tw-bg-opacity: 1;
559+
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
560+
}
561+
562+
.bg-red-500 {
563+
--tw-bg-opacity: 1;
564+
background-color: rgb(239 68 68 / var(--tw-bg-opacity));
565+
}
566+
567+
.px-4 {
568+
padding-left: 1rem;
569+
padding-right: 1rem;
570+
}
571+
572+
.py-2 {
573+
padding-top: 0.5rem;
574+
padding-bottom: 0.5rem;
575+
}
576+
577+
.text-xl {
578+
font-size: 1.25rem;
579+
line-height: 1.75rem;
580+
}
581+
537582
.text-3xl {
538583
font-size: 1.875rem;
539584
line-height: 2.25rem;
540585
}
541586

587+
.text-4xl {
588+
font-size: 2.25rem;
589+
line-height: 2.5rem;
590+
}
591+
542592
.font-bold {
543593
font-weight: 700;
544594
}
545595

546-
.text-green-500 {
596+
.text-blue-500 {
547597
--tw-text-opacity: 1;
548-
color: rgb(34 197 94 / var(--tw-text-opacity));
598+
color: rgb(59 130 246 / var(--tw-text-opacity));
549599
}
550600

551-
.underline {
552-
text-decoration-line: underline;
601+
.text-white {
602+
--tw-text-opacity: 1;
603+
color: rgb(255 255 255 / var(--tw-text-opacity));
553604
}
554605

555606
body {
@@ -591,3 +642,13 @@ body {
591642
#count {
592643
font-size: 24px;
593644
}
645+
646+
.hover\:bg-blue-700:hover {
647+
--tw-bg-opacity: 1;
648+
background-color: rgb(29 78 216 / var(--tw-bg-opacity));
649+
}
650+
651+
.hover\:bg-red-700:hover {
652+
--tw-bg-opacity: 1;
653+
background-color: rgb(185 28 28 / var(--tw-bg-opacity));
654+
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/** @type {import('tailwindcss').Config} */
22
module.exports = {
33
content: ["./pages/**/*.sh"],
4-
theme: {
5-
extend: {},
6-
},
4+
theme: {},
75
plugins: [],
8-
}
6+
};

0 commit comments

Comments
 (0)