Skip to content

Commit

Permalink
refactor: css center tailwind utility
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonpole committed Aug 24, 2024
1 parent aaf2033 commit a81f7dd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
export default {
plugins: {
"tailwindcss/nesting": {},
tailwindcss: {},
autoprefixer: {},
},
Expand Down
16 changes: 13 additions & 3 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ body {
}

main {
@apply grid grid-cols-1 place-items-center gap-24 py-24;
@apply center gap-24 py-24;
}

h2 {
Expand Down Expand Up @@ -46,10 +46,10 @@ figure:has(span):has(video) {

/** container sections */
section[id] {
@apply grid scroll-mt-24 grid-cols-1 place-items-center gap-12 px-4 sm:w-2/3;
@apply center scroll-mt-24 gap-12 px-4 sm:w-2/3;

& > header {
@apply order-first grid grid-cols-1 place-items-center gap-4;
@apply center order-first gap-4;
}

& > header + p {
Expand Down Expand Up @@ -102,6 +102,16 @@ section[id] {

/** utilities */
@layer utilities {
.center {
&:has(:only-child) {
@apply grid grid-cols-1 place-items-center;
}

&:not(:only-child) {
@apply flex flex-col items-center justify-center;
}
}

.gradient-bg {
@apply bg-gradient-to-br from-indigo-500 via-fuchsia-500 to-pink-500;
}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const links = [
*/
export default function () {
return (
<footer className="relative grid h-64 grid-cols-1 place-items-center">
<footer className="center relative h-64">
<section className="absolute inset-0 overflow-hidden opacity-90">
<img
src={footer}
Expand All @@ -40,7 +40,7 @@ export default function () {
{links.map((link) => (
<li key={link.url + "__footer"}>
<a
className="grid size-16 grid-cols-1 place-items-center rounded-full border-2 border-current p-4"
className="center size-16 rounded-full border-2 border-current p-4"
href={link.url}
target="_blank"
>
Expand Down
6 changes: 3 additions & 3 deletions src/routes/how.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export default function () {
</video>
<button
className={cx(
"pointer-events-none absolute z-10 grid size-12 grid-cols-1 place-items-center self-center",
"center pointer-events-none absolute z-10 size-12 self-center",
"rounded-full text-white opacity-90 backdrop-blur-md backdrop-filter",
playing && "hidden",
playing && "!hidden",
)}
>
<FaPlayCircle className="size-12" />
Expand All @@ -87,7 +87,7 @@ export default function () {
key={item.title + "__how"}
className="flex flex-col items-center gap-4 border border-base-content/10 bg-base-200 p-4"
>
<header className="grid size-16 grid-cols-1 place-items-center rounded-full border-2 border-current">
<header className="center size-16 rounded-full border-2 border-current">
<item.icon className="text-5xl" />
</header>
<p className="text-center text-xl font-extrabold">{item.title}</p>
Expand Down

0 comments on commit a81f7dd

Please sign in to comment.